Solution Retrieval - PDESolutions
MethodOfLines wraps the solution of its generated DAEProblem, ODEProblem, or NonlinearProblem in a PDE solution object, reshaping it and providing a convenient interface for accessing results and interpolations. Time-dependent problems use PDETimeSeriesSolution; stationary problems use PDENoTimeSolution.
Solution Retrieval
For example, for a PDESystem such as the following:
@named pdesys = PDESystem(eqs, bcs, domains, [t, x, y], [u(t, x, y), v((t, x, y))])after the solve:
sol = solve(prob)You can access the solutions for u and v like this:
solu = sol[u(t, x, y)]
solv = sol[v(t, x, y)]Note that the result in this case will be a 3D Array, dimensions matching the order that they appear in the argument signature of the variable. The time variable must appear either first or last in the arguments, or an error will be thrown.
Grid Retrieval
To access the discretized axes for the independent variables, simply index the solution with the independent variable itself:
disc_t = sol[t]
disc_x = sol[x]
disc_y = sol[y]Interpolations
To access an interpolation of the solution, call the sol object:
#Interpolated solution of `u` at t = 0.4, x = 1.7, y = 2.6
u_interp = sol(0.4, 1.7, 2.6, dv = u(t, x, y))To retrieve an interpolation in all dependent variables as a vector, leave off the dv argument. Be sure to supply a value for every independent variable in the order that they appear in sol.ivs. The vector is in the order of sol.dvs.
uv_interp = sol(0.4, 1.7, 2.6)Stepping with the integrator interface
init and step! do not wrap the solution they accumulate: integ.sol is the plain DAESolution (or ODESolution), which knows only the discretized unknowns, so integ.sol[u(t, x, y)] and integ.sol[x] throw Symbol ... is not present in the system. Wrap the accumulated solution with SciMLBase.wrap_sol whenever the PDE-level interface is wanted:
integ = init(prob)
step!(integ, 0.1, true)
sol = SciMLBase.wrap_sol(integ.sol)
sol[u(t, x, y)] # the saved states so far, as an array over time and the grid
sol[x]The wrapped fields hold the states saved up to that point and are not updated by further steps, so call wrap_sol again after stepping and discard the earlier wrapper.
Original solution
The original solver solution is stored in sol.original_sol.
To avoid wrapping entirely, use the wrap keyword argument to solve:
sol = solve(prob; wrap = Val(false))> typeof(sol)
DAESolutionThis is useful where speed is important, but the shape of the solution is not.