# Periodic and non-periodic boundary condition in PDE

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?

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

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[] ) - (X[t, x] /.
sol1[] ), {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[] ) - (Y[t, x] /.
sol2[] ), {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[] ) - (Z[t, x] /.
sol3[] ), {t, 0, 2 Pi}, {x, 0, 2 Pi}]
Plot3D[ftest[t, x], {t, 0, 2 Pi}, {x, 0, 2 Pi}, PlotRange -> All]   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].

• Thank you very much! I will send an email. Feb 26, 2022 at 16:27