simulai.math package
Submodules
simulai.math.differentiation module
- class simulai.math.differentiation.CenteredDerivative(config: Optional[dict] = None)[source]
Bases:
object
- class simulai.math.differentiation.CollocationDerivative(config: Optional[dict] = None)[source]
Bases:
object
- interpolate_and_solve(data: ~typing.Optional[~numpy.ndarray] = None, x_grid: ~typing.Optional[~numpy.ndarray] = None, x: ~typing.Optional[~numpy.ndarray] = None) -> (<class 'numpy.ndarray'>, <class 'numpy.ndarray'>)[source]
Performing collocation differentiation
- Parameters
data (np.ndarray) – values to be differentiated
x_grid (np.ndarray) – the grid in which the input is defined
x – the grid in which to interpolate the input
- Returns
a pair (interpolated, derivated)
- Return type
(np.ndarray, np.ndarray)
- solve(data: Optional[ndarray] = None, x: Optional[ndarray] = None) ndarray [source]
Performing collocation differentiation
- Parameters
data (np.ndarray) – values to be differentiated
x – the axis to be used for executing the differentiation (Optional)
- Returns
the derivatives of the input data along the chosen axis
- Return type
np.ndarray
- class simulai.math.differentiation.Derivative[source]
Bases:
object
Parent class for the derivative operations It is used for identification purposes
- class simulai.math.differentiation.LeleDerivative(N: int = 1, h: float = 1)[source]
Bases:
object
- delta_0(j: int, N: int, h: float) float [source]
term delta_0 from the Lele’s expression
- Parameters
j (int) – node index
N (int) – total number of nodes
h (float) – mesh discretization size
- Returns
the evaluation of delta_0
- Return type
float
- delta_1(j: int, N: int) float [source]
term delta_1 from the Lele’s expression
- Parameters
j (int) – node index
N (int) – total number of nodes
- Returns
the evaluation of delta_1
- Return type
float
- delta_2(j: int, N: int) float [source]
term delta_2 from the Lele’s expression
- Parameters
j (int) – node index
N (int) – total number of nodes
- Returns
the evaluation of delta_2
- Return type
float
- delta_3(j: int, N: int, h: float) float [source]
term delta_3 from the Lele’s expression
- Parameters
j (int) – node index
N (int) – total number of nodes
h (float) – mesh discretization size
- Returns
the evaluation of delta_3
- Return type
float
- delta_4(j: int, N: int, h: float) float [source]
term delta_4 from the Lele’s expression
- Parameters
j (int) – node index
N (int) – total number of nodes
h (float) – mesh discretization size
- Returns
the evaluation of delta_4
- Return type
float
- class simulai.math.differentiation.SpaceDerivative[source]
Bases:
Derivative
- class simulai.math.differentiation.TimeDerivative[source]
Bases:
Derivative
Numerical time derivative based on centered differences.
simulai.math.expressions module
- class simulai.math.expressions.FromSymbol2FLambda(engine: str = 'numpy', variables: Optional[List[str]] = None)[source]
Bases:
object
- convert(expression: Optional[str] = None) callable [source]
It receives a string mathematical expression and converts it into a callable function
- Parameters
expression (str) – a string containing the mathematical expression definition
- Returns
a callable function equivalent to the string expression
:rtype function
simulai.math.filtering module
- class simulai.math.filtering.SVDThreshold[source]
Bases:
object
- Marcenko_Pastur_integral(t: float, beta: Optional[float] = None) float [source]
Marcenko-Pastur Integral
- Parameters
t (float) – integration variable
beta (float) – parameter beta
- Returns
evaluation of the Marcenko-Pastur integral
- Return type
float
- MedianMarcenkoPastur(beta: float) float [source]
Marcenko-Pastur Median
- Parameters
beta (float) – parameter beta
- Returns
evaluation of the Marcenko-Pastur median
- Return type
float
- exec(singular_values: Optional[ndarray] = None, data_shape: Optional[Union[tuple, list]] = None, gamma: Optional[float] = None) ndarray [source]
- class simulai.math.filtering.TimeAveraging(batch_size: Optional[int] = None, axis: Optional[int] = None)[source]
Bases:
object
- exec(dataset: Union[ndarray, Dataset], path: Optional[str] = None) Dataset [source]
Executing time-averaging
- Parameters
dataset (Union[np.ndarray, h5py.Dataset]) – The dataset to be time-averaged
path (str) – path to save the output into a HDF5 file
- Returns
HDF5 dataset with the time-averaged original data
- Return type
h5py.Dataset
simulai.math.integration module
- class simulai.math.integration.ExplicitIntegrator(coeffs: ndarray, weights: ndarray, right_operator: callable)[source]
Bases:
Integral
- name = 'int'
- step(variables_state_initial: ~numpy.ndarray, dt: float) -> (<class 'numpy.ndarray'>, <class 'numpy.ndarray'>)[source]
It marches a step in the time-integration :param variables_state_initial: initial state :type variables_state_initial: np.ndarray :param dt: timestep size :type dt: float :returns: the integrated state and its time-derivative :rtype: (np.ndarray, np.ndarray)
- step_with_forcings(variables_state_initial: ~numpy.ndarray, forcing_state: ~numpy.ndarray, dt: float) -> (<class 'numpy.ndarray'>, <class 'numpy.ndarray'>)[source]
It marches a step in the time-integration using a concatenated [variables, forcings] state :param variables_state_initial: initial state :type variables_state_initial: np.ndarray :param forcing_state: the state of the forcing terms :type forcing_state: np.ndarray :param dt: timestep size :type dt: float :returns: the integrated state and its time-derivative :rtype: (np.ndarray, np.ndarray)
- step_with_forcings_separated(variables_state_initial: ~numpy.ndarray, forcing_state: ~numpy.ndarray, dt: float) -> (<class 'numpy.ndarray'>, <class 'numpy.ndarray'>)[source]
It marches a step in the time-integration for variables and forcings being operated separately :param variables_state_initial: initial state :type variables_state_initial: np.ndarray :param forcing_state: the state of the forcing terms :type forcing_state: np.ndarray :param dt: timestep size :type dt: float :returns: the integrated state and its time-derivative :rtype: (np.ndarray, np.ndarray)
- class simulai.math.integration.FunctionWrapper(function: callable, extra_dim: bool = True)[source]
Bases:
object
- class simulai.math.integration.RK4(right_operator)[source]
Bases:
ExplicitIntegrator
- name = 'rk4_int'