Skip to content

Commit 3c1e7e8

Browse files
Added RL test files and simulation scripts.
1 parent cdef244 commit 3c1e7e8

5 files changed

Lines changed: 471 additions & 0 deletions

File tree

test/causalize/RLTest/TestRL1.mo

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/* Model for causalization testing =============================================
2+
* Description: model with N algebraic loops.
3+
Ua[i] and Uc[i] must be simultaneously solved.
4+
==============================================================================*/
5+
6+
model TestRL1
7+
constant Integer N = 100;
8+
parameter Real U0 = 1.0;
9+
Real iL[N], Ua[N], Uc[N];
10+
parameter Real Ra = 1, Rb = 1, Rc = 1, L = 1;
11+
equation
12+
L*der(iL[1]) = U0 - Ua[1];
13+
for i in 2:N loop
14+
L*der(iL[i]) = Uc[i-1] - Ua[i];
15+
end for;
16+
for i in 1:N-1 loop
17+
Ua[i] = Rb*iL[i+1] + Uc[i]*Rb/Rc;
18+
end for;
19+
for i in 1:N-1 loop
20+
iL[i] = Ua[i]/Ra + Uc[i]/Rc + iL[i+1];
21+
end for;
22+
iL[N] = Ua[N]/Ra + Uc[N]/Rc;
23+
Ua[N] = Uc[N]*Rb/Rc;
24+
end TestRL1;
25+
26+
//Algebraic Loops:
27+
//der(iL[1])
28+
//der(iL[1]) = U0-Ua[1]
29+
//
30+
//der(iL[i])
31+
//L*der(iL[i]) = Uc[i-1]-Ua[i]
32+
//
33+
//Ua[i]
34+
//Uc[i]
35+
//Ua[i] = Rb*iL[i+1]+Uc[i]*Rb/Rc
36+
//iL[i] = Ua[i]/Ra+Uc[i]/Rc+iL[i+1]
37+
//
38+
//Uc[N]
39+
//Ua[N]
40+
//iL[N] = Ua[N]/Ra+Uc[N]/Rc
41+
//Ua[N] = Uc[N]*Rb/Rc

test/causalize/RLTest/TestRL2.mo

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/* Model for causalization testing =============================================
2+
* Description: model without algebraic loops.
3+
==============================================================================*/
4+
5+
model TestRL2
6+
constant Integer N=1000000;
7+
Real iL[N],iR[N],uL[N];
8+
parameter Real L=1,R=1,L1=1,I=1,R0=1;
9+
equation
10+
for i in 1:N loop
11+
L*der(iL[i])=uL[i];
12+
end for;
13+
for i in 1:N-1 loop
14+
iR[i]-iR[i+1]-iL[i]=0;
15+
uL[i]-uL[i+1]-R*iR[i+1]=0;
16+
end for;
17+
iR[N]-iL[N]+I=0;
18+
uL[1]+(R+R0)*iR[1]=0;
19+
end TestRL2;
20+
21+
//Algebraic Loops:
22+
//der(iL[i])
23+
//L*der(iL[i]) = uL[i]
24+
//
25+
//iR[i]
26+
//iR[i]-iR[i+1]-iL[i] = 0
27+
//
28+
//uL[i+1]
29+
//uL[i]-uL[i+1]-R*iR[i+1] = 0
30+
//
31+
//iR[N]
32+
//iR[N]-iL[N]+I = 0
33+
//
34+
//uL[1]
35+
//uL[1]+(R+R0)*iR[1] = 0

test/causalize/RLTest/TestRL3.mo

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/* Model for causalization testing =============================================
2+
* Description: model with a large algebraic loop of size k*N.
3+
iR[i] and iR[i+1] can be computed out of each other.
4+
uL[i] and uL[i+1] can be computed out of each other.
5+
==============================================================================*/
6+
7+
model TestRL3
8+
constant Integer N=100;
9+
Real iL[N],iR[N],uL[N];
10+
parameter Real L=1,R=1,L1=1,U=1,R0=1;
11+
equation
12+
for i in 1:N loop
13+
L*der(iL[i])=uL[i];
14+
end for;
15+
for i in 1:N-1 loop
16+
iR[i]-iR[i+1]-iL[i]=0;
17+
uL[i]-uL[i+1]-R*iR[i+1]=0;
18+
end for;
19+
U-uL[1]-R*iR[1]=0;
20+
uL[N]-(iR[100]-iL[N])*R0=0;
21+
end TestRL3;
22+
23+
//Algebraic Loops:
24+
//der(iL[i])
25+
//L*der(iL[i]) = uL[i]
26+
//
27+
//iR[i]
28+
//uL[i+1]
29+
//uL[1]
30+
//iR[N]
31+
//iR[i]-iR[i+1]-iL[i] = 0
32+
//uL[i]-uL[i+1]-R*iR[i+1] = 0
33+
//U-uL[1]-R*iR[1] = 0
34+
//uL[N]-(iR[N]-iL[N])*R0 = 0

0 commit comments

Comments
 (0)