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: | lochel |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | Backend | Version: | v1.11.0 |
Keywords: | Cc: | wbraun, lochel |
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)
Change History (10)
Changed 7 years ago by pravinkumar.dalve@…
comment:1 Changed 7 years ago by sjoelund.se
- Component changed from Code Generation to Backend
- Priority changed from high to normal
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 Changed 7 years ago by pravinkumar.dalve@…
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 Changed 7 years ago by sjoelund.se
- Cc wbraun lochel 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 Changed 7 years ago by casella
- Milestone changed from 1.12.0 to 1.13.0
Milestone moved to 1.13.0 due to 1.12.0 already being released.
comment:5 Changed 6 years ago by casella
- Milestone changed from 1.13.0 to 1.14.0
Rescheduled to 1.14.0 after 1.13.0 releasee
comment:6 Changed 5 years ago by casella
- Milestone changed from 1.14.0 to 1.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 Changed 4 years ago by casella
- Milestone changed from 1.16.0 to 1.17.0
Retargeted to 1.17.0 after 1.16.0 release
comment:8 Changed 4 years ago by casella
- Milestone changed from 1.17.0 to 1.18.0
Retargeted to 1.18.0 because of 1.17.0 timed release.
comment:9 Changed 3 years ago by casella
- Milestone 1.18.0 deleted
Ticket retargeted after milestone closed
The issue is commented at the end of Column1 model