Opened 10 years ago

Closed 3 years ago

#3220 closed defect (fixed)

Bug with for loop in algorithms

Reported by: adrpo Owned by: somebody
Priority: high Milestone: 1.19.0
Component: Backend Version: trunk
Keywords: Cc: gustaf

Description

Reported here:
https://openmodelica.org/forum/default-topic/1557-for-loop-bug

model ForLoopBug 
  parameter Integer N = 1; 
  parameter Real p_in = 2e5; 
  Real[N + 1] p; 
  Real[N] dp; 
algorithm
  p[1] := p_in; 
  for i in 1:N loop 
    dp[i] := 10; 
    p[i + 1] := p[i] - dp[i]; 
  end for; 
end ForLoopBug;

Trying to simulate it gets you:

"Error: Model is structurally singular, error found sorting equations 
 1: algorithm
  p[1] := p_in;
  for i in 1:1 loop
    dp[i] := 10.0;
    p[1 + i] := p[i] - dp[i];
  end for;
;
 for variables 
 p[2](2), p[1](3), dp[1](1)
Error: Internal error Transformation Module PFPlusExt index Reduction Method Pantelides failed!
"

Change History (2)

comment:1 Changed 10 years ago by gustaf

  • Cc gustaf added

comment:2 Changed 3 years ago by casella

  • Milestone changed from Future to 1.19.0
  • Resolution set to fixed
  • Status changed from new to closed

Works in 1.19.0

Note: See TracTickets for help on using tickets.