pymor.models package

Submodules

basic module


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

Bases: pymor.models.basic.ModelBase

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, time-independent and Parameter-independent.

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 a given Parameter.
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.
products
A dict of product Operators defined on the discrete space the problem is posed on. For each product a corresponding norm is added as a method of the model.
operators
A dict of additional Operators associated with the model.
parameter_space
The ParameterSpace for which the discrete problem is posed.
estimator
An error estimator for the problem. This can be any object with an estimate(U, mu, m) method. If estimator is not None, an estimate(U, mu) method is added to the model which will call estimator.estimate(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.
cache_region
None or name of the CacheRegion to use.
name
Name of the model.
T

The final time T.

initial_data

The intial data u_0 given by a vector-like Operator. The same as operators['initial_data'].

operator

The Operator L. The same as operators['operator'].

rhs

The right-hand side F. The same as operators['rhs'].

mass

The mass operator M. The same as operators['mass'].

time_stepper

The provided time-stepper.

operators

Dict of all Operators appearing in the model.

products

Dict of all product Operators associated with the model.

to_lti(output='output_functional')[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.operators[output] -> C
None                   -> D
self.mass              -> E

Parameters

output
Key in self.operators to use as output functional.
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.models.basic.ModelBase(operators=None, products=None, estimator=None, visualizer=None, cache_region=None, name=None, **kwargs)[source]

Bases: pymor.models.interfaces.ModelInterface

Base class for Models providing some common functionality.

estimate(U, mu=None)[source]

Estimate the model error for a given solution.

The model error could be the error w.r.t. the analytical solution of the given problem or the model reduction error w.r.t. a corresponding high-dimensional Model.

Parameters

U
The solution obtained by solve.
mu
Parameter for which U has been obtained.

Returns

The estimated error.

visualize(U, **kwargs)[source]

Visualize a solution VectorArray U.

Parameters

U
The VectorArray from solution_space that shall be visualized.
kwargs
See docstring of self.visualizer.visualize.
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.models.basic.StationaryModel(operator, rhs, products=None, operators=None, parameter_space=None, estimator=None, visualizer=None, cache_region=None, name=None)[source]

Bases: pymor.models.basic.ModelBase

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.
products
A dict of inner product Operators defined on the discrete space the problem is posed on. For each product a corresponding norm is added as a method of the model.
operators
A dict of additional Operators associated with the model.
parameter_space
The ParameterSpace for which the discrete problem is posed.
estimator
An error estimator for the problem. This can be any object with an estimate(U, mu, m) method. If estimator is not None, an estimate(U, mu) method is added to the model which will call estimator.estimate(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.
cache_region
None or name of the CacheRegion to use.
name
Name of the model.
operator

The Operator L. The same as operators['operator'].

rhs

The right-hand side F. The same as operators['rhs'].

operators

Dict of all Operators appearing in the model.

products

Dict of all product Operators associated with the model.

interfaces module


class pymor.models.interfaces.ModelInterface[source]

Bases: pymor.core.cache.CacheableInterface, pymor.parameters.base.Parametric

Interface for model objects.

A model object defines a discrete problem via its class and the Operators it contains. Furthermore, models can be solved for a given Parameter resulting in a solution VectorArray.

solution_space

VectorSpace of the VectorArrays returned by solve.

linear

True if the model describes a linear problem.

operators

Dictionary of all Operators contained in the model (see GenericRBReductor for a usage example).

products

Same as Operators but for inner product operators associated with the model.

estimate(U, mu=None)[source]

Estimate the model error for a given solution.

The model error could be the error w.r.t. the analytical solution of the given problem or the model reduction error w.r.t. a corresponding high-dimensional Model.

Parameters

U
The solution obtained by solve.
mu
Parameter for which U has been obtained.

Returns

The estimated error.

solve(mu=None, **kwargs)[source]

Solve the discrete problem for the Parameter mu.

The result will be cached in case caching has been activated for the given model.

Parameters

mu
Parameter for which to solve.

Returns

The solution given as a VectorArray.

visualize(U, **kwargs)[source]

Visualize a solution VectorArray U.

Parameters

U
The VectorArray from solution_space that shall be visualized.

iosys module


class pymor.models.iosys.BilinearModel(A, N, B, C, D, E=None, cont_time=True, estimator=None, visualizer=None, cache_region='memory', name=None)[source]

Bases: pymor.models.iosys.InputStateOutputModel

Class for bilinear systems.

This class describes input-output systems given by

E x'(t)
& =
    A x(t)
    + \sum_{i = 1}^m{N_i x(t) u_i(t)}
    + B u(t), \\
y(t)
& =
    C x(t)
    + D u(t),

if continuous-time, or

E x(k + 1)
& =
    A x(k)
    + \sum_{i = 1}^m{N_i x(k) u_i(k)}
    + B u(k), \\
y(k)
& =
    C x(k)
    + D u(t),

if discrete-time, where E, A, N_i, B, C, and D are linear operators and m is the number of inputs.

Parameters

A
The Operator A.
N
The tuple of Operators N_i.
B
The Operator B.
C
The Operator C.
D
The Operator D or None (then D is assumed to be zero).
E
The Operator E or None (then E is assumed to be identity).
cont_time
True if the system is continuous-time, otherwise False.
estimator
An error estimator for the problem. This can be any object with an estimate(U, mu, model) method. If estimator is not None, an estimate(U, mu) method is added to the model which will call estimator.estimate(U, mu, self).
visualizer
A visualizer for the problem. This can be any object with a visualize(U, model, ...) 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.
cache_region
None or name of the cache region to use. See pymor.core.cache.
name
Name of the system.
n

The order of the system (equal to A.source.dim).

A

The Operator A.

N

The tuple of Operators N_i.

B

The Operator B.

C

The Operator C.

D

The Operator D.

E

The Operator E.

operators

Dictionary of all Operators contained in the model.


class pymor.models.iosys.InputOutputModel(input_space, output_space, cont_time=True, cache_region='memory', name=None, **kwargs)[source]

Bases: pymor.models.basic.ModelBase

Base class for input-output systems.

bode(w)[source]

Evaluate the transfer function on the imaginary axis.

Parameters

w
Angular frequencies at which to compute the transfer function.

Returns

tfw
Transfer function values at frequencies in w, NumPy array of shape (len(w), self.output_dim, self.input_dim).
eval_dtf(s, mu=None)[source]

Evaluate the derivative of the transfer function.

eval_tf(s, mu=None)[source]

Evaluate the transfer function.

mag_plot(w, ax=None, ord=None, Hz=False, dB=False, **mpl_kwargs)[source]

Draw the magnitude Bode plot.

Parameters

w
Angular frequencies at which to evaluate the transfer function.
ax
Axis to which to plot. If not given, matplotlib.pyplot.gca is used.
ord
The order of the norm used to compute the magnitude (the default is the Frobenius norm).
Hz
Should the frequency be in Hz on the plot.
dB
Should the magnitude be in dB on the plot.
mpl_kwargs
Keyword arguments used in the matplotlib plot function.

Returns

out
List of matplotlib artists added.

class pymor.models.iosys.InputStateOutputModel(input_space, state_space, output_space, cont_time=True, cache_region='memory', name=None, **kwargs)[source]

Bases: pymor.models.iosys.InputOutputModel

Base class for input-output systems with state space.


class pymor.models.iosys.LTIModel(A, B, C, D=None, E=None, cont_time=True, solver_options=None, estimator=None, visualizer=None, cache_region='memory', name=None)[source]

Bases: pymor.models.iosys.InputStateOutputModel

Class for linear time-invariant systems.

This class describes input-state-output systems given by

E \dot{x}(t) & = A x(t) + B u(t), \\
        y(t) & = C x(t) + D u(t),

if continuous-time, or

E x(k + 1) & = A x(k) + B u(k), \\
  y(k)     & = C x(k) + D u(k),

if discrete-time, where A, B, C, D, and E are linear operators.

Parameters

A
The Operator A.
B
The Operator B.
C
The Operator C.
D
The Operator D or None (then D is assumed to be zero).
E
The Operator E or None (then E is assumed to be identity).
cont_time
True if the system is continuous-time, otherwise False.
solver_options
The solver options to use to solve the Lyapunov equations.
estimator
An error estimator for the problem. This can be any object with an estimate(U, mu, model) method. If estimator is not None, an estimate(U, mu) method is added to the model which will call estimator.estimate(U, mu, self).
visualizer
A visualizer for the problem. This can be any object with a visualize(U, model, ...) 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.
cache_region
None or name of the cache region to use. See pymor.core.cache.
name
Name of the system.
n

The order of the system.

A

The Operator A.

B

The Operator B.

C

The Operator C.

D

The Operator D.

E

The Operator E.

operators

Dict of all Operators appearing in the model.

__add__(other)[source]

Add an LTIModel.

__mul__(other)[source]

Postmultiply by an LTIModel.

__neg__()[source]

Negate the LTIModel.

__sub__(other)[source]

Subtract an LTIModel.

eval_dtf(s)[source]

Evaluate the derivative of the transfer function.

The derivative of the transfer function at s is

-C (s E - A)^{-1} E (s E - A)^{-1} B.

Note

We assume that either the number of inputs or the number of outputs is much smaller than the order of the system.

Parameters

s
Complex number.

Returns

dtfs
Derivative of transfer function evaluated at the complex number s, NumPy array of shape (self.output_dim, self.input_dim).
eval_tf(s)[source]

Evaluate the transfer function.

The transfer function at s is

C (s E - A)^{-1} B + D.

Note

We assume that either the number of inputs or the number of outputs is much smaller than the order of the system.

Parameters

s
Complex number.

Returns

tfs
Transfer function evaluated at the complex number s, NumPy array of shape (self.output_dim, self.input_dim).
classmethod from_abcde_files(files_basename, cont_time=True, input_id='INPUT', state_id='STATE', output_id='OUTPUT', solver_options=None, estimator=None, visualizer=None, cache_region='memory', name=None)[source]

Create LTIModel from matrices stored in a .[ABCDE] files.

Parameters

files_basename
The basename of files containing A, B, C, and optionally D and E.
cont_time
True if the system is continuous-time, otherwise False.
input_id
Id of the input space.
state_id
Id of the state space.
output_id
Id of the output space.
solver_options
The solver options to use to solve the Lyapunov equations.
estimator
An error estimator for the problem. This can be any object with an estimate(U, mu, model) method. If estimator is not None, an estimate(U, mu) method is added to the model which will call estimator.estimate(U, mu, self).
visualizer
A visualizer for the problem. This can be any object with a visualize(U, model, ...) 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.
cache_region
None or name of the cache region to use. See pymor.core.cache.
name
Name of the system.

Returns

lti
The LTIModel with operators A, B, C, D, and E.
classmethod from_files(A_file, B_file, C_file, D_file=None, E_file=None, cont_time=True, input_id='INPUT', state_id='STATE', output_id='OUTPUT', solver_options=None, estimator=None, visualizer=None, cache_region='memory', name=None)[source]

Create LTIModel from matrices stored in separate files.

Parameters

A_file
The name of the file (with extension) containing A.
B_file
The name of the file (with extension) containing B.
C_file
The name of the file (with extension) containing C.
D_file
None or the name of the file (with extension) containing D.
E_file
None or the name of the file (with extension) containing E.
cont_time
True if the system is continuous-time, otherwise False.
input_id
Id of the input space.
state_id
Id of the state space.
output_id
Id of the output space.
solver_options
The solver options to use to solve the Lyapunov equations.
estimator
An error estimator for the problem. This can be any object with an estimate(U, mu, model) method. If estimator is not None, an estimate(U, mu) method is added to the model which will call estimator.estimate(U, mu, self).
visualizer
A visualizer for the problem. This can be any object with a visualize(U, model, ...) 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.
cache_region
None or name of the cache region to use. See pymor.core.cache.
name
Name of the system.

Returns

lti
The LTIModel with operators A, B, C, D, and E.
classmethod from_mat_file(file_name, cont_time=True, input_id='INPUT', state_id='STATE', output_id='OUTPUT', solver_options=None, estimator=None, visualizer=None, cache_region='memory', name=None)[source]

Create LTIModel from matrices stored in a .mat file.

Parameters

file_name
The name of the .mat file (extension .mat does not need to be included) containing A, B, C, and optionally D and E.
cont_time
True if the system is continuous-time, otherwise False.
input_id
Id of the input space.
state_id
Id of the state space.
output_id
Id of the output space.
solver_options
The solver options to use to solve the Lyapunov equations.
estimator
An error estimator for the problem. This can be any object with an estimate(U, mu, model) method. If estimator is not None, an estimate(U, mu) method is added to the model which will call estimator.estimate(U, mu, self).
visualizer
A visualizer for the problem. This can be any object with a visualize(U, model, ...) 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.
cache_region
None or name of the cache region to use. See pymor.core.cache.
name
Name of the system.

Returns

lti
The LTIModel with operators A, B, C, D, and E.
classmethod from_matrices(A, B, C, D=None, E=None, cont_time=True, input_id='INPUT', state_id='STATE', output_id='OUTPUT', solver_options=None, estimator=None, visualizer=None, cache_region='memory', name=None)[source]

Create LTIModel from matrices.

Parameters

A
The NumPy array or SciPy spmatrix A.
B
The NumPy array or SciPy spmatrix B.
C
The NumPy array or SciPy spmatrix C.
D
The NumPy array or SciPy spmatrix D or None (then D is assumed to be zero).
E
The NumPy array or SciPy spmatrix E or None (then E is assumed to be identity).
cont_time
True if the system is continuous-time, otherwise False.
input_id
Id of the input space.
state_id
Id of the state space.
output_id
Id of the output space.
solver_options
The solver options to use to solve the Lyapunov equations.
estimator
An error estimator for the problem. This can be any object with an estimate(U, mu, model) method. If estimator is not None, an estimate(U, mu) method is added to the model which will call estimator.estimate(U, mu, self).
visualizer
A visualizer for the problem. This can be any object with a visualize(U, model, ...) 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.
cache_region
None or name of the cache region to use. See pymor.core.cache.
name
Name of the system.

Returns

lti
The LTIModel with operators A, B, C, D, and E.
gramian(typ)[source]

Compute a Gramian.

Parameters

typ

The type of the Gramian:

  • 'c_lrcf': low-rank Cholesky factor of the controllability Gramian,
  • 'o_lrcf': low-rank Cholesky factor of the observability Gramian,
  • 'c_dense': dense controllability Gramian,
  • 'o_dense': dense observability Gramian,

Returns

If typ is 'c_lrcf' or 'o_lrcf', then the Gramian factor as a VectorArray from self.A.source. If typ is 'c_dense' or 'o_dense', then the Gramian as a NumPy array.

h2_norm()[source]

Compute the H2-norm of the LTIModel.

hankel_norm()[source]

Compute the Hankel-norm of the LTIModel.

hinf_norm(return_fpeak=False, ab13dd_equilibrate=False)[source]

Compute the H_infinity-norm of the LTIModel.

Parameters

return_fpeak
Should the frequency at which the maximum is achieved should be returned.
ab13dd_equilibrate
Should slycot.ab13dd use equilibration.

Returns

norm
H_infinity-norm.
fpeak
Frequency at which the maximum is achieved (if return_fpeak is True).
hsU()[source]

Left Hankel singular vectors.

Returns

Uh
NumPy array of left singluar vectors.
hsV()[source]

Right Hankel singular vectors.

Returns

Vh
NumPy array of right singluar vectors.
hsv()[source]

Hankel singular values.

Returns

sv
One-dimensional NumPy array of singular values.
poles()[source]

Compute system poles.


class pymor.models.iosys.LinearDelayModel(A, Ad, tau, B, C, D=None, E=None, cont_time=True, estimator=None, visualizer=None, cache_region='memory', name=None)[source]

Bases: pymor.models.iosys.InputStateOutputModel

Class for linear delay systems.

This class describes input-state-output systems given by

E x'(t)
& =
    A x(t)
    + \sum_{i = 1}^q{A_i x(t - \tau_i)}
    + B u(t), \\
y(t)
& =
    C x(t)
    + D u(t),

if continuous-time, or

E x(k + 1)
& =
    A x(k)
    + \sum_{i = 1}^q{A_i x(k - \tau_i)}
    + B u(k), \\
y(k)
& =
    C x(k)
    + D u(k),

if discrete-time, where E, A, A_i, B, C, and D are linear operators.

Parameters

A
The Operator A.
Ad
The tuple of Operators A_i.
tau
The tuple of delay times (positive floats or ints).
B
The Operator B.
C
The Operator C.
D
The Operator D or None (then D is assumed to be zero).
E
The Operator E or None (then E is assumed to be identity).
cont_time
True if the system is continuous-time, otherwise False.
estimator
An error estimator for the problem. This can be any object with an estimate(U, mu, model) method. If estimator is not None, an estimate(U, mu) method is added to the model which will call estimator.estimate(U, mu, self).
visualizer
A visualizer for the problem. This can be any object with a visualize(U, model, ...) 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.
cache_region
None or name of the cache region to use. See pymor.core.cache.
name
Name of the system.
n

The order of the system (equal to A.source.dim).

q

The number of delay terms.

tau

The tuple of delay times.

A

The Operator A.

Ad

The tuple of Operators A_i.

B

The Operator B.

C

The Operator C.

D

The Operator D.

E

The Operator E.

operators

Dict of all Operators appearing in the model.

eval_dtf(s)[source]

Evaluate the derivative of the transfer function.

The derivative of the transfer function at s is

-C \left(s E - A
        - \sum_{i = 1}^q{e^{-\tau_i s} A_i}\right)^{-1}
    \left(E
        + \sum_{i = 1}^q{\tau_i e^{-\tau_i s} A_i}\right)
    \left(s E - A
        - \sum_{i = 1}^q{e^{-\tau_i s} A_i}\right)^{-1} B.

Note

We assume that either the number of inputs or the number of outputs is much smaller than the order of the system.

Parameters

s
Complex number.

Returns

dtfs
Derivative of transfer function evaluated at the complex number s, NumPy array of shape (self.output_dim, self.input_dim).
eval_tf(s)[source]

Evaluate the transfer function.

The transfer function at s is

C \left(s E - A
    - \sum_{i = 1}^q{e^{-\tau_i s} A_i}\right)^{-1} B
+ D.

Note

We assume that either the number of inputs or the number of outputs is much smaller than the order of the system.

Parameters

s
Complex number.

Returns

tfs
Transfer function evaluated at the complex number s, NumPy array of shape (self.output_dim, self.input_dim).

class pymor.models.iosys.LinearStochasticModel(A, As, B, C, D=None, E=None, cont_time=True, estimator=None, visualizer=None, cache_region='memory', name=None)[source]

Bases: pymor.models.iosys.InputStateOutputModel

Class for linear stochastic systems.

This class describes input-state-output systems given by

E \mathrm{d}x(t)
& =
    A x(t) \mathrm{d}t
    + \sum_{i = 1}^q{A_i x(t) \mathrm{d}\omega_i(t)}
    + B u(t) \mathrm{d}t, \\
y(t)
& =
    C x(t)
    + D u(t),

if continuous-time, or

E x(k + 1)
& =
    A x(k)
    + \sum_{i = 1}^q{A_i x(k) \omega_i(k)}
    + B u(k), \\
y(k)
& =
    C x(k)
    + D u(t),

if discrete-time, where E, A, A_i, B, C, and D are linear operators and \omega_i are stochastic processes.

Parameters

A
The Operator A.
As
The tuple of Operators A_i.
B
The Operator B.
C
The Operator C.
D
The Operator D or None (then D is assumed to be zero).
E
The Operator E or None (then E is assumed to be identity).
cont_time
True if the system is continuous-time, otherwise False.
estimator
An error estimator for the problem. This can be any object with an estimate(U, mu, model) method. If estimator is not None, an estimate(U, mu) method is added to the model which will call estimator.estimate(U, mu, self).
visualizer
A visualizer for the problem. This can be any object with a visualize(U, model, ...) 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.
cache_region
None or name of the cache region to use. See pymor.core.cache.
name
Name of the system.
n

The order of the system (equal to A.source.dim).

q

The number of stochastic processes.

A

The Operator A.

As

The tuple of Operators A_i.

B

The Operator B.

C

The Operator C.

D

The Operator D.

E

The Operator E.

operators

Dictionary of all Operators contained in the model.


class pymor.models.iosys.SecondOrderModel(M, E, K, B, Cp, Cv=None, D=None, cont_time=True, solver_options=None, estimator=None, visualizer=None, cache_region='memory', name=None)[source]

Bases: pymor.models.iosys.InputStateOutputModel

Class for linear second order systems.

This class describes input-output systems given by

M \ddot{x}(t)
+ E \dot{x}(t)
+ K x(t)
& =
    B u(t), \\
y(t)
& =
    C_p x(t)
    + C_v \dot{x}(t)
    + D u(t),

if continuous-time, or

M x(k + 2)
+ E x(k + 1)
+ K x(k)
& =
    B u(k), \\
y(k)
& =
    C_p x(k)
    + C_v x(k + 1)
    + D u(k),

if discrete-time, where M, E, K, B, C_p, C_v, and D are linear operators.

Parameters

M
The Operator M.
E
The Operator E.
K
The Operator K.
B
The Operator B.
Cp
The Operator Cp.
Cv
The Operator Cv or None (then Cv is assumed to be zero).
D
The Operator D or None (then D is assumed to be zero).
cont_time
True if the system is continuous-time, otherwise False.
solver_options
The solver options to use to solve the Lyapunov equations.
estimator
An error estimator for the problem. This can be any object with an estimate(U, mu, model) method. If estimator is not None, an estimate(U, mu) method is added to the model which will call estimator.estimate(U, mu, self).
visualizer
A visualizer for the problem. This can be any object with a visualize(U, model, ...) 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.
cache_region
None or name of the cache region to use. See pymor.core.cache.
name
Name of the system.
n

The order of the system (equal to M.source.dim).

M

The Operator M.

E

The Operator E.

K

The Operator K.

B

The Operator B.

Cp

The Operator Cp.

Cv

The Operator Cv.

D

The Operator D.

operators

Dictionary of all Operators contained in the model.

__add__(other)[source]

Add a SecondOrderModel or an LTIModel.

__mul__(other)[source]

Postmultiply by a SecondOrderModel or an LTIModel.

__neg__()[source]

Negate the SecondOrderModel.

__radd__(other)[source]

Add to an LTIModel.

__rmul__(other)[source]

Premultiply by an LTIModel.

__rsub__(other)[source]

Subtract from an LTIModel.

__sub__(other)[source]

Subtract a SecondOrderModel or an LTIModel.

eval_dtf(s)[source]

Evaluate the derivative of the transfer function.

s C_v (s^2 M + s E + K)^{-1} B
- (C_p + s C_v) (s^2 M + s E + K)^{-1} (2 s M + E)
    (s^2 M + s E + K)^{-1} B.

Note

We assume that either the number of inputs or the number of outputs is much smaller than the order of the system.

Parameters

s
Complex number.

Returns

dtfs
Derivative of transfer function evaluated at the complex number s, NumPy array of shape (self.output_dim, self.input_dim).
eval_tf(s)[source]

Evaluate the transfer function.

The transfer function at s is

(C_p + s C_v) (s^2 M + s E + K)^{-1} B + D.

Note

We assume that either the number of inputs or the number of outputs is much smaller than the order of the system.

Parameters

s
Complex number.

Returns

tfs
Transfer function evaluated at the complex number s, NumPy array of shape (self.output_dim, self.input_dim).
classmethod from_matrices(M, E, K, B, Cp, Cv=None, D=None, cont_time=True, input_id='INPUT', state_id='STATE', output_id='OUTPUT', solver_options=None, estimator=None, visualizer=None, cache_region='memory', name=None)[source]

Create a second order system from matrices.

Parameters

M
The NumPy array or SciPy spmatrix M.
E
The NumPy array or SciPy spmatrix E.
K
The NumPy array or SciPy spmatrix K.
B
The NumPy array or SciPy spmatrix B.
Cp
The NumPy array or SciPy spmatrix Cp.
Cv
The NumPy array or SciPy spmatrix Cv or None (then Cv is assumed to be zero).
D
The NumPy array or SciPy spmatrix D or None (then D is assumed to be zero).
cont_time
True if the system is continuous-time, otherwise False.
solver_options
The solver options to use to solve the Lyapunov equations.
estimator
An error estimator for the problem. This can be any object with an estimate(U, mu, model) method. If estimator is not None, an estimate(U, mu) method is added to the model which will call estimator.estimate(U, mu, self).
visualizer
A visualizer for the problem. This can be any object with a visualize(U, model, ...) 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.
cache_region
None or name of the cache region to use. See pymor.core.cache.
name
Name of the system.

Returns

lti
The SecondOrderModel with operators M, E, K, B, Cp, Cv, and D.
gramian(typ)[source]

Compute a second-order Gramian.

Parameters

typ

The type of the Gramian:

  • 'pc_lrcf': low-rank Cholesky factor of the position controllability Gramian,
  • 'vc_lrcf': low-rank Cholesky factor of the velocity controllability Gramian,
  • 'po_lrcf': low-rank Cholesky factor of the position observability Gramian,
  • 'vo_lrcf': low-rank Cholesky factor of the velocity observability Gramian,
  • 'pc_dense': dense position controllability Gramian,
  • 'vc_dense': dense velocity controllability Gramian,
  • 'po_dense': dense position observability Gramian,
  • 'vo_dense': dense velocity observability Gramian,

Returns

If typ is 'pc_lrcf', 'vc_lrcf', 'po_lrcf' or 'vo_lrcf', then the Gramian factor as a VectorArray from self.M.source. If typ is 'pc_dense', 'vc_dense', 'po_dense' or 'vo_dense', then the Gramian as a NumPy array.

h2_norm()[source]

Compute the H2-norm.

hankel_norm()[source]

Compute the Hankel-norm.

hinf_norm(return_fpeak=False, ab13dd_equilibrate=False)[source]

Compute the H_infinity-norm.

Parameters

return_fpeak
Should the frequency at which the maximum is achieved should be returned.
ab13dd_equilibrate
Should slycot.ab13dd use equilibration.

Returns

norm
H_infinity-norm.
fpeak
Frequency at which the maximum is achieved (if return_fpeak is True).
poles()[source]

Compute system poles.

psv()[source]

Position singular values.

Returns

One-dimensional NumPy array of singular values.

pvsv()[source]

Position-velocity singular values.

Returns

One-dimensional NumPy array of singular values.

to_lti()[source]

Return a first order representation.

The first order representation

\begin{bmatrix}
    I & 0 \\
    0 & M
\end{bmatrix}
\frac{\mathrm{d}}{\mathrm{d}t}\!
\begin{bmatrix}
    x(t) \\
    \dot{x}(t)
\end{bmatrix}
& =
\begin{bmatrix}
    0 & I \\
    -K & -E
\end{bmatrix}
\begin{bmatrix}
    x(t) \\
    \dot{x}(t)
\end{bmatrix}
+
\begin{bmatrix}
    0 \\
    B
\end{bmatrix}
u(t), \\
y(t)
& =
\begin{bmatrix}
    C_p & C_v
\end{bmatrix}
\begin{bmatrix}
    x(t) \\
    \dot{x}(t)
\end{bmatrix}
+ D u(t)

is returned.

Returns

lti
|LTISystem| equivalent to the second order system.
vpsv()[source]

Velocity-position singular values.

Returns

One-dimensional NumPy array of singular values.

vsv()[source]

Velocity singular values.

Returns

One-dimensional NumPy array of singular values.


class pymor.models.iosys.TransferFunction(input_space, output_space, H, dH, cont_time=True, cache_region='memory', name=None)[source]

Bases: pymor.models.iosys.InputOutputModel

Class for systems represented by a transfer function.

This class describes input-output systems given by a transfer function H(s).

Parameters

input_space
The input VectorSpace. Typically NumpyVectorSpace(m, 'INPUT') where m is the number of inputs.
output_space
The output VectorSpace. Typically NumpyVectorSpace(p, 'OUTPUT') where p is the number of outputs.
H
The transfer function defined at least on the open right complex half-plane. H(s) is a NumPy array of shape (p, m).
dH
The complex derivative of H.
cont_time
True if the system is continuous-time, otherwise False.
cache_region
None or name of the cache region to use. See pymor.core.cache.
name
Name of the system.
tf

The transfer function.

dtf

The complex derivative of the transfer function.

eval_dtf(s)[source]

Evaluate the derivative of the transfer function.

eval_tf(s)[source]

Evaluate the transfer function.

mpi module


class pymor.models.mpi.MPIModel(obj_id, operators, products=None, pickle_local_spaces=True, space_type=<class 'pymor.vectorarrays.mpi.MPIVectorSpace'>)[source]

Bases: pymor.models.basic.ModelBase

Wrapper class for MPI distributed Models.

Given a single-rank implementation of a Model, this wrapper class uses the event loop from pymor.tools.mpi to allow an MPI distributed usage of the Model. The underlying implementation needs to be MPI aware. In particular, the model’s solve method has to perform an MPI parallel solve of the model.

Note that this class is not intended to be instantiated directly. Instead, you should use mpi_wrap_model.

Parameters

obj_id
ObjectId of the local Model on each rank.
operators
Dictionary of all Operators contained in the model, wrapped for use on rank 0. Use mpi_wrap_model to automatically wrap all operators of a given MPI-aware Model.
products
See operators.
pickle_local_spaces
See MPIOperator.
space_type
See MPIOperator.

class pymor.models.mpi.MPIVisualizer(m_obj_id)[source]

Bases: pymor.core.interfaces.ImmutableInterface


pymor.models.mpi.mpi_wrap_model(local_models, use_with=False, with_apply2=False, pickle_local_spaces=True, space_type=<class 'pymor.vectorarrays.mpi.MPIVectorSpace'>)[source]

Wrap MPI distributed local Models to a global Model on rank 0.

Given MPI distributed local Models referred to by the ObjectId local_models, return a new Model which manages these distributed models from rank 0. This is done by first wrapping all Operators of the Model using mpi_wrap_operator.

Alternatively, local_models can be a callable (with no arguments) which is then called on each rank to instantiate the local Models.

When use_with is False, an MPIModel is instantiated with the wrapped operators. A call to solve will then use an MPI parallel call to the solve methods of the wrapped local Models to obtain the solution. This is usually what you want when the actual solve is performed by an implementation in the external solver.

When use_with is True, with_ is called on the local Model on rank 0, to obtain a new Model with the wrapped MPI Operators. This is mainly useful when the local models are generic Models as in pymor.models.basic and solve is implemented directly in pyMOR via operations on the contained Operators.

Parameters

local_models
ObjectId of the local Models on each rank or a callable generating the Models.
use_with
See above.
with_apply2
See MPIOperator.
pickle_local_spaces
See MPIOperator.
space_type
See MPIOperator.