simulai.math package

Submodules

simulai.math.differentiation module

class simulai.math.differentiation.CenteredDerivative(config: Optional[dict] = None)[source]

Bases: object

solve(data: Optional[ndarray] = None, axis: int = 0) ndarray[source]

It solves the centered derivative

Parameters
  • data (np.ndarray) – the values to be differentiated

  • axis (int) – axis to perform the differentiation

Returns

the derivatives of data

Return type

np.ndarray

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

delta_5(j: int, N: int, h: float) float[source]

term delta_5 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_5

Return type

float

solve(f: ndarray) ndarray[source]

Performing Lele differentiation

Parameters

f (np.ndarray) – variable values to be differentiated

Returns

the derivatives of f

Return type

np.ndarray

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

clean_engines() None[source]

Clean all the pre-defined engines

Returns

Nothing

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.HardPositivityLimiting(tol: float = 1e-10)[source]

Bases: object

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

apply(pca: Optional[ROM] = None, data_shape: Optional[Union[tuple, list]] = None) ROM[source]
beta_parameter(shape: Optional[Union[tuple, list]] = None) float[source]
exec(singular_values: Optional[ndarray] = None, data_shape: Optional[Union[tuple, list]] = None, gamma: Optional[float] = None) ndarray[source]
integrand(t: float, beta: Optional[float] = None) ndarray[source]
lambda_function(beta: Optional[float] = None, shape: Optional[Union[tuple, list]] = None) float[source]
lambda_special(beta: Optional[float] = None) float[source]

Evaluating special lambda parameter

Parameters

beta (float) – parameter beta

Returns

special lambda

Return type

float

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

class simulai.math.filtering.TimeSeriesExtremes[source]

Bases: object

Getting up the indices corresponding to the extremes of time-series

apply(gradient_input_data: Optional[ndarray] = None, column: Optional[int] = None)[source]

simulai.math.integration module

class simulai.math.integration.ClassWrapper(class_instance: callable)[source]

Bases: object

eval(input_data: ndarray, t: float) ndarray[source]
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.LSODA(right_operator: callable)[source]

Bases: object

run(current_state: Optional[ndarray] = None, t: Optional[ndarray] = None) ndarray[source]
class simulai.math.integration.RK4(right_operator)[source]

Bases: ExplicitIntegrator

name = 'rk4_int'

simulai.math.kansas module

class simulai.math.kansas.Kansas(points, centers, sigma2='auto', Kernel='gaussian', eps=1e-08)[source]

Bases: object

gen_f1()[source]
get_cross_derivative_matrix(var_index1, var_index2)[source]
get_cross_derivative_matrix_optimized(var_index1, var_index2)[source]
get_first_derivative_matrix(var_index)[source]
get_first_derivative_matrix_aux(var_index)[source]
get_first_derivative_matrix_optimized(var_index)[source]
get_interpolation_matrix()[source]
get_interpolation_matrix_optimized()[source]
get_laplacian_matrix()[source]
get_second_derivative_matrix(var_index)[source]
get_second_derivative_matrix_optimized(var_index)[source]
kernel(r2, sigma2, Kernel_type)[source]
kernel_Dx(r2, rx, sigma2, Kernel_type)[source]
kernel_Dxx(r2, rx2, sigma2, Kernel_type)[source]
kernel_Dxy(r2, rx, ry, sigma2, Kernel_type)[source]
kernel_Laplacian(r2, sigma2, Kernel_type)[source]

simulai.math.products module

simulai.math.products.kronecker(a: ndarray) ndarray[source]

simulai.math.progression module

simulai.math.progression.gp(init, factor, n) list[source]

simulai.math.quadratures module

class simulai.math.quadratures.GaussLegendre(p_order=None)[source]

Bases: object

generate_boundaries(mesh=None)[source]
generate_domain(mesh=None)[source]

simulai.math.spaces module

class simulai.math.spaces.GaussianRandomFields(x_interval=(0, 1), kernel='RBF', length_scale=1, N=None, interp='cubic')[source]

Bases: object

generate_u(features, sensors)[source]
random_u(n_features=None)[source]

Module contents