Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#3656 closed defect (fixed)

Current removeSimpleEquation module causes leading sign error

Reported by: ahaumer@… Owned by: Willi Braun
Priority: blocker Milestone: 1.9.4
Component: Backend Version:
Keywords: Cc: christian.kral@…

Description

I'm developing some new components for teaching, please have a look at the enclosed small library. When simulating the Elevator example, plot cabin.s and cabin.v - I'm surprised why with cabin.s increases with a negative cabin.v. The equations in component MassGravitation v=der(s) seem correct. In an other simulation environment (Dymola) the result is correct.

Attachments (2)

Elevator.mo (12.8 KB ) - added by Christian Kral <dr.christian.kral@…> 9 years ago.
Example to demonstrate bug
cabin.png (19.7 KB ) - added by Christian Kral <dr.christian.kral@…> 9 years ago.
Plot of simulation results

Download all attachments as: .zip

Change History (18)

comment:1 by ahaumer@…, 9 years ago

I can't attach the library.
Please tell me where and how I can register for the OpenModelica trac.
I'm using OpenModelica for teaching, and I'm already registered at OpenModelica.org.

comment:2 by Adrian Pop, 9 years ago

Hi,

I guess you have issues with a bug in Trac because of German default language in browser.
You can go to Preferences->Language and set it to English US and then try to attach again.

Cheers,
Adrian Pop/

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

Attachment: Elevator.mo added

Example to demonstrate bug

comment:3 by Christian Kral <dr.christian.kral@…>, 9 years ago

This issue occurs with OpenModelica 1.9.4~dev-695-g5815c70, both in Windows and Linux 64bit.

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

Attachment: cabin.png added

Plot of simulation results

comment:4 by Christian Kral <dr.christian.kral@…>, 9 years ago

Just to clarify the ticket. The equations of motion in class MassGravitation are

  v = der(s);
  a = der(v);

I therefore expect that the positive slope (derivative) of cabin.s results in a positive velocity cabin.v -- which is not the case. Additionally, the acceleration shall be positive at the beginning of the simulation and negative towards the end of the simulation.

It is thus obvious, that the signs of the curves of cabin.v and cabin.s are wrong, even though the result of cabin.s is correct; I attached a PNG file of the simulations results.

This is a severe problem.

comment:5 by Adrian Pop, 9 years ago

Owner: changed from somebody to Willi Braun
Status: newassigned

Willi, can you have a look at this?

comment:6 by Willi Braun, 9 years ago

Status: assignedaccepted

comment:7 by Willi Braun, 9 years ago

Component: *unknown*Backend
Milestone: Future1.9.4
Priority: highblocker
Status: acceptedassigned

It seems to be again a nasty alias elimination bug in the current removeSimpleEquation module,
since it works correct with the new implementation and also without removeSimpleEquation at all.

comment:8 by Willi Braun, 9 years ago

Summary: mysterious resultCurrent removeSimpleEquation module causes leading sign error

comment:9 by Rüdiger Franke, 9 years ago

There must be a reason why the new implementation is not yet used regularily. Would it be possible to just disable negative aliases for now?

comment:10 by Rüdiger Franke, 9 years ago

Something must be done urgently if OpenModelica produces such wrong results. I tested to disable the detection of negated aliases, in order to get an impression of the impact. This would be one option, in case the root cause is not found in the old implemenation and the new implementation is not yet ready.

See changes in Compiler/BackEnd/RemoveSimpleEquations.mo, function SimpleEquationAcausal:
https://github.com/rfranke/OMCompiler/commit/11832fc4634093926b9074ce343c8e4cbed3662d

The Hudson test results are not that bad, see:
https://test.openmodelica.org/hudson/job/OpenModelica_TEST_PULL_REQUEST/1578/

Here is simulation_modelica_others.EngineV6_output.mos for an example -- less alias eliminations result in less warnings for inconsistent start values:

-There have been 1441 SCCs and now there are 554 SCCs.
+There have been 1295 SCCs and now there are 596 SCCs.
 record SimulationResult
 resultFile = "EngineV6_output_res.mat",
 simulationOptions = "startTime = 0.0, stopTime = 1.01, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'EngineV6_output', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
 messages = ""
 end SimulationResult;
-"Warning: Alias set with several free start values
-* candidate: cylinder1.Cylinder.s(start = -0.3)
-* candidate: cylinder1.gasForce.s_rel(start = 0.0)
-=> select value from cylinder1.Cylinder.s(start = -0.3) for variable: cylinder1.Cylinder.s
-Warning: Alias set with several free start values
-* candidate: cylinder2.Cylinder.s(start = -0.3)
-* candidate: cylinder2.gasForce.s_rel(start = 0.0)
-=> select value from cylinder2.Cylinder.s(start = -0.3) for variable: cylinder2.Cylinder.s
-Warning: Alias set with several free start values
-* candidate: cylinder3.Cylinder.s(start = -0.3)
-* candidate: cylinder3.gasForce.s_rel(start = 0.0)
-=> select value from cylinder3.Cylinder.s(start = -0.3) for variable: cylinder3.Cylinder.s
-Warning: Alias set with several free start values
-* candidate: cylinder4.Cylinder.s(start = -0.3)
-* candidate: cylinder4.gasForce.s_rel(start = 0.0)
-=> select value from cylinder4.Cylinder.s(start = -0.3) for variable: cylinder4.Cylinder.s
-Warning: Alias set with several free start values
-* candidate: cylinder5.Cylinder.s(start = -0.3)
-* candidate: cylinder5.gasForce.s_rel(start = 0.0)
-=> select value from cylinder5.Cylinder.s(start = -0.3) for variable: cylinder5.Cylinder.s
-Warning: Alias set with several free start values
-* candidate: cylinder6.Cylinder.s(start = -0.3)
-* candidate: cylinder6.gasForce.s_rel(start = 0.0)
-=> select value from cylinder6.Cylinder.s(start = -0.3) for variable: cylinder6.Cylinder.s
-"
-561.477558467
+""
+561.4775584669927
 ""

comment:11 by Volker Waurich, 9 years ago

These Warning are called from the RemoveSimpleEquations-module if the start values of alias variables have to be merged. If you are detecting less alias variables you will have less conflicts with different start-values. It only means, that more variables are computed and therefore dont cause start-value conflicts.

comment:12 by Volker Waurich, 9 years ago

Hopefully,

https://github.com/OpenModelica/OMCompiler/commit/a2d3cf252a3bc9f8ccfa986745a2a72edbee1a5e

fixes the problem properly. Lets wait for the library tests if nothing else breaks.

comment:13 by Volker Waurich, 9 years ago

Resolution: fixed
Status: assignedclosed

It seems, that everything works. I will close the ticket.

comment:15 by Martin Sjölund, 9 years ago

Milestone: 1.9.41.9.4-1.9.x

Milestone renamed

comment:16 by Martin Sjölund, 9 years ago

Milestone: 1.9.4-1.9.x1.9.4

Milestone renamed

Note: See TracTickets for help on using tickets.