KarhunenLoeveP1Algorithm

(Source code, png, hires.png, pdf)

../../_images/KarhunenLoeveP1Algorithm.png
class KarhunenLoeveP1Algorithm(*args)

Computation of Karhunen-Loeve decomposition using P1 approximation.

Parameters
meshMesh

The mesh \cD_N that discretizes the domain \cD.

covarianceCovarianceModel

The covariance function to decompose.

sfloat, \geq0

The threshold used to select the most significant eigenmodes, defined in KarhunenLoeveAlgorithm.

Notes

The Karhunen-Loeve P_1 algorithm solves the Fredholm problem associated to the covariance function C: see KarhunenLoeveAlgorithm to get the notations.

The Karhunen-Loeve P_1 approximation uses the P_1 functional basis (\theta_p)_{1 \leq p \leq N} where \theta_p: \cD_N \mapsto \Rset are the basis functions of the P_1 finite element space associated to \cD_N, which vertices are (\vect{s}_i)_{1 \leq i \leq N}.

The covariance function \mat{C} is approximated by its P_1 approximation \hat{\mat{C}} on \cD_N:

\hat{\mat{C}}(\vect{s},\vect{t})=\sum_{\vect{s}_i,\vect{s}_j\in\cV_N}\mat{C}(\vect{s}_i,\vect{s}_j)\theta_i(\vect{s})\theta_j(\vect{t}), \quad  \forall \vect{s},\vect{t}\in\cD_N

The Galerkin approach and the collocation one are equivalent in the P_1 approach and both lead to the following formulation:

\mat{C}\, \mat{G}\, \mat{\Phi}  =   \mat{\Phi}\, \mat{\Lambda}

where \mat{G} = (G_{ij})_{1\leq i,j \leq N} with G_{i\ell}= \int_{\cD} \theta_i(\vect{s})\theta_\ell(\vect{s})\,  d\vect{s}, \mat{\Lambda}=diag(\vect{\lambda}).

Though the eigenvalues computation is performed by LAPACK by default, several other solvers can be used. The solver to use must be specified by setting KarhunenLoeveP1Algorithm-EigenvaluesSolver key in ResourceMap. Some solvers set limits to the number of eigenvalues they can compute with regards to the size of the problem. The following table summarizes the supported solvers and their maximum number of eigenvalues for a problem of size n:

Solver

ResourceMap key

Maximum EV number

Lapack

LAPACK

n

Spectra

SPECTRA

n-2

For large dimension problems, it can be useful to generate the covariance matrix of the problem as a HMatrix instead of a standard dense matrix. In this case, one can set KarhunenLoeveP1Algorithm-CovarianceMatrixStorage key in ResourceMap to HMAT (instead of DENSE).

Examples

Create a Karhunen-Loeve P1 algorithm:

>>> import openturns as ot
>>> mesh = ot.IntervalMesher([10]*2).build(ot.Interval([-1.0]*2, [1.0]*2))
>>> s = 0.01
>>> model = ot.AbsoluteExponential([1.0]*2)
>>> algorithm = ot.KarhunenLoeveP1Algorithm(mesh, model, s)

Run it!

>>> algorithm.run()
>>> result = algorithm.getResult()

Methods

getClassName()

Accessor to the object’s name.

getCovarianceModel()

Accessor to the covariance model.

getId()

Accessor to the object’s id.

getMesh()

Accessor to the mesh.

getName()

Accessor to the object’s name.

getNbModes()

Accessor to number of modes to compute.

getResult()

Get the result structure.

getShadowedId()

Accessor to the object’s shadowed id.

getThreshold()

Accessor to the threshold used to select the most significant eigenmodes.

getVisibility()

Accessor to the object’s visibility state.

hasName()

Test if the object is named.

hasVisibleName()

Test if the object has a distinguishable name.

run()

Computation of the eigenvalues and eigenfunctions values at nodes.

setCovarianceModel(covariance)

Accessor to the covariance model.

setName(name)

Accessor to the object’s name.

setNbModes(nbModes)

Accessor to the maximum number of modes to compute.

setShadowedId(id)

Accessor to the object’s shadowed id.

setThreshold(threshold)

Accessor to the limit ratio on eigenvalues.

setVisibility(visible)

Accessor to the object’s visibility state.

__init__(*args)

Initialize self. See help(type(self)) for accurate signature.

getClassName()

Accessor to the object’s name.

Returns
class_namestr

The object class name (object.__class__.__name__).

getCovarianceModel()

Accessor to the covariance model.

Returns
covModelCovarianceModel

The covariance model.

getId()

Accessor to the object’s id.

Returns
idint

Internal unique identifier.

getMesh()

Accessor to the mesh.

Returns
meshMesh

The mesh \cD_N that discretizes the domain \cD.

getName()

Accessor to the object’s name.

Returns
namestr

The name of the object.

getNbModes()

Accessor to number of modes to compute.

Returns
nint

The maximum number of modes to compute. The actual number of modes also depends on the threshold criterion.

getResult()

Get the result structure.

Returns
resKLKarhunenLoeveResult

The structure containing all the results of the Fredholm problem.

Notes

The structure contains all the results of the Fredholm problem.

getShadowedId()

Accessor to the object’s shadowed id.

Returns
idint

Internal unique identifier.

getThreshold()

Accessor to the threshold used to select the most significant eigenmodes.

Returns
sfloat, positive

The threshold s.

Notes

OpenTURNS truncates the sequence (\lambda_k,  \vect{\varphi}_k)_{k \geq 1} at the index K defined in (3).

getVisibility()

Accessor to the object’s visibility state.

Returns
visiblebool

Visibility flag.

hasName()

Test if the object is named.

Returns
hasNamebool

True if the name is not empty.

hasVisibleName()

Test if the object has a distinguishable name.

Returns
hasVisibleNamebool

True if the name is not empty and not the default one.

run()

Computation of the eigenvalues and eigenfunctions values at nodes.

Notes

Runs the algorithm and creates the result structure KarhunenLoeveResult.

setCovarianceModel(covariance)

Accessor to the covariance model.

Parameters
covModelCovarianceModel

The covariance model.

setName(name)

Accessor to the object’s name.

Parameters
namestr

The name of the object.

setNbModes(nbModes)

Accessor to the maximum number of modes to compute.

Parameters
nint

The maximum number of modes to compute. The actual number of modes also depends on the threshold criterion.

setShadowedId(id)

Accessor to the object’s shadowed id.

Parameters
idint

Internal unique identifier.

setThreshold(threshold)

Accessor to the limit ratio on eigenvalues.

Parameters
sfloat, \geq 0

The threshold s defined in (3).

setVisibility(visible)

Accessor to the object’s visibility state.

Parameters
visiblebool

Visibility flag.