Opened 8 years ago
Closed 8 years ago
#4304 closed discussion (fixed)
assert in initial section
Reported by: | Volker Waurich | Owned by: | Lennart Ochel |
---|---|---|---|
Priority: | low | Milestone: | 1.12.0 |
Component: | Backend | Version: | |
Keywords: | Cc: | Martin Sjölund, Adrian Pop, Lennart Ochel, Willi Braun |
Description (last modified by )
Hi,
In OpenHydraulics.Components.Cylinders.DoubleActingCylinder
You will find:
initial equation assert(cylinderChamberHead.s_rel>=0,"Initial position is smaller than zero");
I suppose that this means to evaluate the assert in the initial system only. Is this valid Modelica? Shall we support this? Currently, this assert hinders some tests to simulate to stopTime.
Change History (14)
comment:1 by , 8 years ago
Description: | modified (diff) |
---|
comment:2 by , 8 years ago
comment:3 by , 8 years ago
yes. It dont think that we separate asserts between simulation and initialization dae. At least in BackendDAECreate.lower, every assert ends up in the removedEqs section.
comment:4 by , 8 years ago
Component: | Third-Party Libraries → Backend |
---|---|
Owner: | changed from | to
Status: | new → accepted |
comment:5 by , 8 years ago
I guess it is then just the same for other initial equations that end up in removedEqs
. I will have a look.
comment:6 by , 8 years ago
Okay, it seems that we should improve BackendDAECreate.lower
a bit. However, we need to fix a front end issue first: The assert is moved to an equation section as following example demonstrates:
loadString(" model A Real x(start=1.0, fixed=true) = -der(x); initial equation assert(time < 0.5, \"Test assert\"); initial algorithm assert(time < 0.6, \"Test assert\"); end A; "); getErrorString(); instantiateModel(A); getErrorString(); // class A // Real x(start = 1.0, fixed = true) = -der(x); // initial algorithm // assert(time < 0.6, \"Test assert\"); // equation // assert(time < 0.5, \"Test assert\"); // end A;
Is there a volunteer who wants to fix the front end? :)
comment:7 by , 8 years ago
Owner: | changed from | to
---|---|
Status: | accepted → assigned |
I'll take the front-end part. Seems like missing an initial flag propagation.
comment:8 by , 8 years ago
We don't have DAE.INITIAL_ASSERT we only have DAE.ASSERT. I will add it, but it will need to be handled in the back-end.
Can one have terminate() as initial equation?
comment:9 by , 8 years ago
I don't think that initial terminate is necessary, but I'm not sure. Anyway, I will take care of the back end part.
comment:11 by , 8 years ago
There are no when equations in initial equations (only when initial()
in the dynamic equations).
comment:12 by , 8 years ago
Owner: | changed from | to
---|
Fixed the front-end part in: b8fe18/OMCompiler.
Added test in: 079d78/OpenModelica-testsuite.
@lochel: take it away :)
comment:13 by , 8 years ago
Thanks @adrpo. I just fixed classification of initial equations and added support for initial terminate statements to the c runtime: OMCompiler#1537.
comment:14 by , 8 years ago
Milestone: | Future → 1.12.0 |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
The coverage tests look good - OpenHydraulics went up a bit.
@vwaurich That means this kind of asserts are evaluated for each time step?