pySimBlocks.blocks.systems.non_linear_state_space¶
- class pySimBlocks.blocks.systems.non_linear_state_space.NonLinearStateSpace(name: str, state_function: Callable, output_function: Callable, input_keys: List[str], output_keys: List[str], x0: ndarray, sample_time: float | None = None)[source]¶
Bases:
BlockUser-defined nonlinear state-space block.
Implements a nonlinear discrete-time system driven by two user-provided callables:
x[k+1] = state_function(t, dt, x, u1, u2, …)
y[k] = output_function(t, dt, x)
Input and output port names are declared dynamically via
input_keysandoutput_keys. All inputs and outputs must be column vectors of shape (n, 1).- input_keys¶
Names of the input ports.
- output_keys¶
Names of the output ports.
- direct_feedthrough = False¶
True if outputs depend directly on inputs.
- is_source = False¶
True if the block produces signals with no inputs.
- classmethod adapt_params(params: Dict[str, Any], params_dir: Path | None = None) Dict[str, Any][source]¶
Load state and output callables from
file_pathYAML keys.- Parameters:
params – Raw parameter dict loaded from the YAML project file.
params_dir – Directory of the project file, for resolving relative paths. Must not be None.
- Returns:
Parameter dict with
state_functionandoutput_functionset to the loaded callables, andfile_path,state_function_name,output_function_namekeys removed.- Raises:
ValueError – If
params_diris None or if required keys are missing fromparams.FileNotFoundError – If the function file does not exist.
AttributeError – If a named function is not found in the module.
TypeError – If a resolved attribute is not callable.
- initialize(t0: float) None[source]¶
Validate function signatures and declare input/output ports.
- Parameters:
t0 – Initial simulation time in seconds.