Opened 8 years ago

Closed 8 years ago

#4248 closed defect (fixed)

OMEdit causes wrong simulation results

Reported by: Christian Kral <dr.christian.kral@…> Owned by: Adrian Pop
Priority: blocker Milestone: 1.11.0
Component: Frontend Version:
Keywords: Cc: a.haumer@…, Lennart Ochel, Martin Sjölund, Patrick Täuber, jhagemann, Adeel Asghar, Adrian Pop

Description

Please consider the attached simulation example IMCNominalOperation.NominalOperation. Run the example and compare the variables

  • powerSensor.y.re
  • imc.powerBalance.powerStator

These two variables must be equal and they are equal in Dymoa. In OpenModelica there exists a deviation by the factor of 3.

As all the voltages and currents are OK, the problem seems to be related with the evaluation of Modelica.Electrical.QuasiStationary.MultiPhase.Functions.activePower.

This issue refers to:

OMEdit 1.12.0~dev-156-g85fb2b9
Connected to OpenModelica 1.12.0~dev-328-g4f7ddab
Linux Mint 18.1 64bit

Attachments (3)

IMCNominalOperation.mo (9.6 KB ) - added by Christian Kral <dr.christian.kral@…> 8 years ago.
Esimulation example demonstrating the issue
deviation.png (19.0 KB ) - added by Christian Kral <dr.christian.kral@…> 8 years ago.
Simulation result showing the deviation
plot-win64.png (11.7 KB ) - added by Adeel Asghar 8 years ago.

Download all attachments as: .zip

Change History (24)

by Christian Kral <dr.christian.kral@…>, 8 years ago

Attachment: IMCNominalOperation.mo added

Esimulation example demonstrating the issue

by Christian Kral <dr.christian.kral@…>, 8 years ago

Attachment: deviation.png added

Simulation result showing the deviation

comment:1 by Adeel Asghar, 8 years ago

Cc: Lennart Ochel Martin Sjölund added
Component: OMEditRun-time
Owner: changed from Adeel Asghar to Willi Braun
Status: newassigned

This might be a Linux issue as they appear same on Windows 64-bit.

by Adeel Asghar, 8 years ago

Attachment: plot-win64.png added

comment:2 by Willi Braun, 8 years ago

Cc: Patrick Täuber added
Component: Run-timeBackend
Summary: OpenModelica causes wrong simulation resultswrapFunctionCall causes wrong results

It works for me without the recently enabled modules wrapFunctionCall module.
A work-a-round is to disable it by +postOptModules-=wrapFunctionCalls.

@adeas31 Can you verify that this module was enabled and it still works on Windows.

comment:3 by Lennart Ochel, 8 years ago

Milestone: Future1.12.0
Owner: changed from Willi Braun to Lennart Ochel
Status: assignedaccepted

comment:4 by ahaumer@…, 8 years ago

I have the same problem on Windows64 with OpenModelica 1.11 beta 3.

comment:5 by Willi Braun, 8 years ago

Milestone: 1.12.01.11.0
Priority: highblocker

in reply to:  5 ; comment:6 by Lennart Ochel, 8 years ago

Cc: jhagemann added

Replying to wbraun

Milestone changed from 1.12.0 to 1.11.0

Why did you change milestone to 1.11.0? The module wrapFunctionCalls will be introduced as feature with version 1.12.0.

in reply to:  6 ; comment:7 by Willi Braun, 8 years ago

Replying to lochel:

Replying to wbraun

Milestone changed from 1.12.0 to 1.11.0

Why did you change milestone to 1.11.0? The module wrapFunctionCalls will be introduced as feature with version 1.12.0.

but it seems also be enabled by default for 1.11 beta 3 as

Replying to ahaumer@...
I have the same problem on Windows64 with OpenModelica 1.11 beta 3.

comment:8 by Lennart Ochel, 8 years ago

I cannot reproduce the issue. Both signals seem to be equal. Maybe you could provide some more information on how to reproduce the issue.

in reply to:  2 comment:9 by Lennart Ochel, 8 years ago

Replying to wbraun:

A work-a-round is to disable it by +postOptModules-=wrapFunctionCalls.

That does not work for me, because then the simulation execution fails.

Simulation execution failed for model: IMCNominalOperation.NominalOperation
DASKR--  AT T (=R1) AND STEPSIZE H (=R2) THE
      In above,  R1 =   9.3462593976256E-10   R2 =   7.7526609695740E-20
DASKR--  ERROR TEST FAILED REPEATEDLY OR WITH ABS(H)=HMIN
stdout            | warning | DDASSL had repeated error test failures on the last attempted step.
stdout            | warning | can't continue. time = 0.000000
stdout            | info    | model terminate | Integrator failed. | Simulation terminated at time 9.34626e-10

in reply to:  7 comment:10 by Lennart Ochel, 8 years ago

Replying to wbraun:

but it seems also be enabled by default for 1.11 beta 3 as

No it's not.

comment:11 by Willi Braun, 8 years ago

Summary: wrapFunctionCall causes wrong resultsOMEdit causes wrong simulation results

Okay, my first analysis was wrong it's not wrapFunctionCall. It's strange I can reproduce the issue with OMEdit, but not on command line with the same omc version.

comment:12 by Martin Sjölund, 8 years ago

OMEdit sets -d=nogen while OMC does not. Does it impact the results?

in reply to:  12 comment:13 by Lennart Ochel, 8 years ago

Replying to sjoelund.se:

OMEdit sets -d=nogen while OMC does not. Does it impact the results?

No. I just tried the example with -d=nogen and the two signals are still equal.

comment:14 by Lennart Ochel, 8 years ago

Cc: Adeel Asghar added

As far as I can see, OMEdit sets the following flags to translate the model:

setMatchingAlgorithm("PFPlusExt"); getErrorString();
setIndexReductionMethod("dynamicStateSelection"); getErrorString();
setCommandLineOptions("-d=initialization"); getErrorString();
setCommandLineOptions("--simCodeTarget=C"); getErrorString();
setCommandLineOptions("--target=gcc"); getErrorString();
setCommandLineOptions("+profiling=none"); getErrorString();

However, it is not possible to reproduce the issue with this configuration. Adeel, what else does OMEdit?

comment:15 by anonymous, 8 years ago

One of signals has a unit, where the other has not. related?

comment:16 by Adeel Asghar, 8 years ago

Try calling the simulation executable from the command line with same arguments as OMEdit does.

in reply to:  15 comment:17 by Lennart Ochel, 8 years ago

Replying to anonymous:

One of signals has a unit, where the other has not. related?

Signal imc.powerBalance.powerStator has unit W, whereas powerSensor.y.re has no unit. I cannot see how this could lead to difference of factor 3 between both signals.

comment:18 by Adeel Asghar, 8 years ago

Its fixed in OMEdit 015e9da/OMEdit.
The problem is caused because some of the query API function is setting some flag and then not resetting it back. Willi is investigating more about it.

comment:19 by Willi Braun, 8 years ago

Cc: Adrian Pop added
Component: BackendFrontend

With the following script we were able to reproduce the issue:

loadModel(Modelica, {"3.2.2"});
getErrorString();

loadFile("./IMCNominalOperation.mo");
getErrorString();

getComponentAnnotations(Modelica.Magnetic.QuasiStatic.FundamentalWave.BasicMachines.BaseClasses.PartialBasicMachine); getErrorString();

simulate(IMCNominalOperation.NominalOperation);

val(powerSensor.y.re, 0.001, "./IMCNominalOperation.NominalOperation_res.mat");
val(imc.powerBalance.powerStator, 0.001, "./IMCNominalOperation.NominalOperation_res.mat");

so the if
getComponentAnnotations(Modelica.Magnetic.QuasiStatic.FundamentalWave.BasicMachines.BaseClasses.PartialBasicMachine); is executed you get different results, otherwise the variables are equal.

comment:20 by Adrian Pop, 8 years ago

Owner: changed from Lennart Ochel to Adrian Pop

comment:21 by Adrian Pop, 8 years ago

Resolution: fixed
Status: acceptedclosed
Note: See TracTickets for help on using tickets.