@@ -12,7 +12,7 @@ equalities before solving. Let's see this in action.
12
12
## Copy-Paste Example
13
13
14
14
``` julia
15
- using ModelingToolkit, Plots
15
+ using ModelingToolkit, Plots, OrdinaryDiffEq
16
16
17
17
@parameters t
18
18
@@ -23,15 +23,15 @@ function Pin(;name)
23
23
end
24
24
25
25
function Ground (;name)
26
- g = Pin (:g )
26
+ @named g = Pin ()
27
27
eqs = [g. v ~ 0 ]
28
28
ODESystem (eqs, t, [], [], systems= [g], name= name)
29
29
end
30
30
31
31
function Resistor (;name, R = 1.0 )
32
32
val = R
33
- p = Pin (:p )
34
- n = Pin (:n )
33
+ @named p = Pin ()
34
+ @named n = Pin ()
35
35
@variables v (t)
36
36
@parameters R
37
37
eqs = [
44
44
45
45
function Capacitor (; name, C = 1.0 )
46
46
val = C
47
- p = Pin (:p )
48
- n = Pin (:n )
47
+ @named p = Pin ()
48
+ @named n = Pin ()
49
49
@variables v (t)
50
50
@parameters C
51
51
D = Differential (t)
59
59
60
60
function ConstantVoltage (;name, V = 1.0 )
61
61
val = V
62
- p = Pin (:p )
63
- n = Pin (:n )
62
+ @named p = Pin ()
63
+ @named n = Pin ()
64
64
@parameters V
65
65
eqs = [
66
66
V ~ p. v - n. v
@@ -135,7 +135,7 @@ names to correspond to duplicates of this topology with unique variables.
135
135
One can then construct a ` Pin ` like:
136
136
137
137
``` julia
138
- Pin (:mypin1 )
138
+ Pin (name = :mypin1 )
139
139
```
140
140
141
141
or equivalently using the ` @named ` helper macro:
@@ -151,7 +151,7 @@ that the voltage in such a `Pin` is equal to zero. This gives:
151
151
152
152
``` julia
153
153
function Ground (;name)
154
- g = Pin (:g )
154
+ @named g = Pin ()
155
155
eqs = [g. v ~ 0 ]
156
156
ODESystem (eqs, t, [], [], systems= [g], name= name)
157
157
end
@@ -167,8 +167,8 @@ zero. This leads to our resistor equations:
167
167
``` julia
168
168
function Resistor (;name, R = 1.0 )
169
169
val = R
170
- p = Pin (:p )
171
- n = Pin (:n )
170
+ @named p = Pin ()
171
+ @named n = Pin ()
172
172
@variables v (t)
173
173
@parameters R
174
174
eqs = [
@@ -190,8 +190,8 @@ Using our knowledge of circuits we similarly construct the Capacitor:
190
190
``` julia
191
191
function Capacitor (; name, C = 1.0 )
192
192
val = C
193
- p = Pin (:p )
194
- n = Pin (:n )
193
+ @named p = Pin ()
194
+ @named n = Pin ()
195
195
@variables v (t)
196
196
@parameters C
197
197
D = Differential (t)
@@ -212,8 +212,8 @@ model this as:
212
212
``` julia
213
213
function ConstantVoltage (;name, V = 1.0 )
214
214
val = V
215
- p = Pin (:p )
216
- n = Pin (:n )
215
+ @named p = Pin ()
216
+ @named n = Pin ()
217
217
@parameters V
218
218
eqs = [
219
219
V ~ p. v - n. v
0 commit comments