Source Code Guide#
This page details the source code class hierarchy.
The source code is stored in src/opinf/
.
Tip
Recommended reading: the Scientific Python Development Guide.
Object-oriented Philosophy#
Python is a highly object-oriented language, which is advantageous for building mathematical software with abstract objects.
One-off routines may be implemented as standalone functions, but in opinf
a class hierarchy is often advantageous.
The opinf
package defines the following main class hierarchies:
Transformer classes are used for normalizing snapshot data (see
opinf.pre
).Basis classes represent the mapping between the full-order state space in \(\RR^{n}\) and the reduced-order state space in \(\RR^{r}\) (see
opinf.basis
)Model classes encapsulate an entire reduced-order model, such as \(\frac{\text{d}}{\text{d}t}\qhat(t) = \Ahat\qhat(t) + \Bhat\u(t)\) or \(\qhat_{j+1} = \Hhat[\qhat_{j} \otimes \qhat_{j}]\). These are the major objects that the user interacts with (see
opinf.models
).Operator classes](../ represent a single operator that forms part of a reduced-order model, e.g., \(\Ahat\q\) or \(\Hhat[\qhat\otimes\qhat]\). Every ROM object has an
operators
attribute that is a list of operator objects (seeopinf.operators
).Solver classes handle the least-squares regression problem at the heart of Operator Inference (see
opinf.lstsq
).
Tip
As you design new classes, take advantage of intermediate classes and inheritance to avoid duplicating code when appropriate.
For example, the operator classes opinf.operators.LinearOperator
and opinf.operators.QuadraticOperator
both inherit from opinf.operators._base._NonparametricOperator
, which handles tasks that are common to all nonparametric operators.
Base Classes#
This section documents private classes that are part of the class hierarchy but are not meant to be instantiated. These are mostly abstract base classes or mixins.
pre
#
TODO
basis
#
TODO
operators
#
Base class for operators that do not depend on external parameters. |
|
Base class for operators that depend on external parameters, i.e., \(\Ophat_\ell(\qhat,\u;\bfmu) = \Ohat_\ell(\bfmu)\d_\ell(\qhat,\u)\). |
|
Base class for parametric operators where the parameter dependence is handled with element-wise interpolation. |
models
#
Base class for all monolithic models. |
|
Base class for nonparametric monolithic models. |
|
Base class for parametric monolithic models. |
|
Base class for parametric monolithic models where all operators MUST be interpolation-based parametric operators. |
lstsq
#
Base class for solvers for the Operator Inference regression problem. |
|
Base solver for regularized linear least-squares problems of the form |