Highlighted

Simulink Co-Sim with a Master-Slave System

Experimenter
Experimenter

Hello,

 

I am trying to split the AMEsim part of my AMEsim (15.2, visual c++ 64bit compiler) + Simulink (r2017b 64bit) Cosim into a master-slave system to enable the simulation to use all CPU cores. Without the master slave, it works just fine and also a master-slave system with no cosim works. However it wont run if I combine the cosim and the master slave system, even with a very simple model. This is the simple model I have been trying it with:

 

 

AMEsim1.PNGAMEsim2.PNG

 

 

 

 

 

 

 

 

 

 

 

 

 

I am getting this AMEsim error log threw the Simulink Simulation:

 

cosim_slave_master_test/master_cosim_test: Evaluating parameter Sample time, set to 0.01.

cosim_slave_master_test/master_cosim_test: Evaluating parameter Print interval, set to 0.01.

cosim_slave_master_test/master_cosim_test: Evaluating parameter Tolerance, set to 1e-05.

cosim_slave_master_test/master_cosim_test: Evaluating parameter Maximum step size, set to 1e+30.

Instantiating a system with 2 unknowns.

 

Requesting hydraulic license ...

got the license for hydraulic, continuing

Number of nodes in HLLWPIPE0 instance 1 evaluated by the automatic selection is 66.

Warning in HLLWPIPE0 instance 1, the number of nodes is limited to the maximum value 10.

 

Requesting amesim_runtime license ...

got the license for amesim_runtime, continuing

 

Requesting discrete_part_runtime license ...

got the license for discrete_part_runtime, continuing

Child is 18208.

Slave associated with HLGSLAV01 instance 1 has stopped running.

Slave associated with HLGSLAV01 instance 1 has stopped running.

 

Total CPU time: 0.046875 seconds.

Could not kill the child 18208

 

I have got the same error with a different, complex model. I could not find any information on AMEsim-Simulink Co-Simulations with a Master-Slave system, so it makes me wonder if it is even possible and if it is possible, where the error is.

3 REPLIES 3

Re: Simulink Co-Sim with a Master-Slave System

Siemens Experimenter Siemens Experimenter
Siemens Experimenter

Hello Andreas,

 

I suspect that the Amesim discrete partitioning (DP) slave waits for the Amesim DP master to start (blocking wait mode)… and that this master never starts. Indeed, a slave can be associated only to one master but I see that you have put the Simulink interface block in the sketch of the DP slave, which will not work. In terms of software architecture, it's always better to have only one master at the top level that manages all the slaves.

 

Therefore, the preferred solution would be to import the Simulink model into the Amesim DP master (SL2Amecosim). Thus the Simulink model will be seen and managed as a standard Amesim submodel and the only master will be the Amesim DP master (that will start the complete co-simulation). If you really need the master to be Simulink, then you should try putting the Simulink interface block in the sketch of the Amesim DP master (not the DP slave). However, such a Matryoshka configuration might lead to more numerical instabilities (the top-level Simulink master will not “see” the Amesim DP slave). 

Re: Simulink Co-Sim with a Master-Slave System

Experimenter
Experimenter

Thank you for your answer.

 

In my model the interface block already is already in the DP master not in the DP slave, so I already tried some kind of Matryoshka configuration, which did not work. So I am assuming this does not work in general because this very basic program does not run.

 

I looked into putting simulink as a slave, but this is not feasable for me, because I am implementing my controls in Simulink and need to do changes on them every iteration. Also I am useing a bunch of third party scripts (e.g. CAN) in there which will have issues compiling.

 

I guess I have to stick with AMEsim only useing one core useing Simulink as the master.

 

Cheers,

Andreas

Re: Simulink Co-Sim with a Master-Slave System

Siemens Valued Contributor Siemens Valued Contributor
Siemens Valued Contributor

Dear @Andreas9,

 

I am not 100% sure of your use case but eventually you might want to see if Simcenter System Synthesis could be of help for you (https://www.plm.automation.siemens.com/global/de/products/simcenter/simcenter-system-synthesis.html)...

 

Because you mentioned that you have to handle scripts in each iterations might there are some features of System Synthesis that could help you on the long run....but again....I am not certain of your typical use cases.

 

Here a couple of screenshots of System Synthesis managing a Simulink model and its scriptsSimulinkSysSyn.jpg

 

Script Management for the Model to be used in System Synthesis

scriptsSysSyn.png

 

 Hope this helps

 

Regards

Dennis