happy holidays, I am solving a coupled ODE - PDE system -for simplicity all coefficients are taken as 1-. I checked other questions on the issue but couldn't find any suitable answer or comparison. The model
$$ \frac{\partial \text{x1}(t,x)}{\partial t}=\frac{\partial ^2\text{x1}(t,x)}{\partial x\, \partial x}+\text{x1}(t,x) \text{x2}(t,x) \text{x3}(t,x)-\text{x1}(t,x)+1,\\ \frac{\partial \text{x2}(t,x)}{\partial t}=\frac{\partial ^2\text{x2}(t,x)}{\partial x\, \partial x}-\text{x2}(t,x),\\ \frac{\partial \text{x3}(t,x)}{\partial t}=1-\text{x1}(t,x)^2-\text{x3}(t,x) $$ The code
Clear["Global`*"]
solveme = NDSolve[{
D[x1[t, x], t] ==
D[x1[t, x], x, x] + x1[t, x] x2[t, x] x3[t, x] - x1[t, x] + 1,
D[x2[t, x], t] == D[x2[t, x], x, x] - x2[t, x],
D[x3[t, x], t] == (1 - x1[t, x]^2) - x3[t, x],
x1[0, x] == If[-20 < x < 20, 30, 0],
x1[t, -200] == 0,
x1[t, 200] == 0,
x2[0, x] == If[-20 < x < 20, 2, 0],
x2[t, -200] == 0,
x2[t, 200] == 0,
x3[0, x] == 1
},
{x1, x2, x3}, {t, 0, 200}, {x, -200, 200}];
DensityPlot[
Evaluate[{x1[t, x]} /. solveme], {t, 0, 200}, {x, -200, 200},
ColorFunction -> "Rainbow", PlotLegends -> Automatic,
Method -> {"MethodOfLines",
"SpatialDiscretization" -> {"TensorProductGrid",
"MaxPoints" -> 101}}, PlotPoints -> 100]
Question Can NDSolve be used for this problem, or do you know\suggest any other approach for coupled PDE - ODE systems?
NDSolve
runs without complaint. What's the problem? (BTW, yourDensityPlot
code has got the wrong options, but it seems irrelevant since you're not asking only aboutNDSolve
.) $\endgroup$Method
option is appropriate forNDSolve
but not forDensityPlot
. Are you thinking the last equation is an ODE? The function $x1$ and therefore $x3$ depend on both $t$ and $x$, so it's not an ODE of the form $du/dt = F(t,u)$. The other equations are clearly PDEs. $\endgroup$NDSolve
won't handle dependent variables with different arguments. So if you havex1[t, x]
, then it must bex3[t, x]
and not justx3[t]
. (This came up before on this site, and I couldn't figure out a way around it.) (2) If, for example, you haveD[x3[t, x], t] == 1 - t^2 - x3[t, x]
, thenNDSolve
will constructx3
by integrating the ODE $du/dt = 1 - t^2 - u^2$ for every value of $x$ in the spatial grid. Everything should be ok, despite the extra work. (I'm not sure I understood your last comment, so I'm taking two shots at it, in hopes that they help.) $\endgroup$