BaseODE

class cubie.odesystems.BaseODE(precision: type[float16] | type[float32] | type[float64] | dtype[float16] | dtype[float32] | dtype[float64], parameters: ValuedSet, specialiser: CUDAFactory, initial_values: Mapping[str, float] | None = None, operation_ordering: str = 'liveness_auto', name: str | None = None)[source]

Bases: CUDAFactory

Abstract base for CUDA-backed ordinary differential equation systems.

Subclasses override build() to compile a CUDA device function that advances the system state and, optionally, provide analytic helpers via get_solver_helper(). The base class handles value management, precision selection, and caching through CUDAFactory.

Notes

Only functions cached during build() (typically dxdt) are available on this base class. Solver helper functions such as the linear operator or preconditioner are generated only by subclasses like SymbolicODE.

BaseODE keeps parameter defaults and initial values outside its compile settings, so it rebuilds only when a new default changes a value compiled into the code.

__init__(precision: type[float16] | type[float32] | type[float64] | dtype[float16] | dtype[float32] | dtype[float64], parameters: ValuedSet, specialiser: CUDAFactory, initial_values: Mapping[str, float] | None = None, operation_ordering: str = 'liveness_auto', name: str | None = None) → None[source]

Initialize the ODE system.

Parameters:
  • precision – Precision factory used for calculations.

  • parameters – The parameters with their defaults.

  • specialiser – Child factory holding the compiled_parameters setting, every parameter swept or fixed at a value, and building the layout, mass and equations of the system assembled for them.

  • initial_values – Default initial values by state name. States left out start from 0.0.

  • operation_ordering – Generated-operation ordering policy: "liveness_auto", "kahn", "greedy", or "dfs". Defaults to CUBIE_OPERATION_ORDERING (liveness_auto when unset).

  • name – Printable identifier for the system. Defaults to None.

_update(updates: Dict[str, Any], silent: bool) → Set[str][source]

Apply settings to the specialiser, then to this system.

Parameters:
  • updates – Setting names to new values.

  • silent – Whether update() ignores unrecognised names.

Returns:

The recognised names.

Return type:

set[str]

abstractmethod build() → ODECache[source]

Compile the dxdt system as a CUDA device function.

Returns:

Cache containing the built dxdt function. Subclasses may add further solver helpers to this cache as needed.

Return type:

ODECache

property compiled_parameters: ParameterSet

The parameter set of the currently compiled system.

copy() → BaseODE[source]

Return an independent system with these values and no build.

property driver_derivatives: Tuple[Tuple[int, int], ...]

The driver index and order of each driver derivative read.

The derivatives follow the drivers in the drivers buffer, in this order.

property dxdt_fn

Compiled dxdt(state, parameters, drivers, observables, out, t) device function.

property fixed_parameter_values: Dict[str, float]

Values compiled into the code, keyed by parameter name.

get_solver_helper(role: str, **request_kwargs: Any) → HelperResult[source]

Return the bound helper member for one role and variant.

Mass-consuming helpers read the system’s own mass.

Parameters:
  • role – Registered role name or preconditioner type name.

  • **request_kwargs – Remaining SolverHelperRequest fields.

Returns:

The bound device callable and its typed metadata.

Return type:

HelperResult

Raises:

NotImplementedError – Always; only SymbolicODE generates helpers.

property initial_values: ValuedSet

Alias for states.

property layout: SystemLayout

The variables in each device buffer, in buffer order.

property mass: Any

Return the system’s mass matrix.

None implies identity, otherwise a diagonal 0/1 matrix produced in structural simplification.

property mass_diagonal_flags: tuple

Return per-state mass flags, True for a differential row.

property num_drivers: int

Length of the drivers buffer the device functions read.

property num_observables: int

Number of observable variables.

property num_parameters: int

Number of parameters.

property num_states: int

Number of state variables.

property observables: VariableSet

The system’s observables.

property observables_fn: Callable

Compiled get_observables(state, parameters, drivers, observables, t) device function.

property operation_count: int

Binary-operator count of the dxdt and observables sources.

property operation_ordering: str

Return the generated-operation ordering policy.

property parameters: ValuedSet

Every parameter with its default value.

set_default_parameters(values: Mapping[str, float]) → None[source]

Set parameter defaults.

This method fixes every parameter that is not swept at its new default value.

Parameters:

values – Parameter names mapped to new default values.

Raises:

KeyError – If a name is not a parameter of the system.

set_initial_values(values: Mapping[str, float]) → None[source]

Set the default initial values of states.

Parameters:

values – State names mapped to new default initial values.

Raises:

KeyError – If a name is not a state of the system.

set_swept_parameters(names: Iterable[str], fixed: Mapping[str, float] | None = None) → None[source]

Set the swept parameters to names.

Parameters:
  • names – Names of the parameters to sweep, in any order.

  • fixed – Fixed values for a subset of the other parameters. This method fixes every parameter neither swept nor named here at its default value.

Raises:
  • KeyError – If a name is not a parameter of the system.

  • ValueError – If a swept name repeats or also has a fixed value.

property sizes: SystemSizes

System component sizes cached for solvers.

property specialiser: CUDAFactory

The child factory that assembles the compiled parameters.

property states: ValuedSet

Every state with its default initial value, or 0.0 for a state given none.

property swept_parameters: Tuple[str, ...]

Names of the parameters array’s rows, in order.

property swept_set: ValuedSet

The swept parameters with their default values, in row order.