Basics
- class rtctools.simulation.simulation_problem.SimulationProblem(**kwargs)[source]
Bases:
DataStoreAccessor
Implements the BMI Interface.
Base class for all Simulation problems. Loads the Modelica Model.
- Variables:
modelica_library_folders – Folders containing any referenced Modelica libraries. Default is an empty list.
- get_current_time()[source]
Return current time of simulation.
- Returns:
The current simulation time.
- get_start_time()[source]
Return start time of experiment.
- Returns:
The start time of the experiment.
- get_var(name)[source]
Return a numpy array from FMU.
- Parameters:
name – Variable name.
- Returns:
The value of the variable.
- get_var_count()[source]
Return the number of variables in the model.
- Returns:
The number of variables in the model.
- get_var_name(i)[source]
Returns the name of a variable.
- Parameters:
i – Index in ordered dictionary returned by method get_variables.
- Returns:
The name of the variable.
- get_var_type(name)[source]
Return type, compatible with numpy.
- Parameters:
name – String variable name.
- Returns:
The numpy-compatible type of the variable.
- Raises:
KeyError
- get_variables()[source]
Return all variables (both internal and user defined)
- Returns:
An ordered dictionary of all variables supported by the model.
- initialize(config_file=None)[source]
Initialize state vector with default values
Initial values are first read from the given Modelica files. If an initial value equals zero or is not provided by a Modelica file, and the variable is not marked as fixed, then the initial value is tried to be set with the initial_state method. When using CSVMixin, this method by default looks for initial values in an initial_state.csv file. Furthermore, if a variable is not marked as fixed and no initial value is given by the initial_state method, the initial value can be overwritten using the seed method. When a variable is marked as fixed, the initial value is only read from the Modelica file.
- Parameters:
config_file – Path to an initialization file.
- rtctools.util.run_simulation_problem(simulation_problem_class, base_folder='..', log_level=20, **kwargs)[source]
Sets up and runs a simulation problem.
- Parameters:
simulation_problem_class – Simulation problem class to solve.
base_folder – Folder within which subfolders “input”, “output”, and “model” exist, containing input and output data, and the model, respectively.
log_level – The log level to use.
- Returns:
SimulationProblem
instance.