the error is At t == 0.030451749711041764`, step size is effectively zero;singularity or stiff system suspected
my calculation time is around 6000 seconds, however.
And the warning is like
Warning: scaled local spatial error estimate of 6884.220329195682 at t = 0.030451749711041764 in the direction of independent variable x is much greater than the prescribed error tolerance. Grid spacing with 25 points may be too large to achieve the desired accuracy or precision. A singularity may have formed or a smaller grid spacing can be specified using the MaxStepSize or MinPoints method option.
I tried to using
Method -> {"PDEDiscretization" -> {"MethodOfLines", "SpatialDiscretization" -> "TensorProductGrid", "MinPoints" -> 100}}}
and increasing the "minpoints", but the promblem was still existed.
CAN anyone help me with that?
my code be like solving an deviation equation
bound1 = {FEND[t] == 2*krec [t]*GEND[t]^2, F[t] == -Fb[t], FbEND[t] == 0, G[t] == Gb[t]/1};
bc1 = {y[0, x] == 0., yb[0, x] == 0., ytA1[0, x] == 0., ytA2[0, x] == 0.};
equ1 = {D[y[t, x], t] == Cdif[t] D[y[t, x], x, x] + SRC[t, x] - D[ytA1[t, x], t],
D[yb[t, x], t] == (Cdif[t]/fac^2) D[yb[t, x], x, x]-D[ytA2[t, x], t],
D[ytA1[t, x], t] == ktAT0[t] y[t, x] TRPA1[t, x] - ktATd0[t] ytA1[t, x],
D[ytA2[t, x], t] == ktAT0[t] yb[t, x] TRPA2[t, x] - ktATd0[t] ytA2[t, x]};
Sol1 = NDSolve[{equ1, bound1, bc1}, {y, yb, ytA1, ytA2}, {t, 0, tmax}, {x, 0, xmax}, MaxSteps -> Infinity, StartingStepSize -> 0.001, MaxStepSize -> 1, Method -> {"PDEDiscretization" -> {"MethodOfLines", "SpatialDiscretization" -> {"TensorProductGrid",
"MinPoints" -> 100}}}];
I am trying to solve the following non linear coupled PDE equation related with ginzburg landau using NDsolve.I am new to Mathematica. I am getting the following error.What is the mistake I am doing?
pde = {D[u[t, x, y], t] ==
D[u[t, x, y], {x, x}] +
D[u[t, x, y], {y,
y}] - (1/u[t, x, y])^3*(D[v[t, x, y], y]^2 +
D[v[t, x, y], x]^2) - u[t, x, y] + u[t, x, y]^3,
D[v[t, x, y], t] ==
D[v[t, x, y], {x, x}] + D[v[t, x, y], {y, y}] -
v[t, x, y]*u[t, x, y] +
(2/u[t, x, y])*(D[u[t, x, y], x]*D[v[t, x, y], x] -
D[u[t, x, y], y]*D[v[t, x, y], y])};bc = {u[0, x, y] == 0, v[0, x, y]== 0, u[t, 5, y] == 1, u[t, x, 5] == 1, D[v[t, 0, y], x] == 0, D[v[t, x, 0], y] == 0};
NDSolve[{pde, bc}, {u, v}, {x, 0, 5}, {y, 0, 5}, {t, 0, 2}]
'Error: NDSolve::deqn: Equation or list of equations expected instead of True in the first argument {{(u^(1,0,0))[t,x,y]==-u[t,x,y]+u[t,x,y]^3+(u^(0,0,y))[t,x,y]-((<<1>>^(<<3>>))[<<3>>]^2+(<<1>>^(<<3>>))[<<3>>]^2)/u[t,x,y]^3+(u^(0,x,0))[t,x,y],(v^(1,0,0))[t,x,y]==-u[t,x,y] v[t,x,y]+(v^(0,0,y))[t,x,y]+(2 (-(<<1>>^(<<3>>))[<<3>>] (<<1>>^(<<3>>))[<<3>>]+(<<1>>^(<<3>>))[<<3>>] (<<1>>^(<<3>>))[<<3>>]))/u[t,x,y]+(v^(0,x,0))[t,x,y]},{u[0,x,y]==0,v[0,x,y]==0,u[t,5,y]==1,u[t,x,5]==1,True,True}}.
NDSolve[{{Derivative[1, 0, 0][u][t, x, y] == -u[t, x, y] +
u[t, x, y]^3 + Derivative[0, 0, y][u][t, x, y] -
(Derivative[0, 0, 1][v][t, x, y]^2 +
Derivative[0, 1, 0][v][t, x, y]^2)/u[t, x, y]^3 +
Derivative[0, x, 0][u][t, x, y],
Derivative[1, 0, 0][v][t, x, y] == (-u[t, x, y])*v[t, x, y] +
Derivative[0, 0, y][v][t, x, y] +
(2*((-Derivative[0, 0, 1][u][t, x, y])*
Derivative[0, 0, 1][v][t, x, y] +
Derivative[0, 1, 0][u][t, x, y]*
Derivative[0, 1, 0][v][t, x, y]))/u[t, x, y] +
Derivative[0, x, 0][v][t, x, y]}, {u[0, x, y] == 0,
v[0, x, y] == 0, u[t, 5, y] == 1, u[t, x, 5] == 1, True,
True}}, {u, v}, {x, 0, 5}, {y, 0, 5}, {t, 0, 2}]
If you look at the value of bc you will see
bc = {u[0, x, y] == 0, v[0, x, y] == 0, u[t, 5, y] == 1,
u[t, x, 5] == 1, D[v[t, 0, y], x] == 0, D[v[t, x, 0], y] == 0}
gives you
{u[0, x, y] == 0, v[0, x, y] == 0, u[t, 5, y] == 1, u[t, x, 5] == 1, True, True}
That is where your error message about True is coming from.
What you were doing was differentiating an expression with respect to x, but the expression had no x in it, thus the result was zero. And 0==0 is always True. Likewise with y. So let's change the way you are trying to tell it the boundary conditions.
bc = {u[0, x, y] == 0, v[0, x, y] == 0, u[t, 5, y] == 1, u[t, x, 5] == 1,
Derivative[0, 1, 0][v][t, 0, y] == 0, Derivative[0, 0, 1][v][t, x, 0] == 0}
or
bc = {u[0, x, y] == 0, v[0, x, y] == 0, u[t, 5, y] == 1, u[t, x, 5] == 1,
D[v[t, x, y], x] == 0/.x->0, D[v[t, x, y], y] == 0/.y->0}
either of which I think should give you what you are looking for.
Once you fix those then you get a different error about Derivative order and non-negative integer.
I believe you fix that by changing your pde from {x,x} and {y,y} to {x,2} and {y,2} like this
pde = {D[u[t, x, y], t] == D[u[t, x, y], {x, 2}] + D[u[t, x, y], {y, 2}] -
(1/u[t, x, y])^3*(D[v[t, x, y], y]^2 + D[v[t, x, y], x]^2) - u[t, x, y] +
u[t, x, y]^3,
D[v[t, x, y], t] == D[v[t, x, y], {x, 2}] + D[v[t, x, y], {y, 2}] - v[t, x, y]*
u[t, x, y] + (2/u[t, x, y])*(D[u[t, x, y], x]*D[v[t, x, y], x] - D[u[t, x, y], y]*
D[v[t, x, y], y])};
Which makes that error go away.
Once you have fixed that and try your NDSolve then zeros in your denominators start to bite you.
Fixing those looks like more than just understanding MMA syntax. That may require understanding your problem and seeing if you can eliminate those zero denominators.
I have been staring at this simple pde for last 20 minutes and can't find why I am getting this error
Boundary and initial conditions are inconsistent
it is that standard 1D heat equation
eq = Derivative[2, 0][u][x, t] == Derivative[0, 1][u][x, t]
and boundary conditions are (notice they are both spatial derivatives)
u'(0,t)=0 (derivative here w.r.t. x )
u'(Pi,t)=0 (derivative here w.r.t. x )
and initial conditions are
u(x,0) = cos(2 x)
So at initial condition, u'(x,0) = -2 sin(2 x), which is zero at both x=0 and x=Pi.
So it seems to me to be consistent with boundary conditions, right? or Am I missing something?
Here is the actual Mathematica code:
ClearAll[u, x, t]
eq = Derivative[2, 0][u][x, t] == Derivative[0, 1][u][x, t]
sol = NDSolve[{eq,
Derivative[1, 0][u][0, t] == 0,
Derivative[1, 0][u][Pi, t] == 0,
u[x, 0] == Cos[2 x]},
u, {t, 0, 12}, {x, 0, Pi}
]
I have a feeling since it is a numerical solver, using Pi in the above, become Real Pi=3.1415... and so at exactly this value the initial and boundary conditions do not match? (floating point comparison somewhere?)
I know about the trick to resolve such an error from help ref/message/NDSolve/ibcinc but my question is really why I am getting this error in the first place, since it seems on the face of it, they are consistent. If it is due to the floating point issue with Pi, then how to resolve this? I tried to use the trick shown in help on this one (i.e. the use of exp(-1000 t) but did not help in removing this error.
question: Why I am getting this error message ?
version 8.04, on windows.
Actually I have been trying to get this solution shown here (also using Mathematica)
http://en.wikipedia.org/wiki/File:Heatequation_exampleB.gif
but the BC and IC shown in the above example gave me this error also, so I made the change in the BC in the hope they become consistent now.
thanks.
edit(1)
Here are the commands I used to plot the plot the solution, and it looks ok
eq = Derivative[2, 0][u][x, t] == Derivative[0, 1][u][x, t]
sol = u /.
First#NDSolve[{eq, Derivative[1, 0][u][0, t] == 0,
Derivative[1, 0][u][Pi, t] == 0, u[x, 0] == Cos[2 x]},
u, {t, 0, 1.5}, {x, 0, Pi}]
Animate[Plot[sol[x, t], {x, 0, Pi},
PlotRange -> {{0, Pi}, {-1, 1}}], {t, 0, 1.5}]
edit(3)
I am still little confused (also did not have coffee yet, which does not help).
I changed the IC so that it is not derivative any more so that the IC (non-derivative) now agrees with the BC's (but those are kept as derivatives). But I still get the same error:
eq = Derivative[2, 0][u][x, t] == Derivative[0, 1][u][x, t]
sol = u /.
First#NDSolve[{eq,
Derivative[1, 0][u][0, t] == 0,
Derivative[1, 0][u][Pi, t] == 0,
u[x, 0] == Sin[2 x]},
u, {t, 0, 1.5}, {x, 0, Pi}
]
NDSolve::ibcinc: Warning: Boundary and initial conditions are inconsistent. >>
Also the solution appears ok when plotted
Animate[Plot[sol[x, t], {x, 0, Pi},
PlotRange -> {{0, Pi}, {-1, 1}}], {t, 0, 1.5}]
What IC is needed for this problem to eliminate this erorr, or is it the case then that only essential BC must be used? and also non-derivative IC's be used, and only after that, I worry on the consistency part?
Szabolcs gave the right hint (See inconsistent boundary condition section in http://reference.wolfram.com/mathematica/tutorial/NDSolvePDE.html)
eq = Derivative[2, 0][u][x, t] == Derivative[0, 1][u][x, t]
sol = u /.
First#NDSolve[{eq, Derivative[1, 0][u][0, t] == 0,
Derivative[1, 0][u][Pi, t] == 0, u[x, 0] == Cos[2 x]},
u, {t, 0, 1.5}, {x, 0, Pi},
Method -> {"MethodOfLines",
"SpatialDiscretization" -> {"TensorProductGrid",
"MinPoints" -> 100}}]
I have filed a suggestion, that the link to the tutorial be added to the NDSolve::ibcinc message page.
I run into the "No more memory available" error message in Mathematica. I understand that "Parallelize[]" isn't (obviously) going to help me. Neither has "ClearSystemCache[]".
What gives? Do I just need more RAM?
My Code
Needs["VectorAnalysis`"]
Needs["DifferentialEquations`InterpolatingFunctionAnatomy`"];
Clear[Eq4, EvapThickFilm, h, S, G, E1, K1, D1, VR, M, R]
Eq4[h_, {S_, G_, E1_, K1_, D1_, VR_, M_, R_}] := \!\(
\*SubscriptBox[\(\[PartialD]\), \(t\)]h\) +
Div[-h^3 G Grad[h] +
h^3 S Grad[Laplacian[h]] + (VR E1^2 h^3)/(D1 (h + K1)^3)
Grad[h] + M (h/(1 + h))^2 Grad[h]] + E1/(
h + K1) + (R/6) D[D[(h^2/(1 + h)), x] h^3, x] == 0;
SetCoordinates[Cartesian[x, y, z]];
EvapThickFilm[S_, G_, E1_, K1_, D1_, VR_, M_, R_] :=
Eq4[h[x, y, t], {S, G, E1, K1, D1, VR, M, R}];
TraditionalForm[EvapThickFilm[S, G, E1, K1, D1, VR, M, R]];
L = 318; TMax = 10;
Off[NDSolve::mxsst];
Clear[Kvar];
Kvar[t_] := Piecewise[{{1, t <= 1}, {2, t > 1}}]
(*Ktemp = Array[0.001+0.001#^2&,13]*)
hSol = h /. NDSolve[{
(*S,G,E,K,D,VR,M*)
EvapThickFilm[1, 3, 0.1, 7, 0.01, 0.1, 0, 160],
h[0, y, t] == h[L, y, t],
h[x, 0, t] == h[x, L, t],
(*h[x,y,0] == 1.1+Cos[x] Sin[2y] *)
h[x, y, 0] ==
1 + (-0.25 Cos[2 \[Pi] x/L] - 0.25 Sin[2 \[Pi] x/L]) Cos[
2 \[Pi] y/L]
},
h,
{x, 0, L},
{y, 0, L},
{t, 0, TMax},
MaxStepSize -> 0.1
][[1]]
hGrid = InterpolatingFunctionGrid[hSol];
Error message
No more memory available.
Mathematica kernel has shut down.
Try quitting other applications and then retry.
My OS specs
Intel Core 2 Duo with 4.00 GB ram, 64 bit OS (Windows 7)
Here you may get a taste of what is happening:
Replace
MaxStepSize -> 0.1
by
MaxStepFraction -> 1/30
And run your code.
Then:
p = Join[#,Reverse##]&#
Table[Plot3D[hSol[x, y, i], {x, 0, L}, {y, 0, L},
PlotRange -> {All, All, {0, 4}}],
{i, 7, 8, .1}]
Export["c:\\plot.gif", p]
So, Mma is trying to refine the solution at those peaks, to no avail.