# pymor.operators package¶

## Submodules¶

### basic module¶

class pymor.operators.basic.LinearComplexifiedListVectorArrayOperatorBase[source]

class pymor.operators.basic.ListVectorArrayOperatorBase[source]
apply(U, mu=None)[source]

Apply the operator to a VectorArray.

Parameters

U

VectorArray of vectors to which the operator is applied.

mu

The Parameter for which to evaluate the operator.

Returns

VectorArray of the operator evaluations.

apply_adjoint(V, mu=None)[source]

Apply the adjoint operator.

For any given linear Operator op, Parameter mu and VectorArrays U, V in the source resp. range we have:

op.apply_adjoint(V, mu).dot(U) == V.dot(op.apply(U, mu))


Thus, when op is represented by a matrix M, apply_adjoint is given by left-multplication of (the complex conjugate of) M with V.

Parameters

V

VectorArray of vectors to which the adjoint operator is applied.

mu

The Parameter for which to apply the adjoint operator.

Returns

VectorArray of the adjoint operator evaluations.

apply_inverse(V, mu=None, least_squares=False)[source]

Apply the inverse operator.

Parameters

V

VectorArray of vectors to which the inverse operator is applied.

mu

The Parameter for which to evaluate the inverse operator.

least_squares

If True, solve the least squares problem:

u = argmin ||op(u) - v||_2.


Since for an invertible operator the least squares solution agrees with the result of the application of the inverse operator, setting this option should, in general, have no effect on the result for those operators. However, note that when no appropriate solver_options are set for the operator, most implementations will choose a least squares solver by default which may be undesirable.

Returns

VectorArray of the inverse operator evaluations.

Raises

InversionError

The operator could not be inverted.

apply_inverse_adjoint(U, mu=None, least_squares=False)[source]

Apply the inverse adjoint operator.

Parameters

U

VectorArray of vectors to which the inverse adjoint operator is applied.

mu

The Parameter for which to evaluate the inverse adjoint operator.

least_squares

If True, solve the least squares problem:

v = argmin ||op^*(v) - u||_2.


Since for an invertible operator the least squares solution agrees with the result of the application of the inverse operator, setting this option should, in general, have no effect on the result for those operators. However, note that when no appropriate solver_options are set for the operator, most operator implementations will choose a least squares solver by default which may be undesirable.

Returns

VectorArray of the inverse adjoint operator evaluations.

Raises

InversionError

The operator could not be inverted.

class pymor.operators.basic.OperatorBase[source]

Base class for Operators providing some default implementations.

When implementing a new operator, it is usually advisable to derive from this class.

__add__(other)[source]

Sum of two operators.

__matmul__(other)[source]

Concatenation of two operators.

__mul__(other)[source]

Product of operator by a scalar.

__radd__(other)

Sum of two operators.

__str__()[source]

Return str(self).

apply2(V, U, mu=None)[source]

Treat the operator as a 2-form by computing V.dot(self.apply(U)).

If the operator is a linear operator given by multiplication with a matrix M, then apply2 is given as:

op.apply2(V, U) = V^T*M*U.


In the case of complex numbers, note that apply2 is anti-linear in the first variable by definition of dot.

Parameters

V

VectorArray of the left arguments V.

U

VectorArray of the right right arguments U.

mu

The Parameter for which to evaluate the operator.

Returns

A NumPy array with shape (len(V), len(U)) containing the 2-form evaluations.

apply_adjoint(V, mu=None)[source]

Apply the adjoint operator.

For any given linear Operator op, Parameter mu and VectorArrays U, V in the source resp. range we have:

op.apply_adjoint(V, mu).dot(U) == V.dot(op.apply(U, mu))


Thus, when op is represented by a matrix M, apply_adjoint is given by left-multplication of (the complex conjugate of) M with V.

Parameters

V

VectorArray of vectors to which the adjoint operator is applied.

mu

The Parameter for which to apply the adjoint operator.

Returns

VectorArray of the adjoint operator evaluations.

apply_inverse(V, mu=None, least_squares=False)[source]

Apply the inverse operator.

Parameters

V

VectorArray of vectors to which the inverse operator is applied.

mu

The Parameter for which to evaluate the inverse operator.

least_squares

If True, solve the least squares problem:

u = argmin ||op(u) - v||_2.


Since for an invertible operator the least squares solution agrees with the result of the application of the inverse operator, setting this option should, in general, have no effect on the result for those operators. However, note that when no appropriate solver_options are set for the operator, most implementations will choose a least squares solver by default which may be undesirable.

Returns

VectorArray of the inverse operator evaluations.

Raises

InversionError

The operator could not be inverted.

apply_inverse_adjoint(U, mu=None, least_squares=False)[source]

Apply the inverse adjoint operator.

Parameters

U

VectorArray of vectors to which the inverse adjoint operator is applied.

mu

The Parameter for which to evaluate the inverse adjoint operator.

least_squares

If True, solve the least squares problem:

v = argmin ||op^*(v) - u||_2.


Since for an invertible operator the least squares solution agrees with the result of the application of the inverse operator, setting this option should, in general, have no effect on the result for those operators. However, note that when no appropriate solver_options are set for the operator, most operator implementations will choose a least squares solver by default which may be undesirable.

Returns

VectorArray of the inverse adjoint operator evaluations.

Raises

InversionError

The operator could not be inverted.

as_range_array(mu=None)[source]

Return a VectorArray representation of the operator in its range space.

In the case of a linear operator with NumpyVectorSpace as source, this method returns for every Parameter mu a VectorArray V in the operator’s range, such that

V.lincomb(U.to_numpy()) == self.apply(U, mu)


for all VectorArrays U.

Parameters

mu

The Parameter for which to return the VectorArray representation.

Returns

V

The VectorArray defined above.

as_source_array(mu=None)[source]

Return a VectorArray representation of the operator in its source space.

In the case of a linear operator with NumpyVectorSpace as range, this method returns for every Parameter mu a VectorArray V in the operator’s source, such that

self.range.make_array(V.dot(U).T) == self.apply(U, mu)


for all VectorArrays U.

Parameters

mu

The Parameter for which to return the VectorArray representation.

Returns

V

The VectorArray defined above.

assemble(mu=None)[source]

Assemble the operator for a given parameter.

The result of the method strongly depends on the given operator. For instance, a matrix-based operator will assemble its matrix, a LincombOperator will try to form the linear combination of its operators, whereas an arbitrary operator might simply return a FixedParameterOperator. The only assured property of the assembled operator is that it no longer depends on a Parameter.

Parameters

mu

The Parameter for which to assemble the operator.

Returns

Parameter-independent, assembled Operator.

d_mu(component, index=())[source]

Return the operator’s derivative with respect to an index of a parameter component.

Parameters

component

Parameter component

index

index in the parameter component

Returns

New Operator representing the partial derivative.

jacobian(U, mu=None)[source]

Return the operator’s Jacobian as a new Operator.

Parameters

U

Length 1 VectorArray containing the vector for which to compute the Jacobian.

mu

The Parameter for which to compute the Jacobian.

Returns

Linear Operator representing the Jacobian.

pairwise_apply2(V, U, mu=None)[source]

Treat the operator as a 2-form by computing V.dot(self.apply(U)).

Same as OperatorInterface.apply2, except that vectors from V and U are applied in pairs.

Parameters

V

VectorArray of the left arguments V.

U

VectorArray of the right right arguments U.

mu

The Parameter for which to evaluate the operator.

Returns

A NumPy array with shape (len(V),) == (len(U),) containing the 2-form evaluations.

class pymor.operators.basic.ProjectedOperator(operator, range_basis, source_basis, product=None, solver_options=None)[source]

Generic Operator representing the projection of an Operator to a subspace.

This operator is implemented as the concatenation of the linear combination with source_basis, application of the original operator and projection onto range_basis. As such, this operator can be used to obtain a reduced basis projection of any given Operator. However, no offline/online decomposition is performed, so this operator is mainly useful for testing before implementing offline/online decomposition for a specific application.

This operator is instantiated in pymor.algorithms.projection.project as a default implementation for parametric or nonlinear operators.

Parameters

operator

The Operator to project.

range_basis
source_basis
product
solver_options

The solver_options for the projected operator.

apply(U, mu=None)[source]

Apply the operator to a VectorArray.

Parameters

U

VectorArray of vectors to which the operator is applied.

mu

The Parameter for which to evaluate the operator.

Returns

VectorArray of the operator evaluations.

apply_adjoint(V, mu=None)[source]

Apply the adjoint operator.

For any given linear Operator op, Parameter mu and VectorArrays U, V in the source resp. range we have:

op.apply_adjoint(V, mu).dot(U) == V.dot(op.apply(U, mu))


Thus, when op is represented by a matrix M, apply_adjoint is given by left-multplication of (the complex conjugate of) M with V.

Parameters

V

VectorArray of vectors to which the adjoint operator is applied.

mu

The Parameter for which to apply the adjoint operator.

Returns

VectorArray of the adjoint operator evaluations.

assemble(mu=None)[source]

Assemble the operator for a given parameter.

The result of the method strongly depends on the given operator. For instance, a matrix-based operator will assemble its matrix, a LincombOperator will try to form the linear combination of its operators, whereas an arbitrary operator might simply return a FixedParameterOperator. The only assured property of the assembled operator is that it no longer depends on a Parameter.

Parameters

mu

The Parameter for which to assemble the operator.

Returns

Parameter-independent, assembled Operator.

jacobian(U, mu=None)[source]

Return the operator’s Jacobian as a new Operator.

Parameters

U

Length 1 VectorArray containing the vector for which to compute the Jacobian.

mu

The Parameter for which to compute the Jacobian.

Returns

Linear Operator representing the Jacobian.

### block module¶

class pymor.operators.block.BlockColumnOperator(blocks)[source]

A column vector of arbitrary Operators.

adjoint_type

alias of BlockRowOperator

class pymor.operators.block.BlockDiagonalOperator(blocks)[source]

Block diagonal Operator of arbitrary Operators.

This is a specialization of BlockOperator for the block diagonal case.

apply(U, mu=None)[source]

Apply the operator to a VectorArray.

Parameters

U

VectorArray of vectors to which the operator is applied.

mu

The Parameter for which to evaluate the operator.

Returns

VectorArray of the operator evaluations.

apply_adjoint(V, mu=None)[source]

Apply the adjoint operator.

For any given linear Operator op, Parameter mu and VectorArrays U, V in the source resp. range we have:

op.apply_adjoint(V, mu).dot(U) == V.dot(op.apply(U, mu))


Thus, when op is represented by a matrix M, apply_adjoint is given by left-multplication of (the complex conjugate of) M with V.

Parameters

V

VectorArray of vectors to which the adjoint operator is applied.

mu

The Parameter for which to apply the adjoint operator.

Returns

VectorArray of the adjoint operator evaluations.

apply_inverse(V, mu=None, least_squares=False)[source]

Apply the inverse operator.

Parameters

V

VectorArray of vectors to which the inverse operator is applied.

mu

The Parameter for which to evaluate the inverse operator.

least_squares

If True, solve the least squares problem:

u = argmin ||op(u) - v||_2.


Since for an invertible operator the least squares solution agrees with the result of the application of the inverse operator, setting this option should, in general, have no effect on the result for those operators. However, note that when no appropriate solver_options are set for the operator, most implementations will choose a least squares solver by default which may be undesirable.

Returns

VectorArray of the inverse operator evaluations.

Raises

InversionError

The operator could not be inverted.

apply_inverse_adjoint(U, mu=None, least_squares=False)[source]

Apply the inverse adjoint operator.

Parameters

U

VectorArray of vectors to which the inverse adjoint operator is applied.

mu

The Parameter for which to evaluate the inverse adjoint operator.

least_squares

If True, solve the least squares problem:

v = argmin ||op^*(v) - u||_2.


Since for an invertible operator the least squares solution agrees with the result of the application of the inverse operator, setting this option should, in general, have no effect on the result for those operators. However, note that when no appropriate solver_options are set for the operator, most operator implementations will choose a least squares solver by default which may be undesirable.

Returns

VectorArray of the inverse adjoint operator evaluations.

Raises

InversionError

The operator could not be inverted.

assemble(mu=None)[source]

Assemble the operator for a given parameter.

The result of the method strongly depends on the given operator. For instance, a matrix-based operator will assemble its matrix, a LincombOperator will try to form the linear combination of its operators, whereas an arbitrary operator might simply return a FixedParameterOperator. The only assured property of the assembled operator is that it no longer depends on a Parameter.

Parameters

mu

The Parameter for which to assemble the operator.

Returns

Parameter-independent, assembled Operator.

class pymor.operators.block.BlockEmbeddingOperator(block_space, component)[source]

class pymor.operators.block.BlockOperator(blocks)[source]

A matrix of arbitrary Operators.

This operator can be applied to a compatible BlockVectorArrays.

Parameters

blocks

Two-dimensional array-like where each entry is an Operator or None.

adjoint_type

alias of BlockOperator

class pymor.operators.block.BlockOperatorBase(blocks)[source]
apply(U, mu=None)[source]

Apply the operator to a VectorArray.

Parameters

U

VectorArray of vectors to which the operator is applied.

mu

The Parameter for which to evaluate the operator.

Returns

VectorArray of the operator evaluations.

apply_adjoint(V, mu=None)[source]

Apply the adjoint operator.

For any given linear Operator op, Parameter mu and VectorArrays U, V in the source resp. range we have:

op.apply_adjoint(V, mu).dot(U) == V.dot(op.apply(U, mu))


Thus, when op is represented by a matrix M, apply_adjoint is given by left-multplication of (the complex conjugate of) M with V.

Parameters

V

VectorArray of vectors to which the adjoint operator is applied.

mu

The Parameter for which to apply the adjoint operator.

Returns

VectorArray of the adjoint operator evaluations.

as_range_array(mu=None)[source]

Return a VectorArray representation of the operator in its range space.

In the case of a linear operator with NumpyVectorSpace as source, this method returns for every Parameter mu a VectorArray V in the operator’s range, such that

V.lincomb(U.to_numpy()) == self.apply(U, mu)


for all VectorArrays U.

Parameters

mu

The Parameter for which to return the VectorArray representation.

Returns

V

The VectorArray defined above.

as_source_array(mu=None)[source]

Return a VectorArray representation of the operator in its source space.

In the case of a linear operator with NumpyVectorSpace as range, this method returns for every Parameter mu a VectorArray V in the operator’s source, such that

self.range.make_array(V.dot(U).T) == self.apply(U, mu)


for all VectorArrays U.

Parameters

mu

The Parameter for which to return the VectorArray representation.

Returns

V

The VectorArray defined above.

assemble(mu=None)[source]

Assemble the operator for a given parameter.

The result of the method strongly depends on the given operator. For instance, a matrix-based operator will assemble its matrix, a LincombOperator will try to form the linear combination of its operators, whereas an arbitrary operator might simply return a FixedParameterOperator. The only assured property of the assembled operator is that it no longer depends on a Parameter.

Parameters

mu

The Parameter for which to assemble the operator.

Returns

Parameter-independent, assembled Operator.

class pymor.operators.block.BlockProjectionOperator(block_space, component)[source]

class pymor.operators.block.BlockRowOperator(blocks)[source]

A row vector of arbitrary Operators.

adjoint_type

alias of BlockColumnOperator

class pymor.operators.block.SecondOrderModelOperator(E, K)[source]

BlockOperator appearing in SecondOrderModel.to_lti().

This represents a block operator

which satisfies

Parameters

E
K
apply(U, mu=None)[source]

Apply the operator to a VectorArray.

Parameters

U

VectorArray of vectors to which the operator is applied.

mu

The Parameter for which to evaluate the operator.

Returns

VectorArray of the operator evaluations.

apply_adjoint(V, mu=None)[source]

Apply the adjoint operator.

For any given linear Operator op, Parameter mu and VectorArrays U, V in the source resp. range we have:

op.apply_adjoint(V, mu).dot(U) == V.dot(op.apply(U, mu))


Thus, when op is represented by a matrix M, apply_adjoint is given by left-multplication of (the complex conjugate of) M with V.

Parameters

V

VectorArray of vectors to which the adjoint operator is applied.

mu

The Parameter for which to apply the adjoint operator.

Returns

VectorArray of the adjoint operator evaluations.

apply_inverse(V, mu=None, least_squares=False)[source]

Apply the inverse operator.

Parameters

V

VectorArray of vectors to which the inverse operator is applied.

mu

The Parameter for which to evaluate the inverse operator.

least_squares

If True, solve the least squares problem:

u = argmin ||op(u) - v||_2.


Since for an invertible operator the least squares solution agrees with the result of the application of the inverse operator, setting this option should, in general, have no effect on the result for those operators. However, note that when no appropriate solver_options are set for the operator, most implementations will choose a least squares solver by default which may be undesirable.

Returns

VectorArray of the inverse operator evaluations.

Raises

InversionError

The operator could not be inverted.

apply_inverse_adjoint(U, mu=None, least_squares=False)[source]

Apply the inverse adjoint operator.

Parameters

U

VectorArray of vectors to which the inverse adjoint operator is applied.

mu

The Parameter for which to evaluate the inverse adjoint operator.

least_squares

If True, solve the least squares problem:

v = argmin ||op^*(v) - u||_2.


Since for an invertible operator the least squares solution agrees with the result of the application of the inverse operator, setting this option should, in general, have no effect on the result for those operators. However, note that when no appropriate solver_options are set for the operator, most operator implementations will choose a least squares solver by default which may be undesirable.

Returns

VectorArray of the inverse adjoint operator evaluations.

Raises

InversionError

The operator could not be inverted.

assemble(mu=None)[source]

Assemble the operator for a given parameter.

The result of the method strongly depends on the given operator. For instance, a matrix-based operator will assemble its matrix, a LincombOperator will try to form the linear combination of its operators, whereas an arbitrary operator might simply return a FixedParameterOperator. The only assured property of the assembled operator is that it no longer depends on a Parameter.

Parameters

mu

The Parameter for which to assemble the operator.

Returns

Parameter-independent, assembled Operator.

class pymor.operators.block.ShiftedSecondOrderModelOperator(M, E, K, a, b)[source]

BlockOperator appearing in second-order systems.

This represents a block operator

which satisfies

Parameters

M
E
K
a, b

Complex numbers.

apply(U, mu=None)[source]

Apply the operator to a VectorArray.

Parameters

U

VectorArray of vectors to which the operator is applied.

mu

The Parameter for which to evaluate the operator.

Returns

VectorArray of the operator evaluations.

apply_adjoint(V, mu=None)[source]

Apply the adjoint operator.

For any given linear Operator op, Parameter mu and VectorArrays U, V in the source resp. range we have:

op.apply_adjoint(V, mu).dot(U) == V.dot(op.apply(U, mu))


Thus, when op is represented by a matrix M, apply_adjoint is given by left-multplication of (the complex conjugate of) M with V.

Parameters

V

VectorArray of vectors to which the adjoint operator is applied.

mu

The Parameter for which to apply the adjoint operator.

Returns

VectorArray of the adjoint operator evaluations.

apply_inverse(V, mu=None, least_squares=False)[source]

Apply the inverse operator.

Parameters

V

VectorArray of vectors to which the inverse operator is applied.

mu

The Parameter for which to evaluate the inverse operator.

least_squares

If True, solve the least squares problem:

u = argmin ||op(u) - v||_2.


Since for an invertible operator the least squares solution agrees with the result of the application of the inverse operator, setting this option should, in general, have no effect on the result for those operators. However, note that when no appropriate solver_options are set for the operator, most implementations will choose a least squares solver by default which may be undesirable.

Returns

VectorArray of the inverse operator evaluations.

Raises

InversionError

The operator could not be inverted.

apply_inverse_adjoint(U, mu=None, least_squares=False)[source]

Apply the inverse adjoint operator.

Parameters

U

VectorArray of vectors to which the inverse adjoint operator is applied.

mu

The Parameter for which to evaluate the inverse adjoint operator.

least_squares

If True, solve the least squares problem:

v = argmin ||op^*(v) - u||_2.


Since for an invertible operator the least squares solution agrees with the result of the application of the inverse operator, setting this option should, in general, have no effect on the result for those operators. However, note that when no appropriate solver_options are set for the operator, most operator implementations will choose a least squares solver by default which may be undesirable.

Returns

VectorArray of the inverse adjoint operator evaluations.

Raises

InversionError

The operator could not be inverted.

assemble(mu=None)[source]

Assemble the operator for a given parameter.

The result of the method strongly depends on the given operator. For instance, a matrix-based operator will assemble its matrix, a LincombOperator will try to form the linear combination of its operators, whereas an arbitrary operator might simply return a FixedParameterOperator. The only assured property of the assembled operator is that it no longer depends on a Parameter.

Parameters

mu

The Parameter for which to assemble the operator.

Returns

Parameter-independent, assembled Operator.

### cg module¶

This module provides some operators for continuous finite element discretizations.

class pymor.operators.cg.AdvectionOperatorP1(grid, boundary_info, advection_function=None, advection_constant=None, dirichlet_clear_columns=False, dirichlet_clear_diag=False, solver_options=None, name=None)[source]

Linear advection Operator for linear finite elements.

The operator is of the form

(Lu)(x) = c ∇ ⋅ [ v(x) u(x) ]


The function v is vector-valued.

Parameters

grid

The Grid for which to assemble the operator.

boundary_info

BoundaryInfo for the treatment of Dirichlet boundary conditions.

advection_function

The Function v(x) with shape_range = (grid.dim, ). If None, constant one is assumed.

advection_constant

The constant c. If None, c is set to one.

dirichlet_clear_columns

If True, set columns of the system matrix corresponding to Dirichlet boundary DOFs to zero to obtain a symmetric system matrix. Otherwise, only the rows will be set to zero.

dirichlet_clear_diag

If True, also set diagonal entries corresponding to Dirichlet boundary DOFs to zero. Otherwise they are set to one.

solver_options

The solver_options for the operator.

name

Name of the operator.

class pymor.operators.cg.AdvectionOperatorQ1(grid, boundary_info, advection_function=None, advection_constant=None, dirichlet_clear_columns=False, dirichlet_clear_diag=False, solver_options=None, name=None)[source]

Linear advection Operator for bilinear finite elements.

The operator is of the form

(Lu)(x) = c ∇ ⋅ [ v(x) u(x) ]


The function v has to be vector-valued.

Parameters

grid

The Grid for which to assemble the operator.

boundary_info

BoundaryInfo for the treatment of Dirichlet boundary conditions.

advection_function

The Function v(x) with shape_range = (grid.dim, ). If None, constant one is assumed.

advection_constant

The constant c. If None, c is set to one.

dirichlet_clear_columns

If True, set columns of the system matrix corresponding to Dirichlet boundary DOFs to zero to obtain a symmetric system matrix. Otherwise, only the rows will be set to zero.

dirichlet_clear_diag

If True, also set diagonal entries corresponding to Dirichlet boundary DOFs to zero. Otherwise they are set to one.

solver_options

The solver_options for the operator.

name

Name of the operator.

class pymor.operators.cg.BoundaryDirichletFunctional(grid, dirichlet_data, boundary_info, name=None)[source]

Linear finite element functional for enforcing Dirichlet boundary values.

Parameters

grid

Grid for which to assemble the functional.

dirichlet_data

Function providing the Dirichlet boundary values.

boundary_info

BoundaryInfo determining the Dirichlet boundaries.

name

The name of the functional.

class pymor.operators.cg.BoundaryL2ProductFunctional(grid, function, boundary_type=None, dirichlet_clear_dofs=False, boundary_info=None, name=None)[source]

Linear finite element functional representing the inner product with an L2-Function on the boundary.

Parameters

grid

Grid for which to assemble the functional.

function

The Function with which to take the inner product.

boundary_type

The type of domain boundary (e.g. ‘neumann’) on which to assemble the functional. If None the functional is assembled over the whole boundary.

dirichlet_clear_dofs

If True, set dirichlet boundary DOFs to zero.

boundary_info

If boundary_type is specified or dirichlet_clear_dofs is True, the BoundaryInfo determining which boundary entity belongs to which physical boundary.

name

The name of the functional.

pymor.operators.cg.CGVectorSpace(grid, id='STATE')[source]

class pymor.operators.cg.DiffusionOperatorP1(grid, boundary_info, diffusion_function=None, diffusion_constant=None, dirichlet_clear_columns=False, dirichlet_clear_diag=False, solver_options=None, name=None)[source]

Diffusion Operator for linear finite elements.

The operator is of the form

(Lu)(x) = c ∇ ⋅ [ d(x) ∇ u(x) ]


The function d can be scalar- or matrix-valued.

Parameters

grid

The Grid for which to assemble the operator.

boundary_info

BoundaryInfo for the treatment of Dirichlet boundary conditions.

diffusion_function

The Function d(x) with shape_range == () or shape_range = (grid.dim, grid.dim). If None, constant one is assumed.

diffusion_constant

The constant c. If None, c is set to one.

dirichlet_clear_columns

If True, set columns of the system matrix corresponding to Dirichlet boundary DOFs to zero to obtain a symmetric system matrix. Otherwise, only the rows will be set to zero.

dirichlet_clear_diag

If True, also set diagonal entries corresponding to Dirichlet boundary DOFs to zero. Otherwise they are set to one.

solver_options

The solver_options for the operator.

name

Name of the operator.

class pymor.operators.cg.DiffusionOperatorQ1(grid, boundary_info, diffusion_function=None, diffusion_constant=None, dirichlet_clear_columns=False, dirichlet_clear_diag=False, solver_options=None, name=None)[source]

Diffusion Operator for bilinear finite elements.

The operator is of the form

(Lu)(x) = c ∇ ⋅ [ d(x) ∇ u(x) ]


The function d can be scalar- or matrix-valued.

Parameters

grid

The Grid for which to assemble the operator.

boundary_info

BoundaryInfo for the treatment of Dirichlet boundary conditions.

diffusion_function

The Function d(x) with shape_range == () or shape_range = (grid.dim, grid.dim). If None, constant one is assumed.

diffusion_constant

The constant c. If None, c is set to one.

dirichlet_clear_columns

If True, set columns of the system matrix corresponding to Dirichlet boundary DOFs to zero to obtain a symmetric system matrix. Otherwise, only the rows will be set to zero.

dirichlet_clear_diag

If True, also set diagonal entries corresponding to Dirichlet boundary DOFs to zero. Otherwise they are set to one.

solver_options

The solver_options for the operator.

name

Name of the operator.

class pymor.operators.cg.InterpolationOperator(grid, function)[source]

Vector-like Lagrange interpolation Operator for continuous finite element spaces.

Parameters

grid

The Grid on which to interpolate.

function

The Function to interpolate.

class pymor.operators.cg.L2ProductFunctionalP1(grid, function, dirichlet_clear_dofs=False, boundary_info=None, name=None)[source]

Linear finite element functional representing the inner product with an L2-Function.

Parameters

grid

Grid for which to assemble the functional.

function

The Function with which to take the inner product.

dirichlet_clear_dofs

If True, set dirichlet boundary DOFs to zero.

boundary_info

BoundaryInfo determining the Dirichlet boundaries in case dirichlet_clear_dofs is set to True.

name

The name of the functional.

class pymor.operators.cg.L2ProductFunctionalQ1(grid, function, dirichlet_clear_dofs=False, boundary_info=None, name=None)[source]

Bilinear finite element functional representing the inner product with an L2-Function.

Parameters

grid

Grid for which to assemble the functional.

function

The Function with which to take the inner product.

dirichlet_clear_dofs

If True, set dirichlet boundary DOFs to zero.

boundary_info

BoundaryInfo determining the Dirichlet boundaries in case dirichlet_clear_dofs is set to True.

name

The name of the functional.

class pymor.operators.cg.L2ProductP1(grid, boundary_info, dirichlet_clear_rows=True, dirichlet_clear_columns=False, dirichlet_clear_diag=False, coefficient_function=None, solver_options=None, name=None)[source]

Operator representing the L2-product between linear finite element functions.

Parameters

grid

The Grid for which to assemble the product.

boundary_info

BoundaryInfo for the treatment of Dirichlet boundary conditions.

dirichlet_clear_rows

If True, set the rows of the system matrix corresponding to Dirichlet boundary DOFs to zero.

dirichlet_clear_columns

If True, set columns of the system matrix corresponding to Dirichlet boundary DOFs to zero.

dirichlet_clear_diag

If True, also set diagonal entries corresponding to Dirichlet boundary DOFs to zero. Otherwise, if either dirichlet_clear_rows or dirichlet_clear_columns is True, the diagonal entries are set to one.

coefficient_function

Coefficient Function for product with shape_range == (). If None, constant one is assumed.

solver_options

The solver_options for the operator.

name

The name of the product.

class pymor.operators.cg.L2ProductQ1(grid, boundary_info, dirichlet_clear_rows=True, dirichlet_clear_columns=False, dirichlet_clear_diag=False, coefficient_function=None, solver_options=None, name=None)[source]

Operator representing the L2-product between bilinear finite element functions.

Parameters

grid

The Grid for which to assemble the product.

boundary_info

BoundaryInfo for the treatment of Dirichlet boundary conditions.

dirichlet_clear_rows

If True, set the rows of the system matrix corresponding to Dirichlet boundary DOFs to zero.

dirichlet_clear_columns

If True, set columns of the system matrix corresponding to Dirichlet boundary DOFs to zero.

dirichlet_clear_diag

If True, also set diagonal entries corresponding to Dirichlet boundary DOFs to zero. Otherwise, if either dirichlet_clear_rows or dirichlet_clear_columns is True, the diagonal entries are set to one.

coefficient_function

Coefficient Function for product with shape_range == (). If None, constant one is assumed.

solver_options

The solver_options for the operator.

name

The name of the product.

class pymor.operators.cg.RobinBoundaryOperator(grid, boundary_info, robin_data=None, solver_options=None, name=None)[source]

Robin boundary Operator for linear finite elements.

The operator represents the contribution of Robin boundary conditions to the stiffness matrix, where the boundary condition is supposed to be given in the form

-[ d(x) ∇u(x) ] ⋅ n(x) = c(x) (u(x) - g(x))


d and n are the diffusion function (see DiffusionOperatorP1) and the unit outer normal in x, while c is the (scalar) Robin parameter function and g is the (also scalar) Robin boundary value function.

Parameters

grid

The Grid over which to assemble the operator.

boundary_info

BoundaryInfo for the treatment of Dirichlet boundary conditions.

robin_data

Tuple providing two Functions that represent the Robin parameter and boundary value function. If None, the resulting operator is zero.

solver_options

The solver_options for the operator.

name

Name of the operator.

### constructions module¶

Module containing some constructions to obtain new operators from old ones.

class pymor.operators.constructions.AdjointOperator(operator, source_product=None, range_product=None, name=None, with_apply_inverse=True, solver_options=None)[source]

Represents the adjoint of a given linear Operator.

For a linear Operator op the adjoint op^* of op is given by:

(op^*(v), u)_s = (v, op(u))_r,


where ( , )_s and ( , )_r denote the inner products on the source and range space of op. If two products are given by P_s and P_r, then:

op^*(v) = P_s^(-1) o op.H o P_r,


Thus, if ( , )_s and ( , )_r are the Euclidean inner products, op^*v is simply given by application of the :attr:adjoint <pymor.operators.interface.OperatorInterface.H> Operator.

Parameters

operator

The Operator of which the adjoint is formed.

source_product

If not None, inner product Operator for the source VectorSpace w.r.t. which to take the adjoint.

range_product

If not None, inner product Operator for the range VectorSpace w.r.t. which to take the adjoint.

name

If not None, name of the operator.

with_apply_inverse

If True, provide own apply_inverse and apply_inverse_adjoint implementations by calling these methods on the given operator. (Is set to False in the default implementation of and apply_inverse_adjoint.)

solver_options

When with_apply_inverse is False, the solver_options to use for the apply_inverse default implementation.

apply(U, mu=None)[source]

Apply the operator to a VectorArray.

Parameters

U

VectorArray of vectors to which the operator is applied.

mu

The Parameter for which to evaluate the operator.

Returns

VectorArray of the operator evaluations.

apply_adjoint(V, mu=None)[source]

Apply the adjoint operator.

For any given linear Operator op, Parameter mu and VectorArrays U, V in the source resp. range we have:

op.apply_adjoint(V, mu).dot(U) == V.dot(op.apply(U, mu))


Thus, when op is represented by a matrix M, apply_adjoint is given by left-multplication of (the complex conjugate of) M with V.

Parameters

V

VectorArray of vectors to which the adjoint operator is applied.

mu

The Parameter for which to apply the adjoint operator.

Returns

VectorArray of the adjoint operator evaluations.

apply_inverse(V, mu=None, least_squares=False)[source]

Apply the inverse operator.

Parameters

V

VectorArray of vectors to which the inverse operator is applied.

mu

The Parameter for which to evaluate the inverse operator.

least_squares

If True, solve the least squares problem:

u = argmin ||op(u) - v||_2.


Since for an invertible operator the least squares solution agrees with the result of the application of the inverse operator, setting this option should, in general, have no effect on the result for those operators. However, note that when no appropriate solver_options are set for the operator, most implementations will choose a least squares solver by default which may be undesirable.

Returns

VectorArray of the inverse operator evaluations.

Raises

InversionError

The operator could not be inverted.

apply_inverse_adjoint(U, mu=None, least_squares=False)[source]

Apply the inverse adjoint operator.

Parameters

U

VectorArray of vectors to which the inverse adjoint operator is applied.

mu

The Parameter for which to evaluate the inverse adjoint operator.

least_squares

If True, solve the least squares problem:

v = argmin ||op^*(v) - u||_2.


Since for an invertible operator the least squares solution agrees with the result of the application of the inverse operator, setting this option should, in general, have no effect on the result for those operators. However, note that when no appropriate solver_options are set for the operator, most operator implementations will choose a least squares solver by default which may be undesirable.

Returns

VectorArray of the inverse adjoint operator evaluations.

Raises

InversionError

The operator could not be inverted.

class pymor.operators.constructions.AffineOperator(operator, name=None)[source]

Decompose an affine Operator into affine_shift and linear_part.

jacobian(U, mu=None)[source]

Return the operator’s Jacobian as a new Operator.

Parameters

U

Length 1 VectorArray containing the vector for which to compute the Jacobian.

mu

The Parameter for which to compute the Jacobian.

Returns

Linear Operator representing the Jacobian.

class pymor.operators.constructions.ComponentProjection(components, source, name=None)[source]

Operator representing the projection of a VectorArray onto some of its components.

Parameters

components

List or 1D NumPy array of the indices of the vector components that are to be extracted by the operator.

source

Source VectorSpace of the operator.

name

Name of the operator.

apply(U, mu=None)[source]

Apply the operator to a VectorArray.

Parameters

U

VectorArray of vectors to which the operator is applied.

mu

The Parameter for which to evaluate the operator.

Returns

VectorArray of the operator evaluations.

restricted(dofs)[source]

Restrict the operator range to a given set of degrees of freedom.

This method returns a restricted version restricted_op of the operator along with an array source_dofs such that for any VectorArray U in self.source the following is true:

self.apply(U, mu).dofs(dofs)
== restricted_op.apply(NumpyVectorArray(U.dofs(source_dofs)), mu))


Such an operator is mainly useful for empirical interpolation where the evaluation of the original operator only needs to be known for few selected degrees of freedom. If the operator has a small stencil, only few source_dofs will be needed to evaluate the restricted operator which can make its evaluation very fast compared to evaluating the original operator.

Parameters

dofs

One-dimensional NumPy array of degrees of freedom in the operator range to which to restrict.

Returns

restricted_op

The restricted operator as defined above. The operator will have NumpyVectorSpace (len(source_dofs)) as source and NumpyVectorSpace (len(dofs)) as range.

source_dofs

One-dimensional NumPy array of source degrees of freedom as defined above.

class pymor.operators.constructions.Concatenation(operators, solver_options=None, name=None)[source]

Operator representing the concatenation of two Operators.

Parameters

operators

Tuple of Operators to concatenate. operators[-1] is the first applied operator, operators[0] is the last applied operator.

solver_options

The solver_options for the operator.

name

Name of the operator.

__matmul__(other)[source]

Concatenation of two operators.

apply(U, mu=None)[source]

Apply the operator to a VectorArray.

Parameters

U

VectorArray of vectors to which the operator is applied.

mu

The Parameter for which to evaluate the operator.

Returns

VectorArray of the operator evaluations.

apply_adjoint(V, mu=None)[source]

Apply the adjoint operator.

For any given linear Operator op, Parameter mu and VectorArrays U, V in the source resp. range we have:

op.apply_adjoint(V, mu).dot(U) == V.dot(op.apply(U, mu))


Thus, when op is represented by a matrix M, apply_adjoint is given by left-multplication of (the complex conjugate of) M with V.

Parameters

V

VectorArray of vectors to which the adjoint operator is applied.

mu

The Parameter for which to apply the adjoint operator.

Returns

VectorArray of the adjoint operator evaluations.

jacobian(U, mu=None)[source]

Return the operator’s Jacobian as a new Operator.

Parameters

U

Length 1 VectorArray containing the vector for which to compute the Jacobian.

mu

The Parameter for which to compute the Jacobian.

Returns

Linear Operator representing the Jacobian.

restricted(dofs)[source]

Restrict the operator range to a given set of degrees of freedom.

This method returns a restricted version restricted_op of the operator along with an array source_dofs such that for any VectorArray U in self.source the following is true:

self.apply(U, mu).dofs(dofs)
== restricted_op.apply(NumpyVectorArray(U.dofs(source_dofs)), mu))


Such an operator is mainly useful for empirical interpolation where the evaluation of the original operator only needs to be known for few selected degrees of freedom. If the operator has a small stencil, only few source_dofs will be needed to evaluate the restricted operator which can make its evaluation very fast compared to evaluating the original operator.

Parameters

dofs

One-dimensional NumPy array of degrees of freedom in the operator range to which to restrict.

Returns

restricted_op

The restricted operator as defined above. The operator will have NumpyVectorSpace (len(source_dofs)) as source and NumpyVectorSpace (len(dofs)) as range.

source_dofs

One-dimensional NumPy array of source degrees of freedom as defined above.

class pymor.operators.constructions.ConstantOperator(value, source, name=None)[source]

A constant Operator always returning the same vector.

Parameters

value

A VectorArray of length 1 containing the vector which is returned by the operator.

source

Source VectorSpace of the operator.

name

Name of the operator.

apply(U, mu=None)[source]

Apply the operator to a VectorArray.

Parameters

U

VectorArray of vectors to which the operator is applied.

mu

The Parameter for which to evaluate the operator.

Returns

VectorArray of the operator evaluations.

apply_inverse(V, mu=None, least_squares=False)[source]

Apply the inverse operator.

Parameters

V

VectorArray of vectors to which the inverse operator is applied.

mu

The Parameter for which to evaluate the inverse operator.

least_squares

If True, solve the least squares problem:

u = argmin ||op(u) - v||_2.


Since for an invertible operator the least squares solution agrees with the result of the application of the inverse operator, setting this option should, in general, have no effect on the result for those operators. However, note that when no appropriate solver_options are set for the operator, most implementations will choose a least squares solver by default which may be undesirable.

Returns

VectorArray of the inverse operator evaluations.

Raises

InversionError

The operator could not be inverted.

jacobian(U, mu=None)[source]

Return the operator’s Jacobian as a new Operator.

Parameters

U

Length 1 VectorArray containing the vector for which to compute the Jacobian.

mu

The Parameter for which to compute the Jacobian.

Returns

Linear Operator representing the Jacobian.

restricted(dofs)[source]

Restrict the operator range to a given set of degrees of freedom.

This method returns a restricted version restricted_op of the operator along with an array source_dofs such that for any VectorArray U in self.source the following is true:

self.apply(U, mu).dofs(dofs)
== restricted_op.apply(NumpyVectorArray(U.dofs(source_dofs)), mu))


Such an operator is mainly useful for empirical interpolation where the evaluation of the original operator only needs to be known for few selected degrees of freedom. If the operator has a small stencil, only few source_dofs will be needed to evaluate the restricted operator which can make its evaluation very fast compared to evaluating the original operator.

Parameters

dofs

One-dimensional NumPy array of degrees of freedom in the operator range to which to restrict.

Returns

restricted_op

The restricted operator as defined above. The operator will have NumpyVectorSpace (len(source_dofs)) as source and NumpyVectorSpace (len(dofs)) as range.

source_dofs

One-dimensional NumPy array of source degrees of freedom as defined above.

class pymor.operators.constructions.FixedParameterOperator(operator, mu=None, name=None)[source]

Makes an Operator Parameter-independent by setting a fixed Parameter.

Parameters

operator

The Operator to wrap.

mu

The fixed Parameter that will be fed to the apply method (and related methods) of operator.

apply(U, mu=None)[source]

Apply the operator to a VectorArray.

Parameters

U

VectorArray of vectors to which the operator is applied.

mu

The Parameter for which to evaluate the operator.

Returns

VectorArray of the operator evaluations.

apply_adjoint(V, mu=None)[source]

Apply the adjoint operator.

For any given linear Operator op, Parameter mu and VectorArrays U, V in the source resp. range we have:

op.apply_adjoint(V, mu).dot(U) == V.dot(op.apply(U, mu))


Thus, when op is represented by a matrix M, apply_adjoint is given by left-multplication of (the complex conjugate of) M with V.

Parameters

V

VectorArray of vectors to which the adjoint operator is applied.

mu

The Parameter for which to apply the adjoint operator.

Returns

VectorArray of the adjoint operator evaluations.

apply_inverse(V, mu=None, least_squares=False)[source]

Apply the inverse operator.

Parameters

V

VectorArray of vectors to which the inverse operator is applied.

mu

The Parameter for which to evaluate the inverse operator.

least_squares

If True, solve the least squares problem:

u = argmin ||op(u) - v||_2.


Since for an invertible operator the least squares solution agrees with the result of the application of the inverse operator, setting this option should, in general, have no effect on the result for those operators. However, note that when no appropriate solver_options are set for the operator, most implementations will choose a least squares solver by default which may be undesirable.

Returns

VectorArray of the inverse operator evaluations.

Raises

InversionError

The operator could not be inverted.

apply_inverse_adjoint(U, mu=None, least_squares=False)[source]

Apply the inverse adjoint operator.

Parameters

U

VectorArray of vectors to which the inverse adjoint operator is applied.

mu

The Parameter for which to evaluate the inverse adjoint operator.

least_squares

If True, solve the least squares problem:

v = argmin ||op^*(v) - u||_2.


Since for an invertible operator the least squares solution agrees with the result of the application of the inverse operator, setting this option should, in general, have no effect on the result for those operators. However, note that when no appropriate solver_options are set for the operator, most operator implementations will choose a least squares solver by default which may be undesirable.

Returns

VectorArray of the inverse adjoint operator evaluations.

Raises

InversionError

The operator could not be inverted.

jacobian(U, mu=None)[source]

Return the operator’s Jacobian as a new Operator.

Parameters

U

Length 1 VectorArray containing the vector for which to compute the Jacobian.

mu

The Parameter for which to compute the Jacobian.

Returns

Linear Operator representing the Jacobian.

class pymor.operators.constructions.IdentityOperator(space, name=None)[source]

The identity Operator.

In other words:

op.apply(U) == U


Parameters

space

The VectorSpace the operator acts on.

name

Name of the operator.

apply(U, mu=None)[source]

Apply the operator to a VectorArray.

Parameters

U

VectorArray of vectors to which the operator is applied.

mu

The Parameter for which to evaluate the operator.

Returns

VectorArray of the operator evaluations.

apply_adjoint(V, mu=None)[source]

Apply the adjoint operator.

For any given linear Operator op, Parameter mu and VectorArrays U, V in the source resp. range we have:

op.apply_adjoint(V, mu).dot(U) == V.dot(op.apply(U, mu))


Thus, when op is represented by a matrix M, apply_adjoint is given by left-multplication of (the complex conjugate of) M with V.

Parameters

V

VectorArray of vectors to which the adjoint operator is applied.

mu

The Parameter for which to apply the adjoint operator.

Returns

VectorArray of the adjoint operator evaluations.

apply_inverse(V, mu=None, least_squares=False)[source]

Apply the inverse operator.

Parameters

V

VectorArray of vectors to which the inverse operator is applied.

mu

The Parameter for which to evaluate the inverse operator.

least_squares

If True, solve the least squares problem:

u = argmin ||op(u) - v||_2.


Since for an invertible operator the least squares solution agrees with the result of the application of the inverse operator, setting this option should, in general, have no effect on the result for those operators. However, note that when no appropriate solver_options are set for the operator, most implementations will choose a least squares solver by default which may be undesirable.

Returns

VectorArray of the inverse operator evaluations.

Raises

InversionError

The operator could not be inverted.

apply_inverse_adjoint(U, mu=None, least_squares=False)[source]

Apply the inverse adjoint operator.

Parameters

U

VectorArray of vectors to which the inverse adjoint operator is applied.

mu

The Parameter for which to evaluate the inverse adjoint operator.

least_squares

If True, solve the least squares problem:

v = argmin ||op^*(v) - u||_2.


Since for an invertible operator the least squares solution agrees with the result of the application of the inverse operator, setting this option should, in general, have no effect on the result for those operators. However, note that when no appropriate solver_options are set for the operator, most operator implementations will choose a least squares solver by default which may be undesirable.

Returns

VectorArray of the inverse adjoint operator evaluations.

Raises

InversionError

The operator could not be inverted.

assemble(mu=None)[source]

Assemble the operator for a given parameter.

The result of the method strongly depends on the given operator. For instance, a matrix-based operator will assemble its matrix, a LincombOperator will try to form the linear combination of its operators, whereas an arbitrary operator might simply return a FixedParameterOperator. The only assured property of the assembled operator is that it no longer depends on a Parameter.

Parameters

mu

The Parameter for which to assemble the operator.

Returns

Parameter-independent, assembled Operator.

restricted(dofs)[source]

Restrict the operator range to a given set of degrees of freedom.

This method returns a restricted version restricted_op of the operator along with an array source_dofs such that for any VectorArray U in self.source the following is true:

self.apply(U, mu).dofs(dofs)
== restricted_op.apply(NumpyVectorArray(U.dofs(source_dofs)), mu))


Such an operator is mainly useful for empirical interpolation where the evaluation of the original operator only needs to be known for few selected degrees of freedom. If the operator has a small stencil, only few source_dofs will be needed to evaluate the restricted operator which can make its evaluation very fast compared to evaluating the original operator.

Parameters

dofs

One-dimensional NumPy array of degrees of freedom in the operator range to which to restrict.

Returns

restricted_op

The restricted operator as defined above. The operator will have NumpyVectorSpace (len(source_dofs)) as source and NumpyVectorSpace (len(dofs)) as range.

source_dofs

One-dimensional NumPy array of source degrees of freedom as defined above.

class pymor.operators.constructions.InducedNorm(product, raise_negative, tol, name)[source]

Instantiated by induced_norm. Do not use directly.

__call__(U, mu=None)[source]

Call self as a function.

class pymor.operators.constructions.InverseAdjointOperator(operator, name=None)[source]

Represents the inverse adjoint of a given Operator.

Parameters

operator

The Operator of which the inverse adjoint is formed.

name

If not None, name of the operator.

apply(U, mu=None)[source]

Apply the operator to a VectorArray.

Parameters

U

VectorArray of vectors to which the operator is applied.

mu

The Parameter for which to evaluate the operator.

Returns

VectorArray of the operator evaluations.

apply_adjoint(V, mu=None)[source]

Apply the adjoint operator.

For any given linear Operator op, Parameter mu and VectorArrays U, V in the source resp. range we have:

op.apply_adjoint(V, mu).dot(U) == V.dot(op.apply(U, mu))


Thus, when op is represented by a matrix M, apply_adjoint is given by left-multplication of (the complex conjugate of) M with V.

Parameters

V

VectorArray of vectors to which the adjoint operator is applied.

mu

The Parameter for which to apply the adjoint operator.

Returns

VectorArray of the adjoint operator evaluations.

apply_inverse(V, mu=None, least_squares=False)[source]

Apply the inverse operator.

Parameters

V

VectorArray of vectors to which the inverse operator is applied.

mu

The Parameter for which to evaluate the inverse operator.

least_squares

If True, solve the least squares problem:

u = argmin ||op(u) - v||_2.


Since for an invertible operator the least squares solution agrees with the result of the application of the inverse operator, setting this option should, in general, have no effect on the result for those operators. However, note that when no appropriate solver_options are set for the operator, most implementations will choose a least squares solver by default which may be undesirable.

Returns

VectorArray of the inverse operator evaluations.

Raises

InversionError

The operator could not be inverted.

apply_inverse_adjoint(U, mu=None, least_squares=False)[source]

Apply the inverse adjoint operator.

Parameters

U

VectorArray of vectors to which the inverse adjoint operator is applied.

mu

The Parameter for which to evaluate the inverse adjoint operator.

least_squares

If True, solve the least squares problem:

v = argmin ||op^*(v) - u||_2.


Since for an invertible operator the least squares solution agrees with the result of the application of the inverse operator, setting this option should, in general, have no effect on the result for those operators. However, note that when no appropriate solver_options are set for the operator, most operator implementations will choose a least squares solver by default which may be undesirable.

Returns

VectorArray of the inverse adjoint operator evaluations.

Raises

InversionError

The operator could not be inverted.

class pymor.operators.constructions.InverseOperator(operator, name=None)[source]

Represents the inverse of a given Operator.

Parameters

operator

The Operator of which the inverse is formed.

name

If not None, name of the operator.

apply(U, mu=None)[source]

Apply the operator to a VectorArray.

Parameters

U

VectorArray of vectors to which the operator is applied.

mu

The Parameter for which to evaluate the operator.

Returns

VectorArray of the operator evaluations.

apply_adjoint(V, mu=None)[source]

Apply the adjoint operator.

For any given linear Operator op, Parameter mu and VectorArrays U, V in the source resp. range we have:

op.apply_adjoint(V, mu).dot(U) == V.dot(op.apply(U, mu))


Thus, when op is represented by a matrix M, apply_adjoint is given by left-multplication of (the complex conjugate of) M with V.

Parameters

V

VectorArray of vectors to which the adjoint operator is applied.

mu

The Parameter for which to apply the adjoint operator.

Returns

VectorArray of the adjoint operator evaluations.

apply_inverse(V, mu=None, least_squares=False)[source]

Apply the inverse operator.

Parameters

V

VectorArray of vectors to which the inverse operator is applied.

mu

The Parameter for which to evaluate the inverse operator.

least_squares

If True, solve the least squares problem:

u = argmin ||op(u) - v||_2.


Since for an invertible operator the least squares solution agrees with the result of the application of the inverse operator, setting this option should, in general, have no effect on the result for those operators. However, note that when no appropriate solver_options are set for the operator, most implementations will choose a least squares solver by default which may be undesirable.

Returns

VectorArray of the inverse operator evaluations.

Raises

InversionError

The operator could not be inverted.

apply_inverse_adjoint(U, mu=None, least_squares=False)[source]

Apply the inverse adjoint operator.

Parameters

U

VectorArray of vectors to which the inverse adjoint operator is applied.

mu

The Parameter for which to evaluate the inverse adjoint operator.

least_squares

If True, solve the least squares problem:

v = argmin ||op^*(v) - u||_2.


Since for an invertible operator the least squares solution agrees with the result of the application of the inverse operator, setting this option should, in general, have no effect on the result for those operators. However, note that when no appropriate solver_options are set for the operator, most operator implementations will choose a least squares solver by default which may be undesirable.

Returns

VectorArray of the inverse adjoint operator evaluations.

Raises

InversionError

The operator could not be inverted.

class pymor.operators.constructions.LincombOperator(operators, coefficients, solver_options=None, name=None)[source]

Linear combination of arbitrary Operators.

This Operator represents a (possibly Parameter dependent) linear combination of a given list of Operators.

Parameters

operators

List of Operators whose linear combination is formed.

coefficients

A list of linear coefficients. A linear coefficient can either be a fixed number or a ParameterFunctional.

solver_options

The solver_options for the operator.

name

Name of the operator.

__add__(other)[source]

Sum of two operators.

__mul__(other)[source]

Product of operator by a scalar.

apply(U, mu=None)[source]

Apply the operator to a VectorArray.

Parameters

U

VectorArray of vectors to which the operator is applied.

mu

The Parameter for which to evaluate the operator.

Returns

VectorArray of the operator evaluations.

apply2(V, U, mu=None)[source]

Treat the operator as a 2-form by computing V.dot(self.apply(U)).

If the operator is a linear operator given by multiplication with a matrix M, then apply2 is given as:

op.apply2(V, U) = V^T*M*U.


In the case of complex numbers, note that apply2 is anti-linear in the first variable by definition of dot.

Parameters

V

VectorArray of the left arguments V.

U

VectorArray of the right right arguments U.

mu

The Parameter for which to evaluate the operator.

Returns

A NumPy array with shape (len(V), len(U)) containing the 2-form evaluations.

apply_adjoint(V, mu=None)[source]

Apply the adjoint operator.

For any given linear Operator op, Parameter mu and VectorArrays U, V in the source resp. range we have:

op.apply_adjoint(V, mu).dot(U) == V.dot(op.apply(U, mu))


Thus, when op is represented by a matrix M, apply_adjoint is given by left-multplication of (the complex conjugate of) M with V.

Parameters

V

VectorArray of vectors to which the adjoint operator is applied.

mu

The Parameter for which to apply the adjoint operator.

Returns

VectorArray of the adjoint operator evaluations.

apply_inverse(V, mu=None, least_squares=False)[source]

Apply the inverse operator.

Parameters

V

VectorArray of vectors to which the inverse operator is applied.

mu

The Parameter for which to evaluate the inverse operator.

least_squares

If True, solve the least squares problem:

u = argmin ||op(u) - v||_2.


Since for an invertible operator the least squares solution agrees with the result of the application of the inverse operator, setting this option should, in general, have no effect on the result for those operators. However, note that when no appropriate solver_options are set for the operator, most implementations will choose a least squares solver by default which may be undesirable.

Returns

VectorArray of the inverse operator evaluations.

Raises

InversionError

The operator could not be inverted.

apply_inverse_adjoint(U, mu=None, least_squares=False)[source]

Apply the inverse adjoint operator.

Parameters

U

VectorArray of vectors to which the inverse adjoint operator is applied.

mu

The Parameter for which to evaluate the inverse adjoint operator.

least_squares

If True, solve the least squares problem:

v = argmin ||op^*(v) - u||_2.


Since for an invertible operator the least squares solution agrees with the result of the application of the inverse operator, setting this option should, in general, have no effect on the result for those operators. However, note that when no appropriate solver_options are set for the operator, most operator implementations will choose a least squares solver by default which may be undesirable.

Returns

VectorArray of the inverse adjoint operator evaluations.

Raises

InversionError

The operator could not be inverted.

as_range_array(mu=None)[source]

Return a VectorArray representation of the operator in its range space.

In the case of a linear operator with NumpyVectorSpace as source, this method returns for every Parameter mu a VectorArray V in the operator’s range, such that

V.lincomb(U.to_numpy()) == self.apply(U, mu)


for all VectorArrays U.

Parameters

mu

The Parameter for which to return the VectorArray representation.

Returns

V

The VectorArray defined above.

as_source_array(mu=None)[source]

Return a VectorArray representation of the operator in its source space.

In the case of a linear operator with NumpyVectorSpace as range, this method returns for every Parameter mu a VectorArray V in the operator’s source, such that

self.range.make_array(V.dot(U).T) == self.apply(U, mu)


for all VectorArrays U.

Parameters

mu

The Parameter for which to return the VectorArray representation.

Returns

V

The VectorArray defined above.

assemble(mu=None)[source]

Assemble the operator for a given parameter.

The result of the method strongly depends on the given operator. For instance, a matrix-based operator will assemble its matrix, a LincombOperator will try to form the linear combination of its operators, whereas an arbitrary operator might simply return a FixedParameterOperator. The only assured property of the assembled operator is that it no longer depends on a Parameter.

Parameters

mu

The Parameter for which to assemble the operator.

Returns

Parameter-independent, assembled Operator.

d_mu(component, index=())[source]

Return the operator’s derivative with respect to an index of a parameter component.

Parameters

component

Parameter component

index

index in the parameter component

Returns

New Operator representing the partial derivative.

evaluate_coefficients(mu)[source]

Compute the linear coefficients for a given Parameter.

Parameters

mu

Parameter for which to compute the linear coefficients.

Returns

List of linear coefficients.

jacobian(U, mu=None)[source]

Return the operator’s Jacobian as a new Operator.

Parameters

U

Length 1 VectorArray containing the vector for which to compute the Jacobian.

mu

The Parameter for which to compute the Jacobian.

Returns

Linear Operator representing the Jacobian.

pairwise_apply2(V, U, mu=None)[source]

Treat the operator as a 2-form by computing V.dot(self.apply(U)).

Same as OperatorInterface.apply2, except that vectors from V and U are applied in pairs.

Parameters

V

VectorArray of the left arguments V.

U

VectorArray of the right right arguments U.

mu

The Parameter for which to evaluate the operator.

Returns

A NumPy array with shape (len(V),) == (len(U),) containing the 2-form evaluations.

class pymor.operators.constructions.LinearOperator(operator, name=None)[source]

Mark the wrapped Operator to be linear.

class pymor.operators.constructions.LowRankOperator(left, core, right, inverted=False, solver_options=None, name=None)[source]

Non-parametric low-rank operator.

Represents an operator of the form or where and are VectorArrays of column vectors and a 2D NumPy array.

Parameters

left

VectorArray representing .

core

NumPy array representing .

right

VectorArray representing .

inverted

Whether is inverted.

solver_options

The solver_options for the operator.

name

Name of the operator.

apply(U, mu=None)[source]

Apply the operator to a VectorArray.

Parameters

U

VectorArray of vectors to which the operator is applied.

mu

The Parameter for which to evaluate the operator.

Returns

VectorArray of the operator evaluations.

apply_adjoint(V, mu=None)[source]

Apply the adjoint operator.

For any given linear Operator op, Parameter mu and VectorArrays U, V in the source resp. range we have:

op.apply_adjoint(V, mu).dot(U) == V.dot(op.apply(U, mu))


Thus, when op is represented by a matrix M, apply_adjoint is given by left-multplication of (the complex conjugate of) M with V.

Parameters

V

VectorArray of vectors to which the adjoint operator is applied.

mu

The Parameter for which to apply the adjoint operator.

Returns

VectorArray of the adjoint operator evaluations.

class pymor.operators.constructions.LowRankUpdatedOperator(operator, lr_operator, coeff, lr_coeff, solver_options=None, name=None)[source]

Represents a linear combination of an Operator and LowRankOperator. Uses the Sherman-Morrison-Woodbury formula in apply_inverse and apply_inverse_adjoint:

Parameters

operator
lr_operator
coeff

A linear coefficient for operator. Can either be a fixed number or a ParameterFunctional.

lr_coeff

A linear coefficient for lr_operator. Can either be a fixed number or a ParameterFunctional.

solver_options

The solver_options for the operator.

name

Name of the operator.

apply_inverse(V, mu=None, least_squares=False)[source]

Apply the inverse operator.

Parameters

V

VectorArray of vectors to which the inverse operator is applied.

mu

The Parameter for which to evaluate the inverse operator.

least_squares

If True, solve the least squares problem:

u = argmin ||op(u) - v||_2.


Since for an invertible operator the least squares solution agrees with the result of the application of the inverse operator, setting this option should, in general, have no effect on the result for those operators. However, note that when no appropriate solver_options are set for the operator, most implementations will choose a least squares solver by default which may be undesirable.

Returns

VectorArray of the inverse operator evaluations.

Raises

InversionError

The operator could not be inverted.

apply_inverse_adjoint(U, mu=None, least_squares=False)[source]

Apply the inverse adjoint operator.

Parameters

U

VectorArray of vectors to which the inverse adjoint operator is applied.

mu

The Parameter for which to evaluate the inverse adjoint operator.

least_squares

If True, solve the least squares problem:

v = argmin ||op^*(v) - u||_2.


Since for an invertible operator the least squares solution agrees with the result of the application of the inverse operator, setting this option should, in general, have no effect on the result for those operators. However, note that when no appropriate solver_options are set for the operator, most operator implementations will choose a least squares solver by default which may be undesirable.

Returns

VectorArray of the inverse adjoint operator evaluations.

Raises

InversionError

The operator could not be inverted.

class pymor.operators.constructions.ProxyOperator(operator, name=None)[source]

Forwards all interface calls to given Operator.

Mainly useful as base class for other Operator implementations.

Parameters

operator

The Operator to wrap.

name

Name of the wrapping operator.

apply(U, mu=None)[source]

Apply the operator to a VectorArray.

Parameters

U

VectorArray of vectors to which the operator is applied.

mu

The Parameter for which to evaluate the operator.

Returns

VectorArray of the operator evaluations.

apply_adjoint(V, mu=None)[source]

Apply the adjoint operator.

For any given linear Operator op, Parameter mu and VectorArrays U, V in the source resp. range we have:

op.apply_adjoint(V, mu).dot(U) == V.dot(op.apply(U, mu))


Thus, when op is represented by a matrix M, apply_adjoint is given by left-multplication of (the complex conjugate of) M with V.

Parameters

V

VectorArray of vectors to which the adjoint operator is applied.

mu

The Parameter for which to apply the adjoint operator.

Returns

VectorArray of the adjoint operator evaluations.

apply_inverse(V, mu=None, least_squares=False)[source]

Apply the inverse operator.

Parameters

V

VectorArray of vectors to which the inverse operator is applied.

mu

The Parameter for which to evaluate the inverse operator.

least_squares

If True, solve the least squares problem:

u = argmin ||op(u) - v||_2.


Since for an invertible operator the least squares solution agrees with the result of the application of the inverse operator, setting this option should, in general, have no effect on the result for those operators. However, note that when no appropriate solver_options are set for the operator, most implementations will choose a least squares solver by default which may be undesirable.

Returns

VectorArray of the inverse operator evaluations.

Raises

InversionError

The operator could not be inverted.

apply_inverse_adjoint(U, mu=None, least_squares=False)[source]

Apply the inverse adjoint operator.

Parameters

U

VectorArray of vectors to which the inverse adjoint operator is applied.

mu

The Parameter for which to evaluate the inverse adjoint operator.

least_squares

If True, solve the least squares problem:

v = argmin ||op^*(v) - u||_2.


Since for an invertible operator the least squares solution agrees with the result of the application of the inverse operator, setting this option should, in general, have no effect on the result for those operators. However, note that when no appropriate solver_options are set for the operator, most operator implementations will choose a least squares solver by default which may be undesirable.

Returns

VectorArray of the inverse adjoint operator evaluations.

Raises

InversionError

The operator could not be inverted.

jacobian(U, mu=None)[source]

Return the operator’s Jacobian as a new Operator.

Parameters

U

Length 1 VectorArray containing the vector for which to compute the Jacobian.

mu

The Parameter for which to compute the Jacobian.

Returns

Linear Operator representing the Jacobian.

restricted(dofs)[source]

Restrict the operator range to a given set of degrees of freedom.

This method returns a restricted version restricted_op of the operator along with an array source_dofs such that for any VectorArray U in self.source the following is true:

self.apply(U, mu).dofs(dofs)
== restricted_op.apply(NumpyVectorArray(U.dofs(source_dofs)), mu))


Such an operator is mainly useful for empirical interpolation where the evaluation of the original operator only needs to be known for few selected degrees of freedom. If the operator has a small stencil, only few source_dofs will be needed to evaluate the restricted operator which can make its evaluation very fast compared to evaluating the original operator.

Parameters

dofs

One-dimensional NumPy array of degrees of freedom in the operator range to which to restrict.

Returns

restricted_op

The restricted operator as defined above. The operator will have NumpyVectorSpace (len(source_dofs)) as source and NumpyVectorSpace (len(dofs)) as range.

source_dofs

One-dimensional NumPy array of source degrees of freedom as defined above.

class pymor.operators.constructions.SelectionOperator(operators, parameter_functional, boundaries, name=None)[source]

An Operator selected from a list of Operators.

operators[i] is used if parameter_functional(mu) is less or equal than boundaries[i] and greater than boundaries[i-1]:

-infty ------- boundaries[i] ---------- boundaries[i+1] ------- infty
|                        |
--- operators[i] ---|---- operators[i+1] ----|---- operators[i+2]
|                        |


Parameters

operators

List of Operators from which one Operator is selected based on the given Parameter.

parameter_functional

The ParameterFunctional used for the selection of one Operator.

boundaries

The interval boundaries as defined above.

name

Name of the operator.

apply(U, mu=None)[source]

Apply the operator to a VectorArray.

Parameters

U

VectorArray of vectors to which the operator is applied.

mu

The Parameter for which to evaluate the operator.

Returns

VectorArray of the operator evaluations.

apply_adjoint(V, mu=None)[source]

Apply the adjoint operator.

For any given linear Operator op, Parameter mu and VectorArrays U, V in the source resp. range we have:

op.apply_adjoint(V, mu).dot(U) == V.dot(op.apply(U, mu))


Thus, when op is represented by a matrix M, apply_adjoint is given by left-multplication of (the complex conjugate of) M with V.

Parameters

V

VectorArray of vectors to which the adjoint operator is applied.

mu

The Parameter for which to apply the adjoint operator.

Returns

VectorArray of the adjoint operator evaluations.

as_range_array(mu=None)[source]

Return a VectorArray representation of the operator in its range space.

In the case of a linear operator with NumpyVectorSpace as source, this method returns for every Parameter mu a VectorArray V in the operator’s range, such that

V.lincomb(U.to_numpy()) == self.apply(U, mu)


for all VectorArrays U.

Parameters

mu

The Parameter for which to return the VectorArray representation.

Returns

V

The VectorArray defined above.

as_source_array(mu=None)[source]

Return a VectorArray representation of the operator in its source space.

In the case of a linear operator with NumpyVectorSpace as range, this method returns for every Parameter mu a VectorArray V in the operator’s source, such that

self.range.make_array(V.dot(U).T) == self.apply(U, mu)


for all VectorArrays U.

Parameters

mu

The Parameter for which to return the VectorArray representation.

Returns

V

The VectorArray defined above.

assemble(mu=None)[source]

Assemble the operator for a given parameter.

The result of the method strongly depends on the given operator. For instance, a matrix-based operator will assemble its matrix, a LincombOperator will try to form the linear combination of its operators, whereas an arbitrary operator might simply return a FixedParameterOperator. The only assured property of the assembled operator is that it no longer depends on a Parameter.

Parameters

mu

The Parameter for which to assemble the operator.

Returns

Parameter-independent, assembled Operator.

class pymor.operators.constructions.VectorArrayOperator(array, adjoint=False, space_id=None, name=None)[source]

Wraps a VectorArray as an Operator.

If adjoint is False, the operator maps from NumpyVectorSpace(len(array)) to array.space by forming linear combinations of the vectors in the array with given coefficient arrays.

If adjoint == True, the operator maps from array.space to NumpyVectorSpace(len(array)) by forming the inner products of the argument with the vectors in the given array.

Parameters

array

The VectorArray which is to be treated as an operator.

adjoint

See description above.

space_id

Id of the source (range) VectorSpace in case adjoint is False (True).

name

The name of the operator.

apply(U, mu=None)[source]

Apply the operator to a VectorArray.

Parameters

U

VectorArray of vectors to which the operator is applied.

mu

The Parameter` for which to evaluate the operator.