Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I want to solve this PDE. I have tried to solve it with NDSolve but found error 'Boundary values may only be specified for one independent variable. Initial values may only be specified at one value of the other independent'. Please help me to solve this problem: I am beginner in Mathematica. This is cylinderical PDE and in equation omega, lambda and fi have constant values i.e 2,3,4

This is what I have tried.

sol = NDSolve[{w^2 (1/p) (D[T[p, x] (D[T[p, x], {p, 1}]), {p, 1}]) 
      + D[T[p, x], {x, 2}] - 2 l (D[T[p, x], {x, 1}]) - 4 f^2 (T[p, x]) == 0,
T[p, 0] == 1, T[p, 1] == 1, T[0, x] == 10, T[1, x] == 1}, 
{T[p, x]}, {p, 0, 1}, {x, 0, 1}] 
share|improve this question
1  
You might have a look at this, though the answer might change within the month. In the meantime, you might look into formatting on this site. –  Mark McClure Apr 30 at 20:50
1  
Please post you (eventually non-working) code –  belisarius Apr 30 at 20:51
1  
sol = NDSolve[{w^2 (1/p) (D[T[p, x] (D[T[p, x], {p, 1}]), {p, 1}]) + D[T[p, x], {x, 2}] - 2 l (D[T[p, x], {x, 1}]) - 4 f^2 (T[p, x]) == 0, T[p, 0] == 1, T[p, 1] == 1, T[0, x] == 10, T[1, x] == 1}, {T[p, x]}, {p, 0, 1}, {x, 0, 1}] –  Umer Apr 30 at 21:10
    
@Umer this does not seem to work? –  chris May 1 at 10:09
    
thank you everyone for commenting. my codes are not working but now i am trying to solve it analytically as jens has mentioned. i wish i could do it numerically. –  Umer May 1 at 10:28
show 2 more comments

1 Answer 1

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.

share|improve this answer
    
Nice! It would be cool to write a wrapper to do this generically (i.e. as a possible attempt for an arbitrary PDE)? –  chris May 1 at 10:11
    
thanks @jens is there any way to solve it numerically like using finite differences (method of lines)? –  Umer May 1 at 10:30
    
@chris That may be possible - although in general it may need more steps to insure that Mathematica multiplies by the correct powers of the independent variables to get the equivalent of pde2. I did manage to make it work in parabolic cylinder coordinates, so maybe I'll post an expanded version later. –  Jens May 1 at 15:12
    
What would be even nicer would be that the interpreter tries separating the problem in various coordinates. (though I guess the sets of possible coordinates depends on the geometry of the boundary condition). It just seems to me a more desirable feature for future versions of mathematica than some esoteric thing that have been introduced. –  chris May 1 at 15:16
    
@Umer The problem is that you require boundary conditions on both ends of both intervals for your variables. The method of lines works only when you pose initial conditions, it doesn't know how to aim for the correct final condition. –  Jens May 1 at 15:17
show 4 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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