pathsim.solvers.gear module
- pathsim.solvers.gear.compute_bdf_coefficients(order, timesteps)[source]
Computes the coefficients for backward differentiation formulas for a given order. The timesteps can be specified for variable timestep BDF methods.
- For m-th order BDF we have for the n-th timestep:
sum(alpha_i * x_i; i=n-m,…,n) = h_n * f_n(x_n, t_n)
- or
x_n = beta * h_n * f_n(x_n, t_n) - sum(alpha_j * x_{n-1-j}; j=0,…,order-1)
- class pathsim.solvers.gear.GEAR(*solver_args, **solver_kwargs)[source]
Bases:
ImplicitSolverBase class for GEAR-type integrators that defines the universal methods.
Numerical integration method based on BDFs (linear multistep methods). Uses n-th order BDF for timestepping and (n-1)-th order BDF coefficients to estimate a lower ordersolutuin for error control.
The adaptive timestep BDF coefficients are dynamically computed at the beginning of each timestep from the buffered previous timsteps.
Notes
Not to be used directly!!!
- buffer(dt)[source]
Buffer the state and timestep. Dynamically precompute the variable timestep BDF coefficients on the fly for the current timestep.
- Parameters:
dt (float) – integration timestep
- revert()[source]
Revert integration engine to previous timestep, this is only relevant for adaptive methods where the simulation timestep ‘dt’ is rescaled and the engine step is recomputed with the smaller timestep.
- error_controller(tr)[source]
Compute scaling factor for adaptive timestep based on absolute and relative tolerances for local truncation error.
Checks if the error tolerance is achieved and returns a success metric.
- Parameters:
tr (array[float]) – truncation error estimate
- Returns:
success (bool) – True if the timestep was successful
error (float) – estimated error of the internal error controller
scale (float) – estimated timestep rescale factor for error control
- step(f, dt)[source]
Finalizes the timestep by resetting the solver for the implicit update equation and computing the lower order estimate of the solution for error control.
- Parameters:
f (array_like) – evaluation of function
dt (float) – integration timestep
- Returns:
success (bool) – True if the timestep was successful
error (float) – estimated error of the internal error controller
scale (float) – estimated timestep rescale factor for error control
- class pathsim.solvers.gear.GEAR21(*solver_args, **solver_kwargs)[source]
Bases:
GEARAdaptive-step GEAR integrator using 2nd order BDF for timestepping and 1st order BDF (Backward Euler) for truncation error estimation.
Suitable for moderately stiff problems where variable timestepping is beneficial.
- Characteristics:
Stepping Order: 2 (max)
Error Estimation Order: 1
Implicit Variable-Step Multistep
Adaptive timestep
A-stable (based on BDF2)
- class pathsim.solvers.gear.GEAR32(*solver_args, **solver_kwargs)[source]
Bases:
GEARAdaptive-step GEAR integrator using 3rd order BDF for timestepping and 2nd order BDF for truncation error estimation.
Suitable for stiff problems requiring higher accuracy than GEAR21.
- Characteristics:
Stepping Order: 3 (max)
Error Estimation Order: 2
Implicit Variable-Step Multistep
Adaptive timestep
A(alpha)-stable (based on BDF3)
- class pathsim.solvers.gear.GEAR43(*solver_args, **solver_kwargs)[source]
Bases:
GEARAdaptive-step GEAR integrator using 4th order BDF for timestepping and 3rd order BDF for truncation error estimation.
Suitable for stiff problems requiring good accuracy.
- Characteristics:
Stepping Order: 4 (max)
Error Estimation Order: 3
Implicit Variable-Step Multistep
Adaptive timestep
A(alpha)-stable (based on BDF4)
- class pathsim.solvers.gear.GEAR54(*solver_args, **solver_kwargs)[source]
Bases:
GEARAdaptive-step GEAR integrator using 5th order BDF for timestepping and 4th order BDF for truncation error estimation.
Suitable for stiff problems requiring high accuracy, but stability region is smaller than lower-order GEAR methods.
- Characteristics:
Stepping Order: 5 (max)
Error Estimation Order: 4
Implicit Variable-Step Multistep
Adaptive timestep
A(alpha)-stable (based on BDF5)
- class pathsim.solvers.gear.GEAR52A(*solver_args, **solver_kwargs)[source]
Bases:
GEARAdaptive-order, adaptive-stepsize GEAR integrator (Variable-Step Variable-Order BDF).
This method dynamically adjusts the BDF order used for timestepping (between 2 and 5) based on error estimates from lower and higher order predictors. It aims to optimize step size by using higher orders for smooth regions and lower, more stable orders for stiff or rapidly changing regions.
Error estimation compares the current order solution with predictions from order n-1 and n+1 formulas.
- Characteristics:
Stepping Order: Variable (2 to 5)
Error Estimation Orders: n-1 and n+1 (relative to current n)
Implicit Variable-Step, Variable-Order Multistep
Adaptive timestep and order
Stability varies with the currently selected order (A-stable or A(alpha)-stable)
- buffer(dt)[source]
Buffer the state and timestep. Dynamically precompute the variable timestep BDF coefficients on the fly for the current timestep.
- Parameters:
dt (float) – evaluation time
- error_controller(tr_m, tr_p)[source]
Compute scaling factor for adaptive timestep based on absolute and relative tolerances of the local truncation error estimate obtained from esimated lower and higher order solution.
Checks if the error tolerance is achieved and returns a success metric.
Adapts the stepping order such that the normalized error is minimized and larger steps can be taken by the integrator.
- Parameters:
- Returns:
success (bool) – True if the timestep was successful
error (float) – estimated error of the internal error controller
scale (float) – estimated timestep rescale factor for error control
- step(f, dt)[source]
Finalizes the timestep by resetting the solver for the implicit update equation and computing the lower and higher order estimate of the solution.
Then calls the error controller.
- Parameters:
f (array_like) – evaluation of function
dt (float) – integration timestep
- Returns:
success (bool) – True if the timestep was successful
error (float) – estimated error of the internal error controller
scale (float) – estimated timestep rescale factor for error control