In some applications, it is advantageous to access components of NDSolve
.
However, we could also need to observe the step size taken in the numerical integration, as in Stiffness Detection.
For example:
{ndssdata} = NDSolve`ProcessEquations[{D[u[t, x], t] ==
0.1 D[u[t, x], x, x] + u[t, x] D[u[t, x], x],
u[0, x] == Cos[2 Pi x], u[t, 0] == u[t, 1]}, u, t, {x, 0, 1},
Method -> "StiffnessSwitching"
(*Method\[Rule]"ExplicitRungeKutta"*)]
tm = 1;
NDSolve`Iterate[ndssdata, {0, tm}]
sol = NDSolve`ProcessSolutions[ndssdata]
My questions:
How to obtain and plot the step sizes just as using
StepDataPlot[]
withNDSolve
;How to save the
InterpolatingFunction
u[t,x] in order to upload and plot with it afterward usingGet[...]
andPlot3D[u[t, x] /. sol...]
after closing and re-opening MMA.
I tried DumpSave["test.mx", sol]
and Get["...\\test.mx"]
which gives me
Get::noopen: Cannot open ...\test.mx. >> $Failed
Please leave your comments and thoughts. Thank you for any suggestions and help.
NDSolveUtilities.m
? The implementation ofStepDataPlot[]
should be there, which you can modify for your needs. $\endgroup$FileNameJoin[{$InstallationDirectory, "AddOns", "ExtraPackages", "DifferentialEquations", "NDSolveUtilities.m"}]
. $\endgroup$sol >> "D:\\sol_data"
for storing the data at a particular location (say at D, with a file name sol_data, no extension is required.) To get the data back to a variable, you can writesolImport=<<"D:\\sol_data"
. This will work even after closing and reopening Mathematica. To plot the data, usePlot3D[u[t, x] /. solImport, {t, 0, 1}, {x, 0, 1}]
. $\endgroup$