skfdiff.core package¶
Subpackages¶
Submodules¶
skfdiff.core.grid_builder module¶
skfdiff.core.spatial_schemes module¶
- class skfdiff.core.spatial_schemes.FiniteDifferenceScheme(scheme: str = 'centered', accuracy: int = 2, offset: int = 0, pattern=<function all_derivatives>)[source]¶
Bases:
object
- skfdiff.core.spatial_schemes.as_finite_diff(derivative, coord, offset=0, accuracy=2, scheme='centered')[source]¶
skfdiff.core.system module¶
- class skfdiff.core.system.BoundaryCondition(unknown: str, axis, pde=<class 'skfdiff.core.system.PDEquation'>, bcs: ~typing.Optional[~typing.Union[str, ~typing.Tuple[str, str]]] = _Nothing.NOTHING)[source]¶
Bases:
object
- class skfdiff.core.system.PDESys(evolution_equations, unknowns, parameters=_Nothing.NOTHING, coordinates=[], boundary_conditions: dict = _Nothing.NOTHING, subs: dict = _Nothing.NOTHING, custom_functions: dict = _Nothing.NOTHING)[source]¶
Bases:
object
- property computation_domains¶
- property coordinates_dict¶
- property equation_dict¶
- jacobian_columns¶
- jacobian_values¶
- property mapper¶
- property parameters_dict¶
- piecewise_system¶
- property unknowns_dict¶
- class skfdiff.core.system.PDEquation(equation: str, unknowns, parameters=[], subs: dict = _Nothing.NOTHING, custom_functions: dict = _Nothing.NOTHING, boundary_conditions: dict = _Nothing.NOTHING, schemes: Sequence[FiniteDifferenceScheme] = (FiniteDifferenceScheme(scheme='centered', accuracy=2, offset=0),), raw: bool = False, dirichlet_nodes: Sequence[Tuple[int, ...]] = _Nothing.NOTHING)[source]¶
Bases:
object
- property computation_domains¶
- computation_nodes¶
- property coordinates_dict¶
- property mapper¶
- property node_coords¶
- property node_coords_subs¶
- property parameters_dict¶
- property parsed_boundary_conditions¶
- property physical_domains¶
- piecewise_system¶
- property stencils¶
- property unknowns_dict¶
skfdiff.core.temporal_schemes module¶
This module regroups all the implemented temporal schemes. They are written as callable class which take the model and some control arguments at the init, and perform a computation step every time they are called.
- The following solvers are implemented:
Backward and Forward Euler, Crank-Nicolson method (with the Theta class)
Some Rosenbrock Wanner schemes (up to the 6th order) with time controler
All the scipy.integrate.ode integrators with the scipy_ode class.
- class skfdiff.core.temporal_schemes.RODASPR(model, tol=0.1, time_stepping=True, max_iter=None, dt_min=None, safety_factor=0.9, solver='auto', recompute_target=True, iteratif_atol=0.001)[source]¶
Bases:
ROW_general
6th order Rosenbrock scheme, with time stepping
- Parameters:
model (skfdiff.Model) – skfdiff Model
tol (float, optional, default 1E-2) – tolerance factor for the time stepping. The time step will adapt to ensure that the maximum relative error on all fields stay under that value.
time_stepping (bool, optional, default True) – allow a variable internal time-step to ensure good agreement between computing performance and accuracy.
max_iter (float or None, optional, default None) – maximum internal iteration allowed
dt_min (float or None, optional, default None) – minimum internal time step allowed
recompute_target (bool, optional, default False) – if True a new computation is done when the target time is exceeded, interpolation used otherwise.
- embeded_timestepping = True¶
- name = 'RODASPR'¶
- class skfdiff.core.temporal_schemes.ROS2(model)[source]¶
Bases:
ROW_general
Second order Rosenbrock scheme, without time stepping
- Parameters:
model (skfdiff.Model) – skfdiff Model
- embeded_timestepping = False¶
- name = 'ROS2'¶
- class skfdiff.core.temporal_schemes.ROS3PRL(model, tol=0.1, time_stepping=True, max_iter=None, dt_min=None, safety_factor=0.9, solver='auto', recompute_target=True, iteratif_atol=0.001)[source]¶
Bases:
ROW_general
4th order Rosenbrock scheme, with time stepping
- Parameters:
model (skfdiff.Model) – skfdiff Model
tol (float, optional, default 1E-2) – tolerance factor for the time stepping. The time step will adapt to ensure that the maximum relative error on all fields stay under that value.
time_stepping (bool, optional, default True) – allow a variable internal time-step to ensure good agreement between computing performance and accuracy.
max_iter (float or None, optional, default None) – maximum internal iteration allowed
dt_min (float or None, optional, default None) – minimum internal time step allowed
recompute_target (bool, optional, default False) – if True a new computation is done when the target time is exceeded, interpolation used otherwise.
- embeded_timestepping = True¶
- name = 'ROS3PRL'¶
- class skfdiff.core.temporal_schemes.ROS3PRw(model, tol=0.1, time_stepping=True, max_iter=None, dt_min=None, safety_factor=0.9, solver='auto', recompute_target=True, iteratif_atol=0.001)[source]¶
Bases:
ROW_general
Third order Rosenbrock scheme, with time stepping
- Parameters:
model (skfdiff.Model) – skfdiff Model
tol (float, optional, default 1E-2) – tolerance factor for the time stepping. The time step will adapt to ensure that the maximum relative error on all fields stay under that value.
time_stepping (bool, optional, default True) – allow a variable internal time-step to ensure good agreement between computing performance and accuracy.
max_iter (float or None, optional, default None) – maximum internal iteration allowed
dt_min (float or None, optional, default None) – minimum internal time step allowed
recompute_target (bool, optional, default False) – if True a new computation is done when the target time is exceeded, interpolation used otherwise.
- embeded_timestepping = True¶
- name = 'ROS3PRw'¶
- class skfdiff.core.temporal_schemes.ROW_general(model, alpha, gamma, b, b_pred=None, time_stepping=False, tol=None, max_iter=None, dt_min=None, safety_factor=0.9, solver='auto', recompute_target=True, iteratif_atol=0.001, initial_dt=None)[source]¶
Bases:
TemporalScheme
Rosenbrock Wanner class of temporal solvers
The implementation and the different parameters can be found in http://www.digibib.tu-bs.de/?docid=00055262
- class skfdiff.core.temporal_schemes.Stationnary(model, solver=<function spsolve>)[source]¶
Bases:
object
Solve the stationnary problem F(U) = 0
- Parameters:
model (skfdiff.Model) – skfdiff Model
solver (callable, optional, default scipy.sparse.linalg.spsolve) – method able to solve a Ax = b linear equation with A a sparse matrix. Take A and b as argument and return x.
- class skfdiff.core.temporal_schemes.Theta(model, theta=1, solver=<function spsolve>)[source]¶
Bases:
TemporalScheme
- Simple theta-based scheme where theta is a weight
if theta = 0, the scheme is a forward-euler scheme if theta = 1, the scheme is a backward-euler scheme if theta = 0.5, the scheme is called a Crank-Nicolson scheme
- Parameters:
model (skfdiff.Model) – skfdiff Model
theta (int, optional, default 1) – weight of the theta-scheme
solver (callable, optional, default scipy.sparse.linalg.spsolve) – method able to solve a Ax = b linear equation with A a sparse matrix. Take A and b as argument and return x.
- embeded_timestepping = False¶
- name = 'theta'¶
- skfdiff.core.temporal_schemes.add_time_stepping(scheme, tol=0.01, ord=2, m=20, reject_factor=2)[source]¶
- skfdiff.core.temporal_schemes.get_temporal_scheme(name)[source]¶
get a temporal_scheme by its name
- Parameters:
name (name {str} -- temporal_scheme) –
- Raises:
NotImplementedError -- raised if the temporal_scheme is not available. –
- Returns:
TemporalScheme – the requested temporal_scheme
- class skfdiff.core.temporal_schemes.scipy_ivp(model, use_jac=True, method='RK45', **integrator_kwargs)[source]¶
Bases:
TemporalScheme
Proxy written around the scipy.integrate.solve_ivp function. Give access to all the scipy integrators.
- Parameters:
model (skfdiff.Model) – skfdiff Model
method (str, optional, default 'RK45') – name of the chosen scipy integration scheme.
**integrator_kwargs – extra arguments provided to the scipy integration scheme.
- embeded_timestepping = True¶
- name = 'scipy_ivp'¶
skfdiff.core.variables module¶
- class skfdiff.core.variables.Coordinate(name)[source]¶
Bases:
object
- property N¶
- property bound¶
- property c_Ns¶
- property c_bounds¶
- property c_discs¶
- property c_idxs¶
- property c_names¶
- property c_step_values¶
- property c_steps¶
- property c_symbols¶
- property coords¶
- property discrete¶
- property idx¶
- property step¶
- property step_value¶
- property symbol¶
- class skfdiff.core.variables.Unknown(name: str)[source]¶
Bases:
object
- property c_Ns¶
- property c_bounds¶
- property c_discs¶
- property c_idxs¶
- property c_names¶
- property c_step_values¶
- property c_steps¶
- property c_symbols¶
- property coords¶
- property discrete¶
- property discrete_i¶
- property node_coords¶
- property node_coords_subs¶
- property physical_domains¶
- property symbol¶