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 is True, 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 the apply_inverse and apply_inverse_adjoint methods of Operators. If an Operator 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 is True, 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 the apply_inverse and apply_inverse_adjoint methods of Operators. If an Operator has no associated solver, DefaultSolver is used.

Methods

solve

Solve operator equation.

solve_adjoint

Solve adjoint operator equation.

jacobian_solver = None[source]

If not None, a Solver for solving linearized equations.

Used by NewtonSolver. If op is an Operator with op.solver not None, then op.jacobian(U, mu) will inhert the jacobian_solver of op.solver.

least_squares = False[source]

If True, the solver solves least-squares problems as defined above.

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_guessVectorArray with the same length as V containing initial guesses for the solution. Some solvers ignore this parameter. If None, 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:

  • UVectorArray containing the solutions.

  • info – Dict with additional information. Only returned when return_info is True.

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_guessVectorArray with the same length as U containing initial guesses for the solution. Some solvers ignore this parameter. If None, 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:

  • VVectorArray containing the solutions.

  • info – Dict with additional information. Only returned when return_info is True.

Raises:

InversionError – The equation could not be solved.