pymor.algorithms.ei

This module contains algorithms for the empirical interpolation of Operators.

The main work for generating the necessary interpolation data is handled by the ei_greedy method. The objects returned by this method can be used to instantiate an EmpiricalInterpolatedOperator.

As a convenience, the interpolate_operators method allows to perform the empirical interpolation of the Operators of a given model with a single function call.

Module Contents

Functions

ei_greedy

Generate data for empirical interpolation using EI-Greedy algorithm.

deim

Generate data for empirical interpolation using DEIM algorithm.

interpolate_operators

Empirical operator interpolation using the EI-Greedy/DEIM algorithm.

interpolate_function

Parameter separable approximation of a Function using Empiricial Interpolation.

_interpolate_operators_build_evaluations

_parallel_ei_greedy

_parallel_ei_greedy_get_empty

_parallel_ei_greedy_initialize

_parallel_ei_greedy_get_vector

_parallel_ei_greedy_update

_identity

pymor.algorithms.ei.ei_greedy(U, error_norm=None, atol=None, rtol=None, max_interpolation_dofs=None, nodal_basis=False, copy=True, pool=dummy_pool)[source]

Generate data for empirical interpolation using EI-Greedy algorithm.

Given a VectorArray U, this method generates a collateral basis and interpolation DOFs for empirical interpolation of the vectors contained in U. The returned objects can be used to instantiate an EmpiricalInterpolatedOperator (with triangular=True).

The interpolation data is generated by a greedy search algorithm, where in each loop iteration the worst approximated vector in U is added to the collateral basis.

Parameters

U

A VectorArray of vectors to interpolate.

error_norm

Norm w.r.t. which to calculate the interpolation error. If None, the Euclidean norm is used. If 'sup', the sup-norm of the dofs is used.

atol

Stop the greedy search if the largest approximation error is below this threshold.

rtol

Stop the greedy search if the largest relative approximation error is below this threshold.

max_interpolation_dofs

Stop the greedy search if the number of interpolation DOF (= dimension of the collateral basis) reaches this value.

nodal_basis

If True, a nodal interpolation basis is constructed. Note that nodal bases are not hierarchical. Their construction involves the inversion of the associated interpolation matrix, which might lead to decreased numerical accuracy.

copy

If False, U will be modified during executing of the algorithm.

pool

If not None, the WorkerPool to use for parallelization.

Returns

interpolation_dofs

NumPy array of the DOFs at which the vectors are evaluated.

collateral_basis

VectorArray containing the generated collateral basis.

data

Dict containing the following fields:

errors

Sequence of maximum approximation errors during greedy search.

triangularity_errors

Sequence of maximum absolute values of interoplation matrix coefficients in the upper triangle (should be near zero).

coefficients

NumPy array of coefficients such that collateral_basis is given by U.lincomb(coefficients).

interpolation_matrix

The interpolation matrix, i.e., the evaluation of collateral_basis at interpolation_dofs.

pymor.algorithms.ei.deim(U, modes=None, pod=True, atol=None, rtol=None, product=None, pod_options={})[source]

Generate data for empirical interpolation using DEIM algorithm.

Given a VectorArray U, this method generates a collateral basis and interpolation DOFs for empirical interpolation of the vectors contained in U. The returned objects can be used to instantiate an EmpiricalInterpolatedOperator (with triangular=False).

The collateral basis is determined by the first pod modes of U.

Parameters

U

A VectorArray of vectors to interpolate.

modes

Dimension of the collateral basis i.e. number of POD modes of the vectors in U.

pod

If True, perform a POD of U to obtain the collateral basis. If False, U is used as collateral basis.

atol

Absolute POD tolerance.

rtol

Relative POD tolerance.

product

Inner product Operator used for the POD.

pod_options

Dictionary of additional options to pass to the pod algorithm.

Returns

interpolation_dofs

NumPy array of the DOFs at which the vectors are interpolated.

collateral_basis

VectorArray containing the generated collateral basis.

data

Dict containing the following fields:

svals

POD singular values.

pymor.algorithms.ei.interpolate_operators(fom, operator_names, parameter_sample, error_norm=None, product=None, atol=None, rtol=None, max_interpolation_dofs=None, pod_options={}, alg='ei_greedy', pool=dummy_pool)[source]

Empirical operator interpolation using the EI-Greedy/DEIM algorithm.

This is a convenience method to facilitate the use of ei_greedy or deim. Given a Model, names of Operators, and a sample of Parameters, first the operators are evaluated on the solution snapshots of the model for the provided parameters. These evaluations are then used as input for ei_greedy/deim. Finally the resulting interpolation data is used to create EmpiricalInterpolatedOperators and a new model with the interpolated operators is returned.

Note that this implementation creates one common collateral basis for all specified operators, which might not be what you want.

Parameters

fom

The Model whose Operators will be interpolated.

operator_names

List of keys in the operators dict of the model. The corresponding Operators will be interpolated.

parameter_sample

A list of Parameters for which solution snapshots are calculated.

error_norm

See ei_greedy. Has no effect if alg == 'deim'.

product

Inner product for POD computation in deim. Has no effect if alg == 'ei_greedy'.

atol

See ei_greedy.

rtol

See ei_greedy.

max_interpolation_dofs

See ei_greedy.

pod_options

Further options for pod algorithm. Has no effect if alg == 'ei_greedy'.

alg

Either ei_greedy or deim.

pool

If not None, the WorkerPool to use for parallelization.

Returns

eim

Model with Operators given by operator_names replaced by EmpiricalInterpolatedOperators.

data

Dict containing the following fields:

dofs

NumPy array of the DOFs at which the Operators have to be evaluated.

basis

VectorArray containing the generated collateral basis.

In addition, data contains the fields of the data dict returned by ei_greedy/deim.

pymor.algorithms.ei.interpolate_function(function, parameter_sample, evaluation_points, atol=None, rtol=None, max_interpolation_dofs=None)[source]

Parameter separable approximation of a Function using Empiricial Interpolation.

This method computes a parameter separated LincombFunction approximating the input Function using Empirical Interpolation :cite`BMNP04`. The actual EI Greedy algorithm is contained in ei_greedy. This function acts as a convenience wrapper, which computes the training data and constructs an EmpiricalInterpolatedFunction from the data returned by ei_greedy.

Note

If possible, choose evaluation_points identical to the coordinates at which the interpolated function is going to be evaluated. Otherwise function will have to be re-evaluated at all new evaluation points for all parameter values given by parameter_sample.

Parameters

function

The function to interpolate.

parameter_sample

A list of Parameters for which function is evaluated to generate the training data.

evaluation_points

NumPy array of coordinates at which function should be evaluated to generate the training data.

atol

See ei_greedy.

rtol

See ei_greedy.

max_interpolation_dofs

See ei_greedy.

Returns

ei_function

The EmpiricalInterpolatedFunction giving the parameter separable approximation of function.

data

dict of additional data as returned by ei_greedy.

pymor.algorithms.ei._interpolate_operators_build_evaluations(mu, fom=None, operators=None, evaluations=None)[source]
pymor.algorithms.ei._parallel_ei_greedy(U, pool, error_norm=None, atol=None, rtol=None, max_interpolation_dofs=None, nodal_basis=False, copy=True)[source]
pymor.algorithms.ei._parallel_ei_greedy_get_empty(U=None)[source]
pymor.algorithms.ei._parallel_ei_greedy_initialize(U=None, error_norm=None, copy=None, data=None)[source]
pymor.algorithms.ei._parallel_ei_greedy_get_vector(data=None)[source]
pymor.algorithms.ei._parallel_ei_greedy_update(new_vec=None, new_dof=None, data=None)[source]
pymor.algorithms.ei._identity(x)[source]