Hello,
I am struggling with a calculation of band bending in solids. For this I have to solve a second order differential equation. In principle this works, however I want to find that particular solution, which just "touches" zero by varying an initial condition (pot'[0]).
BBpot = NDSolve[{(charge[z])*e/(eps*epsrel) == pot''[z],
pot[0] == 0.6}, pot'[z]==somestart,{pot[z]}, {z, 0, 1*10^-6}, Method -> {"EventLocator", "Event" -> pot'[z],"EventAction" :> Throw[zend = z, "StopIntegration"],"EventLocationMethod" -> "LinarInterpolation",Method -> "ExplicitRungeKutta"}]
As an explanation: charge depents on pot itself, which is the function to solve for. The behavior of the solution is quite unspectacular. The function will decrease from its inital 0.6 and in principle become stable, when it reaches a minimum. This is why I stop the integration and assign to zend by EventLocator. However the solution is only physically accurate if the minimum at zend has the value zero. Coming to this solution is possible by changing
pot'[0]
When I put
pot[zend]==0
in the equation system it will not work (probably because it doesn't know zend (yet)?) because it has no starting value for pot'. I also tried using "shooting" method to give a starting value for pot', but am obviously doing something wrong. I also thought of embedding the differential equation in a findroot, but from what I read I don't know how to combine it.
Any help or suggestions are highly appreciated