Opened 7 years ago

Last modified 3 years ago

#4484 new defect

Model becomes singular if equations are written inside if-else

Reported by: pravinkumar.dalve@… Owned by: Lennart Ochel
Priority: normal Milestone:
Component: Backend Version: v1.11.0
Keywords: Cc: Willi Braun, Lennart Ochel

Description

Please see the attached file.

In Column1 model if I write reboiler.feed.-- equations for some variables inside if-else, the model becomes singular. If I write these equations in algorithm outside if-else statement, model works fine.

I am having eight variables in same if-else statement but only four of them behaves like this.

Thank you in advance.

Attachments (1)

post.mo (24.0 KB ) - added by pravinkumar.dalve@… 7 years ago.
The issue is commented at the end of Column1 model

Download all attachments as: .zip

Change History (10)

by pravinkumar.dalve@…, 7 years ago

Attachment: post.mo added

The issue is commented at the end of Column1 model

comment:1 by Martin Sjölund, 7 years ago

Component: Code GenerationBackend
Priority: highnormal

You should have added one working and one modified model to show the problem. So the problem is you want to do something like:

algorithm
  for ... loop
    tray[i] := x;
  end for;
equation
  tray[1] = ...;

If that's the case, be aware that in Modelica any unknown subscript (like i) in an algorithm section is treated as assigning or using the entire array. Which means that you can't use a pattern like for i in 2:size(arr,1) in an array and define index 1 somewhere else.

comment:2 by pravinkumar.dalve@…, 7 years ago

I got what you are saying, but I am not doing that. I am defining whole array at one place only. My problem is when I give equations directly it detects equation and solves, but when I am giving them in if-else statement openmodelica says matrix is singular. And that also for only specific variables. I am giving same equation with and without if-else but still singular matrix problem is coming when I am using if-else.

I have attached working model. To see non working model just uncomment the four eqations each in if and else statement in (feed equation in column1) and comment the equations which I have written at last. The problem is occurring just for these four equations. Openmodelica is detecting other equations.

Just check last part of Column1 model.

tray[1].feed.mixMolFlo := feed[1].mixMolFlo;
tray[1].feed.mixMolEnth := feed[1].mixMolEnth;
tray[1].feed.mixMolFrac[:] := feed[1].mixMolFrac;

these are the four equations, which are making problem

Still if you are unsure I will attach two different models

comment:3 by Martin Sjölund, 7 years ago

Cc: Willi Braun Lennart Ochel added

OK, it seems the problematic part is only tray[1].feed.mixMolFrac[:] := feed[1].mixMolFrac;. tray has size 1, but for some reason if it is tray[f(...)], the compiler says the model is singular.

Even tray[:].feed.mixMolFrac[:] := {feed[1].mixMolFrac}; and tray.feed.mixMolFrac := feed.mixMolFrac; fail... Note: There is nothing about equations failing in this model. Statements inside the for-loop fail, because of the problem with the subscript.

comment:4 by Francesco Casella, 7 years ago

Milestone: 1.12.01.13.0

Milestone moved to 1.13.0 due to 1.12.0 already being released.

comment:5 by Francesco Casella, 6 years ago

Milestone: 1.13.01.14.0

Rescheduled to 1.14.0 after 1.13.0 releasee

comment:6 by Francesco Casella, 5 years ago

Milestone: 1.14.01.16.0

Releasing 1.14.0 which is stable and has many improvements w.r.t. 1.13.2. This issue is rescheduled to 1.16.0

comment:7 by Francesco Casella, 4 years ago

Milestone: 1.16.01.17.0

Retargeted to 1.17.0 after 1.16.0 release

comment:8 by Francesco Casella, 4 years ago

Milestone: 1.17.01.18.0

Retargeted to 1.18.0 because of 1.17.0 timed release.

comment:9 by Francesco Casella, 3 years ago

Milestone: 1.18.0

Ticket retargeted after milestone closed

Note: See TracTickets for help on using tickets.