You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/connectors/connections.md
-24Lines changed: 0 additions & 24 deletions
Original file line number
Diff line number
Diff line change
@@ -118,12 +118,8 @@ sol = solve(prob)
118
118
p1 = plot(sol, idxs = [capacitor.v])
119
119
p2 = plot(sol, idxs = [resistor.i])
120
120
plot(p1, p2)
121
-
savefig("electrical.png");
122
-
nothing; # hide
123
121
```
124
122
125
-

126
-
127
123
### Mechanical Translational Domain
128
124
129
125
#### Across Variable = velocity
@@ -162,12 +158,8 @@ sol_v = solve(prob)
162
158
p1 = plot(sol_v, idxs = [body.v])
163
159
p2 = plot(sol_v, idxs = [damping.f])
164
160
plot(p1, p2)
165
-
savefig("mechanical_velocity.png");
166
-
nothing; # hide
167
161
```
168
162
169
-

170
-
171
163
#### Across Variable = position
172
164
173
165
Now, let's consider the position based approach. We can build the same model with the same components. As can be seen, we now end of up with 2 equations, because we need to relate the lower derivative (position) to force (with acceleration).

209
-
210
198
The question then arises, can the position be plotted when using the Mechanical Translational Domain based on the Velocity Across variable? Yes, we can! There are 2 solutions:
211
199
212
200
1. the `Mass` component will add the position variable when the `s_0` parameter is used to set an initial position. Otherwise the position is not tracked by the component.
@@ -315,24 +303,16 @@ Now we can plot the comparison of the 2 models and see they give the same result
315
303
plot(ylabel = "mass velocity [m/s]")
316
304
plot!(solv, idxs = [bv.v])
317
305
plot!(solp, idxs = [bp.v])
318
-
savefig("mass_velocity.png");
319
-
nothing; # hide
320
306
```
321
307
322
-

323
-
324
308
But, what if we wanted to plot the mass position? This is easy for the position based domain, we have the state `bp₊s(t)`, but for the velocity based domain we have `sv₊delta_s(t)` which is the spring stretch. To get the absolute position we add the spring natrual length (1m) and the fixed position (1m). As can be seen, we then get the same result.
325
309
326
310
```@example connections
327
311
plot(ylabel = "mass position [m]")
328
312
plot!(solv, idxs = [sv.delta_s + 1 + 1])
329
313
plot!(solp, idxs = [bp.s])
330
-
savefig("mass_position.png");
331
-
nothing; # hide
332
314
```
333
315
334
-

335
-
336
316
So in conclusion, the position based domain gives easier access to absolute position information, but requires more initial condition information.
0 commit comments