Basics

class rtctools.simulation.simulation_problem.SimulationProblem

Bases: object

FMU simulation runner.

Implements the BMI Interface.

compiler_options(self)

Subclasses can configure the JModelica.org compiler options here.

Returns:A dictionary of JModelica.org compiler options. See the JModelica.org documentation for details.
finalize(self)

Finalize FMU.

get_current_time(self)

Return current time of simulation.

Returns:The current simulation time.
get_end_time(self)

Return end time of experiment.

Returns:The end time of the experiment.
get_input_variables(self)
get_options(self)

Return the available options of the FMU.

Returns:A dictionary of options supported by the FMU.
get_output_variables(self)
get_parameter_variables(self)
get_start_time(self)

Return start time of experiment.

Returns:The start time of the experiment.
get_var(self, name)

Return a numpy array from FMU.

Parameters:name – Variable name.
Returns:The value of the variable.
get_var_count(self)

Return the number of variables (internal FMU and user declared).

Returns:The number of variables supported by the FMU.
get_var_name(self, i)

Returns the name of a variable.

Parameters:i – Index in ordered dictionary returned by FMU-method get_model_variables.
Returns:The name of the variable.
get_var_rank(self, name)

Not implemented

get_var_shape(self, name)

Not implemented

get_var_type(self, name)

Return type string, compatible with numpy.

Parameters:name – Variable name.
Returns:The type of the variable.
get_variables(self)

Return all variables of FMU (both internal and user defined)

Returns:A list of all variables supported by the FMU.
initialize(self, config_file=None)

Initialize FMU with default values

Parameters:config_file – Path to an initialization file.
post(self)

Any postprocessing takes place here.

pre(self)

Any preprocessing takes place here.

reset(self)

Reset the FMU.

setup_experiment(self, start, stop, dt=-1, tol=None)

Create an experiment.

Parameters:
  • start – Start time for the simulation.
  • stop – Final time for the simulation.
  • dt – Time step size.
  • tol – Tolerance of the underlying FMU method.
simulate(self)

Run model from start_time to end_time.

update(self, dt)

Performs one timestep.

The method setup_experiment must have been called before.

Parameters:dt – Time step size.
rtctools.util.run_simulation_problem(simulation_problem_class, base_folder='..', log_level=logging.INFO)

Sets up and runs a simulation problem.

Parameters:
  • simulation_problem_class – Optimization 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.