skfdiff.core package

Subpackages

Submodules

skfdiff.core.grid_builder module

class skfdiff.core.grid_builder.GridBuilder(system: PDESys)[source]

Bases: object

U_from_fields(fields, t=0)[source]
U_routine(unks, sizes: Tuple[int])[source]
build_flat_from_idxs_mapper(sizes: Tuple[int])[source]
build_idxs_from_flat_mapper(sizes: Tuple[int])[source]
compute_domains(sizes: Tuple[int])[source]

compute grid indices of all the model fields.

compute_flat_from_idxs(idxs, sizes: Tuple[int])[source]
compute_flat_maps(sizes: Tuple[int])[source]
compute_flat_to_unks(sizes: Tuple[int])[source]
compute_gridinfo(sizes: Tuple[int])[source]
compute_idxs(sizes: Tuple[int])[source]
compute_idxs_from_flat(flatindex, sizes: Tuple[int])[source]
compute_indices(sizes: Tuple[int])[source]

compute grid indices of all the model fields.

compute_pivot_idx(shapes: Tuple[int])[source]
compute_shapes(sizes: Tuple[int])[source]

compute the shapes of all the model fields.

compute_sizes(sizes: Tuple[int])[source]

compute the sizes of all the model fields.

compute_steps(sizes, lenghts)[source]

compute the stepsize of all the independent variables.

compute_subgrids(sizes: Tuple[int])[source]
compute_unks_to_flat(sizes: Tuple[int])[source]
fields_from_U(U, fields, t=None)[source]
fields_routine(U, sizes: Tuple[int])[source]
get_relevant_ptrs(i: int, sizes: Tuple[int])[source]
skfdiff.core.grid_builder.list_to_tuple_key(*args, **kwargs)[source]
skfdiff.core.grid_builder.retrieve_cache(key, self)[source]

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

apply(expr)[source]
pop_derivative(expr)[source]
relevant_derivatives(expr)[source]
skfdiff.core.spatial_schemes.all_derivatives(derivative, wrt)[source]
skfdiff.core.spatial_schemes.as_finite_diff(derivative, coord, offset=0, accuracy=2, scheme='centered')[source]
skfdiff.core.spatial_schemes.chain_schemes(schemes, expr, default_scheme='centered', default_accuracy=2)[source]
skfdiff.core.spatial_schemes.upwind(velocity, unk, coord=None, accuracy=2)[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

bcs_validator(attribute, value)[source]
evaluate_side_patterns(node, coord, domain)[source]
get(side, domains, evaluation_node, offset=None)[source]
noflux_default()[source]
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
domains(*node_coords)[source]
get_distances(indexed)[source]
get_domains(indexed)[source]
get_ghost_equation(ghost, node)[source]
is_in_bulk(indexed)[source]
is_outside(indexed)[source]
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.system.dict_product(d)[source]
skfdiff.core.system.list_conditions(domain)[source]
skfdiff.core.system.list_node_coords(domain)[source]
skfdiff.core.system.sign_distance(distance, domain)[source]
skfdiff.core.system.target_axis(derivative, wrt, axis)[source]

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.TemporalScheme[source]

Bases: object

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

skfdiff.core.temporal_schemes.null_hook(t, fields)[source]
skfdiff.core.temporal_schemes.register_temporal_scheme(CustomTemporalScheme)[source]
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
check(attrs, value)[source]
property coords
property discrete
distance_from_domain(node_coord)[source]
distances(node_coord)[source]
domain(node_coord)[source]
domains(*node_coords)[source]
get_node_coord(domain)[source]
property idx
is_in_bulk(node_coord)[source]
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
distances(*node_coords)[source]
domains(*node_coords)[source]
is_in_bulk(*node_coords)[source]
property node_coords
property node_coords_subs
property physical_domains
property symbol

Module contents