Skip to content

Commit

Permalink
use max(defaultNumberOfIntervals, numberOfIntervalsInReference) for s…
Browse files Browse the repository at this point in the history
…imulation so that verification works better (#152)
  • Loading branch information
adrpo authored Oct 31, 2024
1 parent 54beace commit 0d43112
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions testmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ def createOmcSessionNew():

outputFormat="mat"
referenceVars=[]
numberOfIntervalsInReference = 0
referenceFile = conf.get("referenceFile") or ""
if referenceFile != "":
try:
Expand All @@ -243,8 +244,10 @@ def createOmcSessionNew():
referenceVars=[s.strip() for s in open(compSignals).readlines() if (s.strip() != "")] # s.strip().lower() != "time" and ??? I guess we should check time variable...
print(referenceVars)
else:
referenceVars=omc_new.sendExpression('readSimulationResultVars("%s", readParameters=true, openmodelicaStyle=true)' % referenceFile)
referenceVars=omc_new.sendExpression('readSimulationResultVars("%s", readParameters=true, openmodelicaStyle=true)' % referenceFile)
variableFilter="|".join([v.replace("[",".").replace("]",".").replace("(",".").replace(")",".").replace('"',".") for v in referenceVars])
# get the number of intervals from the file
numberOfIntervalsInReference = omc_new.sendExpression('readSimulationResultSize("%s")' % referenceFile)
emit_protected="-emit_protected"
except:
referenceFile=""
Expand Down Expand Up @@ -334,7 +337,7 @@ def sendExpressionOldOrNew(cmd):
return omc_new.sendExpression(cmd)

annotationSimFlags=""
(startTime,stopTime,tolerance,numberOfIntervals,stepSize)=sendExpressionOldOrNew('getSimulationOptions(%s,defaultTolerance=%s,defaultNumberOfIntervals=%s)' % (conf["modelName"], conf["defaultTolerance"], conf["defaultNumberOfIntervals"]))
(startTime,stopTime,tolerance,numberOfIntervals,stepSize)=sendExpressionOldOrNew('getSimulationOptions(%s,defaultTolerance=%s,defaultNumberOfIntervals=%s)' % (conf["modelName"], conf["defaultTolerance"], max(conf["defaultNumberOfIntervals"], numberOfIntervalsInReference)))
if conf["simCodeTarget"]=="C" and sendExpressionOldOrNew('classAnnotationExists(%s, __OpenModelica_simulationFlags)' % conf["modelName"]):
for flag in sendExpressionOldOrNew('getAnnotationNamedModifiers(%s,"__OpenModelica_simulationFlags")' % conf["modelName"]):
if flag=="The searched annotation name not found":
Expand Down

0 comments on commit 0d43112

Please sign in to comment.