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¶
Generate data for empirical interpolation using EI-Greedy algorithm. |
|
Generate data for empirical interpolation using DEIM algorithm. |
|
Empirical operator interpolation using the EI-Greedy/DEIM algorithm. |
|
Parameter separable approximation of a |
|
- 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
VectorArrayU, 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
Uis added to the collateral basis.Parameters
- U
A
VectorArrayof 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,Uwill be modified during executing of the algorithm.- pool
If not
None, theWorkerPoolto use for parallelization.
Returns
- interpolation_dofs
NumPy arrayof the DOFs at which the vectors are evaluated.- collateral_basis
VectorArraycontaining 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 arrayof coefficients such thatcollateral_basisis given byU.lincomb(coefficients).- interpolation_matrix
The interpolation matrix, i.e., the evaluation of
collateral_basisatinterpolation_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
VectorArrayU, 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
podmodes ofU.Parameters
- U
A
VectorArrayof 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 ofUto obtain the collateral basis. IfFalse,Uis used as collateral basis.- atol
Absolute POD tolerance.
- rtol
Relative POD tolerance.
- product
Inner product
Operatorused for the POD.- pod_options
Dictionary of additional options to pass to the
podalgorithm.
Returns
- interpolation_dofs
NumPy arrayof the DOFs at which the vectors are interpolated.- collateral_basis
VectorArraycontaining 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_greedyordeim. 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 createEmpiricalInterpolatedOperatorsand 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
operatorsdict of the model. The correspondingOperatorswill be interpolated.- parameter_sample
A list of
Parametersfor 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
podalgorithm. Has no effect ifalg == 'ei_greedy'.- alg
Either
ei_greedyordeim.- pool
If not
None, theWorkerPoolto use for parallelization.
Returns
- eim
ModelwithOperatorsgiven byoperator_namesreplaced byEmpiricalInterpolatedOperators.- data
Dict containing the following fields:
- dofs
NumPy arrayof the DOFs at which theOperatorshave to be evaluated.- basis
VectorArraycontaining the generated collateral basis.
In addition,
datacontains the fields of thedatadictreturned byei_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
Functionusing Empiricial Interpolation.This method computes a parameter separated
LincombFunctionapproximating the inputFunctionusing 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 anEmpiricalInterpolatedFunctionfrom the data returned byei_greedy.Note
If possible, choose
evaluation_pointsidentical to the coordinates at which the interpolated function is going to be evaluated. Otherwisefunctionwill have to be re-evaluated at all new evaluation points for allparameter valuesgiven byparameter_sample.Parameters
- function
The function to interpolate.
- parameter_sample
A list of
Parametersfor whichfunctionis evaluated to generate the training data.- evaluation_points
NumPy arrayof coordinates at whichfunctionshould 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
EmpiricalInterpolatedFunctiongiving the parameter separable approximation offunction.- data
dictof additional data as returned byei_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]¶