BaseODE
- class cubie.odesystems.BaseODE(precision: type[float16] | type[float32] | type[float64] | dtype[float16] | dtype[float32] | dtype[float64] = <class 'numpy.float32'>, initial_values: Dict[str, float] | None=None, parameters: Dict[str, float] | None=None, constants: Dict[str, float] | None=None, observables: Dict[str, float] | None=None, default_initial_values: Dict[str, float] | None=None, default_parameters: Dict[str, float] | None=None, default_constants: Dict[str, float] | None=None, default_observable_names: Dict[str, float] | None=None, num_drivers: int = 1, 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.- __init__(precision: type[float16] | type[float32] | type[float64] | dtype[float16] | dtype[float32] | dtype[float64] = <class 'numpy.float32'>, initial_values: Dict[str, float] | None=None, parameters: Dict[str, float] | None=None, constants: Dict[str, float] | None=None, observables: Dict[str, float] | None=None, default_initial_values: Dict[str, float] | None=None, default_parameters: Dict[str, float] | None=None, default_constants: Dict[str, float] | None=None, default_observable_names: Dict[str, float] | None=None, num_drivers: int = 1, name: str | None = None) None[source]
Initialize the ODE system.
- Parameters:
initial_values – Initial values for state variables.
parameters – Parameter values for the system.
constants – Constants that are not expected to change between simulations.
observables – Observable values to track.
default_initial_values – Default initial values if
initial_valuesomits entries.default_parameters – Default parameter values if
parametersomits entries.default_constants – Default constant values if
constantsomits entries.default_observable_names – Default observable names if
observablesomits entries.precision – Precision factory used for calculations. Defaults to
numpy.float32.num_drivers – Number of driver or forcing functions. Defaults to
1.name – Printable identifier for the system. Defaults to
None.
- 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:
Notes
Bring constants into local (outer) scope before defining
dxdtbecause CUDA device functions cannot referenceself.
- property config_hash
Configuration hash incorporating constant values.
- property constants: SystemValues
Constant values configured for the system.
- property evaluate_f
Compiled
dxdt(state, parameters, drivers, observables, out, t)device function.
- property evaluate_observables: Callable
Compiled
get_observables(state, parameters, drivers, observables, t)device function.
- get_solver_helper(func_name: str, beta: float = 1.0, gamma: float = 1.0, mass: Any = 1.0, preconditioner_order: int = 0) Callable[source]
Retrieve a cached solver helper function.
- Parameters:
func_name – Identifier for the helper function.
beta – Shift parameter for the linear operator. Defaults to
1.0.gamma – Weight of the Jacobian term in the linear operator. Defaults to
1.0.preconditioner_order – Polynomial order of the preconditioner. Defaults to
0. Unused when generating the linear operator.mass – Mass matrix used by the linear operator. Defaults to identity.
- Returns:
Cached device function corresponding to
func_name.- Return type:
Callable
Notes
Returns
NotImplementedErrorif theODESystemlacks generated code for the requested helper.
- property initial_values: SystemValues
Alias for
states.
- property observables: SystemValues
Observable definitions configured for the system.
- property parameters: SystemValues
Parameter values configured for the system.
- set_constants(updates_dict: Dict[str, float] | None = None, silent: bool = False, **kwargs: float) Set[str][source]
Update constant values in the system.
- Parameters:
updates_dict – Mapping from constant names to their new values.
silent – Set to
Trueto suppress warnings about missing keys.**kwargs – Additional constant updates provided as keyword arguments. These override entries in
updates_dict.
- Returns:
Labels that were recognized and updated.
- Return type:
- property sizes
System component sizes cached for solvers.
- property states: SystemValues
Initial state values configured for the system.
- update(updates_dict: Dict[str, float] | None, silent: bool = False, **kwargs: float) Set[str][source]
Update compile settings through the
CUDAFactoryinterface.Pass updates through the compile-settings interface, which invalidates caches when an update succeeds.
- Parameters:
updates_dict – Dictionary of updates to apply.
silent – Set to
Trueto suppress warnings about missing keys.**kwargs – Additional updates specified as keyword arguments.
- Returns:
Labels that were recognized and updated.
- Return type:
Notes
Pass
silent=Truewhen performing bulk updates that may include values for other components to suppress warnings about missing keys.