Closed joaquinffernandez closed 3 years ago
All variables should be of the same dimension, because operations were defined for elements with identical dimension (it simplified the operations).
Therefore, in the model the declaration of:
ConstantVoltage S;
should be replaced with:
ConstantVoltage S[1, 1];
Executing the following command after making the correction:
./bin/flatter ./test/mccprograms/flatter/Network2D.mo
produced the following output:
model network2D
constant Integer N=4;
constant Integer M=5;
parameter Real Cell_resistor_R[N, M](each start=1);
parameter Real Cell_resistor_T_ref[N, M]=fill(300.15,N);
parameter Real Cell_resistor_alpha[N, M]=fill(0,N);
Real Cell_resistor_v[N, M];
Real Cell_resistor_i[N, M];
Real Cell_resistor_p_v[N, M];
flow Real Cell_resistor_p_i[N, M];
Real Cell_resistor_n_v[N, M];
flow Real Cell_resistor_n_i[N, M];
Real Cell_resistor_R_actual[N, M];
Real Cell_resistor_LossPower[N, M];
Real Cell_resistor_T_heatPort[N, M];
parameter Real Cell_resistor1_R[N, M](each start=1);
parameter Real Cell_resistor1_T_ref[N, M]=fill(300.15,N);
parameter Real Cell_resistor1_alpha[N, M]=fill(0,N);
Real Cell_resistor1_v[N, M];
Real Cell_resistor1_i[N, M];
Real Cell_resistor1_p_v[N, M];
flow Real Cell_resistor1_p_i[N, M];
Real Cell_resistor1_n_v[N, M];
flow Real Cell_resistor1_n_i[N, M];
Real Cell_resistor1_R_actual[N, M];
Real Cell_resistor1_LossPower[N, M];
Real Cell_resistor1_T_heatPort[N, M];
parameter Real Cell_capacitor_C[N, M](each start=1);
Real Cell_capacitor_v[N, M];
Real Cell_capacitor_i[N, M];
Real Cell_capacitor_p_v[N, M];
flow Real Cell_capacitor_p_i[N, M];
Real Cell_capacitor_n_v[N, M];
flow Real Cell_capacitor_n_i[N, M];
parameter Real Cell_capacitor1_C[N, M](each start=1);
Real Cell_capacitor1_v[N, M];
Real Cell_capacitor1_i[N, M];
Real Cell_capacitor1_p_v[N, M];
flow Real Cell_capacitor1_p_i[N, M];
Real Cell_capacitor1_n_v[N, M];
flow Real Cell_capacitor1_n_i[N, M];
Real Cell_l_v[N, M];
flow Real Cell_l_i[N, M];
Real Cell_d_v[N, M];
flow Real Cell_d_i[N, M];
Real Cell_r_v[N, M];
flow Real Cell_r_i[N, M];
Real Cell_u_v[N, M];
flow Real Cell_u_i[N, M];
parameter Real S_V[1, 1](each start=1);
Real S_v[1, 1];
Real S_i[1, 1];
Real S_p_v[1, 1];
flow Real S_p_i[1, 1];
Real S_n_v[1, 1];
flow Real S_n_i[1, 1];
Real G_p_v;
flow Real G_p_i;
initial algorithm
for _Index_0 in 1:N,_Index_1 in 1:M loop
Cell_capacitor_v[_Index_0,_Index_1]:=0;
Cell_capacitor1_v[_Index_0,_Index_1]:=0;
end for;
equation
Cell_resistor_T_heatPort[_Index_0,_Index_1] = Cell_resistor_T_ref[_Index_0,_Index_1];
Cell_resistor_v[_Index_0,_Index_1] = Cell_resistor_p_v[_Index_0,_Index_1]-Cell_resistor_n_v[_Index_0,_Index_1];
0 = Cell_resistor_p_i[_Index_0,_Index_1]+Cell_resistor_n_i[_Index_0,_Index_1];
Cell_resistor_i[_Index_0,_Index_1] = Cell_resistor_p_i[_Index_0,_Index_1];
Cell_resistor_R_actual[_Index_0,_Index_1] = Cell_resistor_R[_Index_0,_Index_1]*(1+Cell_resistor_alpha[_Index_0,_Index_1]*(Cell_resistor_T_heatPort[_Index_0,_Index_1]-Cell_resistor_T_ref[_Index_0,_Index_1]));
Cell_resistor_v[_Index_0,_Index_1] = Cell_resistor_R_actual[_Index_0,_Index_1]*Cell_resistor_i[_Index_0,_Index_1];
Cell_resistor_LossPower[_Index_0,_Index_1] = Cell_resistor_v[_Index_0,_Index_1]*Cell_resistor_i[_Index_0,_Index_1];
Cell_resistor1_T_heatPort[_Index_0,_Index_1] = Cell_resistor1_T_ref[_Index_0,_Index_1];
Cell_resistor1_v[_Index_0,_Index_1] = Cell_resistor1_p_v[_Index_0,_Index_1]-Cell_resistor1_n_v[_Index_0,_Index_1];
0 = Cell_resistor1_p_i[_Index_0,_Index_1]+Cell_resistor1_n_i[_Index_0,_Index_1];
Cell_resistor1_i[_Index_0,_Index_1] = Cell_resistor1_p_i[_Index_0,_Index_1];
Cell_resistor1_R_actual[_Index_0,_Index_1] = Cell_resistor1_R[_Index_0,_Index_1]*(1+Cell_resistor1_alpha[_Index_0,_Index_1]*(Cell_resistor1_T_heatPort[_Index_0,_Index_1]-Cell_resistor1_T_ref[_Index_0,_Index_1]));
Cell_resistor1_v[_Index_0,_Index_1] = Cell_resistor1_R_actual[_Index_0,_Index_1]*Cell_resistor1_i[_Index_0,_Index_1];
Cell_resistor1_LossPower[_Index_0,_Index_1] = Cell_resistor1_v[_Index_0,_Index_1]*Cell_resistor1_i[_Index_0,_Index_1];
Cell_capacitor_v[_Index_0,_Index_1] = Cell_capacitor_p_v[_Index_0,_Index_1]-Cell_capacitor_n_v[_Index_0,_Index_1];
0 = Cell_capacitor_p_i[_Index_0,_Index_1]+Cell_capacitor_n_i[_Index_0,_Index_1];
Cell_capacitor_i[_Index_0,_Index_1] = Cell_capacitor_p_i[_Index_0,_Index_1];
Cell_capacitor_i[_Index_0,_Index_1] = Cell_capacitor_C[_Index_0,_Index_1]*der(Cell_capacitor_v[_Index_0,_Index_1]);
Cell_capacitor1_v[_Index_0,_Index_1] = Cell_capacitor1_p_v[_Index_0,_Index_1]-Cell_capacitor1_n_v[_Index_0,_Index_1];
0 = Cell_capacitor1_p_i[_Index_0,_Index_1]+Cell_capacitor1_n_i[_Index_0,_Index_1];
Cell_capacitor1_i[_Index_0,_Index_1] = Cell_capacitor1_p_i[_Index_0,_Index_1];
Cell_capacitor1_i[_Index_0,_Index_1] = Cell_capacitor1_C[_Index_0,_Index_1]*der(Cell_capacitor1_v[_Index_0,_Index_1]);
S_v[_Index_2,_Index_3] = S_p_v[_Index_2,_Index_3]-S_n_v[_Index_2,_Index_3];
0 = S_p_i[_Index_2,_Index_3]+S_n_i[_Index_2,_Index_3];
S_i[_Index_2,_Index_3] = S_p_i[_Index_2,_Index_3];
S_v[_Index_2,_Index_3] = S_V[_Index_2,_Index_3];
G_p_v = 0;
for i in 1:1:1,j in 2:1:5 loop
Cell_u_v[i,j] = Cell_u_v[1*i+0,1];
end for;
for i in 1:1:1,j in 1:1:1 loop
sum(Cell_u_i[1*i+0, 1:1:5]) = 0;
end for;
for i in 1:1:3,j in 5:1:5 loop
Cell_capacitor1_n[1*i+0,1*j+0]+Cell_capacitor1_n[1*i+0,1*j+0]+Cell_capacitor1_n_i[1*i+0,1*j+0]+Cell_d_i[1*i+0,1*j+0] = 0;
end for;
for i in 2:1:4,j in 5:1:5 loop
Cell_resistor1_p_i[1*i+0,1*j+0]+Cell_u_i[1*i+0,1*j+0] = 0;
end for;
for i in 4:1:4,j in 1:1:4 loop
Cell_capacitor_n_i[1*i+0,1*j+0]+Cell_r_i[1*i+0,1*j+0] = 0;
end for;
for i in 4:1:4,j in 2:1:5 loop
Cell_d_v[i,j] = Cell_d_v[1*i+0,1];
end for;
for i in 4:1:4,j in 1:1:1 loop
sum(Cell_d_i[1*i+0, 1:1:5]) = 0;
end for;
for i in 1:1:3,j in 1:1:4 loop
Cell_d_i[1*i+0,1*j+0]+Cell_resistor1_p_i[1*i+1,1*j+0] = 0;
end for;
for i in 4:1:4,j in 2:1:5 loop
Cell_l_i[1*i+0,1*j+0]+Cell_resistor_p_i[1*i+0,1*j+0] = 0;
end for;
for i in 1:1:4,j in 5:1:5 loop
Cell_r_i[1*i+0,1*j+0]+Cell_resistor_p_i[1*i+0,1*j+-4] = 0;
end for;
for i in 1:1:3,j in 1:1:4 loop
Cell_r_i[1*i+0,1*j+0]+Cell_resistor_p_i[1*i+0,1*j+1] = 0;
end for;
for i in 1:1:4,j in 1:1:5 loop
Cell_capacitor_p[i,j] = Cell_resistor_n[1*i+0,1*j+0];
end for;
for i in 1:1:4,j in 1:1:5 loop
Cell_capacitor1_p[i,j] = Cell_resistor_n[1*i+0,1*j+0];
end for;
for i in 1:1:4,j in 1:1:5 loop
Cell_resistor1_n[i,j] = Cell_resistor_n[1*i+0,1*j+0];
end for;
for i in 1:1:4,j in 1:1:5 loop
Cell_resistor_n_i[1*i+0,1*j+0]+Cell_resistor1_n_i[1*i+0,1*j+0]+Cell_capacitor1_p[1*i+0,1*j+0]+Cell_capacitor1_p[1*i+0,1*j+0]+Cell_capacitor1_p_i[1*i+0,1*j+0]+Cell_capacitor_p_i[1*i+0,1*j+0] = 0;
end for;
for i in 4:1:4,j in 1:1:5 loop
Cell_capacitor1_n[i,j] = S_n;
end for;
for i in 1:1:1,j in 1:1:1 loop
sum(Cell_capacitor1_n[1*i+3, 1:1:5])+sum(Cell_capacitor1_n[1*i+3, 1:1:5])+sum(Cell_capacitor1_n_i[1*i+3, 1:1:5])+S_n_i = 0;
end for;
for i in 1:1:1,j in 1:1:5 loop
Cell_resistor1_p[i,j] = S_p;
end for;
for i in 1:1:1,j in 1:1:1 loop
sum(Cell_resistor1_p_i[1*i+0, 1:1:5])+S_p_i = 0;
end for;
for i in 1:1:4,j in 1:1:1 loop
Cell_l_i[1*i+0,1*j+0]+Cell_capacitor_n_i[1*i+0,1*j+4] = 0;
end for;
for i in 2:1:4,j in 1:1:4 loop
Cell_capacitor1_n[1*i+-1,1*j+0]+Cell_capacitor1_n[1*i+-1,1*j+0]+Cell_capacitor1_n_i[1*i+-1,1*j+0]+Cell_u_i[1*i+0,1*j+0] = 0;
end for;
for i in 1:1:3,j in 2:1:5 loop
Cell_l_i[1*i+0,1*j+0]+Cell_capacitor_n_i[1*i+0,1*j+-1] = 0;
end for;
end network2D;
This model breaks on a segfault, I think it's due to an empty set, we should check of the model is wrong (it works OK in OpenModelica) Network2D model definition:
Backtrace: