As this is a separable problem, I would suggest doing the entire solution analytically instead of numerically. The separation of variables can be performed along the same lines as in this closely related answer. I had to modify the steps slightly to get the variables r
and x
to separate properly, so I'll list the steps here.
First define the PDE and the separation ansatz. In pde2
, I use Expand
to get additional cancellations that Simplify
alone doesn't achieve.
To enforce the boundary conditions, I use Solve
after determining the general solution to each separated function (which are called ax[x]
and ar[r]
here). The separation constant is called $\kappa^2$ in this calculation:
pde = Function[
c, ω^2 (D[c, {r, 2}] + D[c, r]/r) + D[c, {x, 2}] -
2 λ D[c, x] - 4 ϕ^2 c];
ansatz = ar[r] ax[x];
pde2 = Expand[Apply[Subtract, pde[ansatz]/ansatz == 0]]
$$\frac{\omega ^2
\text{ar}''(r)}{\text{ar}(r)}+\frac{\omega ^2
\text{ar}'(r)}{r
\text{ar}(r)}+\frac{\text{ax}''(x)}{\text{ax}
(x)}-\frac{2 \lambda
\text{ax}'(x)}{\text{ax}(x)}-4 \phi^2$$
ar[r] /. First@
DSolve[Select[pde2, D[#, x] == 0 &] == κ^2, ar[r], r]
(*
==>
BesselJ[0, (I r Sqrt[4 k^2 + κ^2])/ω] C[1] +
BesselY[0, -((I r Sqrt[4 k^2 + κ^2])/ω)] C[2]
*)
rSolution[r_] = % /. C[2] -> 0
(* ==> BesselJ[0, (I r Sqrt[4 k^2 + κ^2])/ω] C[1] *)
rCoefficients = First@Solve[rSolution[1] == 1, C[1]];
xSolution[x_] = ax[x] /. First@DSolve[
Select[pde2, D[#, x] =!= 0 &] == -κ^2, ax[x], x,
GeneratedParameters -> B]
(*
==>
E^(x (λ - Sqrt[-κ^2 + λ^2])) B[1] +
E^(x (λ + Sqrt[-κ^2 + λ^2])) B[2]
*)
xCoefficients =
First@Solve[xSolution[0] == 1 && xSolution[1] == 1, {B[1], B[2]}];
generalSolution[r_, x_] =
Simplify[rSolution[r] xSolution[x] /. xCoefficients /. rCoefficients]
$$\frac{e^{(x-1) \left(-\sqrt{\lambda ^2-\kappa
^2}\right)-\lambda } \left(e^{\sqrt{\lambda
^2-\kappa ^2}+\lambda +\lambda x}+e^{x
\left(2 \sqrt{\lambda ^2-\kappa ^2}+\lambda
\right)}-e^{(2 x-1) \sqrt{\lambda ^2-\kappa
^2}+\lambda (x+1)}-e^{\lambda x}\right)
J_0\left(\frac{i r \sqrt{4 k^2+\kappa
^2}}{\omega }\right)}{\left(e^{2
\sqrt{\lambda ^2-\kappa ^2}}-1\right)
J_0\left(\frac{i \sqrt{4 k^2+\kappa
^2}}{\omega }\right)}$$
FullSimplify[pde[generalSolution[r, x]] == 0]
(* ==> True *)
In the expression pde2
, selecting the terms that depend on one or the other variable has to be done with care, since there is also a term that doesn't depend on either of the variables ($-4\phi^2$). So instead of going with FreeQ
to determine whether a variable occurs, I test for the derivatives of each term with respect to a given variable. That way, in Select[pde2, D[#, x] =!= 0 &]
I only collect terms that really depend on x
, whereas in Select[pde2,D[#,x]==0&]
I include terms that depend on r
or are constant.