pymor.solvers.interface
¶
Module Contents¶
- class pymor.solvers.interface.AdjointSolver(solver)[source]¶
Bases:
Solver
Equation solver.
Solves operator equations of the form
\[A(U; \mu) = V\]The operator \(A\) can be linear or non-linear. When \(A\) is linear, a solver can also be used to solve the adjoint equation
\[A^H(V; \mu) = U\]for \(U\).
When
least_squares
isTrue
, the equations are solved in a least-squares sense:\[\operatorname{argmin}_{U} \|A(U; \mu) - V\|^2 \quad\text{or}\quad \operatorname{argmin}_{V} \|A^H(V; \mu) - U\|^2\]Solvers will typically only work for certain classes of
Operators
. In most cases, solvers are invoked by theapply_inverse
andapply_inverse_adjoint
methods ofOperators
. If anOperator
has no associated solver,DefaultSolver
is used.
- class pymor.solvers.interface.Solver[source]¶
Bases:
pymor.core.base.ImmutableObject
Equation solver.
Solves operator equations of the form
\[A(U; \mu) = V\]The operator \(A\) can be linear or non-linear. When \(A\) is linear, a solver can also be used to solve the adjoint equation
\[A^H(V; \mu) = U\]for \(U\).
When
least_squares
isTrue
, the equations are solved in a least-squares sense:\[\operatorname{argmin}_{U} \|A(U; \mu) - V\|^2 \quad\text{or}\quad \operatorname{argmin}_{V} \|A^H(V; \mu) - U\|^2\]Solvers will typically only work for certain classes of
Operators
. In most cases, solvers are invoked by theapply_inverse
andapply_inverse_adjoint
methods ofOperators
. If anOperator
has no associated solver,DefaultSolver
is used.Methods
Solve operator equation.
Solve adjoint operator equation.
- jacobian_solver = None[source]¶
If not
None
, aSolver
for solving linearized equations.Used by
NewtonSolver
. Ifop
is anOperator
withop.solver
notNone
, thenop.jacobian(U, mu)
will inhert thejacobian_solver
ofop.solver
.
- solve(operator, V, mu=None, initial_guess=None, return_info=False)[source]¶
Solve operator equation.
- Parameters:
operator – The
Operator
\(A\).V – The right-hand side
VectorArray
\(V\).mu – The
parameter values
for which to solve the equation.initial_guess –
VectorArray
with the same length asV
containing initial guesses for the solution. Some solvers ignore this parameter. IfNone
, a solver-dependent default is used.return_info – If
True
, return a dict with additional information on the solution process (runtime, iterations, residuals, etc.) as a second return value.
- Returns:
U –
VectorArray
containing the solutions.info – Dict with additional information. Only returned when
return_info
isTrue
.
- Raises:
InversionError – The equation could not be solved.
- solve_adjoint(operator, U, mu=None, initial_guess=None, return_info=False)[source]¶
Solve adjoint operator equation.
- Parameters:
operator – The
Operator
\(A\).U – The right-hand side
VectorArray
\(U\).mu – The
parameter values
for which to solve the equation.initial_guess –
VectorArray
with the same length asU
containing initial guesses for the solution. Some solvers ignore this parameter. IfNone
, a solver-dependent default is used.return_info – If
True
, return a dict with additional information on the solution process (runtime, iterations, residuals, etc.) as a second return value.
- Returns:
V –
VectorArray
containing the solutions.info – Dict with additional information. Only returned when
return_info
isTrue
.
- Raises:
InversionError – The equation could not be solved.