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, axis, pde=<class 'skfdiff.core.system.PDEquation'>, bcs: Union[str, Tuple[str, str], None] = NOTHING)[source]¶ Bases:
object
-
class
skfdiff.core.system.PDESys(evolution_equations, unknowns, parameters=NOTHING, coordinates=[], boundary_conditions: dict = NOTHING, subs: dict = NOTHING)[source]¶ Bases:
object-
coordinates_dict¶
-
equation_dict¶
-
jacobian_columns¶
-
jacobian_values¶
-
mapper¶
-
parameters_dict¶
-
piecewise_system¶
-
unknowns_dict¶
-
-
class
skfdiff.core.system.PDEquation(equation: str, unknowns, parameters=[], subs: dict = {}, boundary_conditions: dict = NOTHING, schemes: Sequence[skfdiff.core.spatial_schemes.FiniteDifferenceScheme] = (FiniteDifferenceScheme(scheme='centered', accuracy=2, offset=0), ), raw: bool = False, dirichlet_nodes: Sequence[Tuple[int, ...]] = NOTHING)[source]¶ Bases:
object-
computation_domains¶
-
computation_nodes¶
-
coordinates_dict¶
-
mapper¶
-
node_coords¶
-
node_coords_subs¶
-
parameters_dict¶
-
parsed_boundary_conditions¶
-
physical_domains¶
-
piecewise_system¶
-
stencils¶
-
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:
skfdiff.core.temporal_schemes.ROW_general6th 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:
skfdiff.core.temporal_schemes.ROW_generalSecond 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:
skfdiff.core.temporal_schemes.ROW_general4th 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:
skfdiff.core.temporal_schemes.ROW_generalThird 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:
skfdiff.core.temporal_schemes.TemporalSchemeRosenbrock 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:
objectSolve 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:
skfdiff.core.temporal_schemes.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
{str} -- temporal_scheme name (name) –
- 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:
skfdiff.core.temporal_schemes.TemporalSchemeProxy 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-
N¶
-
bound¶
-
c_Ns¶
-
c_bounds¶
-
c_discs¶
-
c_idxs¶
-
c_names¶
-
c_step_values¶
-
c_steps¶
-
c_symbols¶
-
coords¶
-
discrete¶
-
idx¶
-
step¶
-
step_value¶
-
symbol¶
-