pymor.operators package¶
Submodules¶
basic module¶
-
class
pymor.operators.basic.LinearComplexifiedListVectorArrayOperatorBase[source]¶
-
class
pymor.operators.basic.ListVectorArrayOperatorBase[source]¶ Bases:
pymor.operators.basic.OperatorBaseMethods
apply2,as_range_array,as_source_array,assemble,d_mu,jacobian,pairwise_apply2disable_logging,enable_logging,has_interface_name,implementor_names,implementorsAttributes
H,linear,range,solver_options,source-
apply(U, mu=None)[source]¶ Apply the operator to a
VectorArray.Parameters
- U
VectorArrayof vectors to which the operator is applied.- mu
The
Parameterfor which to evaluate the operator.
Returns
VectorArrayof the operator evaluations.
-
apply_adjoint(V, mu=None)[source]¶ Apply the adjoint operator.
For any given linear
Operatorop,ParametermuandVectorArraysU,Vin thesourceresp.rangewe have:op.apply_adjoint(V, mu).dot(U) == V.dot(op.apply(U, mu))
Thus, when
opis represented by a matrixM,apply_adjointis given by left-multplication of (the complex conjugate of)MwithV.Parameters
- V
VectorArrayof vectors to which the adjoint operator is applied.- mu
The
Parameterfor which to apply the adjoint operator.
Returns
VectorArrayof the adjoint operator evaluations.
-
apply_inverse(V, mu=None, least_squares=False)[source]¶ Apply the inverse operator.
Parameters
- V
VectorArrayof vectors to which the inverse operator is applied.- mu
The
Parameterfor 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_optionsare set for the operator, most implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArrayof 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
VectorArrayof vectors to which the inverse adjoint operator is applied.- mu
The
Parameterfor 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_optionsare set for the operator, most operator implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArrayof the inverse adjoint operator evaluations.Raises
- InversionError
The operator could not be inverted.
-
-
class
pymor.operators.basic.OperatorBase[source]¶ Bases:
pymor.operators.interfaces.OperatorInterfaceBase class for
Operatorsproviding some default implementations.When implementing a new operator, it is usually advisable to derive from this class.
Methods
Attributes
H,linear,range,solver_options,source-
__radd__(other)¶ Sum of two operators.
-
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
apply2is given as:op.apply2(V, U) = V^T*M*U.
In the case of complex numbers, note that
apply2is anti-linear in the first variable by definition ofdot.Parameters
- V
VectorArrayof the left arguments V.- U
VectorArrayof the right right arguments U.- mu
The
Parameterfor which to evaluate the operator.
Returns
A
NumPy arraywith shape(len(V), len(U))containing the 2-form evaluations.
-
apply_adjoint(V, mu=None)[source]¶ Apply the adjoint operator.
For any given linear
Operatorop,ParametermuandVectorArraysU,Vin thesourceresp.rangewe have:op.apply_adjoint(V, mu).dot(U) == V.dot(op.apply(U, mu))
Thus, when
opis represented by a matrixM,apply_adjointis given by left-multplication of (the complex conjugate of)MwithV.Parameters
- V
VectorArrayof vectors to which the adjoint operator is applied.- mu
The
Parameterfor which to apply the adjoint operator.
Returns
VectorArrayof the adjoint operator evaluations.
-
apply_inverse(V, mu=None, least_squares=False)[source]¶ Apply the inverse operator.
Parameters
- V
VectorArrayof vectors to which the inverse operator is applied.- mu
The
Parameterfor 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_optionsare set for the operator, most implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArrayof 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
VectorArrayof vectors to which the inverse adjoint operator is applied.- mu
The
Parameterfor 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_optionsare set for the operator, most operator implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArrayof the inverse adjoint operator evaluations.Raises
- InversionError
The operator could not be inverted.
-
as_range_array(mu=None)[source]¶ Return a
VectorArrayrepresentation of the operator in its range space.In the case of a linear operator with
NumpyVectorSpaceassource, this method returns for everyParametermuaVectorArrayVin the operator’srange, such thatV.lincomb(U.to_numpy()) == self.apply(U, mu)
for all
VectorArraysU.Parameters
- mu
The
Parameterfor which to return theVectorArrayrepresentation.
Returns
- V
The
VectorArraydefined above.
-
as_source_array(mu=None)[source]¶ Return a
VectorArrayrepresentation of the operator in its source space.In the case of a linear operator with
NumpyVectorSpaceasrange, this method returns for everyParametermuaVectorArrayVin the operator’ssource, such thatself.range.make_array(V.dot(U).T) == self.apply(U, mu)
for all
VectorArraysU.Parameters
- mu
The
Parameterfor which to return theVectorArrayrepresentation.
Returns
- V
The
VectorArraydefined 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
LincombOperatorwill try to form the linear combination of its operators, whereas an arbitrary operator might simply return aFixedParameterOperator. The only assured property of the assembled operator is that it no longer depends on aParameter.Parameters
- mu
The
Parameterfor 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
Operatorrepresenting the partial derivative.
-
jacobian(U, mu=None)[source]¶ Return the operator’s Jacobian as a new
Operator.Parameters
- U
Length 1
VectorArraycontaining the vector for which to compute the Jacobian.- mu
The
Parameterfor which to compute the Jacobian.
Returns
Linear
Operatorrepresenting 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 fromVandUare applied in pairs.Parameters
- V
VectorArrayof the left arguments V.- U
VectorArrayof the right right arguments U.- mu
The
Parameterfor which to evaluate the operator.
Returns
A
NumPy arraywith 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]¶ Bases:
pymor.operators.basic.OperatorBaseGeneric
Operatorrepresenting the projection of anOperatorto a subspace.This operator is implemented as the concatenation of the linear combination with
source_basis, application of the originaloperatorand projection ontorange_basis. As such, this operator can be used to obtain a reduced basis projection of any givenOperator. 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.projectas a default implementation for parametric or nonlinear operators.Parameters
- operator
The
Operatorto project.- range_basis
- source_basis
- product
- solver_options
The
solver_optionsfor the projected operator.
Methods
apply2,apply_inverse,apply_inverse_adjoint,as_range_array,as_source_array,d_mu,pairwise_apply2disable_logging,enable_logging,has_interface_name,implementor_names,implementorsAttributes
-
apply(U, mu=None)[source]¶ Apply the operator to a
VectorArray.Parameters
- U
VectorArrayof vectors to which the operator is applied.- mu
The
Parameterfor which to evaluate the operator.
Returns
VectorArrayof the operator evaluations.
-
apply_adjoint(V, mu=None)[source]¶ Apply the adjoint operator.
For any given linear
Operatorop,ParametermuandVectorArraysU,Vin thesourceresp.rangewe have:op.apply_adjoint(V, mu).dot(U) == V.dot(op.apply(U, mu))
Thus, when
opis represented by a matrixM,apply_adjointis given by left-multplication of (the complex conjugate of)MwithV.Parameters
- V
VectorArrayof vectors to which the adjoint operator is applied.- mu
The
Parameterfor which to apply the adjoint operator.
Returns
VectorArrayof 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
LincombOperatorwill try to form the linear combination of its operators, whereas an arbitrary operator might simply return aFixedParameterOperator. The only assured property of the assembled operator is that it no longer depends on aParameter.Parameters
- mu
The
Parameterfor which to assemble the operator.
Returns
Parameter-independent, assembled
Operator.
block module¶
-
class
pymor.operators.block.BlockColumnOperator(blocks)[source]¶ Bases:
pymor.operators.block.BlockOperatorBaseA column vector of arbitrary
Operators.Methods
Attributes
adjoint_type,blocked_range,blocked_source-
adjoint_type¶ alias of
BlockRowOperator
-
-
class
pymor.operators.block.BlockDiagonalOperator(blocks)[source]¶ Bases:
pymor.operators.block.BlockOperatorBlock diagonal
Operatorof arbitraryOperators.This is a specialization of
BlockOperatorfor the block diagonal case.Methods
apply,apply_adjoint,apply_inverse,apply_inverse_adjoint,assembledisable_logging,enable_logging,has_interface_name,implementor_names,implementorsAttributes
adjoint_type,blocked_range,blocked_source-
apply(U, mu=None)[source]¶ Apply the operator to a
VectorArray.Parameters
- U
VectorArrayof vectors to which the operator is applied.- mu
The
Parameterfor which to evaluate the operator.
Returns
VectorArrayof the operator evaluations.
-
apply_adjoint(V, mu=None)[source]¶ Apply the adjoint operator.
For any given linear
Operatorop,ParametermuandVectorArraysU,Vin thesourceresp.rangewe have:op.apply_adjoint(V, mu).dot(U) == V.dot(op.apply(U, mu))
Thus, when
opis represented by a matrixM,apply_adjointis given by left-multplication of (the complex conjugate of)MwithV.Parameters
- V
VectorArrayof vectors to which the adjoint operator is applied.- mu
The
Parameterfor which to apply the adjoint operator.
Returns
VectorArrayof the adjoint operator evaluations.
-
apply_inverse(V, mu=None, least_squares=False)[source]¶ Apply the inverse operator.
Parameters
- V
VectorArrayof vectors to which the inverse operator is applied.- mu
The
Parameterfor 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_optionsare set for the operator, most implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArrayof 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
VectorArrayof vectors to which the inverse adjoint operator is applied.- mu
The
Parameterfor 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_optionsare set for the operator, most operator implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArrayof 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
LincombOperatorwill try to form the linear combination of its operators, whereas an arbitrary operator might simply return aFixedParameterOperator. The only assured property of the assembled operator is that it no longer depends on aParameter.Parameters
- mu
The
Parameterfor which to assemble the operator.
Returns
Parameter-independent, assembled
Operator.
-
-
class
pymor.operators.block.BlockEmbeddingOperator(block_space, component)[source]¶ Bases:
pymor.operators.block.BlockColumnOperatorMethods
Attributes
adjoint_type,blocked_range,blocked_source
-
class
pymor.operators.block.BlockOperator(blocks)[source]¶ Bases:
pymor.operators.block.BlockOperatorBaseA matrix of arbitrary
Operators.This operator can be
appliedto a compatibleBlockVectorArrays.Parameters
- blocks
Two-dimensional array-like where each entry is an
OperatororNone.
Methods
Attributes
adjoint_type,blocked_range,blocked_source-
adjoint_type¶ alias of
BlockOperator
-
class
pymor.operators.block.BlockOperatorBase(blocks)[source]¶ Bases:
pymor.operators.basic.OperatorBaseMethods
Attributes
-
apply(U, mu=None)[source]¶ Apply the operator to a
VectorArray.Parameters
- U
VectorArrayof vectors to which the operator is applied.- mu
The
Parameterfor which to evaluate the operator.
Returns
VectorArrayof the operator evaluations.
-
apply_adjoint(V, mu=None)[source]¶ Apply the adjoint operator.
For any given linear
Operatorop,ParametermuandVectorArraysU,Vin thesourceresp.rangewe have:op.apply_adjoint(V, mu).dot(U) == V.dot(op.apply(U, mu))
Thus, when
opis represented by a matrixM,apply_adjointis given by left-multplication of (the complex conjugate of)MwithV.Parameters
- V
VectorArrayof vectors to which the adjoint operator is applied.- mu
The
Parameterfor which to apply the adjoint operator.
Returns
VectorArrayof the adjoint operator evaluations.
-
as_range_array(mu=None)[source]¶ Return a
VectorArrayrepresentation of the operator in its range space.In the case of a linear operator with
NumpyVectorSpaceassource, this method returns for everyParametermuaVectorArrayVin the operator’srange, such thatV.lincomb(U.to_numpy()) == self.apply(U, mu)
for all
VectorArraysU.Parameters
- mu
The
Parameterfor which to return theVectorArrayrepresentation.
Returns
- V
The
VectorArraydefined above.
-
as_source_array(mu=None)[source]¶ Return a
VectorArrayrepresentation of the operator in its source space.In the case of a linear operator with
NumpyVectorSpaceasrange, this method returns for everyParametermuaVectorArrayVin the operator’ssource, such thatself.range.make_array(V.dot(U).T) == self.apply(U, mu)
for all
VectorArraysU.Parameters
- mu
The
Parameterfor which to return theVectorArrayrepresentation.
Returns
- V
The
VectorArraydefined 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
LincombOperatorwill try to form the linear combination of its operators, whereas an arbitrary operator might simply return aFixedParameterOperator. The only assured property of the assembled operator is that it no longer depends on aParameter.Parameters
- mu
The
Parameterfor which to assemble the operator.
Returns
Parameter-independent, assembled
Operator.
-
-
class
pymor.operators.block.BlockProjectionOperator(block_space, component)[source]¶ Bases:
pymor.operators.block.BlockRowOperatorMethods
Attributes
adjoint_type,blocked_range,blocked_source
-
class
pymor.operators.block.BlockRowOperator(blocks)[source]¶ Bases:
pymor.operators.block.BlockOperatorBaseA row vector of arbitrary
Operators.Methods
Attributes
adjoint_type,blocked_range,blocked_source-
adjoint_type¶ alias of
BlockColumnOperator
-
-
class
pymor.operators.block.SecondOrderModelOperator(E, K)[source]¶ Bases:
pymor.operators.block.BlockOperatorBlockOperator appearing in SecondOrderModel.to_lti().
This represents a block operator
\mathcal{A} = \begin{bmatrix} 0 & I \\ -K & -E \end{bmatrix},
which satisfies
\mathcal{A}^H &= \begin{bmatrix} 0 & -K^H \\ I & -E^H \end{bmatrix}, \\ \mathcal{A}^{-1} &= \begin{bmatrix} -K^{-1} E & -K^{-1} \\ I & 0 \end{bmatrix}, \\ \mathcal{A}^{-H} &= \begin{bmatrix} -E^H K^{-H} & I \\ -K^{-H} & 0 \end{bmatrix}.
Methods
apply,apply_adjoint,apply_inverse,apply_inverse_adjoint,assembledisable_logging,enable_logging,has_interface_name,implementor_names,implementorsAttributes
adjoint_type,blocked_range,blocked_source-
apply(U, mu=None)[source]¶ Apply the operator to a
VectorArray.Parameters
- U
VectorArrayof vectors to which the operator is applied.- mu
The
Parameterfor which to evaluate the operator.
Returns
VectorArrayof the operator evaluations.
-
apply_adjoint(V, mu=None)[source]¶ Apply the adjoint operator.
For any given linear
Operatorop,ParametermuandVectorArraysU,Vin thesourceresp.rangewe have:op.apply_adjoint(V, mu).dot(U) == V.dot(op.apply(U, mu))
Thus, when
opis represented by a matrixM,apply_adjointis given by left-multplication of (the complex conjugate of)MwithV.Parameters
- V
VectorArrayof vectors to which the adjoint operator is applied.- mu
The
Parameterfor which to apply the adjoint operator.
Returns
VectorArrayof the adjoint operator evaluations.
-
apply_inverse(V, mu=None, least_squares=False)[source]¶ Apply the inverse operator.
Parameters
- V
VectorArrayof vectors to which the inverse operator is applied.- mu
The
Parameterfor 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_optionsare set for the operator, most implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArrayof 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
VectorArrayof vectors to which the inverse adjoint operator is applied.- mu
The
Parameterfor 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_optionsare set for the operator, most operator implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArrayof 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
LincombOperatorwill try to form the linear combination of its operators, whereas an arbitrary operator might simply return aFixedParameterOperator. The only assured property of the assembled operator is that it no longer depends on aParameter.Parameters
- mu
The
Parameterfor which to assemble the operator.
Returns
Parameter-independent, assembled
Operator.
-
-
class
pymor.operators.block.ShiftedSecondOrderModelOperator(M, E, K, a, b)[source]¶ Bases:
pymor.operators.block.BlockOperatorBlockOperator appearing in second-order systems.
This represents a block operator
a \mathcal{E} + b \mathcal{A} = \begin{bmatrix} a I & b I \\ -b K & a M - b E \end{bmatrix},
which satisfies
(a \mathcal{E} + b \mathcal{A})^H &= \begin{bmatrix} \overline{a} I & -\overline{b} K^H \\ \overline{b} I & \overline{a} M^H - \overline{b} E^H \end{bmatrix}, \\ (a \mathcal{E} + b \mathcal{A})^{-1} &= \begin{bmatrix} (a^2 M - a b E + b^2 K)^{-1} (a M - b E) & -b (a^2 M - a b E + b^2 K)^{-1} \\ b (a^2 M - a b E + b^2 K)^{-1} K & a (a^2 M - a b E + b^2 K)^{-1} \end{bmatrix}, \\ (a \mathcal{E} + b \mathcal{A})^{-H} &= \begin{bmatrix} (a M - b E)^H (a^2 M - a b E + b^2 K)^{-H} & \overline{b} K^H (a^2 M - a b E + b^2 K)^{-H} \\ -\overline{b} (a^2 M - a b E + b^2 K)^{-H} & \overline{a} (a^2 M - a b E + b^2 K)^{-H} \end{bmatrix}.
Methods
apply,apply_adjoint,apply_inverse,apply_inverse_adjoint,assembledisable_logging,enable_logging,has_interface_name,implementor_names,implementorsAttributes
adjoint_type,blocked_range,blocked_source-
apply(U, mu=None)[source]¶ Apply the operator to a
VectorArray.Parameters
- U
VectorArrayof vectors to which the operator is applied.- mu
The
Parameterfor which to evaluate the operator.
Returns
VectorArrayof the operator evaluations.
-
apply_adjoint(V, mu=None)[source]¶ Apply the adjoint operator.
For any given linear
Operatorop,ParametermuandVectorArraysU,Vin thesourceresp.rangewe have:op.apply_adjoint(V, mu).dot(U) == V.dot(op.apply(U, mu))
Thus, when
opis represented by a matrixM,apply_adjointis given by left-multplication of (the complex conjugate of)MwithV.Parameters
- V
VectorArrayof vectors to which the adjoint operator is applied.- mu
The
Parameterfor which to apply the adjoint operator.
Returns
VectorArrayof the adjoint operator evaluations.
-
apply_inverse(V, mu=None, least_squares=False)[source]¶ Apply the inverse operator.
Parameters
- V
VectorArrayof vectors to which the inverse operator is applied.- mu
The
Parameterfor 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_optionsare set for the operator, most implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArrayof 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
VectorArrayof vectors to which the inverse adjoint operator is applied.- mu
The
Parameterfor 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_optionsare set for the operator, most operator implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArrayof 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
LincombOperatorwill try to form the linear combination of its operators, whereas an arbitrary operator might simply return aFixedParameterOperator. The only assured property of the assembled operator is that it no longer depends on aParameter.Parameters
- mu
The
Parameterfor 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]¶ Bases:
pymor.operators.numpy.NumpyMatrixBasedOperatorLinear advection
Operatorfor linear finite elements.The operator is of the form
(Lu)(x) = c ∇ ⋅ [ v(x) u(x) ]
The function
vis vector-valued.Parameters
- grid
The
Gridfor which to assemble the operator.- boundary_info
BoundaryInfofor the treatment of Dirichlet boundary conditions.- advection_function
The
Functionv(x)withshape_range = (grid.dim, ). IfNone, constant one is assumed.- advection_constant
The constant
c. IfNone,cis 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_optionsfor 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]¶ Bases:
pymor.operators.numpy.NumpyMatrixBasedOperatorLinear advection
Operatorfor bilinear finite elements.The operator is of the form
(Lu)(x) = c ∇ ⋅ [ v(x) u(x) ]
The function
vhas to be vector-valued.Parameters
- grid
The
Gridfor which to assemble the operator.- boundary_info
BoundaryInfofor the treatment of Dirichlet boundary conditions.- advection_function
The
Functionv(x)withshape_range = (grid.dim, ). IfNone, constant one is assumed.- advection_constant
The constant
c. IfNone,cis 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_optionsfor the operator.- name
Name of the operator.
-
class
pymor.operators.cg.BoundaryDirichletFunctional(grid, dirichlet_data, boundary_info, name=None)[source]¶ Bases:
pymor.operators.numpy.NumpyMatrixBasedOperatorLinear finite element functional for enforcing Dirichlet boundary values.
Parameters
- grid
Gridfor which to assemble the functional.- dirichlet_data
Functionproviding the Dirichlet boundary values.- boundary_info
BoundaryInfodetermining 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]¶ Bases:
pymor.operators.numpy.NumpyMatrixBasedOperatorLinear finite element functional representing the inner product with an L2-
Functionon the boundary.Parameters
- grid
Gridfor which to assemble the functional.- function
The
Functionwith which to take the inner product.- boundary_type
The type of domain boundary (e.g. ‘neumann’) on which to assemble the functional. If
Nonethe functional is assembled over the whole boundary.- dirichlet_clear_dofs
If
True, set dirichlet boundary DOFs to zero.- boundary_info
If
boundary_typeis specified ordirichlet_clear_dofsisTrue, theBoundaryInfodetermining which boundary entity belongs to which physical boundary.- name
The name of the functional.
-
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]¶ Bases:
pymor.operators.numpy.NumpyMatrixBasedOperatorDiffusion
Operatorfor linear finite elements.The operator is of the form
(Lu)(x) = c ∇ ⋅ [ d(x) ∇ u(x) ]
The function
dcan be scalar- or matrix-valued.Parameters
- grid
The
Gridfor which to assemble the operator.- boundary_info
BoundaryInfofor the treatment of Dirichlet boundary conditions.- diffusion_function
The
Functiond(x)withshape_range == ()orshape_range = (grid.dim, grid.dim). IfNone, constant one is assumed.- diffusion_constant
The constant
c. IfNone,cis 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_optionsfor 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]¶ Bases:
pymor.operators.numpy.NumpyMatrixBasedOperatorDiffusion
Operatorfor bilinear finite elements.The operator is of the form
(Lu)(x) = c ∇ ⋅ [ d(x) ∇ u(x) ]
The function
dcan be scalar- or matrix-valued.Parameters
- grid
The
Gridfor which to assemble the operator.- boundary_info
BoundaryInfofor the treatment of Dirichlet boundary conditions.- diffusion_function
The
Functiond(x)withshape_range == ()orshape_range = (grid.dim, grid.dim). IfNone, constant one is assumed.- diffusion_constant
The constant
c. IfNone,cis 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_optionsfor the operator.- name
Name of the operator.
-
class
pymor.operators.cg.InterpolationOperator(grid, function)[source]¶ Bases:
pymor.operators.numpy.NumpyMatrixBasedOperatorVector-like Lagrange interpolation
Operatorfor continuous finite element spaces.
-
class
pymor.operators.cg.L2ProductFunctionalP1(grid, function, dirichlet_clear_dofs=False, boundary_info=None, name=None)[source]¶ Bases:
pymor.operators.numpy.NumpyMatrixBasedOperatorLinear finite element functional representing the inner product with an L2-
Function.Parameters
- grid
Gridfor which to assemble the functional.- function
The
Functionwith which to take the inner product.- dirichlet_clear_dofs
If
True, set dirichlet boundary DOFs to zero.- boundary_info
BoundaryInfodetermining the Dirichlet boundaries in casedirichlet_clear_dofsis set toTrue.- name
The name of the functional.
-
class
pymor.operators.cg.L2ProductFunctionalQ1(grid, function, dirichlet_clear_dofs=False, boundary_info=None, name=None)[source]¶ Bases:
pymor.operators.numpy.NumpyMatrixBasedOperatorBilinear finite element functional representing the inner product with an L2-
Function.Parameters
- grid
Gridfor which to assemble the functional.- function
The
Functionwith which to take the inner product.- dirichlet_clear_dofs
If
True, set dirichlet boundary DOFs to zero.- boundary_info
BoundaryInfodetermining the Dirichlet boundaries in casedirichlet_clear_dofsis set toTrue.- 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]¶ Bases:
pymor.operators.numpy.NumpyMatrixBasedOperatorOperatorrepresenting the L2-product between linear finite element functions.Parameters
- grid
The
Gridfor which to assemble the product.- boundary_info
BoundaryInfofor 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 eitherdirichlet_clear_rowsordirichlet_clear_columnsisTrue, the diagonal entries are set to one.- coefficient_function
Coefficient
Functionfor product withshape_range == (). IfNone, constant one is assumed.- solver_options
The
solver_optionsfor 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]¶ Bases:
pymor.operators.numpy.NumpyMatrixBasedOperatorOperatorrepresenting the L2-product between bilinear finite element functions.Parameters
- grid
The
Gridfor which to assemble the product.- boundary_info
BoundaryInfofor 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 eitherdirichlet_clear_rowsordirichlet_clear_columnsisTrue, the diagonal entries are set to one.- coefficient_function
Coefficient
Functionfor product withshape_range == (). IfNone, constant one is assumed.- solver_options
The
solver_optionsfor 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]¶ Bases:
pymor.operators.numpy.NumpyMatrixBasedOperatorRobin boundary
Operatorfor 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))
dandnare the diffusion function (seeDiffusionOperatorP1) and the unit outer normal inx, whilecis the (scalar) Robin parameter function andgis the (also scalar) Robin boundary value function.Parameters
- grid
The
Gridover which to assemble the operator.- boundary_info
BoundaryInfofor the treatment of Dirichlet boundary conditions.- robin_data
Tuple providing two
Functionsthat represent the Robin parameter and boundary value function. IfNone, the resulting operator is zero.- solver_options
The
solver_optionsfor 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]¶ Bases:
pymor.operators.basic.OperatorBaseRepresents the adjoint of a given linear
Operator.For a linear
Operatoropthe adjointop^*ofopis given by:(op^*(v), u)_s = (v, op(u))_r,
where
( , )_sand( , )_rdenote the inner products on the source and range space ofop. If two products are given byP_sandP_r, then:op^*(v) = P_s^(-1) o op.H o P_r,
Thus, if
( , )_sand( , )_rare the Euclidean inner products,op^*vis simply given by application of the :attr:adjoint <pymor.operators.interface.OperatorInterface.H>`Operator.Parameters
- operator
The
Operatorof which the adjoint is formed.- source_product
If not
None, inner productOperatorfor the sourceVectorSpacew.r.t. which to take the adjoint.- range_product
If not
None, inner productOperatorfor the rangeVectorSpacew.r.t. which to take the adjoint.- name
If not
None, name of the operator.- with_apply_inverse
If
True, provide ownapply_inverseandapply_inverse_adjointimplementations by calling these methods on the givenoperator. (Is set toFalsein the default implementation of andapply_inverse_adjoint.)- solver_options
When
with_apply_inverseisFalse, thesolver_optionsto use for theapply_inversedefault implementation.
Methods
apply2,as_range_array,as_source_array,assemble,d_mu,jacobian,pairwise_apply2disable_logging,enable_logging,has_interface_name,implementor_names,implementorsAttributes
-
apply(U, mu=None)[source]¶ Apply the operator to a
VectorArray.Parameters
- U
VectorArrayof vectors to which the operator is applied.- mu
The
Parameterfor which to evaluate the operator.
Returns
VectorArrayof the operator evaluations.
-
apply_adjoint(V, mu=None)[source]¶ Apply the adjoint operator.
For any given linear
Operatorop,ParametermuandVectorArraysU,Vin thesourceresp.rangewe have:op.apply_adjoint(V, mu).dot(U) == V.dot(op.apply(U, mu))
Thus, when
opis represented by a matrixM,apply_adjointis given by left-multplication of (the complex conjugate of)MwithV.Parameters
- V
VectorArrayof vectors to which the adjoint operator is applied.- mu
The
Parameterfor which to apply the adjoint operator.
Returns
VectorArrayof the adjoint operator evaluations.
-
apply_inverse(V, mu=None, least_squares=False)[source]¶ Apply the inverse operator.
Parameters
- V
VectorArrayof vectors to which the inverse operator is applied.- mu
The
Parameterfor 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_optionsare set for the operator, most implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArrayof 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
VectorArrayof vectors to which the inverse adjoint operator is applied.- mu
The
Parameterfor 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_optionsare set for the operator, most operator implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArrayof the inverse adjoint operator evaluations.Raises
- InversionError
The operator could not be inverted.
-
class
pymor.operators.constructions.AffineOperator(operator, name=None)[source]¶ Bases:
pymor.operators.constructions.ProxyOperatorDecompose an affine
Operatorinto affine_shift and linear_part.Methods
Attributes
-
class
pymor.operators.constructions.ComponentProjection(components, source, name=None)[source]¶ Bases:
pymor.operators.basic.OperatorBaseOperatorrepresenting the projection of aVectorArrayonto some of its components.Parameters
- components
List or 1D
NumPy arrayof the indices of the vectorcomponentsthat are to be extracted by the operator.- source
Source
VectorSpaceof the operator.- name
Name of the operator.
Methods
Attributes
-
apply(U, mu=None)[source]¶ Apply the operator to a
VectorArray.Parameters
- U
VectorArrayof vectors to which the operator is applied.- mu
The
Parameterfor which to evaluate the operator.
Returns
VectorArrayof 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_opof the operator along with an arraysource_dofssuch that for anyVectorArrayUinself.sourcethe 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 interpolationwhere 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 fewsource_dofswill 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 arrayof degrees of freedom in the operatorrangeto which to restrict.
Returns
- restricted_op
The restricted operator as defined above. The operator will have
NumpyVectorSpace(len(source_dofs))assourceandNumpyVectorSpace(len(dofs))asrange.- source_dofs
One-dimensional
NumPy arrayof source degrees of freedom as defined above.
-
class
pymor.operators.constructions.Concatenation(operators, solver_options=None, name=None)[source]¶ Bases:
pymor.operators.basic.OperatorBaseOperatorrepresenting the concatenation of twoOperators.Parameters
- operators
Tuple of
Operatorsto concatenate.operators[-1]is the first applied operator,operators[0]is the last applied operator.- solver_options
The
solver_optionsfor the operator.- name
Name of the operator.
Methods
apply2,apply_inverse,apply_inverse_adjoint,as_range_array,as_source_array,assemble,d_mu,pairwise_apply2disable_logging,enable_logging,has_interface_name,implementor_names,implementorsAttributes
-
apply(U, mu=None)[source]¶ Apply the operator to a
VectorArray.Parameters
- U
VectorArrayof vectors to which the operator is applied.- mu
The
Parameterfor which to evaluate the operator.
Returns
VectorArrayof the operator evaluations.
-
apply_adjoint(V, mu=None)[source]¶ Apply the adjoint operator.
For any given linear
Operatorop,ParametermuandVectorArraysU,Vin thesourceresp.rangewe have:op.apply_adjoint(V, mu).dot(U) == V.dot(op.apply(U, mu))
Thus, when
opis represented by a matrixM,apply_adjointis given by left-multplication of (the complex conjugate of)MwithV.Parameters
- V
VectorArrayof vectors to which the adjoint operator is applied.- mu
The
Parameterfor which to apply the adjoint operator.
Returns
VectorArrayof the adjoint operator evaluations.
-
jacobian(U, mu=None)[source]¶ Return the operator’s Jacobian as a new
Operator.Parameters
- U
Length 1
VectorArraycontaining the vector for which to compute the Jacobian.- mu
The
Parameterfor which to compute the Jacobian.
Returns
Linear
Operatorrepresenting the Jacobian.
-
restricted(dofs)[source]¶ Restrict the operator range to a given set of degrees of freedom.
This method returns a restricted version
restricted_opof the operator along with an arraysource_dofssuch that for anyVectorArrayUinself.sourcethe 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 interpolationwhere 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 fewsource_dofswill 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 arrayof degrees of freedom in the operatorrangeto which to restrict.
Returns
- restricted_op
The restricted operator as defined above. The operator will have
NumpyVectorSpace(len(source_dofs))assourceandNumpyVectorSpace(len(dofs))asrange.- source_dofs
One-dimensional
NumPy arrayof source degrees of freedom as defined above.
-
class
pymor.operators.constructions.ConstantOperator(value, source, name=None)[source]¶ Bases:
pymor.operators.basic.OperatorBaseA constant
Operatoralways returning the same vector.Parameters
- value
A
VectorArrayof length 1 containing the vector which is returned by the operator.- source
Source
VectorSpaceof the operator.- name
Name of the operator.
Methods
apply2,apply_adjoint,apply_inverse_adjoint,as_range_array,as_source_array,assemble,d_mu,pairwise_apply2disable_logging,enable_logging,has_interface_name,implementor_names,implementorsAttributes
-
apply(U, mu=None)[source]¶ Apply the operator to a
VectorArray.Parameters
- U
VectorArrayof vectors to which the operator is applied.- mu
The
Parameterfor which to evaluate the operator.
Returns
VectorArrayof the operator evaluations.
-
apply_inverse(V, mu=None, least_squares=False)[source]¶ Apply the inverse operator.
Parameters
- V
VectorArrayof vectors to which the inverse operator is applied.- mu
The
Parameterfor 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_optionsare set for the operator, most implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArrayof 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
VectorArraycontaining the vector for which to compute the Jacobian.- mu
The
Parameterfor which to compute the Jacobian.
Returns
Linear
Operatorrepresenting the Jacobian.
-
restricted(dofs)[source]¶ Restrict the operator range to a given set of degrees of freedom.
This method returns a restricted version
restricted_opof the operator along with an arraysource_dofssuch that for anyVectorArrayUinself.sourcethe 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 interpolationwhere 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 fewsource_dofswill 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 arrayof degrees of freedom in the operatorrangeto which to restrict.
Returns
- restricted_op
The restricted operator as defined above. The operator will have
NumpyVectorSpace(len(source_dofs))assourceandNumpyVectorSpace(len(dofs))asrange.- source_dofs
One-dimensional
NumPy arrayof source degrees of freedom as defined above.
-
class
pymor.operators.constructions.FixedParameterOperator(operator, mu=None, name=None)[source]¶ Bases:
pymor.operators.constructions.ProxyOperatorMakes an
OperatorParameter-independent by setting a fixedParameter.Parameters
Methods
Attributes
-
apply(U, mu=None)[source]¶ Apply the operator to a
VectorArray.Parameters
- U
VectorArrayof vectors to which the operator is applied.- mu
The
Parameterfor which to evaluate the operator.
Returns
VectorArrayof the operator evaluations.
-
apply_adjoint(V, mu=None)[source]¶ Apply the adjoint operator.
For any given linear
Operatorop,ParametermuandVectorArraysU,Vin thesourceresp.rangewe have:op.apply_adjoint(V, mu).dot(U) == V.dot(op.apply(U, mu))
Thus, when
opis represented by a matrixM,apply_adjointis given by left-multplication of (the complex conjugate of)MwithV.Parameters
- V
VectorArrayof vectors to which the adjoint operator is applied.- mu
The
Parameterfor which to apply the adjoint operator.
Returns
VectorArrayof the adjoint operator evaluations.
-
apply_inverse(V, mu=None, least_squares=False)[source]¶ Apply the inverse operator.
Parameters
- V
VectorArrayof vectors to which the inverse operator is applied.- mu
The
Parameterfor 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_optionsare set for the operator, most implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArrayof 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
VectorArrayof vectors to which the inverse adjoint operator is applied.- mu
The
Parameterfor 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_optionsare set for the operator, most operator implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArrayof the inverse adjoint operator evaluations.Raises
- InversionError
The operator could not be inverted.
-
-
class
pymor.operators.constructions.IdentityOperator(space, name=None)[source]¶ Bases:
pymor.operators.basic.OperatorBaseThe identity
Operator.In other words:
op.apply(U) == U
Parameters
- space
The
VectorSpacethe operator acts on.- name
Name of the operator.
Methods
Attributes
-
apply(U, mu=None)[source]¶ Apply the operator to a
VectorArray.Parameters
- U
VectorArrayof vectors to which the operator is applied.- mu
The
Parameterfor which to evaluate the operator.
Returns
VectorArrayof the operator evaluations.
-
apply_adjoint(V, mu=None)[source]¶ Apply the adjoint operator.
For any given linear
Operatorop,ParametermuandVectorArraysU,Vin thesourceresp.rangewe have:op.apply_adjoint(V, mu).dot(U) == V.dot(op.apply(U, mu))
Thus, when
opis represented by a matrixM,apply_adjointis given by left-multplication of (the complex conjugate of)MwithV.Parameters
- V
VectorArrayof vectors to which the adjoint operator is applied.- mu
The
Parameterfor which to apply the adjoint operator.
Returns
VectorArrayof the adjoint operator evaluations.
-
apply_inverse(V, mu=None, least_squares=False)[source]¶ Apply the inverse operator.
Parameters
- V
VectorArrayof vectors to which the inverse operator is applied.- mu
The
Parameterfor 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_optionsare set for the operator, most implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArrayof 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
VectorArrayof vectors to which the inverse adjoint operator is applied.- mu
The
Parameterfor 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_optionsare set for the operator, most operator implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArrayof 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
LincombOperatorwill try to form the linear combination of its operators, whereas an arbitrary operator might simply return aFixedParameterOperator. The only assured property of the assembled operator is that it no longer depends on aParameter.Parameters
- mu
The
Parameterfor 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_opof the operator along with an arraysource_dofssuch that for anyVectorArrayUinself.sourcethe 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 interpolationwhere 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 fewsource_dofswill 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 arrayof degrees of freedom in the operatorrangeto which to restrict.
Returns
- restricted_op
The restricted operator as defined above. The operator will have
NumpyVectorSpace(len(source_dofs))assourceandNumpyVectorSpace(len(dofs))asrange.- source_dofs
One-dimensional
NumPy arrayof source degrees of freedom as defined above.
-
class
pymor.operators.constructions.InducedNorm(product, raise_negative, tol, name)[source]¶ Bases:
pymor.core.interfaces.ImmutableInterface,pymor.parameters.base.ParametricInstantiated by
induced_norm. Do not use directly.Attributes
-
class
pymor.operators.constructions.InverseAdjointOperator(operator, name=None)[source]¶ Bases:
pymor.operators.basic.OperatorBaseRepresents the inverse adjoint of a given
Operator.Parameters
- operator
The
Operatorof which the inverse adjoint is formed.- name
If not
None, name of the operator.
Methods
apply2,as_range_array,as_source_array,assemble,d_mu,jacobian,pairwise_apply2disable_logging,enable_logging,has_interface_name,implementor_names,implementorsAttributes
-
apply(U, mu=None)[source]¶ Apply the operator to a
VectorArray.Parameters
- U
VectorArrayof vectors to which the operator is applied.- mu
The
Parameterfor which to evaluate the operator.
Returns
VectorArrayof the operator evaluations.
-
apply_adjoint(V, mu=None)[source]¶ Apply the adjoint operator.
For any given linear
Operatorop,ParametermuandVectorArraysU,Vin thesourceresp.rangewe have:op.apply_adjoint(V, mu).dot(U) == V.dot(op.apply(U, mu))
Thus, when
opis represented by a matrixM,apply_adjointis given by left-multplication of (the complex conjugate of)MwithV.Parameters
- V
VectorArrayof vectors to which the adjoint operator is applied.- mu
The
Parameterfor which to apply the adjoint operator.
Returns
VectorArrayof the adjoint operator evaluations.
-
apply_inverse(V, mu=None, least_squares=False)[source]¶ Apply the inverse operator.
Parameters
- V
VectorArrayof vectors to which the inverse operator is applied.- mu
The
Parameterfor 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_optionsare set for the operator, most implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArrayof 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
VectorArrayof vectors to which the inverse adjoint operator is applied.- mu
The
Parameterfor 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_optionsare set for the operator, most operator implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArrayof the inverse adjoint operator evaluations.Raises
- InversionError
The operator could not be inverted.
-
class
pymor.operators.constructions.InverseOperator(operator, name=None)[source]¶ Bases:
pymor.operators.basic.OperatorBaseRepresents the inverse of a given
Operator.Parameters
- operator
The
Operatorof which the inverse is formed.- name
If not
None, name of the operator.
Methods
apply2,as_range_array,as_source_array,assemble,d_mu,jacobian,pairwise_apply2disable_logging,enable_logging,has_interface_name,implementor_names,implementorsAttributes
-
apply(U, mu=None)[source]¶ Apply the operator to a
VectorArray.Parameters
- U
VectorArrayof vectors to which the operator is applied.- mu
The
Parameterfor which to evaluate the operator.
Returns
VectorArrayof the operator evaluations.
-
apply_adjoint(V, mu=None)[source]¶ Apply the adjoint operator.
For any given linear
Operatorop,ParametermuandVectorArraysU,Vin thesourceresp.rangewe have:op.apply_adjoint(V, mu).dot(U) == V.dot(op.apply(U, mu))
Thus, when
opis represented by a matrixM,apply_adjointis given by left-multplication of (the complex conjugate of)MwithV.Parameters
- V
VectorArrayof vectors to which the adjoint operator is applied.- mu
The
Parameterfor which to apply the adjoint operator.
Returns
VectorArrayof the adjoint operator evaluations.
-
apply_inverse(V, mu=None, least_squares=False)[source]¶ Apply the inverse operator.
Parameters
- V
VectorArrayof vectors to which the inverse operator is applied.- mu
The
Parameterfor 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_optionsare set for the operator, most implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArrayof 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
VectorArrayof vectors to which the inverse adjoint operator is applied.- mu
The
Parameterfor 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_optionsare set for the operator, most operator implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArrayof 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]¶ Bases:
pymor.operators.basic.OperatorBaseLinear combination of arbitrary
Operators.This
Operatorrepresents a (possiblyParameterdependent) linear combination of a given list ofOperators.Parameters
- operators
List of
Operatorswhose 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_optionsfor the operator.- name
Name of the operator.
Methods
Attributes
-
apply(U, mu=None)[source]¶ Apply the operator to a
VectorArray.Parameters
- U
VectorArrayof vectors to which the operator is applied.- mu
The
Parameterfor which to evaluate the operator.
Returns
VectorArrayof 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
apply2is given as:op.apply2(V, U) = V^T*M*U.
In the case of complex numbers, note that
apply2is anti-linear in the first variable by definition ofdot.Parameters
- V
VectorArrayof the left arguments V.- U
VectorArrayof the right right arguments U.- mu
The
Parameterfor which to evaluate the operator.
Returns
A
NumPy arraywith shape(len(V), len(U))containing the 2-form evaluations.
-
apply_adjoint(V, mu=None)[source]¶ Apply the adjoint operator.
For any given linear
Operatorop,ParametermuandVectorArraysU,Vin thesourceresp.rangewe have:op.apply_adjoint(V, mu).dot(U) == V.dot(op.apply(U, mu))
Thus, when
opis represented by a matrixM,apply_adjointis given by left-multplication of (the complex conjugate of)MwithV.Parameters
- V
VectorArrayof vectors to which the adjoint operator is applied.- mu
The
Parameterfor which to apply the adjoint operator.
Returns
VectorArrayof the adjoint operator evaluations.
-
apply_inverse(V, mu=None, least_squares=False)[source]¶ Apply the inverse operator.
Parameters
- V
VectorArrayof vectors to which the inverse operator is applied.- mu
The
Parameterfor 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_optionsare set for the operator, most implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArrayof 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
VectorArrayof vectors to which the inverse adjoint operator is applied.- mu
The
Parameterfor 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_optionsare set for the operator, most operator implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArrayof the inverse adjoint operator evaluations.Raises
- InversionError
The operator could not be inverted.
-
as_range_array(mu=None)[source]¶ Return a
VectorArrayrepresentation of the operator in its range space.In the case of a linear operator with
NumpyVectorSpaceassource, this method returns for everyParametermuaVectorArrayVin the operator’srange, such thatV.lincomb(U.to_numpy()) == self.apply(U, mu)
for all
VectorArraysU.Parameters
- mu
The
Parameterfor which to return theVectorArrayrepresentation.
Returns
- V
The
VectorArraydefined above.
-
as_source_array(mu=None)[source]¶ Return a
VectorArrayrepresentation of the operator in its source space.In the case of a linear operator with
NumpyVectorSpaceasrange, this method returns for everyParametermuaVectorArrayVin the operator’ssource, such thatself.range.make_array(V.dot(U).T) == self.apply(U, mu)
for all
VectorArraysU.Parameters
- mu
The
Parameterfor which to return theVectorArrayrepresentation.
Returns
- V
The
VectorArraydefined 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
LincombOperatorwill try to form the linear combination of its operators, whereas an arbitrary operator might simply return aFixedParameterOperator. The only assured property of the assembled operator is that it no longer depends on aParameter.Parameters
- mu
The
Parameterfor 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
Operatorrepresenting the partial derivative.
-
evaluate_coefficients(mu)[source]¶ Compute the linear coefficients for a given
Parameter.Parameters
- mu
Parameterfor 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
VectorArraycontaining the vector for which to compute the Jacobian.- mu
The
Parameterfor which to compute the Jacobian.
Returns
Linear
Operatorrepresenting 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 fromVandUare applied in pairs.Parameters
- V
VectorArrayof the left arguments V.- U
VectorArrayof the right right arguments U.- mu
The
Parameterfor which to evaluate the operator.
Returns
A
NumPy arraywith shape(len(V),) == (len(U),)containing the 2-form evaluations.
-
class
pymor.operators.constructions.LinearOperator(operator, name=None)[source]¶ Bases:
pymor.operators.constructions.ProxyOperatorMark the wrapped
Operatorto be linear.
-
class
pymor.operators.constructions.LowRankOperator(left, core, right, inverted=False, solver_options=None, name=None)[source]¶ Bases:
pymor.operators.basic.OperatorBaseNon-parametric low-rank operator.
Represents an operator of the form L C R^H or L C^{-1} R^H where L and R are
VectorArraysof column vectors and C a 2DNumPy array.Parameters
- left
VectorArrayrepresenting L.- core
NumPy arrayrepresenting C.- right
VectorArrayrepresenting R.- inverted
Whether C is inverted.
- solver_options
The
solver_optionsfor the operator.- name
Name of the operator.
Methods
Attributes
-
apply(U, mu=None)[source]¶ Apply the operator to a
VectorArray.Parameters
- U
VectorArrayof vectors to which the operator is applied.- mu
The
Parameterfor which to evaluate the operator.
Returns
VectorArrayof the operator evaluations.
-
apply_adjoint(V, mu=None)[source]¶ Apply the adjoint operator.
For any given linear
Operatorop,ParametermuandVectorArraysU,Vin thesourceresp.rangewe have:op.apply_adjoint(V, mu).dot(U) == V.dot(op.apply(U, mu))
Thus, when
opis represented by a matrixM,apply_adjointis given by left-multplication of (the complex conjugate of)MwithV.Parameters
- V
VectorArrayof vectors to which the adjoint operator is applied.- mu
The
Parameterfor which to apply the adjoint operator.
Returns
VectorArrayof the adjoint operator evaluations.
-
class
pymor.operators.constructions.LowRankUpdatedOperator(operator, lr_operator, coeff, lr_coeff, solver_options=None, name=None)[source]¶ Bases:
pymor.operators.constructions.LincombOperatorOperatorplusLowRankOperator.Represents a linear combination of an
OperatorandLowRankOperator. Uses the Sherman-Morrison-Woodbury formula inapply_inverseandapply_inverse_adjoint:\left(\alpha A + \beta L C R^H \right)^{-1} & = \alpha^{-1} A^{-1} - \alpha^{-1} \beta A^{-1} L C \left(\alpha C + \beta C R^H A^{-1} L C \right)^{-1} C R^H A^{-1}, \\ \left(\alpha A + \beta L C^{-1} R^H \right)^{-1} & = \alpha^{-1} A^{-1} - \alpha^{-1} \beta A^{-1} L \left(\alpha C + \beta R^H A^{-1} L \right)^{-1} R^H A^{-1}.
Parameters
- operator
- lr_operator
- coeff
A linear coefficient for
operator. Can either be a fixed number or aParameterFunctional.- lr_coeff
A linear coefficient for
lr_operator. Can either be a fixed number or aParameterFunctional.- solver_options
The
solver_optionsfor the operator.- name
Name of the operator.
Methods
Attributes
-
apply_inverse(V, mu=None, least_squares=False)[source]¶ Apply the inverse operator.
Parameters
- V
VectorArrayof vectors to which the inverse operator is applied.- mu
The
Parameterfor 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_optionsare set for the operator, most implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArrayof 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
VectorArrayof vectors to which the inverse adjoint operator is applied.- mu
The
Parameterfor 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_optionsare set for the operator, most operator implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArrayof the inverse adjoint operator evaluations.Raises
- InversionError
The operator could not be inverted.
-
class
pymor.operators.constructions.ProxyOperator(operator, name=None)[source]¶ Bases:
pymor.operators.basic.OperatorBaseForwards all interface calls to given
Operator.Mainly useful as base class for other
Operatorimplementations.Parameters
- operator
The
Operatorto wrap.- name
Name of the wrapping operator.
Methods
Attributes
-
apply(U, mu=None)[source]¶ Apply the operator to a
VectorArray.Parameters
- U
VectorArrayof vectors to which the operator is applied.- mu
The
Parameterfor which to evaluate the operator.
Returns
VectorArrayof the operator evaluations.
-
apply_adjoint(V, mu=None)[source]¶ Apply the adjoint operator.
For any given linear
Operatorop,ParametermuandVectorArraysU,Vin thesourceresp.rangewe have:op.apply_adjoint(V, mu).dot(U) == V.dot(op.apply(U, mu))
Thus, when
opis represented by a matrixM,apply_adjointis given by left-multplication of (the complex conjugate of)MwithV.Parameters
- V
VectorArrayof vectors to which the adjoint operator is applied.- mu
The
Parameterfor which to apply the adjoint operator.
Returns
VectorArrayof the adjoint operator evaluations.
-
apply_inverse(V, mu=None, least_squares=False)[source]¶ Apply the inverse operator.
Parameters
- V
VectorArrayof vectors to which the inverse operator is applied.- mu
The
Parameterfor 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_optionsare set for the operator, most implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArrayof 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
VectorArrayof vectors to which the inverse adjoint operator is applied.- mu
The
Parameterfor 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_optionsare set for the operator, most operator implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArrayof 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
VectorArraycontaining the vector for which to compute the Jacobian.- mu
The
Parameterfor which to compute the Jacobian.
Returns
Linear
Operatorrepresenting the Jacobian.
-
restricted(dofs)[source]¶ Restrict the operator range to a given set of degrees of freedom.
This method returns a restricted version
restricted_opof the operator along with an arraysource_dofssuch that for anyVectorArrayUinself.sourcethe 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 interpolationwhere 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 fewsource_dofswill 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 arrayof degrees of freedom in the operatorrangeto which to restrict.
Returns
- restricted_op
The restricted operator as defined above. The operator will have
NumpyVectorSpace(len(source_dofs))assourceandNumpyVectorSpace(len(dofs))asrange.- source_dofs
One-dimensional
NumPy arrayof source degrees of freedom as defined above.
-
class
pymor.operators.constructions.SelectionOperator(operators, parameter_functional, boundaries, name=None)[source]¶ Bases:
pymor.operators.basic.OperatorBaseAn
Operatorselected from a list ofOperators.operators[i]is used ifparameter_functional(mu)is less or equal thanboundaries[i]and greater thanboundaries[i-1]:-infty ------- boundaries[i] ---------- boundaries[i+1] ------- infty | | --- operators[i] ---|---- operators[i+1] ----|---- operators[i+2] | |
Parameters
- operators
List of
Operatorsfrom which oneOperatoris selected based on the givenParameter.- parameter_functional
The
ParameterFunctionalused for the selection of oneOperator.- boundaries
The interval boundaries as defined above.
- name
Name of the operator.
Methods
Attributes
-
apply(U, mu=None)[source]¶ Apply the operator to a
VectorArray.Parameters
- U
VectorArrayof vectors to which the operator is applied.- mu
The
Parameterfor which to evaluate the operator.
Returns
VectorArrayof the operator evaluations.
-
apply_adjoint(V, mu=None)[source]¶ Apply the adjoint operator.
For any given linear
Operatorop,ParametermuandVectorArraysU,Vin thesourceresp.rangewe have:op.apply_adjoint(V, mu).dot(U) == V.dot(op.apply(U, mu))
Thus, when
opis represented by a matrixM,apply_adjointis given by left-multplication of (the complex conjugate of)MwithV.Parameters
- V
VectorArrayof vectors to which the adjoint operator is applied.- mu
The
Parameterfor which to apply the adjoint operator.
Returns
VectorArrayof the adjoint operator evaluations.
-
as_range_array(mu=None)[source]¶ Return a
VectorArrayrepresentation of the operator in its range space.In the case of a linear operator with
NumpyVectorSpaceassource, this method returns for everyParametermuaVectorArrayVin the operator’srange, such thatV.lincomb(U.to_numpy()) == self.apply(U, mu)
for all
VectorArraysU.Parameters
- mu
The
Parameterfor which to return theVectorArrayrepresentation.
Returns
- V
The
VectorArraydefined above.
-
as_source_array(mu=None)[source]¶ Return a
VectorArrayrepresentation of the operator in its source space.In the case of a linear operator with
NumpyVectorSpaceasrange, this method returns for everyParametermuaVectorArrayVin the operator’ssource, such thatself.range.make_array(V.dot(U).T) == self.apply(U, mu)
for all
VectorArraysU.Parameters
- mu
The
Parameterfor which to return theVectorArrayrepresentation.
Returns
- V
The
VectorArraydefined 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
LincombOperatorwill try to form the linear combination of its operators, whereas an arbitrary operator might simply return aFixedParameterOperator. The only assured property of the assembled operator is that it no longer depends on aParameter.Parameters
- mu
The
Parameterfor which to assemble the operator.
Returns
Parameter-independent, assembled
Operator.
-
class
pymor.operators.constructions.VectorArrayOperator(array, adjoint=False, space_id=None, name=None)[source]¶ Bases:
pymor.operators.basic.OperatorBaseWraps a
VectorArrayas anOperator.If
adjointisFalse, the operator maps fromNumpyVectorSpace(len(array))toarray.spaceby forming linear combinations of the vectors in the array with given coefficient arrays.If
adjoint == True, the operator maps fromarray.spacetoNumpyVectorSpace(len(array))by forming the inner products of the argument with the vectors in the given array.Parameters
- array
The
VectorArraywhich is to be treated as an operator.- adjoint
See description above.
- space_id
Id of the
source(range)VectorSpacein caseadjointisFalse(True).- name
The name of the operator.
Methods
Attributes
-
apply(U, mu=None)[source]¶ Apply the operator to a
VectorArray.Parameters
- U
VectorArrayof vectors to which the operator is applied.- mu
The
Parameterfor which to evaluate the operator.
Returns
VectorArrayof the operator evaluations.
-
apply_adjoint(V, mu=None)[source]¶ Apply the adjoint operator.
For any given linear
Operatorop,ParametermuandVectorArraysU,Vin thesourceresp.rangewe have:op.apply_adjoint(V, mu).dot(U) == V.dot(op.apply(U, mu))
Thus, when
opis represented by a matrixM,apply_adjointis given by left-multplication of (the complex conjugate of)MwithV.Parameters
- V
VectorArrayof vectors to which the adjoint operator is applied.- mu
The
Parameterfor which to apply the adjoint operator.
Returns
VectorArrayof the adjoint operator evaluations.
-
apply_inverse_adjoint(U, mu=None, least_squares=False)[source]¶ Apply the inverse adjoint operator.
Parameters
- U
VectorArrayof vectors to which the inverse adjoint operator is applied.- mu
The
Parameterfor 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_optionsare set for the operator, most operator implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArrayof the inverse adjoint operator evaluations.Raises
- InversionError
The operator could not be inverted.
-
as_range_array(mu=None)[source]¶ Return a
VectorArrayrepresentation of the operator in its range space.In the case of a linear operator with
NumpyVectorSpaceassource, this method returns for everyParametermuaVectorArrayVin the operator’srange, such thatV.lincomb(U.to_numpy()) == self.apply(U, mu)
for all
VectorArraysU.Parameters
- mu
The
Parameterfor which to return theVectorArrayrepresentation.
Returns
- V
The
VectorArraydefined above.
-
as_source_array(mu=None)[source]¶ Return a
VectorArrayrepresentation of the operator in its source space.In the case of a linear operator with
NumpyVectorSpaceasrange, this method returns for everyParametermuaVectorArrayVin the operator’ssource, such thatself.range.make_array(V.dot(U).T) == self.apply(U, mu)
for all
VectorArraysU.Parameters
- mu
The
Parameterfor which to return theVectorArrayrepresentation.
Returns
- V
The
VectorArraydefined above.
-
restricted(dofs)[source]¶ Restrict the operator range to a given set of degrees of freedom.
This method returns a restricted version
restricted_opof the operator along with an arraysource_dofssuch that for anyVectorArrayUinself.sourcethe 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 interpolationwhere 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 fewsource_dofswill 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 arrayof degrees of freedom in the operatorrangeto which to restrict.
Returns
- restricted_op
The restricted operator as defined above. The operator will have
NumpyVectorSpace(len(source_dofs))assourceandNumpyVectorSpace(len(dofs))asrange.- source_dofs
One-dimensional
NumPy arrayof source degrees of freedom as defined above.
-
class
pymor.operators.constructions.VectorFunctional(vector, product=None, name=None)[source]¶ Bases:
pymor.operators.constructions.VectorArrayOperatorWrap a vector as a linear
Functional.Given a vector
vof dimensiond, this class represents the functionalf: R^d ----> R^1 u |---> (u, v)
where
( , )denotes the inner product given byproduct.In particular, if
productisNoneVectorFunctional(vector).as_source_array() == vector.
If
productis not none, we obtainVectorFunctional(vector).as_source_array() == product.apply(vector).
Parameters
- vector
VectorArrayof length 1 containing the vectorv.- product
Operatorrepresenting the scalar product to use.- name
Name of the operator.
-
class
pymor.operators.constructions.VectorOperator(vector, name=None)[source]¶ Bases:
pymor.operators.constructions.VectorArrayOperatorWrap a vector as a vector-like
Operator.Given a vector
vof dimensiond, this class represents the operatorop: R^1 ----> R^d x |---> x⋅vIn particular:
VectorOperator(vector).as_range_array() == vector
Parameters
- vector
VectorArrayof length 1 containing the vectorv.- name
Name of the operator.
-
class
pymor.operators.constructions.ZeroOperator(range, source, name=None)[source]¶ Bases:
pymor.operators.basic.OperatorBaseThe
Operatorwhich maps every vector to zero.Parameters
- range
Range
VectorSpaceof the operator.- source
Source
VectorSpaceof the operator.- name
Name of the operator.
Methods
Attributes
-
apply(U, mu=None)[source]¶ Apply the operator to a
VectorArray.Parameters
- U
VectorArrayof vectors to which the operator is applied.- mu
The
Parameterfor which to evaluate the operator.
Returns
VectorArrayof the operator evaluations.
-
apply_adjoint(V, mu=None)[source]¶ Apply the adjoint operator.
For any given linear
Operatorop,ParametermuandVectorArraysU,Vin thesourceresp.rangewe have:op.apply_adjoint(V, mu).dot(U) == V.dot(op.apply(U, mu))
Thus, when
opis represented by a matrixM,apply_adjointis given by left-multplication of (the complex conjugate of)MwithV.Parameters
- V
VectorArrayof vectors to which the adjoint operator is applied.- mu
The
Parameterfor which to apply the adjoint operator.
Returns
VectorArrayof the adjoint operator evaluations.
-
apply_inverse(V, mu=None, least_squares=False)[source]¶ Apply the inverse operator.
Parameters
- V
VectorArrayof vectors to which the inverse operator is applied.- mu
The
Parameterfor 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_optionsare set for the operator, most implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArrayof 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
VectorArrayof vectors to which the inverse adjoint operator is applied.- mu
The
Parameterfor 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_optionsare set for the operator, most operator implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArrayof the inverse adjoint operator evaluations.Raises
- InversionError
The operator could not be inverted.
-
restricted(dofs)[source]¶ Restrict the operator range to a given set of degrees of freedom.
This method returns a restricted version
restricted_opof the operator along with an arraysource_dofssuch that for anyVectorArrayUinself.sourcethe 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 interpolationwhere 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 fewsource_dofswill 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 arrayof degrees of freedom in the operatorrangeto which to restrict.
Returns
- restricted_op
The restricted operator as defined above. The operator will have
NumpyVectorSpace(len(source_dofs))assourceandNumpyVectorSpace(len(dofs))asrange.- source_dofs
One-dimensional
NumPy arrayof source degrees of freedom as defined above.
-
pymor.operators.constructions.induced_norm(product, raise_negative=True, tol=1e-10, name=None)[source]¶ Obtain induced norm of an inner product.
The norm of the vectors in a
VectorArrayU is calculated by callingproduct.pairwise_apply2(U, U, mu=mu).
In addition, negative norm squares of absolute value smaller than
tolare clipped to0. Ifraise_negativeisTrue, aValueErrorexception is raised if there are negative norm squares of absolute value larger thantol.Parameters
- product
The inner product
Operatorfor which the norm is to be calculated.- raise_negative
If
True, raise an exception if calculated norm is negative.- tol
See above.
- name
optional, if None product’s name is used
Returns
- norm
A function
norm(U, mu=None)taking aVectorArrayUas input together with theParametermuwhich is passed to the product.
Defaults
raise_negative, tol (see
pymor.core.defaults)
ei module¶
-
class
pymor.operators.ei.EmpiricalInterpolatedOperator(operator, interpolation_dofs, collateral_basis, triangular, solver_options=None, name=None)[source]¶ Bases:
pymor.operators.basic.OperatorBaseInterpolate an
Operatorusing Empirical Operator Interpolation.Let
Lbe anOperator,0 <= c_1, ..., c_M < L.range.dimindices of interpolation DOFs and letb_1, ..., b_M in R^(L.range.dim)be collateral basis vectors. If moreoverψ_j(U)denotes the j-th component ofU, the empirical interpolationL_EIofLw.r.t. the given data is given by| M | L_EI(U, μ) = ∑ b_i⋅λ_i such that | i=1 | | ψ_(c_i)(L_EI(U, μ)) = ψ_(c_i)(L(U, μ)) for i=0,...,M
Since the original operator only has to be evaluated at the given interpolation DOFs,
EmpiricalInterpolatedOperatorcallsrestrictedto obtain a restricted version of the operator which is used to quickly obtain the required evaluations. If therestrictedmethod, is not implemented, the full operator will be evaluated (which will lead to the same result, but without any speedup).The interpolation DOFs and the collateral basis can be generated using the algorithms provided in the
pymor.algorithms.eimodule.Parameters
- operator
The
Operatorto interpolate.- interpolation_dofs
List or 1D
NumPy arrayof the interpolation DOFsc_1, ..., c_M.- collateral_basis
VectorArraycontaining the collateral basisb_1, ..., b_M.- triangular
If
True, assume that ψ_(c_i)(b_j) = 0 for i < j, which means that the interpolation matrix is triangular.- solver_options
The
solver_optionsfor the operator.- name
Name of the operator.
Methods
Attributes
operatorH,linear,range,solver_options,source-
apply(U, mu=None)[source]¶ Apply the operator to a
VectorArray.Parameters
- U
VectorArrayof vectors to which the operator is applied.- mu
The
Parameterfor which to evaluate the operator.
Returns
VectorArrayof the operator evaluations.
-
class
pymor.operators.ei.ProjectedEmpiciralInterpolatedOperator(restricted_operator, interpolation_matrix, source_basis_dofs, projected_collateral_basis, triangular, solver_options=None, name=None)[source]¶ Bases:
pymor.operators.basic.OperatorBaseA projected
EmpiricalInterpolatedOperator.Methods
Attributes
H,linear,range,solver_options,source-
apply(U, mu=None)[source]¶ Apply the operator to a
VectorArray.Parameters
- U
VectorArrayof vectors to which the operator is applied.- mu
The
Parameterfor which to evaluate the operator.
Returns
VectorArrayof the operator evaluations.
-
fv module¶
This module provides some operators for finite volume discretizations.
-
class
pymor.operators.fv.DiffusionOperator(grid, boundary_info, diffusion_function=None, diffusion_constant=None, solver_options=None, name=None)[source]¶ Bases:
pymor.operators.numpy.NumpyMatrixBasedOperatorFinite Volume Diffusion
Operator.The operator is of the form
(Lu)(x) = c ∇ ⋅ [ d(x) ∇ u(x) ]
Parameters
- grid
The
Gridover which to assemble the operator.- boundary_info
BoundaryInfofor the treatment of Dirichlet boundary conditions.- diffusion_function
The scalar-valued
Functiond(x). IfNone, constant one is assumed.- diffusion_constant
The constant
c. IfNone,cis set to one.- solver_options
The
solver_optionsfor the operator.- name
Name of the operator.
-
class
pymor.operators.fv.EngquistOsherFlux(flux, flux_derivative, gausspoints=5, intervals=1)[source]¶ Bases:
pymor.operators.fv.NumericalConvectiveFluxInterfaceEngquist-Osher numerical flux.
If
fis the analytical flux, andf'its derivative, the Engquist-Osher flux is given by:F(U_in, U_out, normal, vol) = vol * [c^+(U_in, normal) + c^-(U_out, normal)] U_in c^+(U_in, normal) = f(0)⋅normal + ∫ max(f'(s)⋅normal, 0) ds s=0 U_out c^-(U_out, normal) = ∫ min(f'(s)⋅normal, 0) ds s=0Parameters
Methods
evaluate_stage1,evaluate_stage2disable_logging,enable_logging,has_interface_name,implementor_names,implementors
-
class
pymor.operators.fv.L2Product(grid, solver_options=None, name=None)[source]¶ Bases:
pymor.operators.numpy.NumpyMatrixBasedOperatorOperatorrepresenting the L2-product between finite volume functions.Parameters
- grid
The
Gridfor which to assemble the product.- solver_options
The
solver_optionsfor the operator.- name
The name of the product.
-
class
pymor.operators.fv.L2ProductFunctional(grid, function=None, boundary_info=None, dirichlet_data=None, diffusion_function=None, diffusion_constant=None, neumann_data=None, order=1, name=None)[source]¶ Bases:
pymor.operators.numpy.NumpyMatrixBasedOperatorFinite volume functional representing the inner product with an L2-
Function.Additionally, boundary conditions can be enforced by providing
dirichlet_dataandneumann_datafunctions.Parameters
- grid
Gridfor which to assemble the functional.- function
The
Functionwith which to take the inner product orNone.- boundary_info
BoundaryInfodetermining the Dirichlet and Neumann boundaries orNone. IfNone, no boundary treatment is performed.- dirichlet_data
Functionproviding the Dirichlet boundary values. IfNone, constant-zero boundary is assumed.- diffusion_function
See
DiffusionOperator. Has to be specified in casedirichlet_datais given.- diffusion_constant
See
DiffusionOperator. Has to be specified in casedirichlet_datais given.- neumann_data
Functionproviding the Neumann boundary values. IfNone, constant-zero is assumed.- order
Order of the Gauss quadrature to use for numerical integration.
- name
The name of the functional.
-
class
pymor.operators.fv.LaxFriedrichsFlux(flux, lxf_lambda=1.0)[source]¶ Bases:
pymor.operators.fv.NumericalConvectiveFluxInterfaceLax-Friedrichs numerical flux.
If
fis the analytical flux, the Lax-Friedrichs fluxFis given by:F(U_in, U_out, normal, vol) = vol * [normal⋅(f(U_in) + f(U_out))/2 + (U_in - U_out)/(2*λ)]
Parameters
- flux
Functiondefining the analytical fluxf.- lxf_lambda
The stabilization parameter
λ.
Methods
evaluate_stage1,evaluate_stage2disable_logging,enable_logging,has_interface_name,implementor_names,implementors
-
class
pymor.operators.fv.LinearAdvectionLaxFriedrichs(grid, boundary_info, velocity_field, lxf_lambda=1.0, solver_options=None, name=None)[source]¶ Bases:
pymor.operators.numpy.NumpyMatrixBasedOperatorLinear advection finite Volume
Operatorusing Lax-Friedrichs flux.The operator is of the form
L(u, mu)(x) = ∇ ⋅ (v(x, mu)⋅u(x))
See
LaxFriedrichsFluxfor the definition of the Lax-Friedrichs flux.Parameters
- grid
Gridover which to assemble the operator.- boundary_info
BoundaryInfodetermining the Dirichlet and Neumann boundaries.- velocity_field
Functiondefining the velocity fieldv.- lxf_lambda
The stabilization parameter
λ.- solver_options
The
solver_optionsfor the operator.- name
The name of the operator.
-
class
pymor.operators.fv.NonlinearAdvectionOperator(grid, boundary_info, numerical_flux, dirichlet_data=None, solver_options=None, space_id='STATE', name=None)[source]¶ Bases:
pymor.operators.basic.OperatorBaseNonlinear finite volume advection
Operator.The operator is of the form
L(u, mu)(x) = ∇ ⋅ f(u(x), mu)
Parameters
- grid
Gridfor which to evaluate the operator.- boundary_info
BoundaryInfodetermining the Dirichlet and Neumann boundaries.- numerical_flux
The
NumericalConvectiveFluxto use.- dirichlet_data
Functionproviding the Dirichlet boundary values. IfNone, constant-zero boundary is assumed.- solver_options
The
solver_optionsfor the operator.- name
The name of the operator.
Methods
Attributes
-
apply(U, mu=None)[source]¶ Apply the operator to a
VectorArray.Parameters
- U
VectorArrayof vectors to which the operator is applied.- mu
The
Parameterfor which to evaluate the operator.
Returns
VectorArrayof the operator evaluations.
-
jacobian(U, mu=None)[source]¶ Return the operator’s Jacobian as a new
Operator.Parameters
- U
Length 1
VectorArraycontaining the vector for which to compute the Jacobian.- mu
The
Parameterfor which to compute the Jacobian.
Returns
Linear
Operatorrepresenting the Jacobian.
-
restricted(dofs)[source]¶ Restrict the operator range to a given set of degrees of freedom.
This method returns a restricted version
restricted_opof the operator along with an arraysource_dofssuch that for anyVectorArrayUinself.sourcethe 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 interpolationwhere 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 fewsource_dofswill 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 arrayof degrees of freedom in the operatorrangeto which to restrict.
Returns
- restricted_op
The restricted operator as defined above. The operator will have
NumpyVectorSpace(len(source_dofs))assourceandNumpyVectorSpace(len(dofs))asrange.- source_dofs
One-dimensional
NumPy arrayof source degrees of freedom as defined above.
-
class
pymor.operators.fv.NonlinearReactionOperator(grid, reaction_function, reaction_function_derivative=None, space_id='STATE', name=None)[source]¶ Bases:
pymor.operators.basic.OperatorBaseMethods
Attributes
-
apply(U, ind=None, mu=None)[source]¶ Apply the operator to a
VectorArray.Parameters
- U
VectorArrayof vectors to which the operator is applied.- mu
The
Parameterfor which to evaluate the operator.
Returns
VectorArrayof the operator evaluations.
-
-
class
pymor.operators.fv.NumericalConvectiveFluxInterface[source]¶ Bases:
pymor.core.interfaces.ImmutableInterface,pymor.parameters.base.ParametricInterface for numerical convective fluxes for finite volume schemes.
Numerical fluxes defined by this interfaces are functions of the form
F(U_inner, U_outer, unit_outer_normal, edge_volume, mu).- The flux evaluation is vectorized and happens in two stages:
evaluate_stage1receives aNumPy arrayUof all values which appear asU_innerorU_outerfor all edges the flux shall be evaluated at and returns atupleofNumPy arrayseach of the same length asU.evaluate_stage2receives the reorderedstage1_datafor each edge as well as the unit outer normal and the volume of the edges.stage1_datais given as follows: IfR_lisl-th entry of thetuplereturned byevaluate_stage1, thel-th entryD_lof of thestage1_datatuple has the shape(num_edges, 2) + R_l.shape[1:]. If for edgekthe valuesU_innerandU_outerare thei-th andj-th value in theUarray provided toevaluate_stage1, we haveD_l[k, 0] == R_l[i], D_l[k, 1] == R_l[j].
evaluate_stage2returns aNumPy arrayof the flux evaluations for each edge.
Methods
evaluate_stage1,evaluate_stage2disable_logging,enable_logging,has_interface_name,implementor_names,implementors
-
class
pymor.operators.fv.ReactionOperator(grid, reaction_coefficient, solver_options=None, name=None)[source]¶ Bases:
pymor.operators.numpy.NumpyMatrixBasedOperatorFinite Volume reaction
Operator.The operator is of the form
L(u, mu)(x) = c(x, mu)⋅u(x)
Parameters
- grid
The
Gridfor which to assemble the operator.- reaction_coefficient
The function ‘c’
- solver_options
The
solver_optionsfor the operator.- name
The name of the operator.
-
class
pymor.operators.fv.SimplifiedEngquistOsherFlux(flux, flux_derivative)[source]¶ Bases:
pymor.operators.fv.NumericalConvectiveFluxInterfaceEngquist-Osher numerical flux. Simplified Implementation for special case.
For the definition of the Engquist-Osher flux see
EngquistOsherFlux. This class provides a faster and more accurate implementation for the special case thatf(0) == 0and the derivative offonly changes sign at0.Parameters
Methods
evaluate_stage1,evaluate_stage2disable_logging,enable_logging,has_interface_name,implementor_names,implementors
-
pymor.operators.fv.nonlinear_advection_engquist_osher_operator(grid, boundary_info, flux, flux_derivative, gausspoints=5, intervals=1, dirichlet_data=None, solver_options=None, name=None)[source]¶ Instantiate a
NonlinearAdvectionOperatorusingEngquistOsherFlux.
-
pymor.operators.fv.nonlinear_advection_lax_friedrichs_operator(grid, boundary_info, flux, lxf_lambda=1.0, dirichlet_data=None, solver_options=None, name=None)[source]¶ Instantiate a
NonlinearAdvectionOperatorusingLaxFriedrichsFlux.
-
pymor.operators.fv.nonlinear_advection_simplified_engquist_osher_operator(grid, boundary_info, flux, flux_derivative, dirichlet_data=None, solver_options=None, name=None)[source]¶ Instantiate a
NonlinearAdvectionOperatorusingSimplifiedEngquistOsherFlux.
interfaces module¶
-
class
pymor.operators.interfaces.OperatorInterface[source]¶ Bases:
pymor.core.interfaces.ImmutableInterface,pymor.parameters.base.ParametricInterface for
Parameterdependent discrete operators.An operator in pyMOR is simply a mapping which for any given
Parametermaps vectors from itssourceVectorSpaceto vectors in itsrangeVectorSpace.Note that there is no special distinction between functionals and operators in pyMOR. A functional is simply an operator with
NumpyVectorSpace(1)as itsrangeVectorSpace.Methods
Attributes
H,linear,range,solver_options,source-
solver_options¶ If not
None, a dict which can contain the following keys:- ‘inverse’
solver options used for
apply_inverse- ‘inverse_adjoint’
solver options used for
apply_inverse_adjoint- ‘jacobian’
solver options for the operators returned by
jacobian(has no effect for linear operators)
If
solver_optionsisNoneor a dict entry is missing orNone, default options are used. The interpretation of the given solver options is up to the operator at hand. In general, values insolver_optionsshould either be strings (indicating a solver type) or dicts of options, usually with an entry'type'which specifies the solver type to use and further items which configure this solver.
-
linear¶ Trueif the operator is linear.
-
source¶ The source
VectorSpace.
-
range¶ The range
VectorSpace.
-
H¶ The adjoint operator, i.e.
self.H.apply(V, mu) == self.apply_adjoint(V, mu)
for all V, mu.
-
abstract
apply(U, mu=None)[source]¶ Apply the operator to a
VectorArray.Parameters
- U
VectorArrayof vectors to which the operator is applied.- mu
The
Parameterfor which to evaluate the operator.
Returns
VectorArrayof the operator evaluations.
-
abstract
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
apply2is given as:op.apply2(V, U) = V^T*M*U.
In the case of complex numbers, note that
apply2is anti-linear in the first variable by definition ofdot.Parameters
- V
VectorArrayof the left arguments V.- U
VectorArrayof the right right arguments U.- mu
The
Parameterfor which to evaluate the operator.
Returns
A
NumPy arraywith shape(len(V), len(U))containing the 2-form evaluations.
-
abstract
apply_adjoint(V, mu=None)[source]¶ Apply the adjoint operator.
For any given linear
Operatorop,ParametermuandVectorArraysU,Vin thesourceresp.rangewe have:op.apply_adjoint(V, mu).dot(U) == V.dot(op.apply(U, mu))
Thus, when
opis represented by a matrixM,apply_adjointis given by left-multplication of (the complex conjugate of)MwithV.Parameters
- V
VectorArrayof vectors to which the adjoint operator is applied.- mu
The
Parameterfor which to apply the adjoint operator.
Returns
VectorArrayof the adjoint operator evaluations.
-
abstract
apply_inverse(V, mu=None, least_squares=False)[source]¶ Apply the inverse operator.
Parameters
- V
VectorArrayof vectors to which the inverse operator is applied.- mu
The
Parameterfor 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_optionsare set for the operator, most implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArrayof the inverse operator evaluations.Raises
- InversionError
The operator could not be inverted.
-
abstract
apply_inverse_adjoint(U, mu=None, least_squares=False)[source]¶ Apply the inverse adjoint operator.
Parameters
- U
VectorArrayof vectors to which the inverse adjoint operator is applied.- mu
The
Parameterfor 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_optionsare set for the operator, most operator implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArrayof the inverse adjoint operator evaluations.Raises
- InversionError
The operator could not be inverted.
-
as_range_array(mu=None)[source]¶ Return a
VectorArrayrepresentation of the operator in its range space.In the case of a linear operator with
NumpyVectorSpaceassource, this method returns for everyParametermuaVectorArrayVin the operator’srange, such thatV.lincomb(U.to_numpy()) == self.apply(U, mu)
for all
VectorArraysU.Parameters
- mu
The
Parameterfor which to return theVectorArrayrepresentation.
Returns
- V
The
VectorArraydefined above.
-
as_source_array(mu=None)[source]¶ Return a
VectorArrayrepresentation of the operator in its source space.In the case of a linear operator with
NumpyVectorSpaceasrange, this method returns for everyParametermuaVectorArrayVin the operator’ssource, such thatself.range.make_array(V.dot(U).T) == self.apply(U, mu)
for all
VectorArraysU.Parameters
- mu
The
Parameterfor which to return theVectorArrayrepresentation.
Returns
- V
The
VectorArraydefined above.
-
as_vector(mu=None)[source]¶ Return a vector representation of a linear functional or vector operator.
Depending on the operator’s
sourceandrange, this method is equivalent to callingas_range_arrayoras_source_arrayrespectively. The resultingVectorArrayis required to have length 1.Parameters
- mu
The
Parameterfor which to return the vector representation.
Returns
- V
VectorArrayof length 1 containing the vector representation.
-
abstract
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
LincombOperatorwill try to form the linear combination of its operators, whereas an arbitrary operator might simply return aFixedParameterOperator. The only assured property of the assembled operator is that it no longer depends on aParameter.Parameters
- mu
The
Parameterfor which to assemble the operator.
Returns
Parameter-independent, assembled
Operator.
-
abstract
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
Operatorrepresenting the partial derivative.
-
abstract
jacobian(U, mu=None)[source]¶ Return the operator’s Jacobian as a new
Operator.Parameters
- U
Length 1
VectorArraycontaining the vector for which to compute the Jacobian.- mu
The
Parameterfor which to compute the Jacobian.
Returns
Linear
Operatorrepresenting the Jacobian.
-
abstract
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 fromVandUare applied in pairs.Parameters
- V
VectorArrayof the left arguments V.- U
VectorArrayof the right right arguments U.- mu
The
Parameterfor which to evaluate the operator.
Returns
A
NumPy arraywith shape(len(V),) == (len(U),)containing the 2-form evaluations.
-
restricted(dofs)[source]¶ Restrict the operator range to a given set of degrees of freedom.
This method returns a restricted version
restricted_opof the operator along with an arraysource_dofssuch that for anyVectorArrayUinself.sourcethe 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 interpolationwhere 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 fewsource_dofswill 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 arrayof degrees of freedom in the operatorrangeto which to restrict.
Returns
- restricted_op
The restricted operator as defined above. The operator will have
NumpyVectorSpace(len(source_dofs))assourceandNumpyVectorSpace(len(dofs))asrange.- source_dofs
One-dimensional
NumPy arrayof source degrees of freedom as defined above.
-
mpi module¶
-
class
pymor.operators.mpi.MPIOperator(obj_id, mpi_range, mpi_source, with_apply2=False, pickle_local_spaces=True, space_type=<class 'pymor.vectorarrays.mpi.MPIVectorSpace'>)[source]¶ Bases:
pymor.operators.basic.OperatorBaseMPI distributed
Operator.Given a single-rank implementation of an
Operator, this wrapper class uses the event loop frompymor.tools.mpito allow an MPI distributed usage of theOperator.Instances of
MPIOperatorcan be used on rank 0 like any other (non-distributed)Operator.Note, however, that the underlying
Operatorimplementation needs to be MPI aware. For instance, the operator’sapplymethod has to perform the necessary MPI communication to obtain all DOFs hosted on other MPI ranks which are required for the local operator evaluation.Instead of instantiating
MPIOperatordirectly, it is usually preferable to usempi_wrap_operatorinstead.Parameters
- obj_id
- mpi_range
Set to
Trueif the range of theOperatoris MPI distributed.- mpi_source
Set to
Trueif the source of theOperatoris MPI distributed.- with_apply2
Set to
Trueif the operator implementation has its own MPI aware implementation ofapply2andpairwise_apply2. Otherwise, the default implementations usingapplyanddotwill be used.- pickle_local_spaces
If
pickle_local_spacesisFalse, a unique identifier is computed for each local source/rangeVectorSpace, which is then transferred to rank 0 instead of the trueVectorSpace. This allows the useage ofMPIVectorArrayeven when the localVectorSpacesare not picklable.- space_type
This class will be used to wrap the local
VectorArraysreturned by the local operators into an MPI distributedVectorArraymanaged from rank 0. By default,MPIVectorSpacewill be used, other options areMPIVectorSpaceAutoCommandMPIVectorSpaceNoComm.
Methods
Attributes
H,linear,range,solver_options,source-
apply(U, mu=None)[source]¶ Apply the operator to a
VectorArray.Parameters
- U
VectorArrayof vectors to which the operator is applied.- mu
The
Parameterfor which to evaluate the operator.
Returns
VectorArrayof 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
apply2is given as:op.apply2(V, U) = V^T*M*U.
In the case of complex numbers, note that
apply2is anti-linear in the first variable by definition ofdot.Parameters
- V
VectorArrayof the left arguments V.- U
VectorArrayof the right right arguments U.- mu
The
Parameterfor which to evaluate the operator.
Returns
A
NumPy arraywith shape(len(V), len(U))containing the 2-form evaluations.
-
apply_adjoint(V, mu=None)[source]¶ Apply the adjoint operator.
For any given linear
Operatorop,ParametermuandVectorArraysU,Vin thesourceresp.rangewe have:op.apply_adjoint(V, mu).dot(U) == V.dot(op.apply(U, mu))
Thus, when
opis represented by a matrixM,apply_adjointis given by left-multplication of (the complex conjugate of)MwithV.Parameters
- V
VectorArrayof vectors to which the adjoint operator is applied.- mu
The
Parameterfor which to apply the adjoint operator.
Returns
VectorArrayof the adjoint operator evaluations.
-
apply_inverse(V, mu=None, least_squares=False)[source]¶ Apply the inverse operator.
Parameters
- V
VectorArrayof vectors to which the inverse operator is applied.- mu
The
Parameterfor 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_optionsare set for the operator, most implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArrayof 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
VectorArrayof vectors to which the inverse adjoint operator is applied.- mu
The
Parameterfor 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_optionsare set for the operator, most operator implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArrayof the inverse adjoint operator evaluations.Raises
- InversionError
The operator could not be inverted.
-
as_range_array(mu=None)[source]¶ Return a
VectorArrayrepresentation of the operator in its range space.In the case of a linear operator with
NumpyVectorSpaceassource, this method returns for everyParametermuaVectorArrayVin the operator’srange, such thatV.lincomb(U.to_numpy()) == self.apply(U, mu)
for all
VectorArraysU.Parameters
- mu
The
Parameterfor which to return theVectorArrayrepresentation.
Returns
- V
The
VectorArraydefined above.
-
as_source_array(mu=None)[source]¶ Return a
VectorArrayrepresentation of the operator in its source space.In the case of a linear operator with
NumpyVectorSpaceasrange, this method returns for everyParametermuaVectorArrayVin the operator’ssource, such thatself.range.make_array(V.dot(U).T) == self.apply(U, mu)
for all
VectorArraysU.Parameters
- mu
The
Parameterfor which to return theVectorArrayrepresentation.
Returns
- V
The
VectorArraydefined 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
LincombOperatorwill try to form the linear combination of its operators, whereas an arbitrary operator might simply return aFixedParameterOperator. The only assured property of the assembled operator is that it no longer depends on aParameter.Parameters
- mu
The
Parameterfor 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
VectorArraycontaining the vector for which to compute the Jacobian.- mu
The
Parameterfor which to compute the Jacobian.
Returns
Linear
Operatorrepresenting 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 fromVandUare applied in pairs.Parameters
- V
VectorArrayof the left arguments V.- U
VectorArrayof the right right arguments U.- mu
The
Parameterfor which to evaluate the operator.
Returns
A
NumPy arraywith shape(len(V),) == (len(U),)containing the 2-form evaluations.
-
restricted(dofs)[source]¶ Restrict the operator range to a given set of degrees of freedom.
This method returns a restricted version
restricted_opof the operator along with an arraysource_dofssuch that for anyVectorArrayUinself.sourcethe 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 interpolationwhere 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 fewsource_dofswill 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 arrayof degrees of freedom in the operatorrangeto which to restrict.
Returns
- restricted_op
The restricted operator as defined above. The operator will have
NumpyVectorSpace(len(source_dofs))assourceandNumpyVectorSpace(len(dofs))asrange.- source_dofs
One-dimensional
NumPy arrayof source degrees of freedom as defined above.
-
pymor.operators.mpi.mpi_wrap_operator(obj_id, mpi_range, mpi_source, with_apply2=False, pickle_local_spaces=True, space_type=<class 'pymor.vectorarrays.mpi.MPIVectorSpace'>)[source]¶ Wrap MPI distributed local
Operatorsto a globalOperatoron rank 0.Given MPI distributed local
Operatorsreferred to by theObjectIdobj_id, return a newOperatorwhich manages these distributed operators from rank 0. This is done by instantiatingMPIOperator. Additionally, the structure of the wrapped operators is preserved. E.g.LincombOperatorswill be wrapped as aLincombOperatorofMPIOperators.Parameters
See : class:
MPIOperator.Returns
The wrapped
Operator.
numpy module¶
This module provides the following NumPy based Operators:
NumpyMatrixOperatorwraps a 2DNumPy arrayas anOperator.NumpyMatrixBasedOperatorshould be used as base class for allOperatorswhich assemble into aNumpyMatrixOperator.NumpyGenericOperatorwraps an arbitrary Python function betweenNumPy arraysas anOperator.
-
class
pymor.operators.numpy.NumpyGenericOperator(mapping, adjoint_mapping=None, dim_source=1, dim_range=1, linear=False, parameter_type=None, source_id=None, range_id=None, solver_options=None, name=None)[source]¶ Bases:
pymor.operators.basic.OperatorBaseWraps an arbitrary Python function between
NumPy arraysas anOperator.Parameters
- mapping
The function to wrap. If
parameter_typeisNone, the function is of the formmapping(U)and is expected to be vectorized. In particular:mapping(U).shape == U.shape[:-1] + (dim_range,).
If
parameter_typeis notNone, the function has to have the signaturemapping(U, mu).- adjoint_mapping
The adjoint function to wrap. If
parameter_typeisNone, the function is of the formadjoint_mapping(U)and is expected to be vectorized. In particular:adjoint_mapping(U).shape == U.shape[:-1] + (dim_source,).
If
parameter_typeis notNone, the function has to have the signatureadjoint_mapping(U, mu).- dim_source
Dimension of the operator’s source.
- dim_range
Dimension of the operator’s range.
- linear
Set to
Trueif the providedmappingandadjoint_mappingare linear.- parameter_type
The
ParameterTypeof theParametersthe mapping accepts.- solver_options
The
solver_optionsfor the operator.- name
Name of the operator.
Methods
Attributes
H,linear,range,solver_options,source-
apply(U, mu=None)[source]¶ Apply the operator to a
VectorArray.Parameters
- U
VectorArrayof vectors to which the operator is applied.- mu
The
Parameterfor which to evaluate the operator.
Returns
VectorArrayof the operator evaluations.
-
apply_adjoint(V, mu=None)[source]¶ Apply the adjoint operator.
For any given linear
Operatorop,ParametermuandVectorArraysU,Vin thesourceresp.rangewe have:op.apply_adjoint(V, mu).dot(U) == V.dot(op.apply(U, mu))
Thus, when
opis represented by a matrixM,apply_adjointis given by left-multplication of (the complex conjugate of)MwithV.Parameters
- V
VectorArrayof vectors to which the adjoint operator is applied.- mu
The
Parameterfor which to apply the adjoint operator.
Returns
VectorArrayof the adjoint operator evaluations.
-
class
pymor.operators.numpy.NumpyMatrixBasedOperator[source]¶ Bases:
pymor.operators.basic.OperatorBaseBase class for operators which assemble into a
NumpyMatrixOperator.Methods
Attributes
-
sparse¶ Trueif the operator assembles into a sparse matrix,Falseif the operator assembles into a dense matrix,Noneif unknown.
-
apply(U, mu=None)[source]¶ Apply the operator to a
VectorArray.Parameters
- U
VectorArrayof vectors to which the operator is applied.- mu
The
Parameterfor which to evaluate the operator.
Returns
VectorArrayof the operator evaluations.
-
apply_adjoint(V, mu=None)[source]¶ Apply the adjoint operator.
For any given linear
Operatorop,ParametermuandVectorArraysU,Vin thesourceresp.rangewe have:op.apply_adjoint(V, mu).dot(U) == V.dot(op.apply(U, mu))
Thus, when
opis represented by a matrixM,apply_adjointis given by left-multplication of (the complex conjugate of)MwithV.Parameters
- V
VectorArrayof vectors to which the adjoint operator is applied.- mu
The
Parameterfor which to apply the adjoint operator.
Returns
VectorArrayof the adjoint operator evaluations.
-
apply_inverse(V, mu=None, least_squares=False)[source]¶ Apply the inverse operator.
Parameters
- V
VectorArrayof vectors to which the inverse operator is applied.- mu
The
Parameterfor 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_optionsare set for the operator, most implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArrayof the inverse operator evaluations.Raises
- InversionError
The operator could not be inverted.
-
as_range_array(mu=None)[source]¶ Return a
VectorArrayrepresentation of the operator in its range space.In the case of a linear operator with
NumpyVectorSpaceassource, this method returns for everyParametermuaVectorArrayVin the operator’srange, such thatV.lincomb(U.to_numpy()) == self.apply(U, mu)
for all
VectorArraysU.Parameters
- mu
The
Parameterfor which to return theVectorArrayrepresentation.
Returns
- V
The
VectorArraydefined above.
-
as_source_array(mu=None)[source]¶ Return a
VectorArrayrepresentation of the operator in its source space.In the case of a linear operator with
NumpyVectorSpaceasrange, this method returns for everyParametermuaVectorArrayVin the operator’ssource, such thatself.range.make_array(V.dot(U).T) == self.apply(U, mu)
for all
VectorArraysU.Parameters
- mu
The
Parameterfor which to return theVectorArrayrepresentation.
Returns
- V
The
VectorArraydefined 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
LincombOperatorwill try to form the linear combination of its operators, whereas an arbitrary operator might simply return aFixedParameterOperator. The only assured property of the assembled operator is that it no longer depends on aParameter.Parameters
- mu
The
Parameterfor which to assemble the operator.
Returns
Parameter-independent, assembled
Operator.
-
export_matrix(filename, matrix_name=None, output_format='matlab', mu=None)[source]¶ Save the matrix of the operator to a file.
Parameters
- filename
Name of output file.
- matrix_name
The name, the output matrix is given. (Comment field is used in case of Matrix Market output_format.) If
None, theOperator’snameis used.- output_format
Output file format. Either
matlabormatrixmarket.- mu
The
Parameterto assemble the to be exported matrix for.
-
-
class
pymor.operators.numpy.NumpyMatrixOperator(matrix, source_id=None, range_id=None, solver_options=None, name=None)[source]¶ Bases:
pymor.operators.numpy.NumpyMatrixBasedOperatorWraps a 2D
NumPy arrayas anOperator.Parameters
- matrix
The
NumPy arraywhich is to be wrapped.- source_id
The id of the operator’s
sourceVectorSpace.- range_id
The id of the operator’s
rangeVectorSpace.- solver_options
The
solver_optionsfor the operator.- name
Name of the operator.
Methods
apply,apply_adjoint,apply_inverse,apply_inverse_adjoint,as_range_array,as_source_array,assemble,from_filedisable_logging,enable_logging,has_interface_name,implementor_names,implementorsAttributes
-
apply(U, mu=None)[source]¶ Apply the operator to a
VectorArray.Parameters
- U
VectorArrayof vectors to which the operator is applied.- mu
The
Parameterfor which to evaluate the operator.
Returns
VectorArrayof the operator evaluations.
-
apply_adjoint(V, mu=None)[source]¶ Apply the adjoint operator.
For any given linear
Operatorop,ParametermuandVectorArraysU,Vin thesourceresp.rangewe have:op.apply_adjoint(V, mu).dot(U) == V.dot(op.apply(U, mu))
Thus, when
opis represented by a matrixM,apply_adjointis given by left-multplication of (the complex conjugate of)MwithV.Parameters
- V
VectorArrayof vectors to which the adjoint operator is applied.- mu
The
Parameterfor which to apply the adjoint operator.
Returns
VectorArrayof the adjoint operator evaluations.
-
apply_inverse(V, mu=None, least_squares=False, check_finite=True, default_sparse_solver_backend='scipy')[source]¶ Apply the inverse operator.
Parameters
- V
VectorArrayof vectors to which the inverse operator is applied.- mu
The
Parameterfor 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_optionsare set for the operator, most implementations will choose a least squares solver by default which may be undesirable.- check_finite
Test if solution only contains finite values.
- default_sparse_solver_backend
Default sparse solver backend to use (scipy, pyamg, generic).
Returns
VectorArrayof the inverse operator evaluations.Raises
- InversionError
The operator could not be inverted.
Defaults
check_finite, default_sparse_solver_backend (see
pymor.core.defaults)
-
apply_inverse_adjoint(U, mu=None, least_squares=False)[source]¶ Apply the inverse adjoint operator.
Parameters
- U
VectorArrayof vectors to which the inverse adjoint operator is applied.- mu
The
Parameterfor 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_optionsare set for the operator, most operator implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArrayof the inverse adjoint operator evaluations.Raises
- InversionError
The operator could not be inverted.
-
as_range_array(mu=None)[source]¶ Return a
VectorArrayrepresentation of the operator in its range space.In the case of a linear operator with
NumpyVectorSpaceassource, this method returns for everyParametermuaVectorArrayVin the operator’srange, such thatV.lincomb(U.to_numpy()) == self.apply(U, mu)
for all
VectorArraysU.Parameters
- mu
The
Parameterfor which to return theVectorArrayrepresentation.
Returns
- V
The
VectorArraydefined above.
-
as_source_array(mu=None)[source]¶ Return a
VectorArrayrepresentation of the operator in its source space.In the case of a linear operator with
NumpyVectorSpaceasrange, this method returns for everyParametermuaVectorArrayVin the operator’ssource, such thatself.range.make_array(V.dot(U).T) == self.apply(U, mu)
for all
VectorArraysU.Parameters
- mu
The
Parameterfor which to return theVectorArrayrepresentation.
Returns
- V
The
VectorArraydefined 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
LincombOperatorwill try to form the linear combination of its operators, whereas an arbitrary operator might simply return aFixedParameterOperator. The only assured property of the assembled operator is that it no longer depends on aParameter.Parameters
- mu
The
Parameterfor which to assemble the operator.
Returns
Parameter-independent, assembled
Operator.