qmat.qcoeffο
Defines the base abstract class to generate \(Q\)-coefficients (Butcher tables) :
the QGenerator π
Each submodule contains specializations of this class for many kind of methods :
collocation: Collocation basedbutcher: Runge-Kutta based (Butcher tables)
Submodulesο
Attributesο
Dictionary containing all specialized |
Classesο
Base abstract class for all \(Q\)-coefficients generators |
Functionsο
|
Class decorator to register a specialized |
|
Generate \(Q\)-coefficients for a given method |
Package Contentsο
- class QGenerator[source]ο
Base abstract class for all \(Q\)-coefficients generators
- classmethod getInstance()[source]ο
Provide an instance of this QGenerator using default parameters.
- abstract property nodesο
Nodes \(\tau\) (\(c\) coefficients in Butcher table)
- abstract property Qο
\(Q\) coefficients (\(A\) Butcher table)
- abstract property weightsο
Weights \(\omega\) (\(b\) coefficients in Butcher table)
- abstract property weightsEmbeddedο
Weights for a secondary lower order method from the same stages.
- property nNodes: intο
Number of nodes (or stages) for this QGenerator
- property rightIsNode: boolο
Wether or not the last nodes is the right boundary
- property T: numpy.ndarrayο
Transfer matrix from zero-to-nodes to node-to-node
- property S: numpy.ndarrayο
Quadrature matrix in node to node (N2N)
- property Tinv: numpy.ndarrayο
Transfer matrix from node-to-node to zero-to-node
- property hCoeffs: numpy.ndarrayο
\(h\) interpolation coefficients for the right boundary
- genCoeffs(form='Z2N', hCoeffs=False, embedded=False)[source]ο
Generate \(Q\)-coefficients of this
QGeneratorobject.- Parameters:
form (str, optional) β Write coefficients in zero-to-nodes (Z2N) or node-to-node (N2N). The default is βZ2Nβ.
hCoeffs (bool, optional) β Wether or not returning the \(h\) coefficients. The default is False.
embedded (bool, optional) β Wether or not returning the embedded \(h\) coefficients. The default is False.
- Returns:
out β Contains (nodes, weights, Q). If hCoeffs=True, returns (nodes, weights, Q, hCoeffs). If embedded=True, weights is a 2xM array containing embedded weights in weights[1].
- Return type:
tuple
- abstract property orderο
Global convergence order of the method
- property orderEmbedded: intο
Global convergence order of the associated embedded method
- solveDahlquist(lam, u0, tEnd, nSteps, useEmbeddedWeights=False)[source]ο
Solve the Dahlquist test problem
\[\frac{du}{dt} = \lambda u, \quad t \in [0, T], \quad u(0)=u_0\]- Parameters:
lam (complex or float) β The \(\lambda\) coefficient.
u0 (complex or float) β The initial solution \(u_0\).
tEnd (float) β Final time \(T\).
nSteps (int) β Number of time-step for the whole \([0,T]\) interval.
useEmbeddedWeights (bool, optional) β Wether or not use the embedded weights for the step update. The default is False.
- Returns:
uNum β Array containing the nSteps+1 solutions \(\{u(0), ..., u(T)\}\).
- Return type:
np.ndarray
- errorDahlquist(lam, u0, tEnd, nSteps, uNum=None, useEmbeddedWeights=False)[source]ο
Compute \(L_\infty\) error in time for the Dahlquist problem
- Parameters:
lam (complex or float) β The \(\lambda\) coefficient.
u0 (complex or float) β The initial solution \(u_0\).
tEnd (float) β Final time \(T\).
nSteps (int) β Number of time-step for the whole \([0,T]\) interval.
uNum (np.ndarray, optional) β Numerical solution, if not provided use the solveDahlquist method to compute the solution. The default is None.
useEmbeddedWeights (bool, optional) β Wether or not use the embedded weights for the step update. The default is False.
- Returns:
The \(L_\infty\) norm.
- Return type:
float
- Q_GENERATORS: dict[str, type[QGenerator]]ο
Dictionary containing all specialized
QGeneratorclasses, with all their aliases
- register(cls: type[T]) type[T][source]ο
Class decorator to register a specialized
QGeneratorclass in qmat
- genQCoeffs(qType, form='Z2N', hCoeffs=False, embedded=False, **params)[source]ο
Generate \(Q\)-coefficients for a given method
- Parameters:
qType (str) β Name (or alias) of the QGenerator.
form (str, optional) β Write coefficients in zero-to-nodes (Z2N) or node-to-node (N2N). The default is βZ2Nβ.
hCoeffs (bool, optional) β Wether or not returning the \(h\) coefficients. The default is False.
embedded (bool, optional) β Wether or not returning the embedded \(h\) coefficients. The default is False.
**params β Parameters to be used to instantiate the QGenerator.
- Returns:
out β Contains (nodes, weights, Q). If hCoeffs=True, returns (nodes, weights, Q, hCoeffs). If embedded=True, weights is a 2xM array containing embedded weights in weights[1].
- Return type:
tuple