Simulation Documentation

This page contains the Simulation Package documentation.

The simulation Package

This package contains the interface to different simulation packages.

The assimulo_interface Module

This file contains code for mapping our JMI Models to the Problem specifications required by Assimulo.

exception jmodelica.simulation.assimulo_interface.FMIModel_Exception[source]

Bases: exceptions.Exception

A FMIModel Exception.

class jmodelica.simulation.assimulo_interface.FMIODE(model, input=None, result_file_name='', with_jacobian=False)[source]

Bases: assimulo.problem.Explicit_Problem

An Assimulo Explicit Model extended to FMI interface.

completed_step(solver)[source]

Method which is called at each successful step.

f(t, y, sw=None)[source]

The rhs (right-hand-side) for an ODE problem.

finalize(solver)[source]
g(t, y, sw)[source]

The event indicator function for a ODE problem.

handle_event(solver, event_info)[source]

This method is called when Assimulo finds an event.

handle_result(solver, t, y)[source]

Post processing (stores the time points).

input

Property for accessing the input. The input must be a 2-tuple with the first object as a list of names of the input variables and with the other as a subclass of the class Trajectory.

j(t, y, sw=None)

The jacobian function for an ODE problem.

print_step_info()[source]

Prints the information about step events.

t(t, y, sw)[source]

Time event function.

write_cont

Property for accessing the values should be written to the file continuously during the simulation.

class jmodelica.simulation.assimulo_interface.JMIDAE(model, input=None, result_file_name='')[source]

Bases: assimulo.problem.Implicit_Problem

An Assimulo Implicit Model extended to JMI interface.

check_eIter(before, after)[source]

Helper function for handle_event to determine if we have event iteration.

Parameters:

Values of the event indicator functions (state_events) before and 
after we have changed mode of operations.
eps

Property for accessing the epsilon used for adjusting the event indicators.

event_switch(solver, event_info)[source]

This is where we turn the switches. If we have an event, this is where it will be taken care of.

event_info is a vector consisting of -1, 0, +1, and is as long as 
the number of event functions. A -1 symbolises that an event has 
occured at the specified switch and is decreasing. A 0 symbolises 
that nothing has happend. A +1 symbolises that an event has occured 
at the specified switch and is increasing.

This is the default event handling.

f(t, y, yd, sw=None)[source]

The residual function for an DAE problem.

g(t, y, yd, sw)[source]

The event indicator function for a DAE problem.

g_adjust(t, y, yd, sw)[source]

This function adjusts the event functions according to Martin Otter et al defined in ‘Modeling of Mixed Continuous/Discrete Systems in Modelica’.

g_init(t, y, yd, sw)[source]

The event indicator function for a DAE problem at initial time.

handle_event(solver, event_info)[source]

This method is called when assimulo finds an event.

init_mode(solver)[source]

Initiates the new mode.

initiate(solver)[source]

Initiates the problem.

input

Property for accessing the input. The input must be a 2-tuple with the first object as a list of names of the input variables and with the other as a subclass of the class Trajectory.

j(c, t, y, yd, sw=None)[source]

The jacobian function for an DAE problem.

log

Property for accessing the logging level. Determines if the logging should be activated (True) or deactivated (False).

max_eIter

Property for setting the maximum number of event iterations allowed.

reset()[source]

Resets the model to it’s default values.

write_cont

Property for accessing the values should be written to the file continuously during the simulation.

class jmodelica.simulation.assimulo_interface.JMIDAESens(model, input=None, result_file_name='')[source]

Bases: assimulo.problem.Implicit_Problem

An Assimulo Implicit Model extended to JMI interface with support for sensitivities.

f(t, y, yd, p=None)[source]

The residual function for an DAE problem.

finalize(solver)[source]
get_sens_result()[source]

Returns the sensitivity results together with the names.

Returns:

parameter_names, sensitivity_matrix = JMIDAESens.get_sens_result()
    
parameters_names -- 
    The names of the parameters for which sensitivities have been 
    calculated.
                           
sensitivity_matrix -- 
    A matrix containing the sensitivities for all the parameters. 
    sensitivity_matrix[0], gives the result for the first parameter 
    in the parameters_names list.
handle_result(solver, t, y, yd)[source]

Post processing (stores the time points and the sensitivity result).

j(c, t, y, yd, sw=None, p=None)[source]

The jacobian function for an DAE problem.

log

Property for accessing the logging level. Determines if the logging should be activated (True) or deactivated (False).

write_cont

Property for accessing the values should be written to the file continuously during the simulation.

exception jmodelica.simulation.assimulo_interface.JMIModel_Exception[source]

Bases: exceptions.Exception

A JMIModel Exception.

class jmodelica.simulation.assimulo_interface.JMIODE(model, input=None, result_file_name='')[source]

Bases: assimulo.problem.Explicit_Problem

An Assimulo Explicit Model extended to JMI interface.

Not extended with handling for discontinuities.

To use an explicit solver the problem have to be defined in specific way, namely: der(x) = f(t,x) in the modelica model. See http://www.jmodelica.org/page/10

f(t, y, sw=None)[source]

The rhs (right-hand-side) for an ODE problem.

g(t, y, sw)[source]

The event indicator function for a ODE problem.

input

Property for accessing the input. The input must be a 2-tuple with the first object as a list of names of the input variables and with the other as a subclass of the class Trajectory.

j(t, y, sw=None)[source]

The jacobian function for an ODE problem.

reset()[source]

Resets the model to it’s default values.

write_cont

Property for accessing the values should be written to the file continuously during the simulation.

jmodelica.simulation.assimulo_interface.createLogger(model, minimum_level)[source]

Creates a logger.

jmodelica.simulation.assimulo_interface.write_data(simulator, write_scaled_result=False, result_file_name='')[source]

Writes simulation data to a file. Takes as input a simulated model.