FMU initialization

6 posts / 0 new
Last post
Jacopo
Offline
Joined: 2011-11-08
FMU initialization

Hi all,
 
I’d like to initialize an FMU model using Dymola since JModelica apparently fails in solving the non linear equations system, I know that I can import the results using the init=ResultDymolaTextual() syntax but I don’t know how to set all the variables in the model equal to the one in the init object. Do I have to use the
x_res = init['x']
sim_model.set(‘x', x_res)
syntax for every variable of the model or is there a function to initialize all of them at once?
 
Thank you very much!
Best regards
 
Jacopo

jakesson
Offline
Joined: 2009-03-14
Dear Jacopo,   It depends on

Dear Jacopo,
 
It depends on the type of sim_model: if it is of type JMUModel, you may use JMUModel.initialize_from_data to achieve this.
 
Best regards
/Johan

mathias
Offline
Joined: 2012-05-11
FMUModel initialization

Is there a corresponding method for FMUModel:s? Or what is the preferred way of programmatically initializing FMU:s from previous simulation runs. We would like to run several consecutive simulation executions, i.e. simulate(time 0 to 1) followed by simulate(time 1 to 2), ... initializing the simulate(1 to 2) start states to the end states of simulate(0 to 1).
 
/Björn and Mathias
 

chria
Offline
Joined: 2009-07-29
Reinitializing an FMU and

Reinitializing an FMU and running a series of simulation is not really completely thought through in FMI. However I believe there are a two options available.

1.

If you have run a simulation using the .simulate method the model is already initialized and go to go. So what one has to do is just change the state variables values and start the simulation again (in principle). So in order to get the states value references you can do something like this:

references = model.get_state_value_references() #Retrieves the value references for the state variables

#Get all variables in the model so that we can find out about which variablename maps to the given state value references.
all_real = model.get_variable_names(data_type=0,include_alias=False)
all_real_as_dict = dict(all_real)

#Loop over references and extract the names related to the valuereference from all_real_as_dict ...
name_1 = all_real_as_dict[references[0]] #For all variables

#Extract the values from your result file and use model.get to set the values into the model.
 

Ok, so far so good. Now you also need to update derivatives values in the model:

model.get_derivatives()

And you also need to call event_update to check if there are any switches that should be turned.

model.event_update()

Note that this call can change your state values so check them again.

Finally you need to disable initialization when calling the simulate method.
 

opts = model.simulate_options()
opts["initialize"] = False

model.simulate(options=opts)

2.

There is also a second options that is related to providing a parameter to all your start values in the model and before calling the simulate method you need to set all those parameters in the model. This options requires that the model is reloaded after each simulation.

I have also created a ticket for creating a convenience function for this similar to what is done in JMU models. (https://trac.jmodelica.org/ticket/1972)

Best
/Christian

tikdrian
Offline
Joined: 2010-02-18
FMU initialization from data

Hi,
I saw this discussion and I was wondering if there is something new for the FMU initialisation using a data file. 
I’d like to initialize a FMU model using a Dymola file, since JM initialization apparently fails. I've tried to manually introduce initial start values for the system variables, but it's quite difficult when the size of the system is high.
 
I want also ask about the difference between JMU and FMU compilations in terms of computation time. What I've noticed in my case, is that the JMU compilation is quite slow compared to the FMU compilation (order of minutes). What could be the cause? The FMU compiler is more optimized?
 
Best regards,
Adrian

chria
Offline
Joined: 2009-07-29
Hi,   There has been no

Hi,
 
There has been no progress in this area unfortunately. The current FMI framework does not support this.
 
Our focus has been on improving the FMU compilation as the JMUs are currently being phased out (or will in the near future) so that is the reason why it is faster, but on the other hand I would have thought that the improvements would also impact the JMU compilation.
 
Best
/Christian

Login or register to post comments