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)

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)
DAESolution

This is useful where speed is important, but the shape of the solution is not.