I'm trying to use Mathematica to get some early approximate solutions to a system of algebraic and partial differential equations. It is actually 1D model of an ideal gas in a tube. I'll divide my question into two parts so it will be more understandable:
- Part one:
I want to solve Navier–Stokes equations for a compressible inviscid isothermal fluid in a 1D tube:
$\frac{\partial P}{\partial t}+\frac{\partial \left( \nu P \right)}{\partial u}=0$
$\frac{\partial \left(P \nu\right) }{\partial t}+\frac{\partial \left( P \nu^2 \right) }{\partial u}+\mathring{R} T_a\frac{\partial P}{\partial u}=0$
Initial condition:
- $\nu\left( u,0 \right)=0$
- $P\left( u,0 \right)=1$
Dirichlet boundary condition (step signal)
$\left\{\begin{matrix} if \, t<1 \, then & \nu\left( 0,t \right)=0 \\ else & P\left( 0,t \right)=2 \end{matrix}\right.$
and $P\left( 1,t \right)=1$
I know I can use NDSolveValue and NDSolve to have some numerical solutions. for example I used the command below to solve a simplified version of the above system of PDEs:
pval = NDSolveValue[{D[p[x, t]*v[x, t], x] + D[p[x, t], t] == 0,
D[p[x, t], x] + D[p[x, t]*v[x, t]^2, x] + D[p[x, t]*v[x, t], t] ==
0, p[0, t] == UnitStep[t - 1] + 1, p[1, t] == 1, p[x, 0] == 1,
v[x, 0] == 0}, p, {x, 0, 1}, {t, 0, 3},
Method -> {"MethodOfLines", "TemporalVariable" -> t,
"SpatialDiscretization" -> {"TensorProductGrid",
"MaxPoints" -> 4000, "MinPoints" -> 4000}}, MaxStepSize -> 0.001]
Dimensions[sol1["Grid"]]
but the result I get is pretty awful:
ContourPlot[pval[x, t], {x, 0, 1}, {t, 0, 2.2}]
and it does not go furthure than t=2.232...
My first guess I don't have the right temporal resolution, but I don't know how to set it like what I have found for spatial resolution.
But I would like to ask my question in a general form:
- How should I solve this system of algebraic and PDEs. DSolve, NDSolveValue or NDSolve?
how to get reasonable solutions by setting the spatial and temporal step size?
- Part two:
I would like to solve the Navier–Stokes equations for a compressible viscose adiabatic fluid in a 1D tube:
- Ideal gas: $P=\mathring{R} T \rho$
- conservation of mass: $\frac{\partial \rho}{\partial t}+\frac{\partial \left( \nu \rho \right)}{\partial u}=0$
- conservation of linear momentum: $\frac{\partial \left(\rho \nu\right) }{\partial t}+\frac{\partial \left( \rho \nu^2 \right) }{\partial u}+\frac{\partial P}{\partial u}-\frac{4\mu\nu}{D}=0$
- conservation of heat for a control volume, assuming the Newtonian viscose fluid, the conduction/radiation is negligible (adiabatic for the whole tube): $\mu\nu^2=\frac{cD}{4}\left( \frac{\partial\left( T\rho\nu \right)}{\partial u}+\frac{\partial \left(\rho T \right)}{\partial t} \right)$
these equations in Mathematica format:
p[x, t] == T[x, t]*q[x, t]
D[q[x, t]*v[x, t], x] + D[q[x, t], t] == 0
D[p[x, t], x] + D[q[x, t]*v[x, t]^2, x] + D[q[x, t]*v[x, t], t] -v[x,t]==0
v[x, t]^2 - D[T[x, t]*q[x, t]*v[x, t], x] == 0
Where $\mathring{R}$, $\nu$, $D$ and $c$ are constants. $P$, $\rho$, $\nu$ and $T$ are functions of $x$ and $t$
I would like to ask my question in a general form:
- How should I solve this system of algebraic and PDEs. DSolve, NDSolveValue or NDSolve?
- how to get reasonable solutions by setting the spatial and temporal step size?
P.S. I'm not able to get the right tags for my post!
NDSolve
andNDSolveValue
in general produce the same result,.DSolve
is unlikely to produce a solution for this nonlinear problem. Your plot suggests that the solution may be unstable numerically for the parameters chosen. $\endgroup$MaxStepSize -> {10^-3, 2 10^-4}]
, the computation goes beyond2.23
without difficulty, although it does show signs of numerical instability beyondt == 5
. What, precisely, is your question? $\endgroup$p[0, t] == UnitStep[t - 1] + 1
does not accurately represent yourx == 0
boundary condition. Also, you may wish to delete some of the old material now at the end of your question. Best wishes. $\endgroup$