Skip to content

Solver parameters

dexter.simulate.params

Helper types to pass parameters to the solver.

Classes:

SteppingMethod()

The method used to calculate the next optimal step.

See classmethods for the different stepping methods.

EnergyAdaptiveStep(rel_tol: float = 1e-08, abs_tol: float = 1e-10) -> SteppingMethod classmethod

Forces the step size to be small enough so that the Energy difference from step to step is under a certain threshold.

Parameters:

  • rel_tol (float, default: 1e-08 ) –

    The relative tolerance to compare the relative energy error with.

  • abs_tol (float, default: 1e-10 ) –

    The absolute error tolerance. Prevents the relative energy error from becoming too small, causing the particle to get stuck.

Example
>>> method = dex.SteppingMethod.EnergyAdaptiveStep(1e-11, 1e-14)

ErrorAdaptiveStep(rel_tol: float, abs_tol: float) -> SteppingMethod classmethod

Classic RK error estimation : Adjust the step size to minimize the local truncation error.

Note that the errors are not normalized, therefore the tolerances must be set according to the scale of the system’s time derivatives. A good starting point is rel_tol=1e-17 and abs_tol=1e-19.

Parameters:

  • rel_tol (float) –

    The relative tolerance to compare the relative error with.

  • abs_tol (float) –

    The absolute error tolerance. Prevents the relative error from becoming too small, causing the particle to get stuck.

Example
>>> method = dex.SteppingMethod.ErrorAdaptiveStep(1e-17, 1e-19)

FixedStep(step: float) -> SteppingMethod classmethod

Fixed time step.

Parameters:

  • step (float) –

    The time step in Normalized units.

Example
>>> method = dex.SteppingMethod.FixedStep(0.01)

SolverParams(method: SteppingMethod | None = None, max_steps: int = 1000000, first_step: float = 0.1, safety_factor: float = 0.9)

Container for the solver parameters.

Parameters:

  • method (SteppingMethod | None, default: None ) –

    The optimal step calculation method.

  • max_steps (int, default: 1000000 ) –

    The maximum amount of steps a particle can make before terminating its integration.

  • first_step (float, default: 0.1 ) –

    The initial time step for the RKF45 adaptive step method in Normalized Units. The value is empirical.

  • safety_factor (float, default: 0.9 ) –

    The safety factor of the solver. Should be less than $1.0$.

Example
>>> solver_params = dex.SolverParams(
...     method=dex.SteppingMethod.EnergyAdaptiveStep(rel_tol=1e-7, abs_tol=1e-9),
...     max_steps=100_000,
...     first_step=1e-3,
... )

IntersectParams(intersection: Intersection, angle: float, turns: int, directionality: Directionality = 'Initial')

Defines all necessary parameters for the Particle.intersect routine.

Parameters:

  • intersection (Intersection) –

    The surface of section $\Sigma$, defined by an equation $x_i=\alpha$, where $x_i = \theta$ or $\zeta$.

  • angle (float) –

    The constant that defines the surface of section.

  • turns (int) –

    The number of intersections to calculate.

  • directionality (Directionality, default: 'Initial' ) –

    The method with which Poincare intersections are recorded.

Example
>>> intersect_params = dex.IntersectParams("ConstTheta", 0, 800)
>>> intersect_params = dex.IntersectParams("ConstZeta", np.pi, 1000)

Attributes:

  • intersection (Intersection) –

    The surface of section $\Sigma$, defined by an equation $x_i=\alpha$, where $x_i = \theta$ or $\zeta$.

  • angle (float) –

    The constant that defines the surface of section.

  • turns (int) –

    The number of intersections to calculate.

  • directionality (Directionality) –

    The method with which Poincare intersections are recorded.