pymor.operators package¶
Submodules¶
basic module¶

class
pymor.operators.basic.
OperatorBase
[source]¶ Bases:
pymor.operators.interfaces.OperatorInterface
Base class for
Operators
providing some default implementations.When implementing a new operator, it is usually advisable to derive from this class.
Methods
Attributes

__radd__
(other)¶ Sum of two operators.

apply2
(V, U, U_ind=None, V_ind=None, mu=None, product=None)[source]¶ Treat the operator as a 2form by calculating (V, op(U)).
In general
op.apply2(V, U)
is equivalent to:product.apply2(V, op.apply(U)).
In case no
product
has been specified,op.apply2(V, U)
is equivialent to:V.dot(op.apply(U)).
In the latter case, assuming that
op
is a linear operator given by multiplication with a matrix M, then:op.apply2(V, U) = V^T*M*U.
Parameters
 V
VectorArray
of the left arguments V. U
VectorArray
of the right right arguments U. V_ind
 The indices of the vectors in
V
to which the operator shall be applied (seeVectorArray
documentation for further details).  U_ind
 The indices of the vectors in
U
to which the operator shall be applied (seeVectorArray
documentation for further details).  mu
 The
Parameter
for which to evaluate the operator.  product
 The inner product used in the expression
(V, op(U))
given as anOperator
. IfNone
, the euclidean product is chosen.
Returns
A
NumPy array
with shape(len(V_ind), len(U_ind))
containing the 2form evaluations.

apply_adjoint
(U, ind=None, mu=None, source_product=None, range_product=None)[source]¶ Apply the adjoint operator.
For a linear operator
op
the adjointop^*
ofop
is given by:(op^*(v), u)_s = (v, op(u))_r,
where
( , )_s
and( , )_r
denote the inner products on the source and range space ofop
. Ifop
and the two products are given by the matricesM
,P_s
andP_r
, then:op^*(v) = P_s^(1) * M^T * P_r * v,
with
M^T
denoting the transposed ofM
. Thus, if( , )_s
and( , )_r
are the Euclidean inner products,op^*v
is simply given by multiplication of the matrix ofop
withv
from the left.Parameters
 U
VectorArray
of vectors to which the adjoint operator is applied. ind
 The indices of the vectors in
U
to which the operator shall be applied (see theVectorArray
documentation for further details).  mu
 The
Parameter
for which to apply the adjoint operator.  source_product
 The inner product
Operator
on the source space. IfNone
, the Euclidean product is chosen.  range_product
 The inner product
Operator
on the range space. IfNone
, the Euclidean product is chosen.
Returns
VectorArray
of the adjoint operator evaluations.

apply_inverse
(V, ind=None, mu=None, least_squares=False)[source]¶ Apply the inverse operator.
Parameters
 V
VectorArray
of vectors to which the inverse operator is applied. ind
 The indices of the vectors in
V
to which the inverse operator shall be applied (seeVectorArray
documentation for further details).  mu
 The
Parameter
for which to evaluate the inverse operator.  least_squares
If
True
, solve the least squares problem:u = argmin op(u)  v_2.
Since for an invertible operator the least squares solution agrees with the result of the application of the inverse operator, setting this option should, in general, have no effect on the result for those operators. However, note that when no appropriate
solver_options
are set for the operator, most implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArray
of the inverse operator evaluations.Raises
 InversionError
 The operator could not be inverted.

apply_inverse_adjoint
(U, ind=None, mu=None, source_product=None, range_product=None, least_squares=False)[source]¶ Apply the inverse adjoint operator.
Parameters
 U
VectorArray
of vectors to which the inverse adjoint operator is applied. ind
 The indices of the vectors in
U
to which the inverse adjoint operator shall be applied (see theVectorArray
documentation for further details).  mu
 The
Parameter
for which to evaluate the inverse adjoint operator.  source_product
 See
apply_adjoint
.  range_product
 See
apply_adjoint
.  least_squares
If
True
, solve the least squares problem:v = argmin op*(v)  u_2.
Since for an invertible operator the least squares solution agrees with the result of the application of the inverse operator, setting this option should, in general, have no effect on the result for those operators. However, note that when no appropriate
solver_options
are set for the operator, most operator implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArray
of the inverse adjoint operator evaluations.Raises
 InversionError
 The operator could not be inverted.

as_vector
(mu=None)[source]¶ Return a vector representation of a linear functional or vector operator.
This method may only be called on linear functionals, i.e. linear
Operators
withNumpyVectorSpace
(1)
asrange
, or on operators describing vectors, i.e. linearOperators
withNumpyVectorSpace
(1)
assource
.In the case of a functional, the identity
self.as_vector(mu).dot(U) == self.apply(U, mu)
holds, whereas in the case of a vectorlike operator we have
self.as_vector(mu) == self.apply(NumpyVectorArray(1), mu).
Parameters
 mu
 The
Parameter
for which to return the vector representation.
Returns
 V
VectorArray
of length 1 containing the vector representation.V
belongs toself.source
for functionals and toself.range
for vectorlike operators.

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 matrixbased operator will assemble its matrix, a
LincombOperator
will 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
Parameter
for which to assemble the operator.
Returns
Parameterindependent, assembled
Operator
.

jacobian
(U, mu=None)[source]¶ Return the operator’s Jacobian as a new
Operator
.Parameters
 U
 Length 1
VectorArray
containing the vector for which to compute the Jacobian.  mu
 The
Parameter
for which to compute the Jacobian.
Returns
Linear
Operator
representing the Jacobian.

pairwise_apply2
(V, U, U_ind=None, V_ind=None, mu=None, product=None)[source]¶ Treat the operator as a 2form by calculating (V, op(U)).
Same as
OperatorInterface.apply2
, except that vectors fromV
andU
are applied in pairs.Parameters
 V
VectorArray
of the left arguments V. U
VectorArray
of the right right arguments U. V_ind
 The indices of the vectors in
V
to which the operator shall be applied (seeVectorArray
documentation for further details).  U_ind
 The indices of the vectors in
U
to which the operator shall be applied (seeVectorArray
documentation for further details).  mu
 The
Parameter
for which to evaluate the operator.  product
 The inner product used in the expression
(V, op(U))
given as anOperator
. IfNone
, the euclidean product is chosen.
Returns
A
NumPy array
with shape(len(V_ind),) == (len(U_ind),)
containing the 2form evaluations.

projected
(range_basis, source_basis, product=None, name=None)[source]¶ Project the operator to subspaces of the source and range space.
Given an inner product
( ⋅, ⋅)
, source vectorsb_1, ..., b_N
and range vectorsc_1, ..., c_M
, the projectionop_proj
ofop
is defined by[ op_proj(e_j) ]_i = ( c_i, op(b_j) )
for all i,j, where
e_j
denotes the jth canonical basis vector of R^N.In particular, if the
c_i
are orthonormal w.r.t. the given product, thenop_proj
is the coordinate representation w.r.t. theb_i/c_i
bases of the restriction ofop
tospan(b_i)
concatenated with the orthogonal projection ontospan(c_i)
.From another point of view, if
op
is viewed as a bilinear form (seeapply2
) and( ⋅, ⋅ )
is the Euclidean inner product, thenop_proj
represents the matrix of the bilinear form restrictedspan(b_i) / spanc(c_i)
(w.r.t. theb_i/c_i
bases).How the projected operator is realized will depend on the implementation of the operator to project. While a projected
NumpyMatrixOperator
will again be aNumpyMatrixOperator
, only a genericProjectedOperator
can be returned in general.A default implementation is provided in
OperatorBase
.Parameters
 range_basis
 The vectors
c_1, ..., c_M
as aVectorArray
. IfNone
, no projection in the range space is performed.  source_basis
 The vectors
b_1, ..., b_N
as aVectorArray
orNone
. IfNone
, no restriction of the source space is performed.  product
 An
Operator
representing the inner product. IfNone
, the Euclidean inner product is chosen.  name
 Name of the projected operator.
Returns
The projected
Operator
op_proj
.


class
pymor.operators.basic.
ProjectedOperator
(operator, range_basis, source_basis, product=None, solver_options=None, name=None)[source]¶ Bases:
pymor.operators.basic.OperatorBase
Generic
Operator
representing the projection of anOperator
to a subspace.This operator is implemented as the concatenation of the linear combination with
source_basis
, application of the originaloperator
and 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 the default implementation of
projected
inOperatorBase
for parametric or nonlinear operators.Parameters
Methods
Attributes

apply
(U, ind=None, mu=None)[source]¶ Apply the operator to a
VectorArray
.Parameters
 U
VectorArray
of vectors to which the operator is applied. ind
 The indices of the vectors in
U
to which the operator shall be applied (see theVectorArray
documentation for further details).  mu
 The
Parameter
for which to evaluate the operator.
Returns
VectorArray
of the 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 matrixbased operator will assemble its matrix, a
LincombOperator
will 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
Parameter
for which to assemble the operator.
Returns
Parameterindependent, assembled
Operator
.

block module¶

class
pymor.operators.block.
BlockDiagonalOperator
(blocks)[source]¶ Bases:
pymor.operators.block.BlockOperator
Block diagonal
Operator
of arbitraryOperators
.This is a specialization of
BlockOperator
for the block diagonal case.Methods
Attributes

apply_inverse
(V, ind=None, mu=None, least_squares=False)[source]¶ Apply the inverse operator.
Parameters
 V
VectorArray
of vectors to which the inverse operator is applied. ind
 The indices of the vectors in
V
to which the inverse operator shall be applied (seeVectorArray
documentation for further details).  mu
 The
Parameter
for which to evaluate the inverse operator.  least_squares
If
True
, solve the least squares problem:u = argmin op(u)  v_2.
Since for an invertible operator the least squares solution agrees with the result of the application of the inverse operator, setting this option should, in general, have no effect on the result for those operators. However, note that when no appropriate
solver_options
are set for the operator, most implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArray
of the inverse operator evaluations.Raises
 InversionError
 The operator could not be inverted.

apply_inverse_adjoint
(U, ind=None, mu=None, source_product=None, range_product=None, least_squares=False)[source]¶ Apply the inverse adjoint operator.
Parameters
 U
VectorArray
of vectors to which the inverse adjoint operator is applied. ind
 The indices of the vectors in
U
to which the inverse adjoint operator shall be applied (see theVectorArray
documentation for further details).  mu
 The
Parameter
for which to evaluate the inverse adjoint operator.  source_product
 See
apply_adjoint
.  range_product
 See
apply_adjoint
.  least_squares
If
True
, solve the least squares problem:v = argmin op*(v)  u_2.
Since for an invertible operator the least squares solution agrees with the result of the application of the inverse operator, setting this option should, in general, have no effect on the result for those operators. However, note that when no appropriate
solver_options
are set for the operator, most operator implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArray
of the inverse adjoint operator evaluations.Raises
 InversionError
 The operator could not be inverted.


class
pymor.operators.block.
BlockOperator
(blocks)[source]¶ Bases:
pymor.operators.basic.OperatorBase
A sparse matrix of arbitrary
Operators
.This operator can be
applied
toBlockVectorArrays
of an appropriatesubtype
.Methods
Attributes

apply
(U, ind=None, mu=None)[source]¶ Apply the operator to a
VectorArray
.Parameters
 U
VectorArray
of vectors to which the operator is applied. ind
 The indices of the vectors in
U
to which the operator shall be applied (see theVectorArray
documentation for further details).  mu
 The
Parameter
for which to evaluate the operator.
Returns
VectorArray
of the operator evaluations.

apply_adjoint
(U, ind=None, mu=None, source_product=None, range_product=None)[source]¶ Apply the adjoint operator.
For a linear operator
op
the adjointop^*
ofop
is given by:(op^*(v), u)_s = (v, op(u))_r,
where
( , )_s
and( , )_r
denote the inner products on the source and range space ofop
. Ifop
and the two products are given by the matricesM
,P_s
andP_r
, then:op^*(v) = P_s^(1) * M^T * P_r * v,
with
M^T
denoting the transposed ofM
. Thus, if( , )_s
and( , )_r
are the Euclidean inner products,op^*v
is simply given by multiplication of the matrix ofop
withv
from the left.Parameters
 U
VectorArray
of vectors to which the adjoint operator is applied. ind
 The indices of the vectors in
U
to which the operator shall be applied (see theVectorArray
documentation for further details).  mu
 The
Parameter
for which to apply the adjoint operator.  source_product
 The inner product
Operator
on the source space. IfNone
, the Euclidean product is chosen.  range_product
 The inner product
Operator
on the range space. IfNone
, the Euclidean product is chosen.
Returns
VectorArray
of the adjoint operator evaluations.

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.NumpyMatrixBasedOperator
Linear advection
Operator
for linear finite elements.The operator is of the form
(Lu)(x) = c ∇ ⋅ [ v(x) u(x) ]
The function
v
is vectorvalued. The current implementation works in one and two dimensions, but can be trivially extended to arbitrary dimensions.Parameters
 grid
 The
Grid
for which to assemble the operator.  boundary_info
BoundaryInfo
for the treatment of Dirichlet boundary conditions. advection_function
 The
Function
v(x)
withshape_range = (grid.dim_outer, )
. IfNone
, constant one is assumed.  advection_constant
 The constant
c
. IfNone
,c
is set to one.  dirichlet_clear_columns
 If
True
, set columns of the system matrix corresponding to Dirichlet boundary DOFs to zero to obtain a symmetric system matrix. Otherwise, only the rows will be set to zero.  dirichlet_clear_diag
 If
True
, also set diagonal entries corresponding to Dirichlet boundary DOFs to zero. Otherwise they are set to one.  name
 Name of the operator.
Methods
Attributes

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.NumpyMatrixBasedOperator
Linear advection
Operator
for bilinear finite elements.The operator is of the form
(Lu)(x) = c ∇ ⋅ [ v(x) u(x) ]
The function
v
has to be vectorvalued. The current implementation works in two dimensions, but can be trivially extended to arbitrary dimensions.Parameters
 grid
 The
Grid
for which to assemble the operator.  boundary_info
BoundaryInfo
for the treatment of Dirichlet boundary conditions. advection_function
 The
Function
v(x)
withshape_range = (grid.dim_outer, )
. IfNone
, constant one is assumed.  advection_constant
 The constant
c
. IfNone
,c
is set to one.  dirichlet_clear_columns
 If
True
, set columns of the system matrix corresponding to Dirichlet boundary DOFs to zero to obtain a symmetric system matrix. Otherwise, only the rows will be set to zero.  dirichlet_clear_diag
 If
True
, also set diagonal entries corresponding to Dirichlet boundary DOFs to zero. Otherwise they are set to one.  name
 Name of the operator.
Methods
Attributes

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.NumpyMatrixBasedOperator
Diffusion
Operator
for linear finite elements.The operator is of the form
(Lu)(x) = c ∇ ⋅ [ d(x) ∇ u(x) ]
The function
d
can be scalar or matrixvalued. The current implementation works in one and two dimensions, but can be trivially extended to arbitrary dimensions.Parameters
 grid
 The
Grid
for which to assemble the operator.  boundary_info
BoundaryInfo
for the treatment of Dirichlet boundary conditions. diffusion_function
 The
Function
d(x)
withshape_range == ()
orshape_range = (grid.dim_outer, grid.dim_outer)
. IfNone
, constant one is assumed.  diffusion_constant
 The constant
c
. IfNone
,c
is set to one.  dirichlet_clear_columns
 If
True
, set columns of the system matrix corresponding to Dirichlet boundary DOFs to zero to obtain a symmetric system matrix. Otherwise, only the rows will be set to zero.  dirichlet_clear_diag
 If
True
, also set diagonal entries corresponding to Dirichlet boundary DOFs to zero. Otherwise they are set to one.  name
 Name of the operator.
Methods
Attributes

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.NumpyMatrixBasedOperator
Diffusion
Operator
for bilinear finite elements.The operator is of the form
(Lu)(x) = c ∇ ⋅ [ d(x) ∇ u(x) ]
The function
d
can be scalar or matrixvalued. The current implementation works in two dimensions, but can be trivially extended to arbitrary dimensions.Parameters
 grid
 The
Grid
for which to assemble the operator.  boundary_info
BoundaryInfo
for the treatment of Dirichlet boundary conditions. diffusion_function
 The
Function
d(x)
withshape_range == ()
orshape_range = (grid.dim_outer, grid.dim_outer)
. IfNone
, constant one is assumed.  diffusion_constant
 The constant
c
. IfNone
,c
is set to one.  dirichlet_clear_columns
 If
True
, set columns of the system matrix corresponding to Dirichlet boundary DOFs to zero to obtain a symmetric system matrix. Otherwise, only the rows will be set to zero.  dirichlet_clear_diag
 If
True
, also set diagonal entries corresponding to Dirichlet boundary DOFs to zero. Otherwise they are set to one.  name
 Name of the operator.
Methods
Attributes

class
pymor.operators.cg.
InterpolationOperator
(grid, function)[source]¶ Bases:
pymor.operators.numpy.NumpyMatrixBasedOperator
Vectorlike Lagrange interpolation
Operator
for continuous finite element spaces.Methods
Attributes

class
pymor.operators.cg.
L2ProductFunctionalP1
(grid, function, boundary_info=None, dirichlet_data=None, neumann_data=None, robin_data=None, order=2, solver_options=None, name=None)[source]¶ Bases:
pymor.operators.numpy.NumpyMatrixBasedOperator
Linear finite element
Functional
representing the inner product with an L2Function
.Boundary treatment can be performed by providing
boundary_info
anddirichlet_data
, in which case the DOFs corresponding to Dirichlet boundaries are set to the values provided bydirichlet_data
. Neumann boundaries are handled by providing aneumann_data
function, Robin boundaries by providing arobin_data
tuple.The current implementation works in one and two dimensions, but can be trivially extended to arbitrary dimensions.
Parameters
 grid
Grid
for which to assemble the functional. function
 The
Function
with which to take the inner product.  boundary_info
BoundaryInfo
determining the Dirichlet and Neumann boundaries orNone
. IfNone
, no boundary treatment is performed. dirichlet_data
Function
providing the Dirichlet boundary values. IfNone
, constantzero boundary is assumed. neumann_data
Function
providing the Neumann boundary values. IfNone
, constantzero is assumed. robin_data
 Tuple of two
Functions
providing the Robin parameter and boundary values, seeRobinBoundaryOperator
. IfNone
, constantzero for both functions is assumed.  order
 Order of the Gauss quadrature to use for numerical integration.
 name
 The name of the functional.
Methods
Attributes

class
pymor.operators.cg.
L2ProductFunctionalQ1
(grid, function, boundary_info=None, dirichlet_data=None, neumann_data=None, robin_data=None, order=2, name=None)[source]¶ Bases:
pymor.operators.numpy.NumpyMatrixBasedOperator
Bilinear finite element
Functional
representing the inner product with an L2Function
.Boundary treatment can be performed by providing
boundary_info
anddirichlet_data
, in which case the DOFs corresponding to Dirichlet boundaries are set to the values provided bydirichlet_data
. Neumann boundaries are handled by providing aneumann_data
function, Robin boundaries by providing arobin_data
tuple.The current implementation works in two dimensions, but can be trivially extended to arbitrary dimensions.
Parameters
 grid
Grid
for which to assemble the functional. function
 The
Function
with which to take the inner product.  boundary_info
BoundaryInfo
determining the Dirichlet boundaries orNone
. IfNone
, no boundary treatment is performed. dirichlet_data
Function
providing the Dirichlet boundary values. IfNone
, constantzero boundary is assumed. neumann_data
Function
providing the Neumann boundary values. IfNone
, constantzero is assumed. robin_data
 Tuple of two
Functions
providing the Robin parameter and boundary values, seeRobinBoundaryOperator
. IfNone
, constantzero for both functions is assumed.  order
 Order of the Gauss quadrature to use for numerical integration.
 name
 The name of the functional.
Methods
Attributes

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.NumpyMatrixBasedOperator
Operator
representing the L2product between linear finite element functions.The current implementation works in one and two dimensions, but can be trivially extended to arbitrary dimensions.
Parameters
 grid
 The
Grid
for which to assemble the product.  boundary_info
BoundaryInfo
for the treatment of Dirichlet boundary conditions. dirichlet_clear_rows
 If
True
, set the rows of the system matrix corresponding to Dirichlet boundary DOFs to zero.  dirichlet_clear_columns
 If
True
, set columns of the system matrix corresponding to Dirichlet boundary DOFs to zero.  dirichlet_clear_diag
 If
True
, also set diagonal entries corresponding to Dirichlet boundary DOFs to zero. Otherwise, if eitherdirichlet_clear_rows
ordirichlet_clear_columns
isTrue
, the diagonal entries are set to one.  coefficient_function
 Coefficient
Function
for product withshape_range == ()
. IfNone
, constant one is assumed.  name
 The name of the product.
Methods
Attributes

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.NumpyMatrixBasedOperator
Operator
representing the L2product between bilinear finite element functions.The current implementation works in two dimensions, but can be trivially extended to arbitrary dimensions.
Parameters
 grid
 The
Grid
for which to assemble the product.  boundary_info
BoundaryInfo
for the treatment of Dirichlet boundary conditions. dirichlet_clear_rows
 If
True
, set the rows of the system matrix corresponding to Dirichlet boundary DOFs to zero.  dirichlet_clear_columns
 If
True
, set columns of the system matrix corresponding to Dirichlet boundary DOFs to zero.  dirichlet_clear_diag
 If
True
, also set diagonal entries corresponding to Dirichlet boundary DOFs to zero. Otherwise, if eitherdirichlet_clear_rows
ordirichlet_clear_columns
isTrue
, the diagonal entries are set to one.  coefficient_function
 Coefficient
Function
for product withshape_range == ()
. IfNone
, constant one is assumed.  name
 The name of the product.
Methods
Attributes

class
pymor.operators.cg.
RobinBoundaryOperator
(grid, boundary_info, robin_data=None, order=2, solver_options=None, name=None)[source]¶ Bases:
pymor.operators.numpy.NumpyMatrixBasedOperator
Robin boundary
Operator
for linear finite elements.The operator represents the contribution of Robin boundary conditions to the stiffness matrix, where the boundary condition is supposed to be given in the form
[ d(x) ∇u(x) ] ⋅ n(x) = c(x) (u(x)  g(x))
d
andn
are the diffusion function (seeDiffusionOperatorP1
) and the unit outer normal inx
, whilec
is the (scalar) Robin parameter function andg
is the (also scalar) Robin boundary value function.Parameters
 grid
 The
Grid
over which to assemble the operator.  boundary_info
BoundaryInfo
for the treatment of Dirichlet boundary conditions. robin_data
 Tuple providing two
Functions
that represent the Robin parameter and boundary value function. IfNone
, the resulting operator is zero.  name
 Name of the operator.
Methods
Attributes
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.OperatorBase
Represents the adjoint of a given linear
Operator
.See
apply_adjoint
.Parameters
 operator
 The
Operator
of which the adjoint is formed.  source_product
 If not
None
, inner productOperator
for the sourceVectorSpace
w.r.t. which to take the adjoint.  range_product
 If not
None
, inner productOperator
for the rangeVectorSpace
w.r.t. which to take the adjoint.  name
 If not
None
, name of the operator.  with_apply_inverse
 If
True
, provide ownapply_inverse
andapply_inverse_adjoint
implementations by calling these methods on the givenoperator
. (Is set toFalse
in the default implementation of andapply_inverse_adjoint
.)  solver_options
 When
with_apply_inverse
isFalse
, thesolver_options
to use for theapply_inverse
default implementation.
Methods
Attributes

apply
(U, ind=None, mu=None)[source]¶ Apply the operator to a
VectorArray
.Parameters
 U
VectorArray
of vectors to which the operator is applied. ind
 The indices of the vectors in
U
to which the operator shall be applied (see theVectorArray
documentation for further details).  mu
 The
Parameter
for which to evaluate the operator.
Returns
VectorArray
of the operator evaluations.

apply_adjoint
(U, ind=None, mu=None, source_product=None, range_product=None)[source]¶ Apply the adjoint operator.
For a linear operator
op
the adjointop^*
ofop
is given by:(op^*(v), u)_s = (v, op(u))_r,
where
( , )_s
and( , )_r
denote the inner products on the source and range space ofop
. Ifop
and the two products are given by the matricesM
,P_s
andP_r
, then:op^*(v) = P_s^(1) * M^T * P_r * v,
with
M^T
denoting the transposed ofM
. Thus, if( , )_s
and( , )_r
are the Euclidean inner products,op^*v
is simply given by multiplication of the matrix ofop
withv
from the left.Parameters
 U
VectorArray
of vectors to which the adjoint operator is applied. ind
 The indices of the vectors in
U
to which the operator shall be applied (see theVectorArray
documentation for further details).  mu
 The
Parameter
for which to apply the adjoint operator.  source_product
 The inner product
Operator
on the source space. IfNone
, the Euclidean product is chosen.  range_product
 The inner product
Operator
on the range space. IfNone
, the Euclidean product is chosen.
Returns
VectorArray
of the adjoint operator evaluations.

apply_inverse
(V, ind=None, mu=None, least_squares=False)[source]¶ Apply the inverse operator.
Parameters
 V
VectorArray
of vectors to which the inverse operator is applied. ind
 The indices of the vectors in
V
to which the inverse operator shall be applied (seeVectorArray
documentation for further details).  mu
 The
Parameter
for which to evaluate the inverse operator.  least_squares
If
True
, solve the least squares problem:u = argmin op(u)  v_2.
Since for an invertible operator the least squares solution agrees with the result of the application of the inverse operator, setting this option should, in general, have no effect on the result for those operators. However, note that when no appropriate
solver_options
are set for the operator, most implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArray
of the inverse operator evaluations.Raises
 InversionError
 The operator could not be inverted.

apply_inverse_adjoint
(U, ind=None, mu=None, source_product=None, range_product=None, least_squares=False)[source]¶ Apply the inverse adjoint operator.
Parameters
 U
VectorArray
of vectors to which the inverse adjoint operator is applied. ind
 The indices of the vectors in
U
to which the inverse adjoint operator shall be applied (see theVectorArray
documentation for further details).  mu
 The
Parameter
for which to evaluate the inverse adjoint operator.  source_product
 See
apply_adjoint
.  range_product
 See
apply_adjoint
.  least_squares
If
True
, solve the least squares problem:v = argmin op*(v)  u_2.
Since for an invertible operator the least squares solution agrees with the result of the application of the inverse operator, setting this option should, in general, have no effect on the result for those operators. However, note that when no appropriate
solver_options
are set for the operator, most operator implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArray
of the inverse adjoint operator evaluations.Raises
 InversionError
 The operator could not be inverted.

projected
(range_basis, source_basis, product=None, name=None)[source]¶ Project the operator to subspaces of the source and range space.
Given an inner product
( ⋅, ⋅)
, source vectorsb_1, ..., b_N
and range vectorsc_1, ..., c_M
, the projectionop_proj
ofop
is defined by[ op_proj(e_j) ]_i = ( c_i, op(b_j) )
for all i,j, where
e_j
denotes the jth canonical basis vector of R^N.In particular, if the
c_i
are orthonormal w.r.t. the given product, thenop_proj
is the coordinate representation w.r.t. theb_i/c_i
bases of the restriction ofop
tospan(b_i)
concatenated with the orthogonal projection ontospan(c_i)
.From another point of view, if
op
is viewed as a bilinear form (seeapply2
) and( ⋅, ⋅ )
is the Euclidean inner product, thenop_proj
represents the matrix of the bilinear form restrictedspan(b_i) / spanc(c_i)
(w.r.t. theb_i/c_i
bases).How the projected operator is realized will depend on the implementation of the operator to project. While a projected
NumpyMatrixOperator
will again be aNumpyMatrixOperator
, only a genericProjectedOperator
can be returned in general.A default implementation is provided in
OperatorBase
.Parameters
 range_basis
 The vectors
c_1, ..., c_M
as aVectorArray
. IfNone
, no projection in the range space is performed.  source_basis
 The vectors
b_1, ..., b_N
as aVectorArray
orNone
. IfNone
, no restriction of the source space is performed.  product
 An
Operator
representing the inner product. IfNone
, the Euclidean inner product is chosen.  name
 Name of the projected operator.
Returns
The projected
Operator
op_proj
.

class
pymor.operators.constructions.
ComponentProjection
(components, source, name=None)[source]¶ Bases:
pymor.operators.basic.OperatorBase
Operator
representing the projection of aVectorArray
on some of its components.Parameters
 components
 List or 1D
NumPy array
of the indices of the vectorcomponents
that ar to be extracted by the operator.  source
 Source
VectorSpace
of the operator.  name
 Name of the operator.
Methods
Attributes

apply
(U, ind=None, mu=None)[source]¶ Apply the operator to a
VectorArray
.Parameters
 U
VectorArray
of vectors to which the operator is applied. ind
 The indices of the vectors in
U
to which the operator shall be applied (see theVectorArray
documentation for further details).  mu
 The
Parameter
for which to evaluate the operator.
Returns
VectorArray
of the operator evaluations.

restricted
(dofs)[source]¶ Restrict the operator range to a given set of degrees of freedom.
This method returns a restricted version
restricted_op
of the operator along with an arraysource_dofs
such that for anyVectorArray
U
inself.source
the following is true:self.apply(U, mu).components(dofs) == restricted_op.apply(NumpyVectorArray(U.components(source_dofs)), mu))
Such an operator is mainly useful for
empirical interpolation
where the evaluation of the original operator only needs to be known for few selected degrees of freedom. If the operator has a small stencil, only fewsource_dofs
will be needed to evaluate the restricted operator which can make its evaluation very fast compared to evaluating the original operator.Parameters
 dofs
 Onedimensional
NumPy array
of degrees of freedom in the operatorrange
to which to restrict.
Returns
 restricted_op
 The restricted operator as defined above. The operator will have
NumpyVectorSpace
(len(source_dofs))
assource
andNumpyVectorSpace
(len(dofs))
asrange
.  source_dofs
 Onedimensional
NumPy array
of source degrees of freedom as defined above.

class
pymor.operators.constructions.
Concatenation
(second, first, solver_options=None, name=None)[source]¶ Bases:
pymor.operators.basic.OperatorBase
Operator
representing the concatenation of twoOperators
.Parameters
Methods
Attributes

apply
(U, ind=None, mu=None)[source]¶ Apply the operator to a
VectorArray
.Parameters
 U
VectorArray
of vectors to which the operator is applied. ind
 The indices of the vectors in
U
to which the operator shall be applied (see theVectorArray
documentation for further details).  mu
 The
Parameter
for which to evaluate the operator.
Returns
VectorArray
of the operator evaluations.

apply_adjoint
(U, ind=None, mu=None, source_product=None, range_product=None)[source]¶ Apply the adjoint operator.
For a linear operator
op
the adjointop^*
ofop
is given by:(op^*(v), u)_s = (v, op(u))_r,
where
( , )_s
and( , )_r
denote the inner products on the source and range space ofop
. Ifop
and the two products are given by the matricesM
,P_s
andP_r
, then:op^*(v) = P_s^(1) * M^T * P_r * v,
with
M^T
denoting the transposed ofM
. Thus, if( , )_s
and( , )_r
are the Euclidean inner products,op^*v
is simply given by multiplication of the matrix ofop
withv
from the left.Parameters
 U
VectorArray
of vectors to which the adjoint operator is applied. ind
 The indices of the vectors in
U
to which the operator shall be applied (see theVectorArray
documentation for further details).  mu
 The
Parameter
for which to apply the adjoint operator.  source_product
 The inner product
Operator
on the source space. IfNone
, the Euclidean product is chosen.  range_product
 The inner product
Operator
on the range space. IfNone
, the Euclidean product is chosen.
Returns
VectorArray
of the adjoint operator evaluations.

jacobian
(U, mu=None)[source]¶ Return the operator’s Jacobian as a new
Operator
.Parameters
 U
 Length 1
VectorArray
containing the vector for which to compute the Jacobian.  mu
 The
Parameter
for which to compute the Jacobian.
Returns
Linear
Operator
representing the Jacobian.

projected
(range_basis, source_basis, product=None, name=None)[source]¶ Project the operator to subspaces of the source and range space.
Given an inner product
( ⋅, ⋅)
, source vectorsb_1, ..., b_N
and range vectorsc_1, ..., c_M
, the projectionop_proj
ofop
is defined by[ op_proj(e_j) ]_i = ( c_i, op(b_j) )
for all i,j, where
e_j
denotes the jth canonical basis vector of R^N.In particular, if the
c_i
are orthonormal w.r.t. the given product, thenop_proj
is the coordinate representation w.r.t. theb_i/c_i
bases of the restriction ofop
tospan(b_i)
concatenated with the orthogonal projection ontospan(c_i)
.From another point of view, if
op
is viewed as a bilinear form (seeapply2
) and( ⋅, ⋅ )
is the Euclidean inner product, thenop_proj
represents the matrix of the bilinear form restrictedspan(b_i) / spanc(c_i)
(w.r.t. theb_i/c_i
bases).How the projected operator is realized will depend on the implementation of the operator to project. While a projected
NumpyMatrixOperator
will again be aNumpyMatrixOperator
, only a genericProjectedOperator
can be returned in general.A default implementation is provided in
OperatorBase
.Parameters
 range_basis
 The vectors
c_1, ..., c_M
as aVectorArray
. IfNone
, no projection in the range space is performed.  source_basis
 The vectors
b_1, ..., b_N
as aVectorArray
orNone
. IfNone
, no restriction of the source space is performed.  product
 An
Operator
representing the inner product. IfNone
, the Euclidean inner product is chosen.  name
 Name of the projected operator.
Returns
The projected
Operator
op_proj
.

restricted
(dofs)[source]¶ Restrict the operator range to a given set of degrees of freedom.
This method returns a restricted version
restricted_op
of the operator along with an arraysource_dofs
such that for anyVectorArray
U
inself.source
the following is true:self.apply(U, mu).components(dofs) == restricted_op.apply(NumpyVectorArray(U.components(source_dofs)), mu))
Such an operator is mainly useful for
empirical interpolation
where the evaluation of the original operator only needs to be known for few selected degrees of freedom. If the operator has a small stencil, only fewsource_dofs
will be needed to evaluate the restricted operator which can make its evaluation very fast compared to evaluating the original operator.Parameters
 dofs
 Onedimensional
NumPy array
of degrees of freedom in the operatorrange
to which to restrict.
Returns
 restricted_op
 The restricted operator as defined above. The operator will have
NumpyVectorSpace
(len(source_dofs))
assource
andNumpyVectorSpace
(len(dofs))
asrange
.  source_dofs
 Onedimensional
NumPy array
of source degrees of freedom as defined above.


class
pymor.operators.constructions.
ConstantOperator
(value, source, name=None)[source]¶ Bases:
pymor.operators.basic.OperatorBase
A constant
Operator
always returning the same vector.Parameters
 value
 A
VectorArray
of length 1 containing the vector which is returned by the operator.  source
 Source
VectorSpace
of the operator.  name
 Name of the operator.
Methods
Attributes

apply
(U, ind=None, mu=None)[source]¶ Apply the operator to a
VectorArray
.Parameters
 U
VectorArray
of vectors to which the operator is applied. ind
 The indices of the vectors in
U
to which the operator shall be applied (see theVectorArray
documentation for further details).  mu
 The
Parameter
for which to evaluate the operator.
Returns
VectorArray
of the operator evaluations.

jacobian
(U, mu=None)[source]¶ Return the operator’s Jacobian as a new
Operator
.Parameters
 U
 Length 1
VectorArray
containing the vector for which to compute the Jacobian.  mu
 The
Parameter
for which to compute the Jacobian.
Returns
Linear
Operator
representing the Jacobian.

projected
(range_basis, source_basis, product=None, name=None)[source]¶ Project the operator to subspaces of the source and range space.
Given an inner product
( ⋅, ⋅)
, source vectorsb_1, ..., b_N
and range vectorsc_1, ..., c_M
, the projectionop_proj
ofop
is defined by[ op_proj(e_j) ]_i = ( c_i, op(b_j) )
for all i,j, where
e_j
denotes the jth canonical basis vector of R^N.In particular, if the
c_i
are orthonormal w.r.t. the given product, thenop_proj
is the coordinate representation w.r.t. theb_i/c_i
bases of the restriction ofop
tospan(b_i)
concatenated with the orthogonal projection ontospan(c_i)
.From another point of view, if
op
is viewed as a bilinear form (seeapply2
) and( ⋅, ⋅ )
is the Euclidean inner product, thenop_proj
represents the matrix of the bilinear form restrictedspan(b_i) / spanc(c_i)
(w.r.t. theb_i/c_i
bases).How the projected operator is realized will depend on the implementation of the operator to project. While a projected
NumpyMatrixOperator
will again be aNumpyMatrixOperator
, only a genericProjectedOperator
can be returned in general.A default implementation is provided in
OperatorBase
.Parameters
 range_basis
 The vectors
c_1, ..., c_M
as aVectorArray
. IfNone
, no projection in the range space is performed.  source_basis
 The vectors
b_1, ..., b_N
as aVectorArray
orNone
. IfNone
, no restriction of the source space is performed.  product
 An
Operator
representing the inner product. IfNone
, the Euclidean inner product is chosen.  name
 Name of the projected operator.
Returns
The projected
Operator
op_proj
.

restricted
(dofs)[source]¶ Restrict the operator range to a given set of degrees of freedom.
This method returns a restricted version
restricted_op
of the operator along with an arraysource_dofs
such that for anyVectorArray
U
inself.source
the following is true:self.apply(U, mu).components(dofs) == restricted_op.apply(NumpyVectorArray(U.components(source_dofs)), mu))
Such an operator is mainly useful for
empirical interpolation
where the evaluation of the original operator only needs to be known for few selected degrees of freedom. If the operator has a small stencil, only fewsource_dofs
will be needed to evaluate the restricted operator which can make its evaluation very fast compared to evaluating the original operator.Parameters
 dofs
 Onedimensional
NumPy array
of degrees of freedom in the operatorrange
to which to restrict.
Returns
 restricted_op
 The restricted operator as defined above. The operator will have
NumpyVectorSpace
(len(source_dofs))
assource
andNumpyVectorSpace
(len(dofs))
asrange
.  source_dofs
 Onedimensional
NumPy array
of source degrees of freedom as defined above.

class
pymor.operators.constructions.
FixedParameterOperator
(operator, mu=None, name=None)[source]¶ Bases:
pymor.operators.basic.OperatorBase
Makes an
Operator
Parameter
independent by setting a fixedParameter
.Parameters
Methods
Attributes

apply
(U, ind=None, mu=None)[source]¶ Apply the operator to a
VectorArray
.Parameters
 U
VectorArray
of vectors to which the operator is applied. ind
 The indices of the vectors in
U
to which the operator shall be applied (see theVectorArray
documentation for further details).  mu
 The
Parameter
for which to evaluate the operator.
Returns
VectorArray
of the operator evaluations.

apply_adjoint
(U, ind=None, mu=None, source_product=None, range_product=None)[source]¶ Apply the adjoint operator.
For a linear operator
op
the adjointop^*
ofop
is given by:(op^*(v), u)_s = (v, op(u))_r,
where
( , )_s
and( , )_r
denote the inner products on the source and range space ofop
. Ifop
and the two products are given by the matricesM
,P_s
andP_r
, then:op^*(v) = P_s^(1) * M^T * P_r * v,
with
M^T
denoting the transposed ofM
. Thus, if( , )_s
and( , )_r
are the Euclidean inner products,op^*v
is simply given by multiplication of the matrix ofop
withv
from the left.Parameters
 U
VectorArray
of vectors to which the adjoint operator is applied. ind
 The indices of the vectors in
U
to which the operator shall be applied (see theVectorArray
documentation for further details).  mu
 The
Parameter
for which to apply the adjoint operator.  source_product
 The inner product
Operator
on the source space. IfNone
, the Euclidean product is chosen.  range_product
 The inner product
Operator
on the range space. IfNone
, the Euclidean product is chosen.
Returns
VectorArray
of the adjoint operator evaluations.

apply_inverse
(V, ind=None, mu=None, least_squares=False)[source]¶ Apply the inverse operator.
Parameters
 V
VectorArray
of vectors to which the inverse operator is applied. ind
 The indices of the vectors in
V
to which the inverse operator shall be applied (seeVectorArray
documentation for further details).  mu
 The
Parameter
for which to evaluate the inverse operator.  least_squares
If
True
, solve the least squares problem:u = argmin op(u)  v_2.
Since for an invertible operator the least squares solution agrees with the result of the application of the inverse operator, setting this option should, in general, have no effect on the result for those operators. However, note that when no appropriate
solver_options
are set for the operator, most implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArray
of the inverse operator evaluations.Raises
 InversionError
 The operator could not be inverted.

apply_inverse_adjoint
(U, ind=None, mu=None, source_product=None, range_product=None, least_squares=False)[source]¶ Apply the inverse adjoint operator.
Parameters
 U
VectorArray
of vectors to which the inverse adjoint operator is applied. ind
 The indices of the vectors in
U
to which the inverse adjoint operator shall be applied (see theVectorArray
documentation for further details).  mu
 The
Parameter
for which to evaluate the inverse adjoint operator.  source_product
 See
apply_adjoint
.  range_product
 See
apply_adjoint
.  least_squares
If
True
, solve the least squares problem:v = argmin op*(v)  u_2.
Since for an invertible operator the least squares solution agrees with the result of the application of the inverse operator, setting this option should, in general, have no effect on the result for those operators. However, note that when no appropriate
solver_options
are set for the operator, most operator implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArray
of the inverse adjoint operator evaluations.Raises
 InversionError
 The operator could not be inverted.

jacobian
(U, mu=None)[source]¶ Return the operator’s Jacobian as a new
Operator
.Parameters
 U
 Length 1
VectorArray
containing the vector for which to compute the Jacobian.  mu
 The
Parameter
for which to compute the Jacobian.
Returns
Linear
Operator
representing the Jacobian.

restricted
(dofs)[source]¶ Restrict the operator range to a given set of degrees of freedom.
This method returns a restricted version
restricted_op
of the operator along with an arraysource_dofs
such that for anyVectorArray
U
inself.source
the following is true:self.apply(U, mu).components(dofs) == restricted_op.apply(NumpyVectorArray(U.components(source_dofs)), mu))
Such an operator is mainly useful for
empirical interpolation
where the evaluation of the original operator only needs to be known for few selected degrees of freedom. If the operator has a small stencil, only fewsource_dofs
will be needed to evaluate the restricted operator which can make its evaluation very fast compared to evaluating the original operator.Parameters
 dofs
 Onedimensional
NumPy array
of degrees of freedom in the operatorrange
to which to restrict.
Returns
 restricted_op
 The restricted operator as defined above. The operator will have
NumpyVectorSpace
(len(source_dofs))
assource
andNumpyVectorSpace
(len(dofs))
asrange
.  source_dofs
 Onedimensional
NumPy array
of source degrees of freedom as defined above.


class
pymor.operators.constructions.
IdentityOperator
(space, name=None)[source]¶ Bases:
pymor.operators.basic.OperatorBase
The identity
Operator
.In other words:
op.apply(U) == U
Parameters
 space
 The
VectorSpace
the operator acts on.  name
 Name of the operator.
Methods
Attributes

apply
(U, ind=None, mu=None)[source]¶ Apply the operator to a
VectorArray
.Parameters
 U
VectorArray
of vectors to which the operator is applied. ind
 The indices of the vectors in
U
to which the operator shall be applied (see theVectorArray
documentation for further details).  mu
 The
Parameter
for which to evaluate the operator.
Returns
VectorArray
of the operator evaluations.

apply_adjoint
(U, ind=None, mu=None, source_product=None, range_product=None)[source]¶ Apply the adjoint operator.
For a linear operator
op
the adjointop^*
ofop
is given by:(op^*(v), u)_s = (v, op(u))_r,
where
( , )_s
and( , )_r
denote the inner products on the source and range space ofop
. Ifop
and the two products are given by the matricesM
,P_s
andP_r
, then:op^*(v) = P_s^(1) * M^T * P_r * v,
with
M^T
denoting the transposed ofM
. Thus, if( , )_s
and( , )_r
are the Euclidean inner products,op^*v
is simply given by multiplication of the matrix ofop
withv
from the left.Parameters
 U
VectorArray
of vectors to which the adjoint operator is applied. ind
 The indices of the vectors in
U
to which the operator shall be applied (see theVectorArray
documentation for further details).  mu
 The
Parameter
for which to apply the adjoint operator.  source_product
 The inner product
Operator
on the source space. IfNone
, the Euclidean product is chosen.  range_product
 The inner product
Operator
on the range space. IfNone
, the Euclidean product is chosen.
Returns
VectorArray
of the adjoint operator evaluations.

apply_inverse
(V, ind=None, mu=None, least_squares=False)[source]¶ Apply the inverse operator.
Parameters
 V
VectorArray
of vectors to which the inverse operator is applied. ind
 The indices of the vectors in
V
to which the inverse operator shall be applied (seeVectorArray
documentation for further details).  mu
 The
Parameter
for which to evaluate the inverse operator.  least_squares
If
True
, solve the least squares problem:u = argmin op(u)  v_2.
Since for an invertible operator the least squares solution agrees with the result of the application of the inverse operator, setting this option should, in general, have no effect on the result for those operators. However, note that when no appropriate
solver_options
are set for the operator, most implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArray
of the inverse operator evaluations.Raises
 InversionError
 The operator could not be inverted.

apply_inverse_adjoint
(U, ind=None, mu=None, source_product=None, range_product=None, least_squares=False)[source]¶ Apply the inverse adjoint operator.
Parameters
 U
VectorArray
of vectors to which the inverse adjoint operator is applied. ind
 The indices of the vectors in
U
to which the inverse adjoint operator shall be applied (see theVectorArray
documentation for further details).  mu
 The
Parameter
for which to evaluate the inverse adjoint operator.  source_product
 See
apply_adjoint
.  range_product
 See
apply_adjoint
.  least_squares
If
True
, solve the least squares problem:v = argmin op*(v)  u_2.
Since for an invertible operator the least squares solution agrees with the result of the application of the inverse operator, setting this option should, in general, have no effect on the result for those operators. However, note that when no appropriate
solver_options
are set for the operator, most operator implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArray
of the inverse adjoint operator evaluations.Raises
 InversionError
 The operator could not be inverted.

assemble
(mu=None)[source]¶ Assemble the operator for a given parameter.
The result of the method strongly depends on the given operator. For instance, a matrixbased operator will assemble its matrix, a
LincombOperator
will 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
Parameter
for which to assemble the operator.
Returns
Parameterindependent, assembled
Operator
.

assemble_lincomb
(operators, coefficients, solver_options=None, name=None)[source]¶ Try to assemble a linear combination of the given operators.
This method is called in the
assemble
method ofLincombOperator
on the first of its operator. If an assembly of the given linear combination is possible, e.g. the linear combination of the system matrices of the operators can be formed, then the assembled operator is returned. Otherwise, the method returnsNone
to indicate that assembly is not possible.Parameters
 operators
 List of
Operators
whose linear combination is formed.  coefficients
 List of the corresponding linear coefficients.
 solver_options
solver_options
for the assembled operator. name
 Name of the assembled operator.
Returns
The assembled
Operator
if assembly is possible, otherwiseNone
.

restricted
(dofs)[source]¶ Restrict the operator range to a given set of degrees of freedom.
This method returns a restricted version
restricted_op
of the operator along with an arraysource_dofs
such that for anyVectorArray
U
inself.source
the following is true:self.apply(U, mu).components(dofs) == restricted_op.apply(NumpyVectorArray(U.components(source_dofs)), mu))
Such an operator is mainly useful for
empirical interpolation
where the evaluation of the original operator only needs to be known for few selected degrees of freedom. If the operator has a small stencil, only fewsource_dofs
will be needed to evaluate the restricted operator which can make its evaluation very fast compared to evaluating the original operator.Parameters
 dofs
 Onedimensional
NumPy array
of degrees of freedom in the operatorrange
to which to restrict.
Returns
 restricted_op
 The restricted operator as defined above. The operator will have
NumpyVectorSpace
(len(source_dofs))
assource
andNumpyVectorSpace
(len(dofs))
asrange
.  source_dofs
 Onedimensional
NumPy array
of 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.Parametric
Instantiated by
induced_norm
. Do not use directly.Methods

class
pymor.operators.constructions.
LincombOperator
(operators, coefficients, solver_options=None, name=None)[source]¶ Bases:
pymor.operators.basic.OperatorBase
Linear combination of arbitrary
Operators
.This
Operator
represents a (possiblyParameter
dependent) linear combination of a given list ofOperators
.Parameters
 operators
 List of
Operators
whose linear combination is formed.  coefficients
 A list of linear coefficients. A linear coefficient can
either be a fixed number or a
ParameterFunctional
.  name
 Name of the operator.
Methods
Attributes

apply
(U, ind=None, mu=None)[source]¶ Apply the operator to a
VectorArray
.Parameters
 U
VectorArray
of vectors to which the operator is applied. ind
 The indices of the vectors in
U
to which the operator shall be applied (see theVectorArray
documentation for further details).  mu
 The
Parameter
for which to evaluate the operator.
Returns
VectorArray
of the operator evaluations.

apply2
(V, U, U_ind=None, V_ind=None, mu=None, product=None)[source]¶ Treat the operator as a 2form by calculating (V, op(U)).
In general
op.apply2(V, U)
is equivalent to:product.apply2(V, op.apply(U)).
In case no
product
has been specified,op.apply2(V, U)
is equivialent to:V.dot(op.apply(U)).
In the latter case, assuming that
op
is a linear operator given by multiplication with a matrix M, then:op.apply2(V, U) = V^T*M*U.
Parameters
 V
VectorArray
of the left arguments V. U
VectorArray
of the right right arguments U. V_ind
 The indices of the vectors in
V
to which the operator shall be applied (seeVectorArray
documentation for further details).  U_ind
 The indices of the vectors in
U
to which the operator shall be applied (seeVectorArray
documentation for further details).  mu
 The
Parameter
for which to evaluate the operator.  product
 The inner product used in the expression
(V, op(U))
given as anOperator
. IfNone
, the euclidean product is chosen.
Returns
A
NumPy array
with shape(len(V_ind), len(U_ind))
containing the 2form evaluations.

apply_adjoint
(U, ind=None, mu=None, source_product=None, range_product=None)[source]¶ Apply the adjoint operator.
For a linear operator
op
the adjointop^*
ofop
is given by:(op^*(v), u)_s = (v, op(u))_r,
where
( , )_s
and( , )_r
denote the inner products on the source and range space ofop
. Ifop
and the two products are given by the matricesM
,P_s
andP_r
, then:op^*(v) = P_s^(1) * M^T * P_r * v,
with
M^T
denoting the transposed ofM
. Thus, if( , )_s
and( , )_r
are the Euclidean inner products,op^*v
is simply given by multiplication of the matrix ofop
withv
from the left.Parameters
 U
VectorArray
of vectors to which the adjoint operator is applied. ind
 The indices of the vectors in
U
to which the operator shall be applied (see theVectorArray
documentation for further details).  mu
 The
Parameter
for which to apply the adjoint operator.  source_product
 The inner product
Operator
on the source space. IfNone
, the Euclidean product is chosen.  range_product
 The inner product
Operator
on the range space. IfNone
, the Euclidean product is chosen.
Returns
VectorArray
of the adjoint operator evaluations.

as_vector
(mu=None)[source]¶ Return a vector representation of a linear functional or vector operator.
This method may only be called on linear functionals, i.e. linear
Operators
withNumpyVectorSpace
(1)
asrange
, or on operators describing vectors, i.e. linearOperators
withNumpyVectorSpace
(1)
assource
.In the case of a functional, the identity
self.as_vector(mu).dot(U) == self.apply(U, mu)
holds, whereas in the case of a vectorlike operator we have
self.as_vector(mu) == self.apply(NumpyVectorArray(1), mu).
Parameters
 mu
 The
Parameter
for which to return the vector representation.
Returns
 V
VectorArray
of length 1 containing the vector representation.V
belongs toself.source
for functionals and toself.range
for vectorlike operators.

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 matrixbased operator will assemble its matrix, a
LincombOperator
will 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
Parameter
for which to assemble the operator.
Returns
Parameterindependent, assembled
Operator
.

evaluate_coefficients
(mu)[source]¶ Compute the linear coefficients for a given
Parameter
.Parameters
 mu
Parameter
for which to compute the linear coefficients.
Returns
List of linear coefficients.

jacobian
(U, mu=None)[source]¶ Return the operator’s Jacobian as a new
Operator
.Parameters
 U
 Length 1
VectorArray
containing the vector for which to compute the Jacobian.  mu
 The
Parameter
for which to compute the Jacobian.
Returns
Linear
Operator
representing the Jacobian.

pairwise_apply2
(V, U, U_ind=None, V_ind=None, mu=None, product=None)[source]¶ Treat the operator as a 2form by calculating (V, op(U)).
Same as
OperatorInterface.apply2
, except that vectors fromV
andU
are applied in pairs.Parameters
 V
VectorArray
of the left arguments V. U
VectorArray
of the right right arguments U. V_ind
 The indices of the vectors in
V
to which the operator shall be applied (seeVectorArray
documentation for further details).  U_ind
 The indices of the vectors in
U
to which the operator shall be applied (seeVectorArray
documentation for further details).  mu
 The
Parameter
for which to evaluate the operator.  product
 The inner product used in the expression
(V, op(U))
given as anOperator
. IfNone
, the euclidean product is chosen.
Returns
A
NumPy array
with shape(len(V_ind),) == (len(U_ind),)
containing the 2form evaluations.

projected
(range_basis, source_basis, product=None, name=None)[source]¶ Project the operator to subspaces of the source and range space.
Given an inner product
( ⋅, ⋅)
, source vectorsb_1, ..., b_N
and range vectorsc_1, ..., c_M
, the projectionop_proj
ofop
is defined by[ op_proj(e_j) ]_i = ( c_i, op(b_j) )
for all i,j, where
e_j
denotes the jth canonical basis vector of R^N.In particular, if the
c_i
are orthonormal w.r.t. the given product, thenop_proj
is the coordinate representation w.r.t. theb_i/c_i
bases of the restriction ofop
tospan(b_i)
concatenated with the orthogonal projection ontospan(c_i)
.From another point of view, if
op
is viewed as a bilinear form (seeapply2
) and( ⋅, ⋅ )
is the Euclidean inner product, thenop_proj
represents the matrix of the bilinear form restrictedspan(b_i) / spanc(c_i)
(w.r.t. theb_i/c_i
bases).How the projected operator is realized will depend on the implementation of the operator to project. While a projected
NumpyMatrixOperator
will again be aNumpyMatrixOperator
, only a genericProjectedOperator
can be returned in general.A default implementation is provided in
OperatorBase
.Parameters
 range_basis
 The vectors
c_1, ..., c_M
as aVectorArray
. IfNone
, no projection in the range space is performed.  source_basis
 The vectors
b_1, ..., b_N
as aVectorArray
orNone
. IfNone
, no restriction of the source space is performed.  product
 An
Operator
representing the inner product. IfNone
, the Euclidean inner product is chosen.  name
 Name of the projected operator.
Returns
The projected
Operator
op_proj
.

projected_to_subbasis
(dim_range=None, dim_source=None, name=None)[source]¶ See
pymor.operators.numpy.NumpyMatrixOperator.projected_to_subbasis
.

class
pymor.operators.constructions.
SelectionOperator
(operators, parameter_functional, boundaries, name=None)[source]¶ Bases:
pymor.operators.basic.OperatorBase
An
Operator
selected from a list ofOperators
.operators[i]
is used ifparameter_functional(mu)
is less or equal thanboundaries[i]
and greater thanboundaries[i1]
:infty  boundaries[i]  boundaries[i+1]  infty    operators[i]  operators[i+1]  operators[i+2]  
Parameters
 operators
 List of
Operators
from which oneOperator
is selected based on the givenParameter
.  parameter_functional
 The
ParameterFunctional
used for the selection of oneOperator
.  boundaries
 The interval boundaries as defined above.
 name
 Name of the operator.
Methods
Attributes

apply
(U, ind=None, mu=None)[source]¶ Apply the operator to a
VectorArray
.Parameters
 U
VectorArray
of vectors to which the operator is applied. ind
 The indices of the vectors in
U
to which the operator shall be applied (see theVectorArray
documentation for further details).  mu
 The
Parameter
for which to evaluate the operator.
Returns
VectorArray
of the operator evaluations.

apply_adjoint
(U, ind=None, mu=None, source_product=None, range_product=None)[source]¶ Apply the adjoint operator.
For a linear operator
op
the adjointop^*
ofop
is given by:(op^*(v), u)_s = (v, op(u))_r,
where
( , )_s
and( , )_r
denote the inner products on the source and range space ofop
. Ifop
and the two products are given by the matricesM
,P_s
andP_r
, then:op^*(v) = P_s^(1) * M^T * P_r * v,
with
M^T
denoting the transposed ofM
. Thus, if( , )_s
and( , )_r
are the Euclidean inner products,op^*v
is simply given by multiplication of the matrix ofop
withv
from the left.Parameters
 U
VectorArray
of vectors to which the adjoint operator is applied. ind
 The indices of the vectors in
U
to which the operator shall be applied (see theVectorArray
documentation for further details).  mu
 The
Parameter
for which to apply the adjoint operator.  source_product
 The inner product
Operator
on the source space. IfNone
, the Euclidean product is chosen.  range_product
 The inner product
Operator
on the range space. IfNone
, the Euclidean product is chosen.
Returns
VectorArray
of the adjoint operator evaluations.

as_vector
(mu=None)[source]¶ Return a vector representation of a linear functional or vector operator.
This method may only be called on linear functionals, i.e. linear
Operators
withNumpyVectorSpace
(1)
asrange
, or on operators describing vectors, i.e. linearOperators
withNumpyVectorSpace
(1)
assource
.In the case of a functional, the identity
self.as_vector(mu).dot(U) == self.apply(U, mu)
holds, whereas in the case of a vectorlike operator we have
self.as_vector(mu) == self.apply(NumpyVectorArray(1), mu).
Parameters
 mu
 The
Parameter
for which to return the vector representation.
Returns
 V
VectorArray
of length 1 containing the vector representation.V
belongs toself.source
for functionals and toself.range
for vectorlike operators.

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 matrixbased operator will assemble its matrix, a
LincombOperator
will 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
Parameter
for which to assemble the operator.
Returns
Parameterindependent, assembled
Operator
.

projected
(range_basis, source_basis, product=None, name=None)[source]¶ Project the operator to subspaces of the source and range space.
Given an inner product
( ⋅, ⋅)
, source vectorsb_1, ..., b_N
and range vectorsc_1, ..., c_M
, the projectionop_proj
ofop
is defined by[ op_proj(e_j) ]_i = ( c_i, op(b_j) )
for all i,j, where
e_j
denotes the jth canonical basis vector of R^N.In particular, if the
c_i
are orthonormal w.r.t. the given product, thenop_proj
is the coordinate representation w.r.t. theb_i/c_i
bases of the restriction ofop
tospan(b_i)
concatenated with the orthogonal projection ontospan(c_i)
.From another point of view, if
op
is viewed as a bilinear form (seeapply2
) and( ⋅, ⋅ )
is the Euclidean inner product, thenop_proj
represents the matrix of the bilinear form restrictedspan(b_i) / spanc(c_i)
(w.r.t. theb_i/c_i
bases).How the projected operator is realized will depend on the implementation of the operator to project. While a projected
NumpyMatrixOperator
will again be aNumpyMatrixOperator
, only a genericProjectedOperator
can be returned in general.A default implementation is provided in
OperatorBase
.Parameters
 range_basis
 The vectors
c_1, ..., c_M
as aVectorArray
. IfNone
, no projection in the range space is performed.  source_basis
 The vectors
b_1, ..., b_N
as aVectorArray
orNone
. IfNone
, no restriction of the source space is performed.  product
 An
Operator
representing the inner product. IfNone
, the Euclidean inner product is chosen.  name
 Name of the projected operator.
Returns
The projected
Operator
op_proj
.

class
pymor.operators.constructions.
VectorArrayOperator
(array, transposed=False, name=None)[source]¶ Bases:
pymor.operators.basic.OperatorBase
Wraps a
VectorArray
as anOperator
.If
transposed
isFalse
, the operator maps fromNumpyVectorSpace(len(array))
toarray.space
by forming linear combinations of the vectors in the array with given coefficient arrays.If
transposed == True
, the operator maps fromarray.space
toNumpyVectorSpace(len(array))
by forming the inner products of the argument with the vectors in the given array.Parameters
 array
 The
VectorArray
which is to be treated as an operator.  transposed
 See description above.
 name
 The name of the operator.
Methods
Attributes

apply
(U, ind=None, mu=None)[source]¶ Apply the operator to a
VectorArray
.Parameters
 U
VectorArray
of vectors to which the operator is applied. ind
 The indices of the vectors in
U
to which the operator shall be applied (see theVectorArray
documentation for further details).  mu
 The
Parameter
for which to evaluate the operator.
Returns
VectorArray
of the operator evaluations.

apply_adjoint
(U, ind=None, mu=None, source_product=None, range_product=None)[source]¶ Apply the adjoint operator.
For a linear operator
op
the adjointop^*
ofop
is given by:(op^*(v), u)_s = (v, op(u))_r,
where
( , )_s
and( , )_r
denote the inner products on the source and range space ofop
. Ifop
and the two products are given by the matricesM
,P_s
andP_r
, then:op^*(v) = P_s^(1) * M^T * P_r * v,
with
M^T
denoting the transposed ofM
. Thus, if( , )_s
and( , )_r
are the Euclidean inner products,op^*v
is simply given by multiplication of the matrix ofop
withv
from the left.Parameters
 U
VectorArray
of vectors to which the adjoint operator is applied. ind
 The indices of the vectors in
U
to which the operator shall be applied (see theVectorArray
documentation for further details).  mu
 The
Parameter
for which to apply the adjoint operator.  source_product
 The inner product
Operator
on the source space. IfNone
, the Euclidean product is chosen.  range_product
 The inner product
Operator
on the range space. IfNone
, the Euclidean product is chosen.
Returns
VectorArray
of the adjoint operator evaluations.

apply_inverse_adjoint
(U, ind=None, mu=None, source_product=None, range_product=None, least_squares=False)[source]¶ Apply the inverse adjoint operator.
Parameters
 U
VectorArray
of vectors to which the inverse adjoint operator is applied. ind
 The indices of the vectors in
U
to which the inverse adjoint operator shall be applied (see theVectorArray
documentation for further details).  mu
 The
Parameter
for which to evaluate the inverse adjoint operator.  source_product
 See
apply_adjoint
.  range_product
 See
apply_adjoint
.  least_squares
If
True
, solve the least squares problem:v = argmin op*(v)  u_2.
Since for an invertible operator the least squares solution agrees with the result of the application of the inverse operator, setting this option should, in general, have no effect on the result for those operators. However, note that when no appropriate
solver_options
are set for the operator, most operator implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArray
of the inverse adjoint operator evaluations.Raises
 InversionError
 The operator could not be inverted.

as_vector
(mu=None)[source]¶ Return a vector representation of a linear functional or vector operator.
This method may only be called on linear functionals, i.e. linear
Operators
withNumpyVectorSpace
(1)
asrange
, or on operators describing vectors, i.e. linearOperators
withNumpyVectorSpace
(1)
assource
.In the case of a functional, the identity
self.as_vector(mu).dot(U) == self.apply(U, mu)
holds, whereas in the case of a vectorlike operator we have
self.as_vector(mu) == self.apply(NumpyVectorArray(1), mu).
Parameters
 mu
 The
Parameter
for which to return the vector representation.
Returns
 V
VectorArray
of length 1 containing the vector representation.V
belongs toself.source
for functionals and toself.range
for vectorlike operators.

assemble_lincomb
(operators, coefficients, solver_options=None, name=None)[source]¶ Try to assemble a linear combination of the given operators.
This method is called in the
assemble
method ofLincombOperator
on the first of its operator. If an assembly of the given linear combination is possible, e.g. the linear combination of the system matrices of the operators can be formed, then the assembled operator is returned. Otherwise, the method returnsNone
to indicate that assembly is not possible.Parameters
 operators
 List of
Operators
whose linear combination is formed.  coefficients
 List of the corresponding linear coefficients.
 solver_options
solver_options
for the assembled operator. name
 Name of the assembled operator.
Returns
The assembled
Operator
if assembly is possible, otherwiseNone
.

restricted
(dofs)[source]¶ Restrict the operator range to a given set of degrees of freedom.
This method returns a restricted version
restricted_op
of the operator along with an arraysource_dofs
such that for anyVectorArray
U
inself.source
the following is true:self.apply(U, mu).components(dofs) == restricted_op.apply(NumpyVectorArray(U.components(source_dofs)), mu))
Such an operator is mainly useful for
empirical interpolation
where the evaluation of the original operator only needs to be known for few selected degrees of freedom. If the operator has a small stencil, only fewsource_dofs
will be needed to evaluate the restricted operator which can make its evaluation very fast compared to evaluating the original operator.Parameters
 dofs
 Onedimensional
NumPy array
of degrees of freedom in the operatorrange
to which to restrict.
Returns
 restricted_op
 The restricted operator as defined above. The operator will have
NumpyVectorSpace
(len(source_dofs))
assource
andNumpyVectorSpace
(len(dofs))
asrange
.  source_dofs
 Onedimensional
NumPy array
of source degrees of freedom as defined above.

class
pymor.operators.constructions.
VectorFunctional
(vector, product=None, name=None)[source]¶ Bases:
pymor.operators.constructions.VectorArrayOperator
Wrap a vector as a linear
Functional
.Given a vector
v
of dimensiond
, this class represents the functionalf: R^d > R^1 u > (u, v)
where
( , )
denotes the inner product given byproduct
.In particular, if
product
isNone
VectorFunctional(vector).as_vector() == vector.
If
product
is not none, we obtainVectorFunctional(vector).as_vector() == product.apply(vector).
Parameters
 vector
VectorArray
of length 1 containing the vectorv
. product
Operator
representing the scalar product to use. name
 Name of the operator.
Methods

class
pymor.operators.constructions.
VectorOperator
(vector, name=None)[source]¶ Bases:
pymor.operators.constructions.VectorArrayOperator
Wrap a vector as a vectorlike
Operator
.Given a vector
v
of dimensiond
, this class represents the operatorop: R^1 > R^d x > x⋅v
In particular:
VectorOperator(vector).as_vector() == vector
Parameters
 vector
VectorArray
of length 1 containing the vectorv
. name
 Name of the operator.
Methods

class
pymor.operators.constructions.
ZeroOperator
(source, range, name=None)[source]¶ Bases:
pymor.operators.basic.OperatorBase
The
Operator
which maps every vector to zero.Parameters
 source
 Source
VectorSpace
of the operator.  range
 Range
VectorSpace
of the operator.  name
 Name of the operator.
Methods
Attributes

apply
(U, ind=None, mu=None)[source]¶ Apply the operator to a
VectorArray
.Parameters
 U
VectorArray
of vectors to which the operator is applied. ind
 The indices of the vectors in
U
to which the operator shall be applied (see theVectorArray
documentation for further details).  mu
 The
Parameter
for which to evaluate the operator.
Returns
VectorArray
of the operator evaluations.

apply_inverse
(V, ind=None, mu=None, least_squares=False)[source]¶ Apply the inverse operator.
Parameters
 V
VectorArray
of vectors to which the inverse operator is applied. ind
 The indices of the vectors in
V
to which the inverse operator shall be applied (seeVectorArray
documentation for further details).  mu
 The
Parameter
for which to evaluate the inverse operator.  least_squares
If
True
, solve the least squares problem:u = argmin op(u)  v_2.
Since for an invertible operator the least squares solution agrees with the result of the application of the inverse operator, setting this option should, in general, have no effect on the result for those operators. However, note that when no appropriate
solver_options
are set for the operator, most implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArray
of the inverse operator evaluations.Raises
 InversionError
 The operator could not be inverted.

apply_inverse_adjoint
(U, ind=None, mu=None, source_product=None, range_product=None, least_squares=False)[source]¶ Apply the inverse adjoint operator.
Parameters
 U
VectorArray
of vectors to which the inverse adjoint operator is applied. ind
 The indices of the vectors in
U
to which the inverse adjoint operator shall be applied (see theVectorArray
documentation for further details).  mu
 The
Parameter
for which to evaluate the inverse adjoint operator.  source_product
 See
apply_adjoint
.  range_product
 See
apply_adjoint
.  least_squares
If
True
, solve the least squares problem:v = argmin op*(v)  u_2.
Since for an invertible operator the least squares solution agrees with the result of the application of the inverse operator, setting this option should, in general, have no effect on the result for those operators. However, note that when no appropriate
solver_options
are set for the operator, most operator implementations will choose a least squares solver by default which may be undesirable.
Returns
VectorArray
of the inverse adjoint operator evaluations.Raises
 InversionError
 The operator could not be inverted.

assemble_lincomb
(operators, coefficients, solver_options=None, name=None)[source]¶ Try to assemble a linear combination of the given operators.
This method is called in the
assemble
method ofLincombOperator
on the first of its operator. If an assembly of the given linear combination is possible, e.g. the linear combination of the system matrices of the operators can be formed, then the assembled operator is returned. Otherwise, the method returnsNone
to indicate that assembly is not possible.Parameters
 operators
 List of
Operators
whose linear combination is formed.  coefficients
 List of the corresponding linear coefficients.
 solver_options
solver_options
for the assembled operator. name
 Name of the assembled operator.
Returns
The assembled
Operator
if assembly is possible, otherwiseNone
.

projected
(range_basis, source_basis, product=None, name=None)[source]¶ Project the operator to subspaces of the source and range space.
Given an inner product
( ⋅, ⋅)
, source vectorsb_1, ..., b_N
and range vectorsc_1, ..., c_M
, the projectionop_proj
ofop
is defined by[ op_proj(e_j) ]_i = ( c_i, op(b_j) )
for all i,j, where
e_j
denotes the jth canonical basis vector of R^N.In particular, if the
c_i
are orthonormal w.r.t. the given product, thenop_proj
is the coordinate representation w.r.t. theb_i/c_i
bases of the restriction ofop
tospan(b_i)
concatenated with the orthogonal projection ontospan(c_i)
.From another point of view, if
op
is viewed as a bilinear form (seeapply2
) and( ⋅, ⋅ )
is the Euclidean inner product, thenop_proj
represents the matrix of the bilinear form restrictedspan(b_i) / spanc(c_i)
(w.r.t. theb_i/c_i
bases).How the projected operator is realized will depend on the implementation of the operator to project. While a projected
NumpyMatrixOperator
will again be aNumpyMatrixOperator
, only a genericProjectedOperator
can be returned in general.A default implementation is provided in
OperatorBase
.Parameters
 range_basis
 The vectors
c_1, ..., c_M
as aVectorArray
. IfNone
, no projection in the range space is performed.  source_basis
 The vectors
b_1, ..., b_N
as aVectorArray
orNone
. IfNone
, no restriction of the source space is performed.  product
 An
Operator
representing the inner product. IfNone
, the Euclidean inner product is chosen.  name
 Name of the projected operator.
Returns
The projected
Operator
op_proj
.

restricted
(dofs)[source]¶ Restrict the operator range to a given set of degrees of freedom.
This method returns a restricted version
restricted_op
of the operator along with an arraysource_dofs
such that for anyVectorArray
U
inself.source
the following is true:self.apply(U, mu).components(dofs) == restricted_op.apply(NumpyVectorArray(U.components(source_dofs)), mu))
Such an operator is mainly useful for
empirical interpolation
where the evaluation of the original operator only needs to be known for few selected degrees of freedom. If the operator has a small stencil, only fewsource_dofs
will be needed to evaluate the restricted operator which can make its evaluation very fast compared to evaluating the original operator.Parameters
 dofs
 Onedimensional
NumPy array
of degrees of freedom in the operatorrange
to which to restrict.
Returns
 restricted_op
 The restricted operator as defined above. The operator will have
NumpyVectorSpace
(len(source_dofs))
assource
andNumpyVectorSpace
(len(dofs))
asrange
.  source_dofs
 Onedimensional
NumPy array
of source degrees of freedom as defined above.

pymor.operators.constructions.
induced_norm
(product, raise_negative=True, tol=1e10, name=None)[source]¶ Obtain induced norm of an inner product.
The norm of the vectors in a
VectorArray
U is calculated by callingproduct.pairwise_apply2(U, U, mu=mu).
In addition, negative norm squares of absolute value smaller than
tol
are clipped to0
. Ifraise_negative
isTrue
, aValueError
exception is raised if there are negative norm squares of absolute value larger thantol
.Parameters
 product
 The inner product
Operator
for which the norm is to be calculated.  raise_negative
 If
True
, raise an exception if calculated norm is negative.  tol
 See above.
Returns
 norm
 A function
norm(U, mu=None)
taking aVectorArray
U
as input together with theParameter
mu
which 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.OperatorBase
Interpolate an
Operator
using Empirical Operator Interpolation.Let
L
be anOperator
,0 <= c_1, ..., c_M < L.range.dim
indices of interpolation DOFs and letb_1, ..., b_M in R^(L.range.dim)
be collateral basis vectors. If moreoverψ_j(U)
denotes the jth component ofU
, the empirical interpolationL_EI
ofL
w.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,
EmpiricalInterpolatedOperator
callsrestricted
to obtain a restricted version of the operator which is used to quickly obtain the required evaluations. If therestricted
method, 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.ei
module.Parameters
 operator
 The
Operator
to interpolate.  interpolation_dofs
 List or 1D
NumPy array
of the interpolation DOFsc_1, ..., c_M
.  collateral_basis
VectorArray
containing 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.  name
 Name of the operator.
Methods
Attributes

apply
(U, ind=None, mu=None)[source]¶ Apply the operator to a
VectorArray
.Parameters
 U
VectorArray
of vectors to which the operator is applied. ind
 The indices of the vectors in
U
to which the operator shall be applied (see theVectorArray
documentation for further details).  mu
 The
Parameter
for which to evaluate the operator.
Returns
VectorArray
of the operator evaluations.

jacobian
(U, mu=None)[source]¶ Return the operator’s Jacobian as a new
Operator
.Parameters
 U
 Length 1
VectorArray
containing the vector for which to compute the Jacobian.  mu
 The
Parameter
for which to compute the Jacobian.
Returns
Linear
Operator
representing the Jacobian.

projected
(range_basis, source_basis, product=None, name=None)[source]¶ Project the operator to subspaces of the source and range space.
Given an inner product
( ⋅, ⋅)
, source vectorsb_1, ..., b_N
and range vectorsc_1, ..., c_M
, the projectionop_proj
ofop
is defined by[ op_proj(e_j) ]_i = ( c_i, op(b_j) )
for all i,j, where
e_j
denotes the jth canonical basis vector of R^N.In particular, if the
c_i
are orthonormal w.r.t. the given product, thenop_proj
is the coordinate representation w.r.t. theb_i/c_i
bases of the restriction ofop
tospan(b_i)
concatenated with the orthogonal projection ontospan(c_i)
.From another point of view, if
op
is viewed as a bilinear form (seeapply2
) and( ⋅, ⋅ )
is the Euclidean inner product, thenop_proj
represents the matrix of the bilinear form restrictedspan(b_i) / spanc(c_i)
(w.r.t. theb_i/c_i
bases).How the projected operator is realized will depend on the implementation of the operator to project. While a projected
NumpyMatrixOperator
will again be aNumpyMatrixOperator
, only a genericProjectedOperator
can be returned in general.A default implementation is provided in
OperatorBase
.Parameters
 range_basis
 The vectors
c_1, ..., c_M
as aVectorArray
. IfNone
, no projection in the range space is performed.  source_basis
 The vectors
b_1, ..., b_N
as aVectorArray
orNone
. IfNone
, no restriction of the source space is performed.  product
 An
Operator
representing the inner product. IfNone
, the Euclidean inner product is chosen.  name
 Name of the projected operator.
Returns
The projected
Operator
op_proj
.

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.OperatorBase
A projected
EmpiricalInterpolatedOperator
.Not intended to be used directly. Instead use
projected
.Methods
Attributes

apply
(U, ind=None, mu=None)[source]¶ Apply the operator to a
VectorArray
.Parameters
 U
VectorArray
of vectors to which the operator is applied. ind
 The indices of the vectors in
U
to which the operator shall be applied (see theVectorArray
documentation for further details).  mu
 The
Parameter
for which to evaluate the operator.
Returns
VectorArray
of the operator evaluations.

fenics module¶
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.NumpyMatrixBasedOperator
Finite Volume Diffusion
Operator
.The operator is of the form
(Lu)(x) = c ∇ ⋅ [ d(x) ∇ u(x) ]
Parameters
 grid
 The
Grid
over which to assemble the operator.  boundary_info
BoundaryInfo
for the treatment of Dirichlet boundary conditions. diffusion_function
 The scalarvalued
Function
d(x)
. IfNone
, constant one is assumed.  diffusion_constant
 The constant
c
. IfNone
,c
is set to one.  name
 Name of the operator.
Methods
Attributes

class
pymor.operators.fv.
EngquistOsherFlux
(flux, flux_derivative, gausspoints=5, intervals=1)[source]¶ Bases:
pymor.operators.fv.NumericalConvectiveFluxInterface
EngquistOsher numerical flux.
If
f
is the analytical flux, andf'
its derivative, the EngquistOsher 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=0
Parameters
Methods
EngquistOsherFlux
evaluate_stage1
,evaluate_stage2
ImmutableInterface
generate_sid
,unlock
,with_
BasicInterface
disable_logging
,enable_logging
,has_interface_name
,implementor_names
,implementors
,lock
,__setattr__
Parametric
build_parameter_type
,local_parameter
,parse_parameter
,strip_parameter

class
pymor.operators.fv.
L2Product
(grid, solver_options=None, name=None)[source]¶ Bases:
pymor.operators.numpy.NumpyMatrixBasedOperator
Operator
representing the L2product between finite volume functions.Parameters
 grid
 The
Grid
for which to assemble the product.  name
 The name of the product.
Methods
Attributes

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.NumpyMatrixBasedOperator
Finite volume
Functional
representing the inner product with an L2Function
.Additionally, boundary conditions can be enforced by providing
dirichlet_data
andneumann_data
functions.Parameters
 grid
Grid
for which to assemble the functional. function
 The
Function
with which to take the inner product orNone
.  boundary_info
BoundaryInfo
determining the Dirichlet and Neumann boundaries orNone
. IfNone
, no boundary treatment is performed. dirichlet_data
Function
providing the Dirichlet boundary values. IfNone
, constantzero boundary is assumed. diffusion_function
 See
DiffusionOperator
. Has to be specified in casedirichlet_data
is given.  diffusion_constant
 See
DiffusionOperator
. Has to be specified in casedirichlet_data
is given.  neumann_data
Function
providing the Neumann boundary values. IfNone
, constantzero is assumed. order
 Order of the Gauss quadrature to use for numerical integration.
 name
 The name of the functional.
Methods
Attributes

class
pymor.operators.fv.
LaxFriedrichsFlux
(flux, lxf_lambda=1.0)[source]¶ Bases:
pymor.operators.fv.NumericalConvectiveFluxInterface
LaxFriedrichs numerical flux.
If
f
is the analytical flux, the LaxFriedrichs fluxF
is 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
Function
defining the analytical fluxf
. lxf_lambda
 The stabilization parameter
λ
.
Methods
LaxFriedrichsFlux
evaluate_stage1
,evaluate_stage2
ImmutableInterface
generate_sid
,unlock
,with_
BasicInterface
disable_logging
,enable_logging
,has_interface_name
,implementor_names
,implementors
,lock
,__setattr__
Parametric
build_parameter_type
,local_parameter
,parse_parameter
,strip_parameter

class
pymor.operators.fv.
LinearAdvectionLaxFriedrichs
(grid, boundary_info, velocity_field, lxf_lambda=1.0, solver_options=None, name=None)[source]¶ Bases:
pymor.operators.numpy.NumpyMatrixBasedOperator
Linear advection finite Volume
Operator
using LaxFriedrichs flux.The operator is of the form
L(u, mu)(x) = ∇ ⋅ (v(x, mu)⋅u(x))
See
LaxFriedrichsFlux
for the definition of the LaxFriedrichs flux.Parameters
 grid
Grid
over which to assemble the operator. boundary_info
BoundaryInfo
determining the Dirichlet and Neumann boundaries. velocity_field
Function
defining the velocity fieldv
. lxf_lambda
 The stabilization parameter
λ
.  name
 The name of the operator.
Methods
Attributes

class
pymor.operators.fv.
NonlinearAdvectionOperator
(grid, boundary_info, numerical_flux, dirichlet_data=None, solver_options=None, name=None)[source]¶ Bases:
pymor.operators.basic.OperatorBase
Nonlinear finite volume advection
Operator
.The operator is of the form
L(u, mu)(x) = ∇ ⋅ f(u(x), mu)
Parameters
 grid
Grid
for which to evaluate the operator. boundary_info
BoundaryInfo
determining the Dirichlet and Neumann boundaries. numerical_flux
 The
NumericalConvectiveFlux
to use.  dirichlet_data
Function
providing the Dirichlet boundary values. IfNone
, constantzero boundary is assumed. name
 The name of the operator.
Methods
Attributes

apply
(U, ind=None, mu=None)[source]¶ Apply the operator to a
VectorArray
.Parameters
 U
VectorArray
of vectors to which the operator is applied. ind
 The indices of the vectors in
U
to which the operator shall be applied (see theVectorArray
documentation for further details).  mu
 The
Parameter
for which to evaluate the operator.
Returns
VectorArray
of the operator evaluations.

jacobian
(U, mu=None)[source]¶ Return the operator’s Jacobian as a new
Operator
.Parameters
 U
 Length 1
VectorArray
containing the vector for which to compute the Jacobian.  mu
 The
Parameter
for which to compute the Jacobian.
Returns
Linear
Operator
representing the Jacobian.

restricted
(dofs)[source]¶ Restrict the operator range to a given set of degrees of freedom.
This method returns a restricted version
restricted_op
of the operator along with an arraysource_dofs
such that for anyVectorArray
U
inself.source
the following is true:self.apply(U, mu).components(dofs) == restricted_op.apply(NumpyVectorArray(U.components(source_dofs)), mu))
Such an operator is mainly useful for
empirical interpolation
where the evaluation of the original operator only needs to be known for few selected degrees of freedom. If the operator has a small stencil, only fewsource_dofs
will be needed to evaluate the restricted operator which can make its evaluation very fast compared to evaluating the original operator.Parameters
 dofs
 Onedimensional
NumPy array
of degrees of freedom in the operatorrange
to which to restrict.
Returns
 restricted_op
 The restricted operator as defined above. The operator will have
NumpyVectorSpace
(len(source_dofs))
assource
andNumpyVectorSpace
(len(dofs))
asrange
.  source_dofs
 Onedimensional
NumPy array
of source degrees of freedom as defined above.

with_
(**kwargs)[source]¶ Returns a copy with changed attributes.
The default implementation is to create a new class instance with the given keyword arguments as arguments for
__init__
. Missing arguments are obtained form instance attributes with the same name.Parameters
**kwargs
 Names of attributes to change with their new values. Each attribute name
has to be contained in
with_arguments
.
Returns
Copy of
self
with changed attributes.

class
pymor.operators.fv.
NumericalConvectiveFluxInterface
[source]¶ Bases:
pymor.core.interfaces.ImmutableInterface
,pymor.parameters.base.Parametric
Interface 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_stage1
receives aNumPy array
U
of all values which appear asU_inner
orU_outer
for all edges the flux shall be evaluated at and returns atuple
ofNumPy arrays
each of the same length asU
.evaluate_stage2
receives the reorderedstage1_data
for each edge as well as the unit outer normal and the volume of the edges.stage1_data
is given as follows: IfR_l
isl
th entry of thetuple
returned byevaluate_stage1
, thel
th entryD_l
of of thestage1_data
tuple has the shape(num_edges, 2) + R_l.shape[1:]
. If for edgek
the valuesU_inner
andU_outer
are thei
th andj
th value in theU
array provided toevaluate_stage1
, we haveD_l[k, 0] == R_l[i], D_l[k, 1] == R_l[j].
evaluate_stage2
returns aNumPy array
of the flux evaluations for each edge.
Methods

class
pymor.operators.fv.
SimplifiedEngquistOsherFlux
(flux, flux_derivative)[source]¶ Bases:
pymor.operators.fv.NumericalConvectiveFluxInterface
EngquistOsher numerical flux. Simplified Implementation for special case.
For the definition of the EngquistOsher flux see
EngquistOsherFlux
. This class provides a faster and more accurate implementation for the special case thatf(0) == 0
and the derivative off
only changes sign at0
.Parameters
Methods

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
NonlinearAdvectionOperator
usingEngquistOsherFlux
.

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
NonlinearAdvectionOperator
usingLaxFriedrichsFlux
.

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
NonlinearAdvectionOperator
usingSimplifiedEngquistOsherFlux
.
interfaces module¶

class
pymor.operators.interfaces.
OperatorInterface
[source]¶ Bases:
pymor.core.interfaces.ImmutableInterface
,pymor.parameters.base.Parametric
Interface for
Parameter
dependent discrete operators.An operator in pyMOR is simply a mapping which for any given
Parameter
maps vectors from its sourceVectorSpace
to vectors in its rangeVectorSpace
.Note that there is no special distinction between functionals and operators in pyMOR. A functional is simply an operator with
NumpyVectorSpace
(1)
as its rangeVectorSpace
.Methods
Attributes

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_options
isNone
or 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_options
should 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
¶ True
if the operator is linear.

source
¶ The source
VectorSpace
.

range
¶ The range
VectorSpace
.

apply
(U, ind=None, mu=None)[source]¶ Apply the operator to a
VectorArray
.Parameters
 U
VectorArray
of vectors to which the operator is applied. ind
 The indices of the vectors in
U
to which the operator shall be applied (see theVectorArray
documentation for further details).  mu
 The
Parameter
for which to evaluate the operator.
Returns
VectorArray
of the operator evaluations.
