bice.time_steppers package

Submodules

bice.time_steppers.bdf module

Backward Differentiation Formula (BDF) time-stepping schemes.

class BDF(problem: Problem, dt_max: float = inf)

Bases: TimeStepper

Variable-order Backward Differentiation Formula (BDF) scheme.

A wrapper around scipy.integrate.BDF for adaptive time-stepping with variable order.

Initialize the adaptive BDF time-stepper.

Parameters:
  • problem – The problem instance to solve.

  • dt_max – Maximum allowed time step size.

atol

absolute tolerance for the solver

dt_max

maximum allowed time step size

factory_reset() None

Reset the underlying scipy BDF solver instance.

Useful when the problem state changes significantly.

problem

reference to the problem

rtol

relative tolerance for the solver

step(problem: Problem) None

Perform a single adaptive BDF step.

Parameters:

problem – The problem instance to step in time.

class BDF2(dt: float = 0.001)

Bases: TimeStepper

Second-order Backward Differentiation Formula (BDF2) scheme.

An implicit method for the numerical solution of ordinary differential equations. It is particularly well-suited for stiff systems.

Initialize the BDF2 time-stepper.

Parameters:

dt – The time step size.

order

the order of the scheme

step(problem: Problem) None

Perform a single BDF2 step.

Uses the problem’s history to retrieve previous solutions for the multi-step formula.

Parameters:

problem – The problem instance to step in time.

bice.time_steppers.runge_kutta module

Runge-Kutta time-stepping schemes.

class RungeKutta4(dt: float = 0.01)

Bases: TimeStepper

Classical fourth-order Runge-Kutta (RK4) scheme.

A popular fourth-order method for the numerical solution of ordinary differential equations.

Initialize the time-stepper.

Parameters:

dt – The time step size.

step(problem: Problem) None

Perform a single RK4 step.

Parameters:

problem – The problem instance to step in time.

class RungeKuttaFehlberg45(dt: float = 0.01, error_tolerance: float = 0.001)

Bases: TimeStepper

Runge-Kutta-Fehlberg (RKF45) scheme with adaptive step size.

Local truncation error is estimated by comparison of RK4 and RK5 schemes, which is then used to determine the optimal step size for the next step.

Initialize the RKF45 time-stepper.

Parameters:
  • dt – The initial time step size.

  • error_tolerance – The local truncation error tolerance for adaptive stepping.

error_tolerance

Local truncation error tolerance

max_rejections

Maximum number of iterations when steps are rejected

rejection_count

counter for the number of rejections in current step

step(problem: Problem) None

Perform a single RKF45 step with adaptive step size.

Parameters:

problem – The problem instance to step in time.

Raises:

Exception – If the maximum number of rejected steps is exceeded.

bice.time_steppers.time_steppers module

Base classes for time-stepping algorithms.

class Euler(dt: float = 0.01)

Bases: TimeStepper

Explicit Euler (Forward Euler) scheme.

A first-order numerical procedure for solving ordinary differential equations with a given initial value.

Initialize the time-stepper.

Parameters:

dt – The time step size.

step(problem: Problem) None

Perform a single explicit Euler step.

Parameters:

problem – The problem instance to step in time.

class ImplicitEuler(dt: float = 0.01)

Bases: TimeStepper

Implicit Euler (Backward Euler) scheme.

A first-order implicit method for solving ordinary differential equations, offering better stability for stiff systems compared to the explicit Euler method.

Initialize the time-stepper.

Parameters:

dt – The time step size.

step(problem: Problem) None

Perform a single implicit Euler step.

Uses the problem’s Newton solver to find the solution at the next time level.

Parameters:

problem – The problem instance to step in time.

class TimeStepper(dt: float = 0.01)

Bases: object

Abstract base class for all time-steppers.

Specifies attributes and methods that all time-steppers should have.

Initialize the time-stepper.

Parameters:

dt – The time step size.

dt

the time step size

step(problem: Problem) None

Perform a single time step on a problem.

Parameters:

problem – The problem instance to step in time.

Raises:

NotImplementedError – This is an abstract base class.

Module contents

Time-stepping schemes for numerical integration.

This package provides various explicit and implicit time-stepping methods for solving Cauchy-type equations, including Euler schemes, Runge-Kutta, and Backward Differentiation Formulae (BDF).

class BDF(problem: Problem, dt_max: float = inf)

Bases: TimeStepper

Variable-order Backward Differentiation Formula (BDF) scheme.

A wrapper around scipy.integrate.BDF for adaptive time-stepping with variable order.

Initialize the adaptive BDF time-stepper.

Parameters:
  • problem – The problem instance to solve.

  • dt_max – Maximum allowed time step size.

atol

absolute tolerance for the solver

bdf: BDF | None
dt_max

maximum allowed time step size

factory_reset() None

Reset the underlying scipy BDF solver instance.

Useful when the problem state changes significantly.

problem

reference to the problem

rtol

relative tolerance for the solver

step(problem: Problem) None

Perform a single adaptive BDF step.

Parameters:

problem – The problem instance to step in time.

class BDF2(dt: float = 0.001)

Bases: TimeStepper

Second-order Backward Differentiation Formula (BDF2) scheme.

An implicit method for the numerical solution of ordinary differential equations. It is particularly well-suited for stiff systems.

Initialize the BDF2 time-stepper.

Parameters:

dt – The time step size.

order

the order of the scheme

step(problem: Problem) None

Perform a single BDF2 step.

Uses the problem’s history to retrieve previous solutions for the multi-step formula.

Parameters:

problem – The problem instance to step in time.

class Euler(dt: float = 0.01)

Bases: TimeStepper

Explicit Euler (Forward Euler) scheme.

A first-order numerical procedure for solving ordinary differential equations with a given initial value.

Initialize the time-stepper.

Parameters:

dt – The time step size.

step(problem: Problem) None

Perform a single explicit Euler step.

Parameters:

problem – The problem instance to step in time.

class ImplicitEuler(dt: float = 0.01)

Bases: TimeStepper

Implicit Euler (Backward Euler) scheme.

A first-order implicit method for solving ordinary differential equations, offering better stability for stiff systems compared to the explicit Euler method.

Initialize the time-stepper.

Parameters:

dt – The time step size.

step(problem: Problem) None

Perform a single implicit Euler step.

Uses the problem’s Newton solver to find the solution at the next time level.

Parameters:

problem – The problem instance to step in time.

class RungeKutta4(dt: float = 0.01)

Bases: TimeStepper

Classical fourth-order Runge-Kutta (RK4) scheme.

A popular fourth-order method for the numerical solution of ordinary differential equations.

Initialize the time-stepper.

Parameters:

dt – The time step size.

step(problem: Problem) None

Perform a single RK4 step.

Parameters:

problem – The problem instance to step in time.

class RungeKuttaFehlberg45(dt: float = 0.01, error_tolerance: float = 0.001)

Bases: TimeStepper

Runge-Kutta-Fehlberg (RKF45) scheme with adaptive step size.

Local truncation error is estimated by comparison of RK4 and RK5 schemes, which is then used to determine the optimal step size for the next step.

Initialize the RKF45 time-stepper.

Parameters:
  • dt – The initial time step size.

  • error_tolerance – The local truncation error tolerance for adaptive stepping.

error_tolerance

Local truncation error tolerance

max_rejections

Maximum number of iterations when steps are rejected

rejection_count

counter for the number of rejections in current step

step(problem: Problem) None

Perform a single RKF45 step with adaptive step size.

Parameters:

problem – The problem instance to step in time.

Raises:

Exception – If the maximum number of rejected steps is exceeded.