Opened 10 years ago

Closed 9 years ago

Last modified 9 years ago

#2927 closed defect (fixed)

Wrong zero crossing function generation

Reported by: Niklas Worschech Owned by: Lennart Ochel
Priority: blocker Milestone: 1.9.4
Component: Backend Version: trunk
Keywords: zero crossings Cc: Willi Braun

Description (last modified by Lennart Ochel)

For this model:

model miniModel
  // PARAMETERS
  parameter Integer nZ = 5;

  // VARIABLES
  Integer lowerZrow;
  Real zIn = 4.3;
  Real[nZ] rowZ = {1,2,3,4,5};
algorithm
  // Finde zIndex
  lowerZrow := 0 "Reset Index";
  for i in 2:nZ loop
    if (i == nZ) then
      lowerZrow := i - 1;
      break;
    end if;
    if zIn < rowZ[i] then
      lowerZrow := i-1;
      break;
    end if;
  end for;
end miniModel;

The omc generate 4 zero crossing functions which is not correct

Change History (8)

comment:1 by Lennart Ochel, 10 years ago

Description: modified (diff)

comment:2 by Lennart Ochel, 10 years ago

The debug-dump "relidx" prints:

number of relations : 0
 number of new zc : 4
 number of new zc : 4
 itmp : 4
collectZCAlgsFor result zc : i == 5 index:4
findZeroCrossings1 number of relations : 4
findZeroCrossings1 sample index: 0
findZeroCrossings1 sample index: 0

This output is not very helpful – at least for me.

The debug-dump "dumpindxdae" prints:

Zero Crossings (number of relations: 4)
========================================
2 == 5 with index = 0 in equations [1] and when conditions []
3 == 5 with index = 1 in equations [1] and when conditions []
4 == 5 with index = 2 in equations [1] and when conditions []
5 == 5 with index = 3 in equations [1] and when conditions []


Relations (number of relations: 4)
========================================
2 == 5 with index = 0 in equations [1] and when conditions []
3 == 5 with index = 1 in equations [1] and when conditions []
4 == 5 with index = 2 in equations [1] and when conditions []
5 == 5 with index = 3 in equations [1] and when conditions []

So there are indeed 4 zero crossings. What are the expected zero crossings? At least the simulation result seem to be what Dymola calculates.

comment:3 by Niklas Worschech, 10 years ago

For discrete variables it should not be generate zero crossings.

comment:4 by Lennart Ochel, 10 years ago

Owner: changed from somebody to Willi Braun
Status: newassigned

comment:5 by Lennart Ochel, 10 years ago

Cc: Willi Braun added
Owner: changed from Willi Braun to Lennart Ochel

Well, I can take care of this ticket. Obviously, the check if a relation is discrete doesn't work as it is supposed to. But that is probably not the only issue with zero crossings. I thought it would be good to also involve Willi since he developed the event stuff some time ago...

comment:6 by Lennart Ochel, 9 years ago

Milestone: Future1.9.4
Resolution: fixed
Status: assignedclosed

This seems to be fixed.

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

Milestone: 1.9.41.9.4-1.9.x

Milestone renamed

comment:8 by Martin Sjölund, 9 years ago

Milestone: 1.9.4-1.9.x1.9.4

Milestone renamed

Note: See TracTickets for help on using tickets.