-
Notifications
You must be signed in to change notification settings - Fork 66
Description
Description
I run into an unexpected behaviour after an update from OpenModelica v1.25.4 to v1.26.3:
I am using OMPython v3.6 for parameter studies, mainly with the ModelicaSystem()-commands.
When I try to set simulation options to a model, I can do so by the common command mod.setSimulationOptions([...]) (Accessing these options via mod.getSimulationOptions() yields exactly the entered parameters...). However, these parameters do not seem to be transferred to the model properly as they are ignored and the default values entered in the simulation setup context or annotation(experiment(...)) section in the model are used.
Steps to Reproduce
Consider the following MWE which is embedded in a package ("MWE_package") (see screenshot):
within MWE_package;
model testmodel
parameter Real scale = 1;
Real Tout;
equation
Tout = time*scale;
annotation(
experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-06, Interval = 0.1));
end testmodel;
Editing this with the following lines of code and OMPython:
from OMPython import ModelicaSystem
from pathlib import Path
lib_path = Path(r"C:\Users\Voelzel\MWE_package\package.mo")
resfilepath = Path(r"D:\testres")
model_name = "MWE_package.testmodel"
startTime = 0
stopTime = 100
stepSize = 1
scaling = 2
mod = ModelicaSystem(
fileName = str(lib_path),
modelName = model_name
)
mod.setParameters([
f"scale={scaling}",
])
mod.setSimulationOptions([
f"startTime={startTime}",
f"stopTime={stopTime}",
f"stepSize={stepSize}",
])
mod.simulate(resultfile = str(resfilepath) + '/outfile.mat')
... gives the unexpected result shown in the following screenshot for the output variable Tout:
As you can see, the simulation stop time time still remains at 10 s instead of the entered 100 s (the same applies to the start time or the step size as well, by the way).
The parameter scale is changed as expected.
Accessing the simulation options after the editing lines above gives:
mod.getSimulationOptions()
{'startTime': '0',
'stopTime': '100',
'stepSize': '1',
'tolerance': '1e-06',
'solver': 'dassl',
'outputFormat': 'mat'}
Does anyone have an idea why setting the simulation options from OMPython does not work here, anymore?
Thanks in advance!
Version and OS
- OpenModelica Version: 1.26.3
- OS: Windows 11, 64 bit
- OMPython version 3.6