1
$\begingroup$

I tried to simplify a complicated PDE to understand what's going wrong, but even the simplest form is not fully accepted by Mathematica and does not work completely.

Please take a look at this:

eq:={D[X[t,x],t]==0,D[Y[t,x],t]==D[Y[t,x],x],D[Z[t,x],t]==D[Z[t,x],x]}

ic:={X[0,x]==x,Y[0,x]==Cos[x],Z[0,x]==Sin[x]}

bc:={Derivative[0,1][Y][t,0]==Derivative[0,1][Y][t,2Pi],Derivative[0,1][Z][t,0]==Derivative[0,1][Z][t,2Pi]}

NDSolve[{ic,bc,eq},{X,Y,Z},{t,0,2Pi},{x,0,2Pi}]

As you can see X[t,x] is non-periodic but Y[t,x] and Z[t,x] are.

When I solve this, I get the message "NDSolve::ibcinc: Warning: boundary and initial conditions are inconsistent." And above all the solution for X[t,x] is not linear as in initial condition ic; with some sort of interpolation close to x=0 and x=2Pi function X[t,x] is made periodic.

Can someone please tell me how to correctly specify initial and boundary conditinos?

$\endgroup$
2
  • $\begingroup$ System of equations looks very artificial since X,Y,Z are independent. To solve separate equation for Y or Z we can use PeriodicBoundaryCondition[]. $\endgroup$ Feb 26, 2022 at 15:42
  • $\begingroup$ Thanks! Yes, it's artificial since I simplified my problem strongly. $\endgroup$
    – lxndr
    Feb 26, 2022 at 16:23

1 Answer 1

2
$\begingroup$

I can not see anything you did wrong. But MMA behaves very peculiar. The error message seems spurious.

You have 3 uncoupled ODE. You may as well solve them separately and compare the solutions:

eq := {D[X[t, x], t] == 0, D[Y[t, x], t] == D[Y[t, x], x], 
  D[Z[t, x], t] == D[Z[t, x], x]}
ic := {X[0, x] == x, Y[0, x] == Cos[x], Z[0, x] == Sin[x]}

bc := {Derivative[0, 1][Y][t, 0] == Derivative[0, 1][Y][t, 2 Pi], 
  Derivative[0, 1][Z][t, 0] == Derivative[0, 1][Z][t, 2 Pi]}
sol0 = NDSolve[{ic, bc, eq}, {X, Y, Z}, {t, 0, 2 Pi}, {x, 0, 2 Pi}]

eq := {D[X[t, x], t] == 0}
ic := {X[0, x] == x}
bc := {}
sol1 = NDSolve[{ic, bc, eq}, {X}, {t, 0, 2 Pi}, {x, 0, 2 Pi}]

eq := {D[Y[t, x], t] == D[Y[t, x], x]}
ic := {Y[0, x] ==Cos[x]}
bc := {Derivative[0, 1][Y][t, 0] == Derivative[0, 1][Y][t, 2 Pi]}
sol2 = NDSolve[{ic, bc, eq}, {Y}, {t, 0, 2 Pi}, {x, 0, 2 Pi}]

eq := {D[Z[t, x], t] == D[Z[t, x], x]}
ic := {Z[0, x] == Sin[x]}
bc := {Derivative[0, 1][Z][t, 0] == Derivative[0, 1][Z][t, 2 Pi]}
sol3 = NDSolve[{ic, bc, eq}, {Z}, {t, 0, 2 Pi}, {x, 0, 2 Pi}]

We may now compare the solutions from the ODE with 3 functions and the separate ODEs by subtracting the corresponding solutions and plot the difference:

ftest = FunctionInterpolation[(X[t, x] /. sol0[[1]] ) - (X[t, x] /. 
     sol1[[1]] ), {t, 0, 2 Pi}, {x, 0, 2 Pi}] 
Plot3D[ftest[t, x], {t, 0, 2 Pi}, {x, 0, 2 Pi}, PlotRange -> All]
ftest = FunctionInterpolation[(Y[t, x] /. sol0[[1]] ) - (Y[t, x] /. 
     sol2[[1]] ), {t, 0, 2 Pi}, {x, 0, 2 Pi}] 
Plot3D[ftest[t, x], {t, 0, 2 Pi}, {x, 0, 2 Pi}, PlotRange -> All]
ftest = FunctionInterpolation[(Z[t, x] /. sol0[[1]] ) - (Z[t, x] /. 
     sol3[[1]] ), {t, 0, 2 Pi}, {x, 0, 2 Pi}] 
Plot3D[ftest[t, x], {t, 0, 2 Pi}, {x, 0, 2 Pi}, PlotRange -> All]

enter image description here

enter image description here

enter image description here

The separate solved solutions seem o.k. ,but it looks like MMA screws up badly when you give it 3 uncoupled ODEs to solve at once. I can not explain this, but I think you should report this to [email protected].

$\endgroup$
5
  • $\begingroup$ Thank you very much! I will send an email. $\endgroup$
    – lxndr
    Feb 26, 2022 at 16:27
  • $\begingroup$ Maybe you want to include a link to this page. $\endgroup$ Feb 26, 2022 at 16:44
  • $\begingroup$ Yes, I already did so. $\endgroup$
    – lxndr
    Feb 26, 2022 at 17:00
  • $\begingroup$ Got an answer. Support forwarded the issue to the developers to eliminate the bug. Years ago I reported a bug in NDSolve and it took 8 months to be fixed and I had to buy an update - I am curious about this time. $\endgroup$
    – lxndr
    Feb 28, 2022 at 21:51
  • $\begingroup$ Thanks' for the feedback. We will have to wait and see. $\endgroup$ Mar 1, 2022 at 10:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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