pathsim.solvers.bdf module

class pathsim.solvers.bdf.BDF(*solver_args, **solver_kwargs)[source]

Bases: ImplicitSolver

Base class for the backward differentiation formula (BDF) integrators.

Notes

This solver class is not intended to be used directly

x

internal ‘working’ state

Type:

numeric, array[numeric]

n

order of integration scheme

Type:

int

s

number of internal intermediate stages

Type:

int

stage

counter for current intermediate stage

Type:

int

eval_stages

rations for evaluation times of intermediate stages

Type:

list[float]

opt

optimizer instance to solve the implicit update equation

Type:

NewtonAnderson, Anderson, etc.

K

bdf coefficients for the state buffer for each order

Type:

dict[int: list[float]]

F

bdf coefficients for the function ‘func’ for each order

Type:

dict[int: float]

history

internal history of past results

Type:

deque[numeric]

startup

internal solver instance for startup (building history) of multistep methods (using ‘DIRK3’ for ‘BDF’ methods)

Type:

Solver

classmethod cast(other, parent, **solver_kwargs)[source]

cast to this solver needs special handling of startup method

Parameters:
  • other (Solver) – solver instance to cast new instance of this class from

  • parent (None | Solver) – solver instance to use as parent

  • solver_kwargs (dict) – other args for the solver

Returns:

engine – instance of BDF solver with params and state from other

Return type:

BDF

stages(t, dt)[source]

Generator that yields the intermediate evaluation time during the timestep ‘t + ratio * dt’.

Parameters:
  • t (float) – evaluation time

  • dt (float) – integration timestep

reset()[source]

“Resets integration engine to initial state.

buffer(dt)[source]

buffer the state for the multistep method

Parameters:

dt (float) – integration timestep

solve(f, J, dt)[source]

Solves the implicit update equation using the optimizer of the engine.

Parameters:
  • f (array_like) – evaluation of function

  • J (array_like) – evaluation of jacobian of function

  • dt (float) – integration timestep

Returns:

err – residual error of the fixed point update equation

Return type:

float

step(f, dt)[source]

Performs the explicit timestep for (t+dt) based on the state and input at (t).

Note

This is only required for the startup solver.

Parameters:
  • f (numeric, array[numeric]) – evaluation of rhs 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.bdf.BDF2(*solver_args, **solver_kwargs)[source]

Bases: BDF

Fixed-step 2nd order Backward Differentiation Formula (BDF).

Implicit linear multistep method. Uses the previous two solution points. A-stable, suitable for stiff problems. Uses BDF1 for the first step.

Characteristics:
  • Order: 2

  • Implicit Multistep

  • Fixed timestep only

  • A-stable

class pathsim.solvers.bdf.BDF3(*solver_args, **solver_kwargs)[source]

Bases: BDF

Fixed-step 3rd order Backward Differentiation Formula (BDF).

Implicit linear multistep method. Uses the previous three solution points. A(alpha)-stable, suitable for stiff problems. Uses lower orders for startup.

Characteristics:
  • Order: 3

  • Implicit Multistep

  • Fixed timestep only

  • A(alpha)-stable (\(\alpha \approx 86^\circ\))

class pathsim.solvers.bdf.BDF4(*solver_args, **solver_kwargs)[source]

Bases: BDF

Fixed-step 4th order Backward Differentiation Formula (BDF).

Implicit linear multistep method. Uses the previous four solution points. A(alpha)-stable, suitable for stiff problems. Uses lower orders for startup.

Characteristics:
  • Order: 4

  • Implicit Multistep

  • Fixed timestep only

  • A(alpha)-stable (\(\alpha \approx 73^\circ\))

class pathsim.solvers.bdf.BDF5(*solver_args, **solver_kwargs)[source]

Bases: BDF

Fixed-step 5th order Backward Differentiation Formula (BDF).

Implicit linear multistep method. Uses the previous five solution points. A(alpha)-stable, suitable for stiff problems. Uses lower orders for startup.

Characteristics:
  • Order: 5

  • Implicit Multistep

  • Fixed timestep only

  • A(alpha)-stable (\(\alpha \approx 51^\circ\))

class pathsim.solvers.bdf.BDF6(*solver_args, **solver_kwargs)[source]

Bases: BDF

Fixed-step 6th order Backward Differentiation Formula (BDF).

Implicit linear multistep method. Uses the previous six solution points. Not A-stable, stability region does not contain the entire left half-plane, limiting its use for highly stiff problems compared to lower-order BDFs. Uses lower orders for startup.

Characteristics:
  • Order: 6

  • Implicit Multistep

  • Fixed timestep only

  • Not A-stable (stability angle approx \(18^\circ\))