pymor.reductors package

Submodules

basic module


class pymor.reductors.basic.GenericRBReconstructor(RB)[source]

Bases: pymor.core.interfaces.BasicInterface

Simple reconstructor forming linear combinations with a reduced basis.

reconstruct(U)[source]

Reconstruct high-dimensional vector from reduced vector U.

restricted_to_subbasis(dim)[source]

See projected_to_subbasis.


class pymor.reductors.basic.SubbasisReconstructor(dim, dim_subbasis, old_recontructor=None)[source]

Bases: pymor.core.interfaces.BasicInterface

Returned by reduce_to_subbasis.

reconstruct(U)[source]

Reconstruct high-dimensional vector from reduced vector U.


pymor.reductors.basic.reduce_generic_rb(discretization, RB, vector_product=None, disable_caching=True, extends=None)[source]

Generic reduced basis reductor.

Replaces each Operator of the given Discretization with the Galerkin projection onto the span of the given reduced basis.

Parameters

discretization
The Discretization which is to be reduced.
RB
VectorArray containing the reduced basis on which to project.
vector_product
Inner product for the projection of vector-like Operators. (A typical vector-like operator would be the initial_data Operator of an InstationaryDiscretization holding the initial data of a Cauchy problem.)
disable_caching
If True, caching of solutions is disabled for the reduced Discretization.
extends
Set by greedy to the result of the last reduction in case the basis extension was hierarchic (ignored).

Returns

rd
The reduced Discretization.
rc
The reconstructor providing a reconstruct(U) method which reconstructs high-dimensional solutions from solutions U of the reduced Discretization.
reduction_data
Additional data produced by the reduction process (empty).

pymor.reductors.basic.reduce_to_subbasis(discretization, dim, reconstructor=None)[source]

Further reduce a Discretization to the subbasis formed by the first dim basis vectors.

This is achieved by calling projected_to_subbasis for each operator of the given Discretization. Additionally, if a reconstructor for the Discretization is provided, its restricted_to_subbasis method is also called to obtain a reconstructor for the further reduced Discretization. Otherwise SubbasisReconstructor is used (which will be less efficient).

Parameters

discretization
The Discretization to further reduce.
dim
The dimension of the subbasis.
reconstructor
Reconstructor for discretization or None.

Returns

rd
The further reduced Discretization.
rc
Reconstructor for rd.

coercive module


class pymor.reductors.coercive.ReduceCoerciveEstimator(residual, residual_range_dims, coercivity_estimator)[source]

Bases: pymor.core.interfaces.ImmutableInterface

Instantiated by reduce_coercive.

Not to be used directly.


class pymor.reductors.coercive.ReduceCoerciveSimpleEstimator(estimator_matrix, coercivity_estimator)[source]

Bases: pymor.core.interfaces.ImmutableInterface

Instantiated by reduce_coercive_simple.

Not to be used directly.


pymor.reductors.coercive.reduce_coercive(discretization, RB, error_product=None, coercivity_estimator=None, disable_caching=True, extends=None)[source]

Reductor for StationaryDiscretizations with coercive linear operator.

This reductor uses reduce_generic_rb for the actual reduce basis projection. The only addition is an error estimator which evaluates the dual norm of the residual with respect to a given inner product. For the reduction of the residual we use reduce_residual for improved numerical stability [BEOR14].

[BEOR14](1, 2) A. Buhr, C. Engwer, M. Ohlberger, S. Rave, A Numerically Stable A Posteriori Error Estimator for Reduced Basis Approximations of Elliptic Equations, Proceedings of the 11th World Congress on Computational Mechanics, 2014.

Parameters

discretization
The Discretization which is to be reduced.
RB
VectorArray containing the reduced basis on which to project.
error_product
Inner product Operator used to calculate Riesz representative of the residual. If None, the Euclidean product is used.
coercivity_estimator
None or a ParameterFunctional returning a lower bound for the coercivity constant of the given problem. Note that the computed error estimate is only guaranteed to be an upper bound for the error when an appropriate coercivity estimate is specified.
disable_caching
If True, caching of solutions is disabled for the reduced Discretization.
extends
Set by greedy to the result of the last reduction in case the basis extension was hierarchic (used to prevent re-computation of residual range basis vectors already obtained from previous reductions).

Returns

rd
The reduced Discretization.
rc
The reconstructor providing a reconstruct(U) method which reconstructs high-dimensional solutions from solutions U of the reduced Discretization.
reduction_data
Additional data produced by the reduction process (compare the extends parameter).

pymor.reductors.coercive.reduce_coercive_simple(discretization, RB, error_product=None, coercivity_estimator=None, disable_caching=True, extends=None)[source]

Reductor for linear StationaryDiscretizations with affinely decomposed operator and rhs.

Note

The reductor reduce_coercive can be used for arbitrary coercive StationaryDiscretizations and offers an improved error estimator with better numerical stability.

This reductor uses reduce_generic_rb for the actual reduced basis projection. The only addition is an error estimator. The estimator evaluates the norm of the residual with respect to a given inner product.

Parameters

discretization
The Discretization which is to be reduced.
RB
VectorArray containing the reduced basis on which to project.
error_product
Inner product Operator used to calculate the Riesz representative of the residual. If None, the Euclidean product is used.
coercivity_estimator
None or a ParameterFunctional returning a lower bound for the coercivity constant of the given problem. Note that the computed error estimate is only guaranteed to be an upper bound for the error when an appropriate coercivity estimate is specified.
disable_caching
If True, caching of solutions is disabled for the reduced Discretization.
extends
Set by greedy to the result of the last reduction in case the basis extension was hierarchic (used to prevent re-computation of residual range basis vectors already obtained from previous reductions).

Returns

rd
The reduced Discretization.
rc
The reconstructor providing a reconstruct(U) method which reconstructs high-dimensional solutions from solutions U of the reduced Discretization.
reduction_data
Additional data produced by the reduction process (compare the extends parameter).

linear module


pymor.reductors.linear.reduce_stationary_affine_linear(*args, **kwargs)[source]

DEPRECATED! Renamed to pymor.reductors.coercive.reduce_coercive_simple.

parabolic module


class pymor.reductors.parabolic.ReduceParabolicEstimator(residual, residual_range_dims, initial_residual, initial_residual_range_dims, coercivity_estimator)[source]

Bases: pymor.core.interfaces.ImmutableInterface

Instantiated by reduce_parabolic.

Not to be used directly.


pymor.reductors.parabolic.reduce_parabolic(discretization, RB, product=None, coercivity_estimator=None, disable_caching=True, extends=None)[source]

Reductor for parabolic equations.

This reductor uses reduce_generic_rb for the actual RB-projection. The only addition is the assembly of an error estimator which bounds the discrete l2-in time / energy-in space error similar to [GP05], [HO08] as follows:

\left[ C_a^{-1}(\mu)\|e_N(\mu)\|^2 + \sum_{n=1}^{N} \Delta t\|e_n(\mu)\|^2_e \right]^{1/2}
    \leq \left[ C_a^{-1}(\mu)\Delta t \sum_{n=1}^{N}\|\mathcal{R}^n(u_n(\mu), \mu)\|^2_{e,-1}
                + C_a^{-1}(\mu)\|e_0\|^2 \right]^{1/2}

Here, \|\cdot\| denotes the norm induced by the problem’s mass matrix (e.g. the L^2-norm) and \|\cdot\|_e is an arbitrary energy norm w.r.t. which the space operator A(\mu) is coercive, and C_a(\mu) is a lower bound for its coercivity constant. Finally, \mathcal{R}^n denotes the implicit Euler timestepping residual for the (fixed) time step size \Delta t,

\mathcal{R}^n(u_n(\mu), \mu) :=
    f - M \frac{u_{n}(\mu) - u_{n-1}(\mu)}{\Delta t} - A(u_n(\mu), \mu),

where M denotes the mass operator and f the source term. The dual norm of the residual is computed using the numerically stable projection from [BEOR14].

Warning

The reduced basis RB is required to be orthonormal w.r.t. the given energy product. If not, the projection of the initial values will be computed incorrectly.

[GP05]M. A. Grepl, A. T. Patera, A Posteriori Error Bounds For Reduced-Basis Approximations Of Parametrized Parabolic Partial Differential Equations, M2AN 39(1), 157-181, 2005.
[HO08]B. Haasdonk, M. Ohlberger, Reduced basis method for finite volume approximations of parametrized evolution equations, M2AN 42(2), 277-302, 2008.

Parameters

discretization
The InstationaryDiscretization which is to be reduced.
RB
VectorArray containing the reduced basis on which to project.
product
The energy inner product Operator w.r.t. the reduction error is estimated. RB must be to be orthonomrmal w.r.t. this product!
coercivity_estimator
None or a ParameterFunctional returning a lower bound C_a(\mu) for the coercivity constant of discretization.operator w.r.t. product.
disable_caching
If True, caching of solutions is disabled for the reduced Discretization.
extends
Set by greedy to the result of the last reduction in case the basis extension was hierarchic (used to prevent re-computation of residual range basis vectors already obtained from previous reductions).

Returns

rd
The reduced Discretization.
rc
The reconstructor providing a reconstruct(U) method which reconstructs high-dimensional solutions from solutions U of the reduced Discretization.
reduction_data
Additional data produced by the reduction process (compare the extends parameter).

residual module


class pymor.reductors.residual.ImplicitEulerResidualOperator(operator, mass, functional, dt, name=None)[source]

Bases: pymor.operators.basic.OperatorBase

Returned by reduce_implicit_euler_residual.

apply(U, U_old, ind, ind_old=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 the VectorArray documentation for further details).
mu
The Parameter for which to evaluate the operator.

Returns

VectorArray of the operator evaluations.


class pymor.reductors.residual.NonProjectedImplicitEulerResidualOperator(operator, mass, functional, dt, product)[source]

Bases: pymor.reductors.residual.ImplicitEulerResidualOperator

Returned by reduce_implicit_euler_residual.

Not to be used directly.

apply(U, U_old, ind=None, ind_old=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 the VectorArray documentation for further details).
mu
The Parameter for which to evaluate the operator.

Returns

VectorArray of the operator evaluations.


class pymor.reductors.residual.NonProjectedReconstructor(product)[source]

Bases: pymor.core.interfaces.ImmutableInterface

Returned by reduce_residual.

Not to be used directly.


class pymor.reductors.residual.NonProjectedResidualOperator(operator, rhs, rhs_is_functional, product)[source]

Bases: pymor.reductors.residual.ResidualOperator

Returned by reduce_residual.

Not to be used directly.

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 the VectorArray documentation for further details).
mu
The Parameter for which to evaluate the operator.

Returns

VectorArray of the operator evaluations.


class pymor.reductors.residual.ResidualOperator(operator, rhs, rhs_is_functional=True, name=None)[source]

Bases: pymor.operators.basic.OperatorBase

Returned by reduce_residual.

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 the VectorArray documentation for further details).
mu
The Parameter for which to evaluate the operator.

Returns

VectorArray of the operator evaluations.


pymor.reductors.residual.reduce_implicit_euler_residual(operator, mass, dt, functional=None, RB=None, product=None, extends=None)[source]

Reduced basis residual reductor with mass operator for implicit Euler timestepping.

Given an operator, mass and a functional, the concatenation of residual operator with the Riesz isomorphism is given by:

riesz_residual.apply(U, U_old, mu)
    == product.apply_inverse(operator.apply(U, mu) + 1/dt*mass.apply(U, mu) - 1/dt*mass.apply(U_old, mu)
       - functional.as_vector(mu))

This reductor determines a low-dimensional subspace of the image of a reduced basis space under riesz_residual using estimate_image_hierarchical, computes an orthonormal basis residual_range of this range space and then returns the Petrov-Galerkin projection

projected_riesz_residual
    === riesz_residual.projected(range_basis=residual_range, source_basis=RB)

of the riesz_residual operator. Given reduced basis coefficient vectors u and u_old, the dual norm of the residual can then be computed as

projected_riesz_residual.apply(u, u_old, mu).l2_norm()

Moreover, a reconstructor is provided such that

reconstructor.reconstruct(projected_riesz_residual.apply(u, u_old, mu))
    == riesz_residual.apply(RB.lincomb(u), RB.lincomb(u_old), mu)

Parameters

operator
See definition of riesz_residual.
mass
The mass operator. See definition of riesz_residual.
dt
The time step size. See definition of riesz_residual.
functional
See definition of riesz_residual. If None, zero right-hand side is assumed.
RB
VectorArray containing a basis of the reduced space onto which to project.
product
Inner product Operator w.r.t. which to compute the Riesz representatives.
extends
Set by greedy to the result of the last reduction in case the basis extension was hierarchic (used to prevent re-computation of residual_range basis vectors already obtained from previous reductions).

Returns

projected_riesz_residual
See above.
reconstructor
See above.
reduction_data
Additional data produced by the reduction process (compare the extends parameter).

pymor.reductors.residual.reduce_residual(operator, rhs=None, RB=None, rhs_is_functional=True, product=None, extends=None)[source]

Generic reduced basis residual reductor.

Given an operator and a right-hand side, the residual is given by:

residual.apply(U, mu) == operator.apply(U, mu) - rhs.as_vector(mu)

When the rhs is a functional we are usually interested in the Riesz representative of the residual:

residual.apply(U, mu)
    == product.apply_inverse(operator.apply(U, mu) - rhs.as_vector(mu))

Given a basis RB of a subspace of the source space of operator, this method uses estimate_image_hierarchical to determine a low-dimensional subspace containing the image of the subspace under residual (resp. riesz_residual), computes an orthonormal basis residual_range for this range space and then returns the Petrov-Galerkin projection

projected_residual
    === residual.projected(range_basis=residual_range, source_basis=RB)

of the residual operator. Given an reduced basis coefficient vector u, w.r.t. RB, the (dual) norm of the residual can then be computed as

projected_residual.apply(u, mu).l2_norm()

Moreover, a reconstructor is provided such that

reconstructor.reconstruct(projected_residual.apply(u, mu))
    == residual.apply(RB.lincomb(u), mu)

Parameters

operator
See definition of residual.
rhs
See definition of residual. If None, zero right-hand side is assumed.
rhs_is_functional
Set this to True when rhs is a Functional.
RB
VectorArray containing a basis of the reduced space onto which to project.
product
Inner product Operator w.r.t. which to compute the Riesz representatives in case rhs_is_functional is True. When product is None, no Riesz representatives are computed
extends
Set by greedy to the result of the last reduction in case the basis extension was hierarchic (used to prevent re-computation of residual_range basis vectors already obtained from previous reductions).

Returns

projected_residual
See above.
reconstructor
See above.
reduction_data
Additional data produced by the reduction process (compare the extends parameter).

stationary module


pymor.reductors.stationary.reduce_stationary_coercive(*args, **kwargs)[source]

DEPRECATED! Renamed to pymor.reductors.coercive.reduce_coercive.