Opened 10 years ago

Closed 3 years ago

#3220 closed defect (fixed)

Bug with for loop in algorithms

Reported by: Adrian Pop Owned by: somebody
Priority: high Milestone: 1.19.0
Component: Backend Version: trunk
Keywords: Cc: Gustaf Thorslund

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 by Gustaf Thorslund, 10 years ago

Cc: Gustaf Thorslund added

comment:2 by Francesco Casella, 3 years ago

Milestone: Future1.19.0
Resolution: fixed
Status: newclosed

Works in 1.19.0

Note: See TracTickets for help on using tickets.