#2970 closed discussion (fixed)
0/0 = ?
Reported by: | Volker Waurich | Owned by: | Volker Waurich |
---|---|---|---|
Priority: | normal | Milestone: | 1.9.4 |
Component: | *unknown* | Version: | trunk |
Keywords: | division | Cc: | Willi Braun, Lennart Ochel, Adrian Pop |
Description
Hi,
Of course, the answer is that the solution of 0/0 is not defined and it should result in NaN or something.
There are some models that fail due to division by zero (e.g. ThermoSysPro.Examples.SimpleExamples.TestCentrifugalPump1.mo) where its not just a/0 but 0/0.
Consider this example:
model test_DivZero Real x,a,b; equation a = 1-time^2; b = 2-2*time; b = a*x; end test_DivZero;
Dymola handles this (it holds the value at time=1.0), OMC not (div by zero).
My question is, do we want to cover as many models as Dymola does or do we want to handle this as div by zero?
Another option would be to calculate the limit at this time step, which is imo (more) correct than holding the value.
Change History (10)
comment:1 by , 10 years ago
comment:2 by , 10 years ago
Note that omc returns successfully for that model. Probably because it changes the time step to something that is not ==1.0 and avoids any problem.
comment:3 by , 10 years ago
Ok. But in the ThermoSysPro model I mentioned, the solver step is not changed and the exe crashes (at least on my machine). Should we fix this or is it ok as it is? Instead of returning a NaN we could catch these cases and do something different (hold value, compute limit).
follow-up: 6 comment:5 by , 10 years ago
comment:6 by , 10 years ago
comment:7 by , 10 years ago
The term 0/0 is avoided by applying a common sub expression replacement. The numerator and denominator are alias variables. Therefore, the term can be removed already in the backend. Since the model simulates now, I will close this ticket.
comment:8 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:9 by , 9 years ago
Milestone: | Future → pre1.9.4 |
---|
It doesn't make sense to keep closed ticket in the "Future" milestone that were simply forgotten to assign to the correct milestone in the past.
comment:10 by , 7 years ago
Milestone: | pre1.9.4 → 1.9.4 |
---|
Removing the pre1.9.4 milestone in favor of 1.9.4.
Well. Anything returning NaN (or inf, or -inf) should trigger an assertion.