Opened 6 years ago
Closed 6 years ago
#5063 closed defect (fixed)
[NF] Variability of integer() result
Reported by: | Adrian Pop | Owned by: | Per Östlund |
---|---|---|---|
Priority: | high | Milestone: | 2.0.0 |
Component: | New Instantiation | Version: | |
Keywords: | Cc: |
Description
The Modelica spec is not clear if integer() function returns a discrete time result. Seems to be a hint about it in the formulation.
integer(x) returns the largest integer not greater than x. The argument shall have type Real. The result has type Integer. [Note, outside of a when-clause state events are triggered when the return value changes discontinuously]
This model:
function r input Integer x; output Integer y; algorithm y := integer(x); end r; model X Real x; Integer z; parameter Integer p = 2; equation z = r(x=integer(x) + p); der(x) = -2 * x; end X;
This gets you with NF:
adrpo33@ida-0030 MINGW64 /c/home/adrpo33/dev/OMTesting/nf $ time ~/dev/OpenModelica/build/bin/omc +d=newInst integer.mo Error processing file: integer.mo [C:/home/adrpo33/dev/OMTesting/nf/integer.mo:16:3-16:26:writable] Error: Function argument x=integer(x) + p in call r with variability continuous is not a discrete expression.
We calculate the variability of the component based on the prefixes and the type Integer
gives you implicit discrete variability.
This issue plagues AdvancedNoise library.
Change History (2)
comment:1 by , 6 years ago
comment:2 by , 6 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
I agree that AdvancedNoise has still many issues but I guess we can close this specific ticket.
Note:
See TracTickets
for help on using tickets.
In 0e00720 I changed the NF so that functions that return a discrete type (e.g. Integer) is treated as discrete if the arguments are continuous. I'm not sure if that's the best way to handle it, but at least it fixes this particular issue. The AdvancedNoise library seems to have more issues though, and some models seem to expose some performance issues in the NF too.