Opened 10 years ago

Closed 8 years ago

Last modified 8 years ago

#2927 closed defect (fixed)

Wrong zero crossing function generation

Reported by: niklwors Owned by: lochel
Priority: blocker Milestone: 1.9.4
Component: Backend Version: trunk
Keywords: zero crossings Cc: wbraun

Description (last modified by lochel)

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 Changed 10 years ago by lochel

  • Description modified (diff)

comment:2 Changed 10 years ago by lochel

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 Changed 10 years ago by niklwors

For discrete variables it should not be generate zero crossings.

comment:4 Changed 10 years ago by lochel

  • Owner changed from somebody to wbraun
  • Status changed from new to assigned

comment:5 Changed 10 years ago by lochel

  • Cc wbraun added
  • Owner changed from wbraun to lochel

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 Changed 8 years ago by lochel

  • Milestone changed from Future to 1.9.4
  • Resolution set to fixed
  • Status changed from assigned to closed

This seems to be fixed.

comment:7 Changed 8 years ago by sjoelund.se

  • Milestone changed from 1.9.4 to 1.9.4-1.9.x

Milestone renamed

comment:8 Changed 8 years ago by sjoelund.se

  • Milestone changed from 1.9.4-1.9.x to 1.9.4

Milestone renamed

Note: See TracTickets for help on using tickets.