-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNetworks.mo
71 lines (65 loc) · 1.36 KB
/
Networks.mo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package Networks
type Voltage = Real(unit="V");
type Current = Real(unit="A");
type Resistance = Real(unit="Ohm");
connector Pin
Voltage v;
flow Current i;
end Pin;
model Resistor
Pin p,n;
Voltage v;
Current i;
parameter Resistance R;
equation
v = p.v-n.v;
i = p.i;
0 = p.i + n.i;
v = R*i;
end Resistor;
model NetworkComponent
Pin p,n;
parameter Resistance R;
Resistor R1(R = R/8);
Resistor R2(R = R/8);
Resistor R3(R = R/8);
Resistor R4(R = R/8);
Resistor R5(R = R/8);
Resistor R6(R = R/8);
Resistor R7(R = R/8);
Resistor R8(R = R/8);
equation
connect(R1.p, p);
connect(R1.n, R2.p);
connect(R2.n, R3.p);
connect(R3.n, R4.p);
connect(R4.n, R5.p);
connect(R5.n, R6.p);
connect(R6.n, R7.p);
connect(R7.n, R8.p);
connect(R8.n, n);
end NetworkComponent;
model VoltageSource
Pin p;
Voltage v = 0;
equation
p.v = v;
end VoltageSource;
model Ground
Pin n;
equation
n.v = 0;
end Ground;
model System
NetworkComponent c1(R = 0.1);
NetworkComponent c2(R = 0.2);
NetworkComponent c3(R = 0.2);
Ground ground;
VoltageSource source(v = sin(time));
equation
connect(source.p, c1.p);
connect(c1.n, c2.p);
connect(c2.n, c3.p);
connect(c3.n, ground.n);
end System;
end Networks;