otf.time_integration.base
Abstract base classes to simulate Systems forward in time.
This module provides abstract solver base classes used throughout the
otf.time_integration package. Implementations here are designed to work with
JAX (e.g., lax.fori_loop) and describe the expected solver public interface:
BaseSolver, SinglestepSolver, MultistageSolver, and MultistepSolver.
Classes:
| Name | Description |
|---|---|
BaseSolver |
Base class for solving true and data-assimilated systems. |
MultistageSolver |
Abstract base for multistage (single-step) integrators. |
MultistepSolver |
Abstract base for linear multistep integrators. |
SinglestepSolver |
Abstract base for single-step integrators. |
BaseSolver
Base class for solving true and data-assimilated systems.
Subclasses must implement the public solve_true and solve methods (or
inherit behavior) and provide _step_factory where appropriate. The
implementations in this module assume JAX-friendly step functions (e.g.,
suitable for use with lax.fori_loop).
Create a solver for system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
system
|
BaseSystem
|
An instance of |
required |
Methods:
| Name | Description |
|---|---|
compute_num_steps |
Compute the number of time steps used to integrate over an interval. |
solve |
Solve the true and data assimilated systems together from |
solve_true |
Solve the true system from |
Source code in src/otf/time_integration/base.py
compute_num_steps
staticmethod
Compute the number of time steps used to integrate over an interval.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t0
|
float
|
Initial and (approximate) final times over which to simulate |
required |
tf
|
float
|
Initial and (approximate) final times over which to simulate |
required |
dt
|
float
|
Simulation step size |
required |
Returns:
| Type | Description |
|---|---|
num_steps
|
Number of steps used to integrate from |
Source code in src/otf/time_integration/base.py
solve
solve(
true0: jndarray,
assimilated0: jndarray,
t0: float,
tf: float,
dt: float,
) -> tuple[jndarray, jndarray, jndarray]
Solve the true and data assimilated systems together from t0 to
(approximately) tf with steps of size dt.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
true0
|
jndarray
|
Initial state of true system |
required |
assimilated0
|
jndarray
|
Initial state of data assimilated system |
required |
t0
|
float
|
Initial and (approximate) final times over which to simulate |
required |
tf
|
float
|
Initial and (approximate) final times over which to simulate |
required |
dt
|
float
|
Simulation step size |
required |
Returns:
| Type | Description |
|---|---|
true
|
True states |
assimilated
|
Data assimilated states |
tls
|
Array of time points |
Source code in src/otf/time_integration/base.py
solve_true
Solve the true system from t0 to (approximately) tf with steps of
size dt.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
true0
|
jndarray
|
Initial state of true system |
required |
t0
|
float
|
Initial and (approximate) final times over which to simulate |
required |
tf
|
float
|
Initial and (approximate) final times over which to simulate |
required |
dt
|
float
|
Simulation step size |
required |
Returns:
| Type | Description |
|---|---|
true
|
True states |
tls
|
Array of time points |
Source code in src/otf/time_integration/base.py
MultistageSolver
Bases: BaseSolver
Abstract base for multistage (single-step) integrators.
Multistage solvers (for example, Runge–Kutta methods) take one step at a
time and may require access to a fully-known model when performing nudged or
assimilated updates. Subclasses should provide _step_factory that returns
jax-friendly step functions used by solve/solve_true.
Create a multistage solver bound to system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
system
|
System_ModelKnown
|
A |
required |
Source code in src/otf/time_integration/base.py
MultistepSolver
Bases: BaseSolver
Abstract base for linear multistep integrators.
Multistep solvers use several previous time levels to advance the solution
(e.g., Adams–Bashforth). Subclasses must set _k >= 2 to indicate how many
history steps they require. A pre_multistep_solver may be provided to
generate initial history or callers can supply the necessary initial states
directly.
Initialize a multistep solver.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
system
|
BaseSystem
|
The system to integrate. |
required |
pre_multistep_solver
|
BaseSolver | None
|
An instantiated |
None
|
Methods:
| Name | Description |
|---|---|
solve_assimilated |
See documentation for |
solve_true |
See documentation for |
Source code in src/otf/time_integration/base.py
solve_assimilated
solve_assimilated(
assimilated0: jndarray,
t0: float,
tf: float,
dt: float,
true_observed: jndarray,
ensure_optimized: bool = True,
) -> tuple[jndarray, jndarray]
See documentation for BaseSolver.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
assimilated0
|
jndarray
|
Initial state(s) of data assimilated system |
required |
true_observed
|
jndarray
|
Observed true states First entries should align with |
required |
ensure_optimized
|
bool
|
If True, check whether |
True
|
Notes
For optimal performance the exact number of observed true states
required for the integration interval and step size should be passed to
true_observed. It seems performance of jit-compiling is improved when
at least one of the following conditions are met, but especially both:
1. arrays from which slices are taken are the same size; and
2. slices themselves are the same size.
Passing the exact number of observed true states helps this code meet
the first condition. This code meets the second condition when passing
arrays to the jit-compiled step functions used in time integration
solvers.
Returns:
| Type | Description |
|---|---|
assimilated
|
Data assimilated states |
tls
|
Array of time points |
Source code in src/otf/time_integration/base.py
557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 | |
solve_true
See documentation for BaseSolver.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
true0
|
jndarray
|
Initial state(s) of true system |
required |
Source code in src/otf/time_integration/base.py
SinglestepSolver
Bases: BaseSolver
Abstract base for single-step integrators.
Single-step solvers advance the solution one time level at a time. They are
suitable for explicit and implicit one-step methods and expect jax-friendly
step functions to be provided by subclasses via _step_factory.
Create a single-step solver for system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
system
|
BaseSystem
|
The system to integrate. For |
required |
Methods:
| Name | Description |
|---|---|
solve_assimilated |
See documentation for |
Source code in src/otf/time_integration/base.py
solve_assimilated
solve_assimilated(
assimilated0: jndarray,
t0: float,
tf: float,
dt: float,
true_observed: jndarray,
ensure_optimized: bool = True,
) -> tuple[jndarray, jndarray]
See documentation for BaseSolver.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
assimilated0
|
jndarray
|
Initial state of data assimilated system |
required |
true_observed
|
jndarray
|
Observed true states |
required |
ensure_optimized
|
bool
|
If True, check whether |
True
|
Notes
For optimal performance the exact number of observed true states
required for the integration interval and step size should be passed to
true_observed. It seems performance of jit-compiling is improved when
at least one of the following conditions are met, but especially both:
1. arrays from which slices are taken are the same size; and
2. slices themselves are the same size.
Passing the exact number of observed true states helps this code meet
the first condition. This code meets the second condition when passing
arrays to the jit-compiled step functions used in time integration
solvers.
Returns:
| Type | Description |
|---|---|
assimilated
|
Data assimilated states |
tls
|
Array of time points |