Skip to content

Commit 8d4ad7e

Browse files
committed
tidy up some examples
1 parent eeb8d69 commit 8d4ad7e

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

docs/src/examples/kinematic_loops.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ connections = [connect(j2.frame_b, b2.frame_a)
169169
170170
@named fourbar_analytic = ODESystem(connections, t, systems = [world; systems])
171171
fourbar_analytic = complete(fourbar_analytic)
172-
ssys = structural_simplify(IRSystem(fourbar_analytic))
173-
prob = ODEProblem(ssys, [], (0.0, 1.4399))
172+
ssys_analytic = structural_simplify(IRSystem(fourbar_analytic))
173+
prob = ODEProblem(ssys_analytic, [], (0.0, 1.4399))
174174
sol2 = solve(prob, FBDF(autodiff=true)) # about 4x faster than the simulation above
175175
plot!(sol2, idxs=[j2.s]) # Plot the same coordinate as above
176176
```
@@ -182,4 +182,21 @@ Multibody.render(fourbar_analytic, sol2; x=-2, y = 2, z = 3, filename = "fourbar
182182
nothing # hide
183183
```
184184

185-
![animation](fourbar_analytic.gif)
185+
![animation](fourbar_analytic.gif)
186+
187+
While the version with a cut joint were solving for
188+
```@example kinloop
189+
length(unknowns(ssys))
190+
```
191+
variables, the version with the joint assembly solved for only
192+
```@example kinloop
193+
length(unknowns(ssys_analytic))
194+
```
195+
variables.
196+
197+
We can also inspect the mass matrices of the two systems to see how many nonlinear algebraic equations the solver has to deal with
198+
```@example kinloop
199+
using LinearAlgebra
200+
diag(ssys.mass_matrix), diag(ssys_analytic.mass_matrix)
201+
```
202+
A 1 on the diagonal indicates a differential equation, while a 0 indicates an algebraic equation. The cut-joint version has 6 nonlinear algebraic equations, while the joint assembly version has only 1. Both of them have 2 differential equations (position and velocity), corresponding to the 1 degree of freedom in the mechanism. Nonlinear algebraic equations are more expensive to solve than differential equations.

docs/src/examples/swing.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ import GLMakie
7676
Multibody.render(model, sol; z = -5, filename = "simple_swing.gif") # Use "simple_swing.mp4" for a video file
7777
nothing # hide
7878
```
79+
7980
![animation](simple_swing.gif)
81+
8082
This makes for a rather interesting-looking springy pendulum!
8183

8284

docs/src/examples/wheel.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ prob = ODEProblem(ssys, [], (0, 6))
167167
sol = solve(prob, Tsit5())
168168
169169
render(model, sol, framerate=30, filename="car.gif", x=6, z=6, y=5)
170+
nothing # hide
170171
```
171172

172173
![car animation](car.gif)

0 commit comments

Comments
 (0)