NOT a answer.
Here is a no successful attempt. Definitive ?
Mathematica has utilities that permit the user to manage time during temporal simulations.
One can advance forward (and even backward) on a certain amount of time. Between theses intervals, I hope it should be possible to change the data.
It is documented in http://reference.wolfram.com/mathematica/tutorial/NDSolveStateData.html#93858351.
I currently use Mathematica 8.0.4., but the functionality I use here are old (maybe Version 5). It is possible that I miss a more recent functionality.
Here is a prolog to this simulation :
ndssdata = First[NDSolve`ProcessEquations[{
D[y[x, t], t] - 4 D[y[x, t], x] == 0,
y[x, 0] == 1/Sqrt[2 \[Pi]] Exp[-(x)^2/2],
y[10, t] == 0
},
y,
{x, -10, 10},
{t, 0, 100}, MaxStepSize -> 0.01,
Method -> {MethodOfLines, TemporalVariable -> t}]]
then one can simulate the first 1.1 seconds :
NDSolve`Iterate[ndssdata, 1.1]
here is the code to see the result :
ndsol = NDSolve`ProcessSolutions[ndssdata]
Plot3D[Evaluate[y[x, t] /. ndsol], {x, -10, 10}, {t, 0, 1.1},
PlotRange -> All]
We can get the actual data from inside the simulator :
actualData=ndssdata@"SolutionVector"["Forward"];
ListPlot[actualData]
It seems that we can modify them, for example multiply them by 2 :
Unprotect[NDSolve`StateData]
ndssdata@"SolutionVector"["Forward"]= 2 ndssdata@"SolutionVector"["Forward"]
ndssdata@"SolutionDerivativeVector"["Forward"]= 2 ndssdata@"SolutionDerivativeVector"
["Forward"]
Protect[NDSolve`StateData]
but it is not effective : ndssdata@"SolutionVector"["Forward"] is not modified
EDIT
At the moment, it seems that to write in ndssdata@"SolutionVector"["Forward"]
is not a solution.
If one want to stop the simulation, change the data, and resume the simulation, there is the possibility to use NDSolve``ReInitialize
:
newstate =
First @ NDSolve`Reinitialize[
ndssdata, {y[x, 0] == 2((ndsol[[1, 2]])[x, 2])}] (* 2="normalisation"*)
NDSolve`Iterate[newstate, 2]
Result :
ndsolnew = NDSolve`ProcessSolutions[newstate]
Plot3D[Evaluate[y[x, t] /. ndsolnew], {x, -10, 10}, {t, 0, 2},
PlotRange -> All]
we see the continuation of the simulation.
Not very good because :
- the time reset to 0 at every ReInitilization
- not applicable to each step
We can view the junction of the two parts with the following code (merge the whole + time of first simulation elongated to 2 seconds + no factor 2):
(* part 1 : *)
ndssdata =
First[NDSolve`ProcessEquations[
{ D[y[x, t], t] - 4 D[y[x, t], x] == 0,
y[x, 0] == 1/Sqrt[2 \[Pi]] Exp[-(x)^2/2],
y[10, t] == 0},
y,
{x, -11, 10},
{t, 0, 100},
MaxStepSize -> 0.01,
Method -> {MethodOfLines, TemporalVariable -> t}
]];
NDSolve`Iterate[ndssdata, 2]
ndsol = NDSolve`ProcessSolutions[ndssdata]
gr1 = Plot3D[Evaluate[y[x, t] /. ndsol],
{x, -10, 3},{t, 0, 2},
PlotRange -> All,PlotStyle -> Specularity[White, 5]];
tEndPartOne = Last[ndssdata @ "CurrentTime"];
(* part 2 : *)
newstate =
First@NDSolve`Reinitialize[
ndssdata,
{y[x, tEndPartOne] == ((ndsol[[1, 2]])[x, 2])}
]
NDSolve`Iterate[newstate, 3.7]
ndsolnew = NDSolve`ProcessSolutions[newstate]
gr2 = Plot3D[Evaluate[y[x, t] /. ndsolnew],
{x, -10, 3},{t, 2, 3.7},
PlotRange -> All];
(* whole :*)
Show[gr1, gr2]
y
at the momentNDSolve
gets the solution for the first time point and then solve they
at the next time point with this solution and so on? …Is it still a PDE-solving issue? $\endgroup$NDSolve
:-) $\endgroup$