1
1
"""
2
- Ground(;name)
2
+ Ground(; name)
3
3
4
4
Zero magnetic potential.
5
5
"""
6
- @component function Ground (; name)
7
- @named port = PositiveMagneticPort ()
8
- eqs = [port. V_m ~ 0 ]
9
- ODESystem (eqs, t, [], [], systems = [port], name = name)
6
+ @mtkmodel Ground begin
7
+ @components begin
8
+ port = PositiveMagneticPort ()
9
+ end
10
+ @equations begin
11
+ port. V_m ~ 0
12
+ end
10
13
end
11
14
12
15
"""
13
16
Idle(;name)
14
17
15
18
Idle running branch.
16
19
"""
17
- @component function Idle (; name)
18
- @named two_port = TwoPort ()
19
- @unpack Phi = two_port
20
- eqs = [
21
- Phi ~ 0 ,
22
- ]
23
- extend (ODESystem (eqs, t, [], [], systems = [], name = name), two_port)
20
+ @mtkmodel Idle begin
21
+ @extend (Phi,) = two_port = TwoPort ()
22
+ @equations begin
23
+ Phi ~ 0
24
+ end
24
25
end
25
26
26
27
"""
27
28
Short(;name)
28
29
29
30
Short cut branch.
30
31
"""
31
- @component function Short (; name)
32
- @named two_port = TwoPort ()
33
- @unpack V_m = two_port
34
- eqs = [
35
- V_m ~ 0 ,
36
- ]
37
- extend (ODESystem (eqs, t, [], [], systems = [], name = name), two_port)
32
+ @mtkmodel Short begin
33
+ @extend (V_m,) = two_port = TwoPort ()
34
+ @equations begin
35
+ V_m ~ 0
36
+ end
38
37
end
39
38
40
39
"""
@@ -44,108 +43,120 @@ Crossing of two branches.
44
43
45
44
This is a simple crossing of two branches. The ports port_p1 and port_p2 are connected, as well as port_n1 and port_n2.
46
45
"""
47
- @component function Crossing (; name)
48
- @named port_p1 = PositiveMagneticPort ()
49
- @named port_p2 = PositiveMagneticPort ()
50
- @named port_n1 = NegativeMagneticPort ()
51
- @named port_n2 = NegativeMagneticPort ()
52
- eqs = [
53
- connect (port_p1, port_p2),
54
- connect (port_n1, port_n2),
55
- ]
56
- ODESystem (eqs, t, [], [], systems = [port_p1, port_p2, port_n1, port_n2], name = name)
46
+ @mtkmodel Crossing begin
47
+ @components begin
48
+ port_p1 = PositiveMagneticPort ()
49
+ port_p2 = PositiveMagneticPort ()
50
+ port_n1 = NegativeMagneticPort ()
51
+ port_n2 = NegativeMagneticPort ()
52
+ end
53
+ @equations begin
54
+ connect (port_p1, port_p2)
55
+ connect (port_n1, port_n2)
56
+ end
57
57
end
58
58
59
59
"""
60
- ConstantPermeance(;name, G_m= 1.0)
60
+ ConstantPermeance(; name, G_m = 1.0)
61
61
62
62
Constant permeance.
63
63
64
64
# Parameters:
65
65
66
66
- `G_m`: [H] Magnetic permeance
67
67
"""
68
- @component function ConstantPermeance (; name, G_m = 1.0 )
69
- @named two_port = TwoPort ()
70
- @unpack V_m, Phi = two_port
71
- @parameters G_m = G_m
72
- eqs = [
73
- Phi ~ G_m * V_m,
74
- ]
75
- extend ( ODESystem (eqs, t, [], [G_m], name = name), two_port)
68
+ @mtkmodel ConstantPermeance begin
69
+ @extend V_m, Phi = two_port = TwoPort ()
70
+ @parameters begin
71
+ G_m = 1.0 , [description = " Magnetic permeance " ]
72
+ end
73
+ @equations begin
74
+ Phi ~ G_m * V_m
75
+ end
76
76
end
77
77
78
78
"""
79
- ConstantReluctance(;name, R_m= 1.0)
79
+ ConstantReluctance(; name, R_m = 1.0)
80
80
81
81
Constant reluctance.
82
82
83
83
# Parameters:
84
84
85
85
- `R_m`: [H^-1] Magnetic reluctance
86
86
"""
87
- @component function ConstantReluctance (; name, R_m = 1.0 )
88
- @named two_port = TwoPort ()
89
- @unpack V_m, Phi = two_port
90
- @parameters R_m = R_m
91
- eqs = [
92
- V_m ~ Phi * R_m,
93
- ]
94
- extend ( ODESystem (eqs, t, [], [R_m], name = name), two_port)
87
+ @mtkmodel ConstantReluctance begin
88
+ @extend V_m, Phi = two_port = TwoPort (; Phi = 0.0 )
89
+ @parameters begin
90
+ R_m = 1.0 , [description = " Magnetic reluctance " ]
91
+ end
92
+ @equations begin
93
+ V_m ~ Phi * R_m
94
+ end
95
95
end
96
96
97
97
"""
98
- ElectroMagneticConverter(;name, N, Phi_start=0.0 )
98
+ ElectroMagneticConverter(; name, N, Phi )
99
99
100
100
Ideal electromagnetic energy conversion.
101
101
102
102
The electromagnetic energy conversion is given by Ampere's law and Faraday's law respectively
103
103
V_m = N * i
104
104
N * dΦ/dt = -v
105
105
106
+ Initial magnetic flux flowing into the port_p can be set with `Phi` ([Wb])
107
+
106
108
# Parameters:
107
109
108
110
- `N`: Number of turns
109
- - `Phi_start`: [Wb] Initial magnetic flux flowing into the port_p
110
111
"""
111
- @component function ElectroMagneticConverter (; name, N, Phi_start = 0.0 )
112
- @named port_p = PositiveMagneticPort ()
113
- @named port_n = NegativeMagneticPort ()
114
- @named p = Pin ()
115
- @named n = Pin ()
116
-
117
- sts = @variables v (t) i (t) V_m (t) Phi (t)= Phi_start
118
- pars = @parameters N = N
119
- eqs = [v ~ p. v - n. v
112
+ @mtkmodel ElectroMagneticConverter begin
113
+ @parameters begin
114
+ N, [description = " Number of turns" ]
115
+ end
116
+ @variables begin
117
+ v (t)
118
+ i (t)
119
+ Phi
120
+ end
121
+ @extend V_m, Phi = two_port = TwoPort (; Phi = Phi)
122
+ @components begin
123
+ p = Pin ()
124
+ n = Pin ()
125
+ end
126
+ @equations begin
127
+ v ~ p. v - n. v
120
128
0 ~ p. i + n. i
121
129
i ~ p. i
122
- V_m ~ port_p. V_m - port_n. V_m
123
- 0 ~ port_p. Phi + port_n. Phi
124
- Phi ~ port_p. Phi
125
- # converter equations:
130
+ # converter equations:
126
131
V_m ~ i * N # Ampere's law
127
- D (Phi) ~ - v / N]
128
- ODESystem (eqs, t, sts, pars, systems = [port_p, port_n, p, n], name = name)
132
+ D (Phi) ~ - v / N
133
+ end
129
134
end
130
135
131
136
"""
132
- EddyCurrent(;name, rho= 0.098e-6, l= 1, A=1, Phi_start=0.0 )
137
+ EddyCurrent(;name, Phi, rho = 0.098e-6, l = 1, A = 1 )
133
138
134
139
For modelling of eddy current in a conductive magnetic flux tube.
140
+ Initial magnetic flux flowing into the port_p can be set with `Phi` ([`Wb`])
135
141
136
142
# Parameters:
137
143
138
144
- `rho`: [ohm * m] Resistivity of flux tube material (default: Iron at 20degC)
139
145
- `l`: [m] Average length of eddy current path
140
146
- `A`: [m^2] Cross sectional area of eddy current path
141
- - `Phi_start`: [Wb] Initial magnetic flux flowing into the port_p
142
- """
143
- @component function EddyCurrent (; name, rho = 0.098e-6 , l = 1 , A = 1 , Phi_start = 0.0 )
144
- @named two_port = TwoPort (Phi_start = Phi_start)
145
- @unpack V_m, Phi = two_port
146
- @parameters R = rho * l / A # Electrical resistance of eddy current path
147
- eqs = [
148
- D (Phi) ~ V_m * R,
149
- ]
150
- extend (ODESystem (eqs, t, [], [R], name = name), two_port)
147
+ """
148
+ @mtkmodel EddyCurrent begin
149
+ @variables begin
150
+ Phi
151
+ end
152
+ @parameters begin
153
+ rho = 0.098e-6 , [description = " Resistivity of flux tube material" ]
154
+ l = 1 , [description = " Average length of eddy current path" ]
155
+ A = 1 , [description = " Cross sectional area of eddy current path" ]
156
+ R = rho * l / A # Electrical resistance of eddy current path
157
+ end
158
+ @extend (V_m, Phi) = two_port = TwoPort (; Phi = Phi)
159
+ @equations begin
160
+ D (Phi) ~ V_m * R
161
+ end
151
162
end
0 commit comments