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:
CUDAFactoryAbstract 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 viaget_solver_helper(). The base class handles value management, precision selection, and caching throughCUDAFactory.Notes
Only functions cached during
build()(typicallydxdt) are available on this base class. Solver helper functions such as the linear operator or preconditioner are generated only by subclasses likeSymbolicODE.BaseODEkeeps 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_parameterssetting, every parameter swept or fixed at a value, and building thelayout,massand 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 toCUBIE_OPERATION_ORDERING(liveness_autowhen 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.
- abstractmethod build() ODECache[source]
Compile the
dxdtsystem as a CUDA device function.- Returns:
Cache containing the built
dxdtfunction. Subclasses may add further solver helpers to this cache as needed.- Return type:
- property compiled_parameters: ParameterSet
The parameter set of the currently compiled system.
- 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
SolverHelperRequestfields.
- Returns:
The bound device callable and its typed metadata.
- Return type:
HelperResult
- Raises:
NotImplementedError – Always; only
SymbolicODEgenerates helpers.
- property layout: SystemLayout
The variables in each device buffer, in buffer order.
- property mass: Any
Return the system’s mass matrix.
Noneimplies identity, otherwise a diagonal 0/1 matrix produced in structural simplification.
- property observables: VariableSet
The system’s observables.
- property observables_fn: Callable
Compiled
get_observables(state, parameters, drivers, observables, t)device function.
- 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.