Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#3656 closed defect (fixed)

Current removeSimpleEquation module causes leading sign error

Reported by: ahaumer@… Owned by: wbraun
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@…> 8 years ago.
Example to demonstrate bug
cabin.png (19.7 KB) - added by Christian Kral <dr.christian.kral@…> 8 years ago.
Plot of simulation results

Download all attachments as: .zip

Change History (18)

comment:1 Changed 8 years ago by ahaumer@…

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 Changed 8 years ago by adrpo

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/

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

Example to demonstrate bug

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

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

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

Plot of simulation results

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

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 Changed 8 years ago by adrpo

  • Owner changed from somebody to wbraun
  • Status changed from new to assigned

Willi, can you have a look at this?

comment:6 Changed 8 years ago by wbraun

  • Status changed from assigned to accepted

comment:7 Changed 8 years ago by wbraun

  • Component changed from *unknown* to Backend
  • Milestone changed from Future to 1.9.4
  • Priority changed from high to blocker
  • Status changed from accepted to assigned

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 Changed 8 years ago by wbraun

  • Summary changed from mysterious result to Current removeSimpleEquation module causes leading sign error

comment:9 Changed 8 years ago by rfranke

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 Changed 8 years ago by rfranke

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 Changed 8 years ago by vwaurich

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 Changed 8 years ago by vwaurich

Hopefully,

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

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

comment:13 Changed 8 years ago by vwaurich

  • Resolution set to fixed
  • Status changed from assigned to closed

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

comment:15 Changed 8 years ago by sjoelund.se

  • Milestone changed from 1.9.4 to 1.9.4-1.9.x

Milestone renamed

comment:16 Changed 8 years ago by sjoelund.se

  • Milestone changed from 1.9.4-1.9.x to 1.9.4

Milestone renamed

Note: See TracTickets for help on using tickets.