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¶
- 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 inU
. The returned objects can be used to instantiate anEmpiricalInterpolatedOperator
(withtriangular=False
).The collateral basis is determined by the first
pod
modes ofU
.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 ofU
to obtain the collateral basis. IfFalse
,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.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 inU
. The returned objects can be used to instantiate anEmpiricalInterpolatedOperator
(withtriangular=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
, theWorkerPool
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 interpolation matrix coefficients in the upper triangle (should be near zero).
- coefficients:
NumPy array
of coefficients such thatcollateral_basis
is given byU.lincomb(coefficients)
.- interpolation_matrix:
The interpolation matrix, i.e., the evaluation of
collateral_basis
atinterpolation_dofs
.
- 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 Empirical Interpolation.This method computes a parameter separated
LincombFunction
approximating the inputFunction
using Empirical Interpolation :cite`BMNP04`. The actual EI Greedy algorithm is contained inei_greedy
. This function acts as a convenience wrapper, which computes the training data and constructs anEmpiricalInterpolatedFunction
from the data returned byei_greedy
.Note
If possible, choose
evaluation_points
identical to the coordinates at which the interpolated function is going to be evaluated. Otherwisefunction
will have to be re-evaluated at all new evaluation points for allparameter values
given byparameter_sample
.Parameters
- function
The function to interpolate.
- parameter_sample
A list of
Parameters
for whichfunction
is evaluated to generate the training data.- evaluation_points
NumPy array
of coordinates at whichfunction
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 offunction
.- data
dict
of additional data as returned byei_greedy
.
- 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
ordeim
. Given aModel
, names ofOperators
, and a sample ofParameters
, first the operators are evaluated on the solution snapshots of the model for the provided parameters. These evaluations are then used as input forei_greedy
/deim
. Finally the resulting interpolation data is used to createEmpiricalInterpolatedOperators
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
- operator_names
List of keys in the
operators
dict of the model. The correspondingOperators
will be interpolated.- parameter_sample
A list of
Parameters
for which solution snapshots are calculated.- error_norm
See
ei_greedy
. Has no effect ifalg == 'deim'
.- product
Inner product for POD computation in
deim
. Has no effect ifalg == '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 ifalg == 'ei_greedy'
.- alg
Either
ei_greedy
ordeim
.- pool
If not
None
, theWorkerPool
to use for parallelization.
Returns
- eim
Model
withOperators
given byoperator_names
replaced byEmpiricalInterpolatedOperators
.- data
Dict containing the following fields:
- dofs:
NumPy array
of the DOFs at which theOperators
have to be evaluated.- basis:
VectorArray
containing the generated collateral basis.
In addition,
data
contains the fields of thedata
dict
returned byei_greedy
/deim
.