1

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}] 
Verbeia
  • 34,233
  • 9
  • 109
  • 224
Umer
  • 11
  • 2
  • 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 '14 at 20:50
  • 1
    Please post you (eventually non-working) code – Dr. belisarius Apr 30 '14 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 '14 at 21:10
  • @Umer this does not seem to work? – chris May 01 '14 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 01 '14 at 10:28
  • Why would you want to do numerically something you can do analytically? – chris May 01 '14 at 15:24
  • This is problem related to diffusion and convection in catalyst pore and last term in equation is 'order of reaction' which is First order in this case. if i ll be able to solve it numerically i can solve it for any other higher order or complex reactions. – Umer May 01 '14 at 15:51

1 Answers1

5

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.

Jens
  • 97,245
  • 7
  • 213
  • 499
  • 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 01 '14 at 10:11
  • thanks @jens is there any way to solve it numerically like using finite differences (method of lines)? – Umer May 01 '14 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 01 '14 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 01 '14 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 01 '14 at 15:17
  • @chris yes - the number of coordinate systems is finite (and they're already built in), but actually here we don't even need to go that far because the coordinates have already been chosen and it's just about identifying the separation step. – Jens May 01 '14 at 15:20
  • @Umer Yes, that is a possible numerical approach that should work for you too. But he also clearly says that it's not the first choice of approach. Even the method of lines can in principle be used if you add another step that varies the initial conditions until the final conditions are met. But all these approaches are "band-aids." In your case, since it's analytically solvable I would maintain that that's the way to go. – Jens May 01 '14 at 16:14
  • @Umer By the way, I also implemented a relaxation method for this kind of problem in Poisson solver using Mathematica. – Jens May 01 '14 at 16:18