Group Abstract Group Abstract

Message Boards Message Boards

Solving coupled differential equation with Neumann boundary conditions?

Posted 3 years ago

I am trying to solve coupled differential equations with Neumann BCs which are dx[n,t]/dn =0 when n=0 and dx[n,t]/dn =0 wnen n=90 but After adding Neumann BCs, it shows error message that these Dirichlet BCs need to be linear but I need to solve these eqs with Neumann BCs But it is not accepting those.

NDSolve[{D[x[n, t], t] == D[x[n, t], {n, 2}] - q[n, t] x[n, t], D[q[n, t], t] == -q[n, t] Exp[x[n, t]], (D[x[n, t], n] /. n -> 0) == 0, (D[x[n, t], n] /. n -> 90) == 0}, {x[n, t], q[n, t]}, {n, 0, 90}, {t, 0, 10}]

and if I put conditions like D[x[0.t],n] ==0 and D[x[90,t],n]==0 then it shows "equation or list of equations expected instead of True in the first argument"

Is there any other way to do so? Please look into this.

POSTED BY: Shruti Monga
5 Replies
Posted 3 years ago
POSTED BY: Shruti Monga

For completeness, here is the same solution using NeumannValue:

s1 = NDSolve[{D[x[n, t], t] == 
    D[x[n, t], {n, 2}] - q[n, t] x[n, t] + 
     NeumannValue[0.005, n == 0] + NeumannValue[0.005, n == 90], 
   D[q[n, t], t] == -q[n, t] Exp[x[n, t]], 
   x[n, 0] == Sin[(n + 90/4)* 2*Pi/90] + 0.005*n, 
   q[n, 0] == 0.01}, {x[n, t], q[n, t]}, {n, 0, 90}, {t, 0, 10}]
Plot3D[x[n, t] /. s1, {n, 0, 90}, {t, 0, 10}, PlotRange -> All]
Plot3D[(x[n, t] /. s) - (x[n, t] /. s1), {n, 0, 90}, {t, 0, 10}, 
 PlotRange -> All]

The last plot compares (subtracts) the two solutions to get zero.

POSTED BY: Neil Singer
Posted 3 years ago

Neil.. after getting Plot3D, I tried Plot[x[20,t],{t,0,100}] It shows blank for any value of n.

Am I doing something wrong or something else is required?.... Plz, look into this.

POSTED BY: Shruti Monga

Shruti,

You need to do this:

Plot[(x[n, t] /. s /. n -> 20) , {t, 0, 10}, PlotRange -> All]

You want to plot x[n,t] using the solution, s:

x[n,t] /. s

s has a substitution rule for x and q in the form of an interpolation function. you need to apply that rule to tell Mathematica what solution you want, x[n,t] or q[n,t]. After that you can substitute in values for n and/or t using /. n->20 or /. t-> 5, etc.

Regards,

Neil

POSTED BY: Neil Singer
POSTED BY: Neil Singer
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard