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
For each component we use a Julia function that returns an `ODESystem`. At the top, we define the fundamental properties of a `Mass`: it has a mass `m`, a position `pos` and a velocity `v`. We also define that the velocity is the rate of change of position with respect to time.
@@ -90,7 +92,7 @@ function Spring(; name, k = 1e4, l = 1.)
90
92
end
91
93
```
92
94
93
-
We now define functions that help construct the equations for a mass-spring system. First, the `connect_spring` function connects a `spring` between two positions `a` and `b`. Note that `a` and `b` can be the `pos` of a `Mass`, or just a fixed position such as `[0., 0.]`.
95
+
We now define functions that help construct the equations for a mass-spring system. First, the `connect_spring` function connects a `spring` between two positions `a` and `b`. Note that `a` and `b` can be the `pos` of a `Mass`, or just a fixed position such as `[0., 0.]`. In that sense, the length of the spring `x` is given by the length of the vector `dir` joining `a` and `b`.
94
96
95
97
```julia
96
98
functionconnect_spring(spring, a, b)
@@ -216,14 +218,16 @@ observed(sys)
216
218
217
219
These are explicit algebraic equations which can be used to reconstruct the required variables on the fly. This leads to dramatic computational savings since implicitly solving an ODE scales as O(n^3), so fewer states are signficantly better!
218
220
219
-
We can access these variables using the solution object. For example, let's retrieve the length of the spring over time:
221
+
We can access these variables using the solution object. For example, let's retrieve the x-position of the mass over time:
0 commit comments