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
* add multibody check function
* use multibody check function
* better world handling in examples and tests
* remove hacky `W` world constructor
* add support for planar mechanics in `multibody`
* handle components without gui metadata
Copy file name to clipboardExpand all lines: docs/src/examples/pendulum.md
+18-15Lines changed: 18 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
# Pendulum--The "Hello World of multi-body dynamics"
2
-
This beginners tutorial will start by modeling a pendulum pivoted around the origin in the world frame. The world frame is a constant that lives inside the Multibody module, all multibody models are "grounded" in the same world, i.e., the `world` component must be included in all models.
2
+
This beginners tutorial will start by modeling a pendulum pivoted around the origin in the world frame. The world frame is a constant that lives inside the Multibody module, all multibody models are "grounded" in the same world, i.e., the `world` component must be included exactly once in all models, at the top level.
3
3
4
4
To start, we load the required packages
5
5
```@example pendulum
@@ -47,12 +47,16 @@ nothing # hide
47
47
```
48
48
The `ODESystem` is the fundamental model type in ModelingToolkit used for multibody-type models.
49
49
50
-
Before we can simulate the system, we must perform model compilation using [`structural_simplify`](@ref)
50
+
Before we can simulate the system, we must perform model check using the function [`multibody`](@ref) and compilation using [`structural_simplify`](@ref)
51
51
```@example pendulum
52
-
ssys = structural_simplify(IRSystem(model))
52
+
ssys = structural_simplify(multibody(model))
53
53
```
54
54
This results in a simplified model with the minimum required variables and equations to be able to simulate the system efficiently. This step rewrites all `connect` statements into the appropriate equations, and removes any redundant variables and equations. To simulate the pendulum, we require two state variables, one for angle and one for angular velocity, we can see above that these state variables have indeed been chosen.
55
55
56
+
```@docs
57
+
multibody
58
+
```
59
+
56
60
We are now ready to create an `ODEProblem` and simulate it. We use the `Rodas4` solver from OrdinaryDiffEq.jl, and pass a dictionary for the initial conditions. We specify only initial condition for some variables, for those variables where no initial condition is specified, the default initial condition defined the model will be used.
This gives us the matrices $A,B,C,D$ in a linearized statespace representation of the system. To make these easier to work with, we load the control packages and call `named_ss` instead of `linearize` to get a named statespace object instead:
418
421
```@example pendulum
419
422
using ControlSystemsMTK
420
-
lsys = named_ss(IRSystem(cp), inputs, outputs; op) # identical to linearize, but packages the resulting matrices in a named statespace object for convenience
423
+
lsys = named_ss(multibody(cp), inputs, outputs; op) # identical to linearize, but packages the resulting matrices in a named statespace object for convenience
0 commit comments