1
$\begingroup$

I'm trying to solve the Fokker-Planck equation

$$\frac{\partial p}{\partial L}(L, \eta)= \frac{\partial}{\partial \eta}\left[\left(\eta^{2}-1\right) \frac{\partial p}{\partial \eta}(L, \eta)\right] = (\eta^2-1)\frac{\partial^2p}{\partial\eta^2}(L,\eta)+2\eta\frac{\partial p}{\partial\eta}(L,\eta), \quad \eta>1$$

with initial condition

$$p(L=0, \eta)=\delta(\eta-1).$$

Ignoring the initial condition my code is

FPE = D[P[L, eta], 
   L] == (1/Lloc)*((eta^2 - 1)*D[P[L, eta], {eta, 2}] + 
     2*eta*D[P[L, eta], eta])

s = NDSolve[{FPE, P[0, eta] == DiracDelta[eta-1]}, P, {L, 0, 30}, {eta, 1, 30}]

to which I get the error "Encountered non-numerical value for a derivative at L == 0." Is there something I have done wrong? I know this FPE has an analytical solution in terms of Legendre polynomials. Any help would be much appreciated. Thanks.

$\endgroup$
3
  • 2
    $\begingroup$ The meaning of the error message seems pretty straightforward to me: you are trying to solve for three unknowns (i.e. the function and its derivatives), but only provided one equation. You need more. Notice also that NDSolve is a numerical solver: you also need information on the range for L and eta, and initial conditions. Everything should have a numerical value. If you want solutions depending on parameters, look at ParametricNDSolve. Perhaps start from the docs and try to reformulate your problem. $\endgroup$
    – MarcoB
    Dec 6, 2019 at 17:21
  • $\begingroup$ Thanks for your comment. I have updated my question. $\endgroup$ Dec 6, 2019 at 17:32
  • $\begingroup$ @rodger_kicks Don't you need two boundary conditions? You only have an initial condition. Without the boundary conditions, you cannot solve. $\endgroup$
    – dearN
    Dec 8, 2019 at 16:37

1 Answer 1

5
$\begingroup$

Try

n = 20;
FPE = D[P[L, eta], L] - D[(eta^2 - 1) D[P[L, eta], eta], eta]
s = Quiet @ NDSolve[{FPE == 0, P[0, eta] == D[Tanh[n (eta - 1)], eta]}, P, {L, 0, 30}, {eta, 1, 30}][[1]]
Plot3D[Evaluate[P[L, eta] /. s], {L, 0, 30}, {eta, 1, 30}]

Here the problem is with DiracDelta[]. Use instead an approximation as

DiracDelta[eta] ~ D[Tanh[n eta], eta]

for $n \gg 1$ and $\eta \ge 0$

$\endgroup$
1
  • $\begingroup$ I can't thank you enough. That approximation is amazing. I didn't think of that. $\endgroup$ Dec 7, 2019 at 19:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.