0
$\begingroup$

I am trying to solve a a pair of coupled partial differential equations but it doesn't seem to work. I am getting the error 'Length of the derivative order is not u1[t,x]the same as the number of arguments',

diff1 = 1.;
diff2 = 1.;
L = 100;
{sol1, sol2} =NDSolveValue[{D[u1[t, x], t] == diff1*D[u1[t, x], {x, 2}] + D[(u1[t, x]*D[u2[t, x], x]), x], 
D[u2[t, x], t] == diff2*D[u2[t, x], {x, 2}] - u2[x, t], 
u1[0, x] == Exp[-x^2], u2[0, x] == PDF[NormalDistribution[20, 1], x], u1[t, -L] == 0, u1[t, L] == 0, u2[t, -L] == -1, u2[t, L] == 1}, {u1, u2}, {t, 0, 
20}, {x, -L, L}, {y, -L, L}]

The equations are, $$\frac{\partial u}{\partial t}=\frac{\partial^2 u}{\partial t^2}-\frac{\partial}{\partial x}\Big(v\frac{\partial u}{\partial x}\Big)$$ $$\frac{\partial v}{\partial x}=\frac{\partial^2 v}{\partial t^2}$$

$\endgroup$
  • 1
    $\begingroup$ Two issues: 1) there's an extraneous {y, -L, L} indicating a 2D system, 2) - u2[x, t] should be - u2[t, x]. After fixing those, it seems to work. $\endgroup$ – Chris K Mar 13 at 17:25
  • $\begingroup$ @ChrisK Do you not get a warning about boundary and initial conditions being inconsistent, after applying the fixes you mentioned? $\endgroup$ – MarcoB Mar 13 at 17:44
  • $\begingroup$ @MarcoB Yes I get that warning, which is correct because the initial conditions don't match the boundary conditions. If OP's interested in the long-term behavior, then it will soon work itself out (try Plot[sol2[t, L], {t, 0, 20}, PlotRange -> All]). If OP's interested in the short term behavior, then the ICs need to be fixed. $\endgroup$ – Chris K Mar 13 at 17:56
  • $\begingroup$ Welcome to Mathematica.SE Guest1! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$ – Chris K Mar 13 at 17:56
  • 1
    $\begingroup$ BTW, I just noticed that the second equation doesn't match between the code and the text. $\endgroup$ – Chris K Mar 13 at 17:59
1
$\begingroup$

Here is your tuneup code,

PDE1 = D[u1[t, x], t] == diff1*D[u1[t, x], {x, 2}] + D[(u2[t, x]*D[u1[t, x], x]), x];

PDE2 = D[u2[t, x], t] == diff2*D[u2[t, x], {x, 2}] -u2[t, x];

diff1 = 1.; diff2 = 1.; L = 100;

{sol1, sol2} = NDSolveValue[{PDE1, PDE2, u1[0, x] == Exp[-x^2], 
   u2[0, x] == PDF[NormalDistribution[20, 1], x], u1[t, -L] == 0, 
   u1[t, L] == 0, u2[t, -L] == -1, u2[t, L] == 1}, {u1, u2}, {t, 0, 20}, {x, -L, L}]

GraphicsRow[{
  Plot3D[sol1[t, x], {t, 0, 20}, {x, -L, L}, PlotRange -> All, AxesLabel -> {t, x, u1}],
  Plot3D[sol2[t, x], {t, 0, 20}, {x, -L, L}, PlotRange -> All, AxesLabel -> {t, x, u2}]
}, ImageSize -> Large]

Mathematica graphics

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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