OMSimulator icon indicating copy to clipboard operation
OMSimulator copied to clipboard

Different values on source and destination connection in ssd file

Open larsviktorlarsson opened this issue 4 months ago • 1 comments

In an ssd file "D16_aero_stimuli.ssd" I have a connetor output "u" on the ssd top level. The "u" connector is connected to an output "u of an FMU in the ssd. After simulation of the model, I expect OMsimulator to log the same values on both "u" and "u.out.y", but this is not the case:

Image

I have uploaded the complete .ssp file as a .zip file.

ParkerSimPack.zip

Running OMSimulator in python on windows: oms.version Out[9]: 'OMSimulator v2.1.3-win-notlm'

Execute the following code to simulate the model of interest:

ssd2Run= "D16_aero_stimuli" from OMSimulator import OMSimulator

oms = OMSimulator() oms.importFile("ParkerSimPack.ssp")# %% oms.setCommandLineOption("--emitEvents=false") # Removes duplicate log samples in result file oms.setCommandLineOption("--stripRoot=true") # Removes root names in variable names in log file oms.activateVariant(SSP1.SSDs[0].root.get("name"),ssd2Run) oms.instantiate(ssd2Run) oms.initialize(ssd2Run)

oms.simulate(ssd2Run) oms.terminate(ssd2Run) oms.delete(ssd2Run)

larsviktorlarsson avatar Sep 19 '25 13:09 larsviktorlarsson

@larsviktorlarsson I have tested your ssp in our new oms3 API and the results looks fine for u and u.out.y, see the plot below

Image

Please try to test the ssp on our new oms3 API which is pushed to the master branch. Please update your branch and test the API, But in principle it should also work with the version you have, But i suggest you to use our new API in python. An example script would be

import logging
logging.basicConfig(level=logging.INFO)

from OMSimulator import SSD, SSP, Settings, Capi

Settings.suppressPath = True

model = SSP('../resources/ParkerSimPack.ssp')
print(model.getAllVariantNames())
model.activeVariantName = "D16_aero_stimuli"
instantiated_model = model.instantiate() ## internally generate the json file and also set the model state like virgin,
print("", flush=True)
instantiated_model.setStopTime(20.0)
instantiated_model.setResultFile("parker_simulation_res.mat")

instantiated_model.initialize()
instantiated_model.simulate()
instantiated_model.terminate()
instantiated_model.delete()

Documentation about the new oms3 API can be read here https://openmodelica.org/doc/OMSimulator/master/OMSimulator/UsersGuide/html/OMSimulatorPython3.html And also more examples on how to use the new API are found here https://github.com/OpenModelica/OMSimulator/tree/master/testsuite/simulation

arun3688 avatar Sep 24 '25 12:09 arun3688