pararealml.operators.fdm package

Submodules

pararealml.operators.fdm.fdm_operator module

class pararealml.operators.fdm.fdm_operator.FDMOperator(integrator: pararealml.operators.fdm.numerical_integrator.NumericalIntegrator, differentiator: pararealml.operators.fdm.numerical_differentiator.NumericalDifferentiator, d_t: float)[source]

Bases: pararealml.operator.Operator

A finite difference method based conventional differential equation solver.

solve(ivp: pararealml.initial_value_problem.InitialValueProblem, parallel_enabled: bool = True) → pararealml.solution.Solution[source]

Returns the IVP’s solution.

Parameters:
  • ivp – the initial value problem to solve
  • parallel_enabled – whether in-time parallelization is enabled
Returns:

the solution of the IVP

pararealml.operators.fdm.fdm_symbol_mapper module

class pararealml.operators.fdm.fdm_symbol_mapper.FDMSymbolMapArg[source]

Bases: tuple

The arguments to the FDM map functions.

d_y_constraint_function

Alias for field number 2

t

Alias for field number 0

y

Alias for field number 1

class pararealml.operators.fdm.fdm_symbol_mapper.FDMSymbolMapper(cp: pararealml.constrained_problem.ConstrainedProblem, differentiator: pararealml.operators.fdm.numerical_differentiator.NumericalDifferentiator)[source]

Bases: pararealml.operators.symbol_mapper.SymbolMapper

A symbol mapper implementation for the FDM operator.

map_concatenated(arg: pararealml.operators.fdm.fdm_symbol_mapper.FDMSymbolMapArg, lhs_type: pararealml.differential_equation.Lhs) → numpy.ndarray[source]

Evaluates the right-hand side of the differential equation system given the map argument and concatenates the resulting sequence of map value arrays along the last axis.

t_map_function() → Callable[[pararealml.operators.fdm.fdm_symbol_mapper.FDMSymbolMapArg], numpy.ndarray][source]

Returns a function for mapping t to a numerical value.

x_map_function(x_axis: int) → Callable[[pararealml.operators.fdm.fdm_symbol_mapper.FDMSymbolMapArg], numpy.ndarray][source]

Returns a function for mapping a component of x to a numerical value.

Parameters:x_axis – the component of x to return a map for
Returns:the mapper function for x
y_curl_map_function(y_indices: Sequence[int], indices_contiguous: Union[bool, numpy.bool_], curl_ind: int) → Callable[[pararealml.operators.fdm.fdm_symbol_mapper.FDMSymbolMapArg], numpy.ndarray][source]

Returns a function for mapping the curl of a set of components of y to a numerical value.

Parameters:
  • y_indices – the components of y whose curl to return a map for
  • indices_contiguous – whether the indices are contiguous
  • curl_ind – the index of the component of the curl to map
Returns:

the mapper function for the curl of y

y_divergence_map_function(y_indices: Sequence[int], indices_contiguous: Union[bool, numpy.bool_]) → Callable[[pararealml.operators.fdm.fdm_symbol_mapper.FDMSymbolMapArg], numpy.ndarray][source]

Returns a function for mapping the divergence of a set of components of y to a numerical value.

Parameters:
  • y_indices – the components of y whose divergence to return a map for
  • indices_contiguous – whether the indices are contiguous
Returns:

the mapper function for the divergence of y

y_gradient_map_function(y_ind: int, x_axis: int) → Callable[[pararealml.operators.fdm.fdm_symbol_mapper.FDMSymbolMapArg], numpy.ndarray][source]

Returns a function for mapping a component of the gradient of y to a numerical value.

Parameters:
  • y_ind – the component of y whose gradient to return a map for
  • x_axis – the x-axis denoting the element of the gradient to return a map for
Returns:

the mapper function for the gradient of y

y_hessian_map_function(y_ind: int, x_axis1: int, x_axis2: int) → Callable[[pararealml.operators.fdm.fdm_symbol_mapper.FDMSymbolMapArg], numpy.ndarray][source]

Returns a function for mapping a component of the Hessian of y to a numerical value.

Parameters:
  • y_ind – the component of y whose Hessian to return a map for
  • x_axis1 – the first x-axis denoting the element of the gradient to return a map for
  • x_axis2 – the second x-axis denoting the element of the gradient to return a map for
Returns:

the mapper function for the Hessian of y

y_laplacian_map_function(y_ind: int) → Callable[[pararealml.operators.fdm.fdm_symbol_mapper.FDMSymbolMapArg], numpy.ndarray][source]

Returns a function for mapping a component of the element-wise scalar Laplacian of y to a numerical value.

Parameters:y_ind – the component of y whose Laplacian to return a mp for
Returns:the mapper function for the Laplacian of y
y_map_function(y_ind: int) → Callable[[pararealml.operators.fdm.fdm_symbol_mapper.FDMSymbolMapArg], numpy.ndarray][source]

Returns a function for mapping a component of y to a numerical value.

Parameters:y_ind – the component of y to return a map for
Returns:the mapper function for y
y_vector_laplacian_map_function(y_indices: Sequence[int], indices_contiguous: Union[bool, numpy.bool_], vector_laplacian_ind: int) → Callable[[pararealml.operators.fdm.fdm_symbol_mapper.FDMSymbolMapArg], numpy.ndarray][source]

Returns a function for mapping the vector Laplacian of a set of components of y to a numerical value.

Parameters:
  • y_indices – the components of y whose vector Laplacian to return a map for
  • indices_contiguous – whether the indices are contiguous
  • vector_laplacian_ind – the index of the component of the vector Laplacian to map
Returns:

the mapper function for the vector Laplacian of y

pararealml.operators.fdm.numerical_differentiator module

class pararealml.operators.fdm.numerical_differentiator.NumericalDifferentiator(tol: float = 0.001)[source]

Bases: abc.ABC

A base class for numerical differentiators.

anti_laplacian(laplacian: numpy.ndarray, mesh: pararealml.mesh.Mesh, y_constraints: Union[Sequence[Optional[pararealml.constraint.Constraint]], numpy.ndarray], derivative_boundary_constraints: Optional[numpy.ndarray] = None, y_init: Optional[numpy.ndarray] = None) → numpy.ndarray[source]

Computes the inverse of the element-wise scalar Laplacian using the Jacobi method.

Parameters:
  • laplacian – the right-hand side of the equation
  • mesh – the mesh representing the discretized spatial domain
  • y_constraints – a sequence of constraints on the values of the solution containing a constraint for each element of y; each constraint must constrain the boundary values of corresponding element of y for the system to be solvable
  • derivative_boundary_constraints – an optional 2D array (x dimension, y dimension) of boundary constraint pairs that specify constraints on the first derivatives of the solution
  • y_init – an optional initial estimate of the solution; if it is None, a random array is used
Returns:

the array representing the solution to Poisson’s equation at every point of the mesh

curl(y: numpy.ndarray, mesh: pararealml.mesh.Mesh, curl_ind: int = 0, derivative_boundary_constraints: Optional[numpy.ndarray] = None) → numpy.ndarray[source]

Computes the curl_ind-th component of the curl of y at every point of the mesh.

Parameters:
  • y – the values of y at every point of the mesh
  • mesh – the mesh representing the discretized spatial domain
  • curl_ind – the index of the component of the curl of y to compute; if y is a two dimensional vector field, it must be 0
  • derivative_boundary_constraints – a 2D array (x dimension, y dimension) of boundary constraint pairs that allow for applying constraints to the calculated first derivatives before using them to compute the curl
Returns:

the curl of y

divergence(y: numpy.ndarray, mesh: pararealml.mesh.Mesh, derivative_boundary_constraints: Optional[numpy.ndarray] = None) → numpy.ndarray[source]

Computes the divergence of y with respect to x at every point of the mesh.

Parameters:
  • y – the values of y at every point of the mesh
  • mesh – the mesh representing the discretized spatial domain
  • derivative_boundary_constraints – a 2D array (x dimension, y dimension) of boundary constraint pairs that allow for applying constraints to the calculated first derivatives before using them to compute the divergence
Returns:

the divergence of y

gradient(y: numpy.ndarray, mesh: pararealml.mesh.Mesh, x_axis: int, derivative_boundary_constraints: Optional[numpy.ndarray] = None) → numpy.ndarray[source]

Computes the column of the Jacobian matrix of y corresponding to the spatial dimension specified by x_axis at every point of the mesh.

Parameters:
  • y – the values of y at every point of the mesh
  • mesh – the mesh representing the discretized spatial domain
  • x_axis – the spatial dimension that y is to be differentiated with respect to
  • derivative_boundary_constraints – a 2D array (x dimension, y dimension) of boundary constraint pairs that allow for applying constraints to the calculated first derivatives
Returns:

the element(s) of the gradient of y corresponding to the specified axis

hessian(y: numpy.ndarray, mesh: pararealml.mesh.Mesh, x_axis1: int, x_axis2: int, derivative_boundary_constraints: Optional[numpy.ndarray] = None) → numpy.ndarray[source]

Computes the column of the Hessian tensor of y corresponding to the spatial dimensions defined by x_axis1 and x_axis2 at every point of the mesh.

Parameters:
  • y – the values of y at every point of the mesh
  • mesh – the mesh representing the discretized spatial domain
  • x_axis1 – the first spatial dimension that y is to be differentiated with respect to
  • x_axis2 – the second spatial dimension that y is to be differentiated with respect to
  • derivative_boundary_constraints – a 2D array (x dimension, y dimension) of boundary constraint pairs that allow for applying constraints to the calculated first derivatives before using them to compute the second derivatives
Returns:

the element(s) of the Hessian of y corresponding to the specified axes

laplacian(y: numpy.ndarray, mesh: pararealml.mesh.Mesh, derivative_boundary_constraints: Optional[numpy.ndarray] = None) → numpy.ndarray[source]

Computes the Laplacian of y at every point of the mesh.

If the last rank of y has a dimension greater than one, the element-wise scalar Laplacian is computed instead of the vector Laplacian (which only makes a difference in curvilinear coordinate systems).

Parameters:
  • y – the values of y at every point of the mesh
  • mesh – the mesh representing the discretized spatial domain
  • derivative_boundary_constraints – a 2D array (x dimension, y dimension) of boundary constraint pairs that allow for applying constraints to the calculated first derivatives before using them to compute the second derivatives and the Laplacian
Returns:

the Laplacian of y

vector_laplacian(y: numpy.ndarray, mesh: pararealml.mesh.Mesh, vector_laplacian_ind: int, derivative_boundary_constraints: Optional[numpy.ndarray] = None) → numpy.ndarray[source]

Computes the vector_laplacian_ind-th component of the vector Laplacian of y at every point of the mesh.

Parameters:
  • y – the values of y at every point of the mesh
  • mesh – the mesh representing the discretized spatial domain
  • vector_laplacian_ind – the index of the component of the vector Laplacian of y to compute
  • derivative_boundary_constraints – a 2D array (x dimension, y dimension) of boundary constraint pairs that allow for applying constraints to the calculated first derivatives before using them to compute the vector Laplacian
Returns:

the vector Laplacian of y

class pararealml.operators.fdm.numerical_differentiator.ThreePointCentralDifferenceMethod(tol: float = 0.001)[source]

Bases: pararealml.operators.fdm.numerical_differentiator.NumericalDifferentiator

A numerical differentiator using a three-point (second order) central difference approximation.

pararealml.operators.fdm.numerical_integrator module

class pararealml.operators.fdm.numerical_integrator.BackwardEulerMethod(tol: float = 1.48e-08, max_iterations: int = 50)[source]

Bases: pararealml.operators.fdm.numerical_integrator.ImplicitMethod

The backward Euler method, an implicit first order Runge-Kutta method.

integral(y: numpy.ndarray, t: float, d_t: float, d_y_over_d_t: Callable[[float, numpy.ndarray], numpy.ndarray], y_constraint_function: Callable[[Optional[float]], Union[Sequence[pararealml.constraint.Constraint], numpy.ndarray, None]]) → numpy.ndarray[source]

Estimates the value of y(t + d_t).

Parameters:
  • y – the value of y(t)
  • t – the value of t
  • d_t – the amount of increase in t
  • d_y_over_d_t – a function that returns the value of y’(t) given t and y
  • y_constraint_function – a function that, given t, returns a sequence of constraints on the values of the solution containing a constraint for each element of y
Returns:

the value of y(t + d_t).

class pararealml.operators.fdm.numerical_integrator.CrankNicolsonMethod(a: float = 0.5, tol: float = 1.48e-08, max_iterations: int = 50)[source]

Bases: pararealml.operators.fdm.numerical_integrator.ImplicitMethod

A first order implicit-explicit method combining the forward and backward Euler methods.

integral(y: numpy.ndarray, t: float, d_t: float, d_y_over_d_t: Callable[[float, numpy.ndarray], numpy.ndarray], y_constraint_function: Callable[[Optional[float]], Union[Sequence[pararealml.constraint.Constraint], numpy.ndarray, None]]) → numpy.ndarray[source]

Estimates the value of y(t + d_t).

Parameters:
  • y – the value of y(t)
  • t – the value of t
  • d_t – the amount of increase in t
  • d_y_over_d_t – a function that returns the value of y’(t) given t and y
  • y_constraint_function – a function that, given t, returns a sequence of constraints on the values of the solution containing a constraint for each element of y
Returns:

the value of y(t + d_t).

class pararealml.operators.fdm.numerical_integrator.ExplicitMidpointMethod[source]

Bases: pararealml.operators.fdm.numerical_integrator.NumericalIntegrator

The explicit midpoint method, a second order Runge-Kutta method.

integral(y: numpy.ndarray, t: float, d_t: float, d_y_over_d_t: Callable[[float, numpy.ndarray], numpy.ndarray], y_constraint_function: Callable[[Optional[float]], Union[Sequence[pararealml.constraint.Constraint], numpy.ndarray, None]]) → numpy.ndarray[source]

Estimates the value of y(t + d_t).

Parameters:
  • y – the value of y(t)
  • t – the value of t
  • d_t – the amount of increase in t
  • d_y_over_d_t – a function that returns the value of y’(t) given t and y
  • y_constraint_function – a function that, given t, returns a sequence of constraints on the values of the solution containing a constraint for each element of y
Returns:

the value of y(t + d_t).

class pararealml.operators.fdm.numerical_integrator.ForwardEulerMethod[source]

Bases: pararealml.operators.fdm.numerical_integrator.NumericalIntegrator

The forward Euler method, an explicit first order Runge-Kutta method.

integral(y: numpy.ndarray, t: float, d_t: float, d_y_over_d_t: Callable[[float, numpy.ndarray], numpy.ndarray], y_constraint_function: Callable[[Optional[float]], Union[Sequence[pararealml.constraint.Constraint], numpy.ndarray, None]]) → numpy.ndarray[source]

Estimates the value of y(t + d_t).

Parameters:
  • y – the value of y(t)
  • t – the value of t
  • d_t – the amount of increase in t
  • d_y_over_d_t – a function that returns the value of y’(t) given t and y
  • y_constraint_function – a function that, given t, returns a sequence of constraints on the values of the solution containing a constraint for each element of y
Returns:

the value of y(t + d_t).

class pararealml.operators.fdm.numerical_integrator.ImplicitMethod(tol: float = 1.48e-08, max_iterations: int = 50)[source]

Bases: pararealml.operators.fdm.numerical_integrator.NumericalIntegrator, abc.ABC

A base class for implicit numerical integrators.

class pararealml.operators.fdm.numerical_integrator.NumericalIntegrator[source]

Bases: abc.ABC

A base class for numerical integrators.

integral(y: numpy.ndarray, t: float, d_t: float, d_y_over_d_t: Callable[[float, numpy.ndarray], numpy.ndarray], y_constraint_function: Callable[[Optional[float]], Union[Sequence[pararealml.constraint.Constraint], numpy.ndarray, None]]) → numpy.ndarray[source]

Estimates the value of y(t + d_t).

Parameters:
  • y – the value of y(t)
  • t – the value of t
  • d_t – the amount of increase in t
  • d_y_over_d_t – a function that returns the value of y’(t) given t and y
  • y_constraint_function – a function that, given t, returns a sequence of constraints on the values of the solution containing a constraint for each element of y
Returns:

the value of y(t + d_t).

class pararealml.operators.fdm.numerical_integrator.RK4[source]

Bases: pararealml.operators.fdm.numerical_integrator.NumericalIntegrator

The RK4 method, an explicit fourth order Runge-Kutta method.

integral(y: numpy.ndarray, t: float, d_t: float, d_y_over_d_t: Callable[[float, numpy.ndarray], numpy.ndarray], y_constraint_function: Callable[[Optional[float]], Union[Sequence[pararealml.constraint.Constraint], numpy.ndarray, None]]) → numpy.ndarray[source]

Estimates the value of y(t + d_t).

Parameters:
  • y – the value of y(t)
  • t – the value of t
  • d_t – the amount of increase in t
  • d_y_over_d_t – a function that returns the value of y’(t) given t and y
  • y_constraint_function – a function that, given t, returns a sequence of constraints on the values of the solution containing a constraint for each element of y
Returns:

the value of y(t + d_t).

Module contents

class pararealml.operators.fdm.FDMOperator(integrator: pararealml.operators.fdm.numerical_integrator.NumericalIntegrator, differentiator: pararealml.operators.fdm.numerical_differentiator.NumericalDifferentiator, d_t: float)[source]

Bases: pararealml.operator.Operator

A finite difference method based conventional differential equation solver.

solve(ivp: pararealml.initial_value_problem.InitialValueProblem, parallel_enabled: bool = True) → pararealml.solution.Solution[source]

Returns the IVP’s solution.

Parameters:
  • ivp – the initial value problem to solve
  • parallel_enabled – whether in-time parallelization is enabled
Returns:

the solution of the IVP

class pararealml.operators.fdm.NumericalDifferentiator(tol: float = 0.001)[source]

Bases: abc.ABC

A base class for numerical differentiators.

anti_laplacian(laplacian: numpy.ndarray, mesh: pararealml.mesh.Mesh, y_constraints: Union[Sequence[Optional[pararealml.constraint.Constraint]], numpy.ndarray], derivative_boundary_constraints: Optional[numpy.ndarray] = None, y_init: Optional[numpy.ndarray] = None) → numpy.ndarray[source]

Computes the inverse of the element-wise scalar Laplacian using the Jacobi method.

Parameters:
  • laplacian – the right-hand side of the equation
  • mesh – the mesh representing the discretized spatial domain
  • y_constraints – a sequence of constraints on the values of the solution containing a constraint for each element of y; each constraint must constrain the boundary values of corresponding element of y for the system to be solvable
  • derivative_boundary_constraints – an optional 2D array (x dimension, y dimension) of boundary constraint pairs that specify constraints on the first derivatives of the solution
  • y_init – an optional initial estimate of the solution; if it is None, a random array is used
Returns:

the array representing the solution to Poisson’s equation at every point of the mesh

curl(y: numpy.ndarray, mesh: pararealml.mesh.Mesh, curl_ind: int = 0, derivative_boundary_constraints: Optional[numpy.ndarray] = None) → numpy.ndarray[source]

Computes the curl_ind-th component of the curl of y at every point of the mesh.

Parameters:
  • y – the values of y at every point of the mesh
  • mesh – the mesh representing the discretized spatial domain
  • curl_ind – the index of the component of the curl of y to compute; if y is a two dimensional vector field, it must be 0
  • derivative_boundary_constraints – a 2D array (x dimension, y dimension) of boundary constraint pairs that allow for applying constraints to the calculated first derivatives before using them to compute the curl
Returns:

the curl of y

divergence(y: numpy.ndarray, mesh: pararealml.mesh.Mesh, derivative_boundary_constraints: Optional[numpy.ndarray] = None) → numpy.ndarray[source]

Computes the divergence of y with respect to x at every point of the mesh.

Parameters:
  • y – the values of y at every point of the mesh
  • mesh – the mesh representing the discretized spatial domain
  • derivative_boundary_constraints – a 2D array (x dimension, y dimension) of boundary constraint pairs that allow for applying constraints to the calculated first derivatives before using them to compute the divergence
Returns:

the divergence of y

gradient(y: numpy.ndarray, mesh: pararealml.mesh.Mesh, x_axis: int, derivative_boundary_constraints: Optional[numpy.ndarray] = None) → numpy.ndarray[source]

Computes the column of the Jacobian matrix of y corresponding to the spatial dimension specified by x_axis at every point of the mesh.

Parameters:
  • y – the values of y at every point of the mesh
  • mesh – the mesh representing the discretized spatial domain
  • x_axis – the spatial dimension that y is to be differentiated with respect to
  • derivative_boundary_constraints – a 2D array (x dimension, y dimension) of boundary constraint pairs that allow for applying constraints to the calculated first derivatives
Returns:

the element(s) of the gradient of y corresponding to the specified axis

hessian(y: numpy.ndarray, mesh: pararealml.mesh.Mesh, x_axis1: int, x_axis2: int, derivative_boundary_constraints: Optional[numpy.ndarray] = None) → numpy.ndarray[source]

Computes the column of the Hessian tensor of y corresponding to the spatial dimensions defined by x_axis1 and x_axis2 at every point of the mesh.

Parameters:
  • y – the values of y at every point of the mesh
  • mesh – the mesh representing the discretized spatial domain
  • x_axis1 – the first spatial dimension that y is to be differentiated with respect to
  • x_axis2 – the second spatial dimension that y is to be differentiated with respect to
  • derivative_boundary_constraints – a 2D array (x dimension, y dimension) of boundary constraint pairs that allow for applying constraints to the calculated first derivatives before using them to compute the second derivatives
Returns:

the element(s) of the Hessian of y corresponding to the specified axes

laplacian(y: numpy.ndarray, mesh: pararealml.mesh.Mesh, derivative_boundary_constraints: Optional[numpy.ndarray] = None) → numpy.ndarray[source]

Computes the Laplacian of y at every point of the mesh.

If the last rank of y has a dimension greater than one, the element-wise scalar Laplacian is computed instead of the vector Laplacian (which only makes a difference in curvilinear coordinate systems).

Parameters:
  • y – the values of y at every point of the mesh
  • mesh – the mesh representing the discretized spatial domain
  • derivative_boundary_constraints – a 2D array (x dimension, y dimension) of boundary constraint pairs that allow for applying constraints to the calculated first derivatives before using them to compute the second derivatives and the Laplacian
Returns:

the Laplacian of y

vector_laplacian(y: numpy.ndarray, mesh: pararealml.mesh.Mesh, vector_laplacian_ind: int, derivative_boundary_constraints: Optional[numpy.ndarray] = None) → numpy.ndarray[source]

Computes the vector_laplacian_ind-th component of the vector Laplacian of y at every point of the mesh.

Parameters:
  • y – the values of y at every point of the mesh
  • mesh – the mesh representing the discretized spatial domain
  • vector_laplacian_ind – the index of the component of the vector Laplacian of y to compute
  • derivative_boundary_constraints – a 2D array (x dimension, y dimension) of boundary constraint pairs that allow for applying constraints to the calculated first derivatives before using them to compute the vector Laplacian
Returns:

the vector Laplacian of y

class pararealml.operators.fdm.ThreePointCentralDifferenceMethod(tol: float = 0.001)[source]

Bases: pararealml.operators.fdm.numerical_differentiator.NumericalDifferentiator

A numerical differentiator using a three-point (second order) central difference approximation.

class pararealml.operators.fdm.NumericalIntegrator[source]

Bases: abc.ABC

A base class for numerical integrators.

integral(y: numpy.ndarray, t: float, d_t: float, d_y_over_d_t: Callable[[float, numpy.ndarray], numpy.ndarray], y_constraint_function: Callable[[Optional[float]], Union[Sequence[pararealml.constraint.Constraint], numpy.ndarray, None]]) → numpy.ndarray[source]

Estimates the value of y(t + d_t).

Parameters:
  • y – the value of y(t)
  • t – the value of t
  • d_t – the amount of increase in t
  • d_y_over_d_t – a function that returns the value of y’(t) given t and y
  • y_constraint_function – a function that, given t, returns a sequence of constraints on the values of the solution containing a constraint for each element of y
Returns:

the value of y(t + d_t).

class pararealml.operators.fdm.ForwardEulerMethod[source]

Bases: pararealml.operators.fdm.numerical_integrator.NumericalIntegrator

The forward Euler method, an explicit first order Runge-Kutta method.

integral(y: numpy.ndarray, t: float, d_t: float, d_y_over_d_t: Callable[[float, numpy.ndarray], numpy.ndarray], y_constraint_function: Callable[[Optional[float]], Union[Sequence[pararealml.constraint.Constraint], numpy.ndarray, None]]) → numpy.ndarray[source]

Estimates the value of y(t + d_t).

Parameters:
  • y – the value of y(t)
  • t – the value of t
  • d_t – the amount of increase in t
  • d_y_over_d_t – a function that returns the value of y’(t) given t and y
  • y_constraint_function – a function that, given t, returns a sequence of constraints on the values of the solution containing a constraint for each element of y
Returns:

the value of y(t + d_t).

class pararealml.operators.fdm.ExplicitMidpointMethod[source]

Bases: pararealml.operators.fdm.numerical_integrator.NumericalIntegrator

The explicit midpoint method, a second order Runge-Kutta method.

integral(y: numpy.ndarray, t: float, d_t: float, d_y_over_d_t: Callable[[float, numpy.ndarray], numpy.ndarray], y_constraint_function: Callable[[Optional[float]], Union[Sequence[pararealml.constraint.Constraint], numpy.ndarray, None]]) → numpy.ndarray[source]

Estimates the value of y(t + d_t).

Parameters:
  • y – the value of y(t)
  • t – the value of t
  • d_t – the amount of increase in t
  • d_y_over_d_t – a function that returns the value of y’(t) given t and y
  • y_constraint_function – a function that, given t, returns a sequence of constraints on the values of the solution containing a constraint for each element of y
Returns:

the value of y(t + d_t).

class pararealml.operators.fdm.RK4[source]

Bases: pararealml.operators.fdm.numerical_integrator.NumericalIntegrator

The RK4 method, an explicit fourth order Runge-Kutta method.

integral(y: numpy.ndarray, t: float, d_t: float, d_y_over_d_t: Callable[[float, numpy.ndarray], numpy.ndarray], y_constraint_function: Callable[[Optional[float]], Union[Sequence[pararealml.constraint.Constraint], numpy.ndarray, None]]) → numpy.ndarray[source]

Estimates the value of y(t + d_t).

Parameters:
  • y – the value of y(t)
  • t – the value of t
  • d_t – the amount of increase in t
  • d_y_over_d_t – a function that returns the value of y’(t) given t and y
  • y_constraint_function – a function that, given t, returns a sequence of constraints on the values of the solution containing a constraint for each element of y
Returns:

the value of y(t + d_t).

class pararealml.operators.fdm.BackwardEulerMethod(tol: float = 1.48e-08, max_iterations: int = 50)[source]

Bases: pararealml.operators.fdm.numerical_integrator.ImplicitMethod

The backward Euler method, an implicit first order Runge-Kutta method.

integral(y: numpy.ndarray, t: float, d_t: float, d_y_over_d_t: Callable[[float, numpy.ndarray], numpy.ndarray], y_constraint_function: Callable[[Optional[float]], Union[Sequence[pararealml.constraint.Constraint], numpy.ndarray, None]]) → numpy.ndarray[source]

Estimates the value of y(t + d_t).

Parameters:
  • y – the value of y(t)
  • t – the value of t
  • d_t – the amount of increase in t
  • d_y_over_d_t – a function that returns the value of y’(t) given t and y
  • y_constraint_function – a function that, given t, returns a sequence of constraints on the values of the solution containing a constraint for each element of y
Returns:

the value of y(t + d_t).

class pararealml.operators.fdm.CrankNicolsonMethod(a: float = 0.5, tol: float = 1.48e-08, max_iterations: int = 50)[source]

Bases: pararealml.operators.fdm.numerical_integrator.ImplicitMethod

A first order implicit-explicit method combining the forward and backward Euler methods.

integral(y: numpy.ndarray, t: float, d_t: float, d_y_over_d_t: Callable[[float, numpy.ndarray], numpy.ndarray], y_constraint_function: Callable[[Optional[float]], Union[Sequence[pararealml.constraint.Constraint], numpy.ndarray, None]]) → numpy.ndarray[source]

Estimates the value of y(t + d_t).

Parameters:
  • y – the value of y(t)
  • t – the value of t
  • d_t – the amount of increase in t
  • d_y_over_d_t – a function that returns the value of y’(t) given t and y
  • y_constraint_function – a function that, given t, returns a sequence of constraints on the values of the solution containing a constraint for each element of y
Returns:

the value of y(t + d_t).