Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

der(x)=0 according to equation, but value is changing in results

der(x)=0 according to equation, but value is changing in results

Hi there,

I'm trying to figure out what's going wrong here.  MX_u[1] should be constant in this plot:
http://i.imgur.com/ot7OCJn.png

I extracted some relevant equations from the <model>.json (bottom of this post)

Maybe scaling or non-linear solver tolerance is the problem?  Has anyone had a problem like this before?  Any hints for how to attack this problem?

The interesting part of the problem is that although equation index 272 states: der(thermoReactor1.MX_u[1]) = 0.0,
in the results der(thermoReactor1.MX_u[1]) is non-zero.

Code:

[{u'defines': [u'der(thermoReactor1.MX_u[1])'],

  u'eqIndex': 272,
  u'equation': [u'0.0'],
  u'section': u'regular',
  u'source': {u'info': {u'colEnd': 0,
    u'colStart': 0,
    u'file': u'',
    u'lineEnd': 0,
    u'lineStart': 0}},
  u'tag': u'assign',
  u'uses': []},
{u'defines': [u'thermoReactor1.MX_u[1]'],
  u'eqIndex': 294,
  u'equation': [u'thermoReactor1.M_u - (thermoReactor1.MX_u[2] + thermoReactor1.MX_u[3] + thermoReactor1.MX_u[4] + thermoReactor1.MX_u[5] + thermoReactor1.MX_u[6] + thermoReactor1.MX_u[7] + thermoReactor1.MX_u[8] + thermoReactor1.MX_u[9])'],
  u'parent': 321,
  u'section': u'regular',
  u'source': {u'info': {u'colEnd': 18,
    u'colStart': 3,
    u'file': u'/home/adam/projects/machine/models/Machine/ThermoReactorBase.mo',
    u'lineEnd': 99,
    u'lineStart': 99},
   u'instance': u'thermoReactor1',
   u'within': [u'Machine.ThermoReactor$thermoReactor1']},
  u'tag': u'assign',
  u'uses': [u'thermoReactor1.MX_u[9]',
   u'thermoReactor1.MX_u[8]',
   u'thermoReactor1.MX_u[7]',
   u'thermoReactor1.MX_u[6]',
   u'thermoReactor1.MX_u[5]',
   u'thermoReactor1.MX_u[4]',
   u'thermoReactor1.MX_u[3]',
   u'thermoReactor1.MX_u[2]',
   u'thermoReactor1.M_u']},
{u'defines': [u'thermoReactor1.ai.MX[1]'],
  u'eqIndex': 322,
  u'equation': [u'thermoReactor1.MX_u[1]'],
  u'section': u'regular',
  u'source': {u'info': {u'colEnd': 0,
    u'colStart': 0,
    u'file': u'',
    u'lineEnd': 0,
    u'lineStart': 0}},
  u'tag': u'assign',
  u'uses': [u'thermoReactor1.MX_u[1]']},
[],
[{u'defines': [u'thermoReactor1.MX_b[5]',
    u'thermoReactor1.MX_b[2]',
    u'thermoReactor1.MX_b[7]',
    u'thermoReactor1.MX_b[9]',
    u'thermoReactor1.MX_b[6]',
    u'thermoReactor1.MX_b[3]',
    u'thermoReactor1.MX_b[8]',
    u'thermoReactor1.MX_b[4]',
    u'thermoReactor1.MX_u[3]',
    u'thermoReactor1.MX_u[4]',
    u'thermoReactor1.MX_u[7]',
    u'thermoReactor1.MX_u[6]',
    u'thermoReactor1.MX_u[2]',
    u'thermoReactor1.MX_u[8]',
    u'thermoReactor1.MX_u[5]',
    u'thermoReactor1.MX_u[9]',
    u'thermoReactor1.M_b',
    u'thermoReactor1.M_u',
    u'thermoReactor1.V_b',
    u'thermoReactor1.T_b',
    u'thermoReactor1.p',
    u'thermoReactor1.T_u'],
   u'display': u'non-linear',
   u'eqIndex': 321,
   u'equation': [[285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,309,310,311,312,313,314,315,316,317,318,319,320],
    []],
   u'section': u'regular',
   u'tag': u'container'}]]

Edited by: adamLange - Apr-28-17 14:25:14

Re: der(x)=0 according to equation, but value is changing in results

Here's a little update.  I reduced the tolerance of the nonlinear solver using the flags newtonXTol and newtonFTol until the simulation failed to converge.  Unfortunately this did not improve the solution noticeably.

I found this ticket:"Convergence issues on nonlinear equations involving der()" https://trac.openmodelica.org/OpenModelica/ticket/3111 Perhaps the issue cited in this ticket is preventing my model from converging when the newtonXTol and newtonFTol are low enough.  Does that sound like reasonable hypothesis?

It getting late here now but tomorrow when I resume I'm going to try these flags:

--preOptModules+=introduceDerAlias

This flag's depricated predecessor is mentioned in the ticket 3111 as a work-around solution.

--postOptModules+=addScaledVars_states

Does this sound like a reasonable plan of attack?  Any further suggestions?

Re: der(x)=0 according to equation, but value is changing in results

--preOptModules+=introduceDerAlias didn't really make much difference.  Using this flag didn't allow the newtonXTol and FTol tolerances to be set lower like I was hoping it might.  Furthermore, the error doesn't seem to be effected very much by changing the nonlinear tolerance.

When the simulation is starting, there is usually a warning: Matrix singular!  The simulation completes despite the warning.  (with the ida solver, dassl fails partway through the solution) So maybe singular matrix warning is an indication that there is a very poorly conditioned matrix as a consequences of the system being modeled?

I also tried to switch the index reduction method.  The simulation will run to completion with dynamicStateSelection but dummyDerivatives fails with a translation error: Internal error BackendDAETransform.analyseStrongComponentBlock failed.

There are 0 guests and 0 other users also viewing this topic
You are here: