pymor.models.basic

Module Contents

class pymor.models.basic.InstationaryModel(T, initial_data, operator, rhs, mass=None, time_stepper=None, num_values=None, output_functional=None, products=None, error_estimator=None, visualizer=None, name=None)[source]

Bases: pymor.models.interface.Model

Generic class for models of instationary problems.

This class describes instationary problems given by the equations:

M * ∂_t u(t, μ) + L(u(μ), t, μ) = F(t, μ)
                        u(0, μ) = u_0(μ)

for t in [0,T], where L is a (possibly non-linear) time-dependent Operator, F is a time-dependent vector-like Operator, and u_0 the initial data. The mass Operator M is assumed to be linear.

Parameters

T

The final time T.

initial_data

The initial data u_0. Either a VectorArray of length 1 or (for the Parameter-dependent case) a vector-like Operator (i.e. a linear Operator with source.dim == 1) which applied to NumpyVectorArray(np.array([1])) will yield the initial data for given parameter values.

operator

The Operator L.

rhs

The right-hand side F.

mass

The mass Operator M. If None, the identity is assumed.

time_stepper

The time-stepper to be used by solve.

num_values

The number of returned vectors of the solution trajectory. If None, each intermediate vector that is calculated is returned.

output_functional

Operator mapping a given solution to the model output. In many applications, this will be a Functional, i.e. an Operator mapping to scalars. This is not required, however.

products

A dict of product Operators defined on the discrete space the problem is posed on. For each product with key 'x' a corresponding attribute x_product, as well as a norm method x_norm is added to the model.

error_estimator

An error estimator for the problem. This can be any object with an estimate_error(U, mu, m) method. If error_estimator is not None, an estimate_error(U, mu) method is added to the model which will call error_estimator.estimate_error(U, mu, self).

visualizer

A visualizer for the problem. This can be any object with a visualize(U, m, ...) method. If visualizer is not None, a visualize(U, *args, **kwargs) method is added to the model which forwards its arguments to the visualizer’s visualize method.

name

Name of the model.

Methods

to_lti

Convert model to LTIModel.

with_time_stepper

to_lti()[source]

Convert model to LTIModel.

This method interprets the given model as an LTIModel in the following way:

-self.operator         -> A
self.rhs               -> B
self.output_functional -> C
None                   -> D
self.mass              -> E
with_time_stepper(**kwargs)[source]
class pymor.models.basic.StationaryModel(operator, rhs, output_functional=None, products=None, error_estimator=None, visualizer=None, name=None)[source]

Bases: pymor.models.interface.Model

Generic class for models of stationary problems.

This class describes discrete problems given by the equation:

L(u(μ), μ) = F(μ)

with a vector-like right-hand side F and a (possibly non-linear) operator L.

Note that even when solving a variational formulation where F is a functional and not a vector, F has to be specified as a vector-like Operator (mapping scalars to vectors). This ensures that in the complex case both L and F are anti-linear in the test variable.

Parameters

operator

The Operator L.

rhs

The vector F. Either a VectorArray of length 1 or a vector-like Operator.

output_functional

Operator mapping a given solution to the model output. In many applications, this will be a Functional, i.e. an Operator mapping to scalars. This is not required, however.

products

A dict of inner product Operators defined on the discrete space the problem is posed on. For each product with key 'x' a corresponding attribute x_product, as well as a norm method x_norm is added to the model.

error_estimator

An error estimator for the problem. This can be any object with an estimate_error(U, mu, m) method. If error_estimator is not None, an estimate_error(U, mu) method is added to the model which will call error_estimator.estimate_error(U, mu, self).

visualizer

A visualizer for the problem. This can be any object with a visualize(U, m, ...) method. If visualizer is not None, a visualize(U, *args, **kwargs) method is added to the model which forwards its arguments to the visualizer’s visualize method.

name

Name of the model.

Methods

deaffinize

Build Model with linear solution space.

deaffinize(arg)[source]

Build Model with linear solution space.

For many Models the solution manifold is contained in an affine subspace of the solution_space, e.g. the affine space of functions with certain fixed boundary values. Most MOR techniques, however, construct linear approximation spaces, which are not fully contained in this affine subspace, even if these spaces are created using snapshot vectors from the subspace. Depending on the FOM, neglecting the affine structure of the solution space may lead to bad approximations or even an ill-posed ROM. A standard approach to circumvent this issue is to replace the FOM with an equivalent Model with linear solution space. This method can be used to obtain such a Model.

Given a vector u_0 from the affine solution space, the returned StationaryModel is equivalent to solving:

L(u(μ) + u_0, μ) = F(μ)

When operator is linear, the affine shift is moved to the right-hand side to obtain:

L(u(μ), μ) = F(μ) - L(u_0, μ)

Solutions of the original Model can be obtained by adding u_0 to the solutions of the deaffinized Model.

The output_functional is adapted accordingly to yield the same output for given parameter values.

Parameters

arg

Either a VectorArray of length 1 containing the vector u_0. Alternatively, parameter values can be provided, for which the model is solved to obtain u_0.

Returns

The deaffinized Model.