BaseStepController

class cubie.integrators.step_control.base_step_controller.BaseStepController(precision: type[float16] | type[float32] | type[float64] | dtype[float16] | dtype[float32] | dtype[float64], dt: float = None, n_states: int = 1, **kwargs)[source]

Bases: CUDAFactory

Factory interface for compiling CUDA step-size controllers.

__init__(precision: type[float16] | type[float32] | type[float64] | dtype[float16] | dtype[float32] | dtype[float64], dt: float = None, n_states: int = 1, **kwargs) None[source]

Initialise the step controller.

Parameters:
  • precision – Precision used for controller calculations.

  • dt – Step size or initial step size.

  • n_states – Number of state variables.

  • **kwargs – Additional parameters passed to the config class.

_apply_filter_coefficients(params: dict) set[str][source]

Translate filter_coefficients in params into gains.

Parameters:

params – Mutable settings mapping; modified in place.

Returns:

The consumed keys.

Return type:

set[str]

Raises:

ValueError – On mixed gain and filter input, or an unsupported gain.

property atol: ndarray

Return absolute tolerance.

build() ControllerCache[source]

Compile the controller and record its bounds and tolerances.

Returns:

The compiled controller with its products filled in.

Return type:

ControllerCache

abstractmethod compile_controller() ControllerCache[source]

Compile the controller device function.

Returns:

The compiled controller.

Return type:

ControllerCache

property device_function: Callable

Return the compiled step-controller device function.

property dt: float

Return the initial step size.

property dt_max: float

Return the maximum supported step size.

property dt_min: float

Return the minimum supported step size.

property gain_names: tuple[str, ...]

Return the PID gain keys this controller’s config carries.

property is_adaptive: bool

Return True if the controller is adaptive.

property mass_flags: Tuple[bool, ...]

Return the per-state mass-diagonal flags.

property n_states: int

Return the number of controlled state variables.

register_buffers() None[source]

Register controller buffers with the central buffer registry.

Registers the timestep_buffer at _timestep_buffer_elements history slots in the location given by compile_settings.timestep_memory_location. Controllers that keep no history (_timestep_buffer_elements == 0) register nothing, so the registry owns the size like every other buffer-registered class.

property rtol: ndarray

Return relative tolerance.

settings_keys: frozenset | None = frozenset({'algorithm_order', 'atol', 'deadband_max', 'deadband_min', 'derivative_gain', 'dt', 'dt_max', 'dt_min', 'filter_coefficients', 'integral_gain', 'mass_flags', 'max_step_growth', 'min_step_shrink', 'n_states', 'newton_target_iters', 'precision', 'proportional_gain', 'rtol', 'safety', 'step_controller', 'timestep_memory_location'})

Loose keys the factory accepts; None accepts every field.

classmethod system_inputs(system: Any, algorithm_order: int) Dict[str, Any][source]

Return controller settings from a system object and step order.

update(updates_dict: dict[str, object] | None = None, silent: bool = False, **kwargs: object) set[str][source]

Propagate configuration updates to the compiled controller.

Parameters:
  • updates_dict – Dictionary of configuration values to update.

  • silent – When True suppress warnings for recognised but unused controller parameters.

  • **kwargs – Additional configuration key-value pairs to update.

Returns:

Names of parameters that were applied successfully.

Return type:

set[str]

Raises:

KeyError – Raised when an update references parameters that are not defined for any controller.