@@ -132,7 +132,7 @@ eqs = [
132
132
133
133
Finally, we can build the model using these equations and components.
134
134
135
- ``` julia
135
+ ``` @example component
136
136
@named _model = ODESystem(eqs, t, [spring.x; spring.dir; mass.pos], [])
137
137
@named model = compose(_model, mass, spring)
138
138
```
@@ -162,25 +162,14 @@ This system can be solved directly as a DAE using [one of the DAE solvers from D
162
162
``` @example component
163
163
sys = structural_simplify(model)
164
164
equations(sys)
165
-
166
- 4-element Vector{Equation}:
167
- Differential(t)(mass₊v[1](t)) ~ (-spring₊k*(spring₊x(t) - spring₊l)*mass₊pos[1](t)) / (mass₊m*spring₊x(t))
168
- Differential(t)(mass₊v[2](t)) ~ (-spring₊k*(spring₊x(t) - spring₊l)*mass₊pos[2](t)) / (mass₊m*spring₊x(t)) - 9.81
169
- Differential(t)(mass₊pos[1](t)) ~ mass₊v[1](t)
170
- Differential(t)(mass₊pos[2](t)) ~ mass₊v[2](t)
171
165
```
172
166
173
167
We are left with only 4 equations involving 4 state variables (` mass.pos[1] ` ,
174
168
` mass.pos[2] ` , ` mass.v[1] ` , ` mass.v[2] ` ). We can solve the system by converting
175
169
it to an ` ODEProblem ` . Some observed variables are not expanded by default. To
176
170
view the complete equations, one can do
177
- ``` julia
178
- julia> full_equations (sys)
179
- 4 - element Vector{Equation}:
180
- Differential (t)(mass₊v[1 ](t)) ~ (- spring₊k* (sqrt (abs2 (mass₊pos[1 ](t)) + abs2 (mass₊pos[2 ](t))) - spring₊l)* mass₊pos[1 ](t)) / (mass₊m* sqrt (abs2 (mass₊pos[1 ](t)) + abs2 (mass₊pos[2 ](t))))
181
- Differential (t)(mass₊v[2 ](t)) ~ (- spring₊k* (sqrt (abs2 (mass₊pos[1 ](t)) + abs2 (mass₊pos[2 ](t))) - spring₊l)* mass₊pos[2 ](t)) / (mass₊m* sqrt (abs2 (mass₊pos[1 ](t)) + abs2 (mass₊pos[2 ](t)))) - 9.81
182
- Differential (t)(mass₊pos[1 ](t)) ~ mass₊v[1 ](t)
183
- Differential (t)(mass₊pos[2 ](t)) ~ mass₊v[2 ](t)
171
+ ``` @example component
172
+ full_equations(sys)
184
173
```
185
174
186
175
This is done as follows:
0 commit comments