Skip to content

Commit bcad2a2

Browse files
committed
complete some models
1 parent 81dd2af commit bcad2a2

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

docs/src/examples/pendulum.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ nothing # hide
4242
With all components and connections defined, we can create an `ODESystem` like so:
4343
```@example pendulum
4444
@named model = ODESystem(connections, t, systems=[world, joint, body])
45+
model = complete(model)
4546
nothing # hide
4647
```
4748
The `ODESystem` is the fundamental model type in ModelingToolkit used for multibody-type models.
@@ -88,6 +89,7 @@ connections = [connect(world.frame_b, joint.frame_a)
8889
connect(body.frame_a, joint.frame_b)]
8990

9091
@named model = ODESystem(connections, t, systems = [world, joint, body, damper])
92+
model = complete(model)
9193
ssys = structural_simplify(IRSystem(model))
9294

9395
prob = ODEProblem(ssys, [damper.phi_rel => 1], (0, 10))
@@ -120,6 +122,7 @@ connections = [connect(world.frame_b, joint.frame_a)
120122
connect(body_0.frame_a, joint.frame_b)]
121123

122124
@named model = ODESystem(connections, t, systems = [world, joint, body_0, damper, spring])
125+
model = complete(model)
123126
ssys = structural_simplify(IRSystem(model))
124127

125128
prob = ODEProblem(ssys, [], (0, 10))
@@ -146,6 +149,7 @@ connections = [connect(world.frame_b, multibody_spring.frame_a)
146149
connect(root_body.frame_a, multibody_spring.frame_b)]
147150

148151
@named model = ODESystem(connections, t, systems = [world, multibody_spring, root_body])
152+
model = complete(model)
149153
ssys = structural_simplify(IRSystem(model))
150154

151155
defs = Dict(collect(root_body.r_0) .=> [0, 1e-3, 0]) # The spring has a singularity at zero length, so we start some distance away
@@ -163,6 +167,7 @@ push!(connections, connect(multibody_spring.spring2d.flange_a, damper.flange_a))
163167
push!(connections, connect(multibody_spring.spring2d.flange_b, damper.flange_b))
164168

165169
@named model = ODESystem(connections, t, systems = [world, multibody_spring, root_body, damper])
170+
model = complete(model)
166171
ssys = structural_simplify(IRSystem(model))
167172
prob = ODEProblem(ssys, defs, (0, 10))
168173

docs/src/examples/ropes_and_cables.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ connections = [connect(world.frame_b, rope.frame_a)
3030

3131
@named stiff_rope = ODESystem(connections, t, systems = [world, body, rope])
3232

33+
stiff_rope = complete(stiff_rope)
3334
ssys = structural_simplify(IRSystem(stiff_rope))
3435
prob = ODEProblem(ssys, [], (0, 5))
3536
sol = solve(prob, Rodas4(autodiff=false))
@@ -53,6 +54,7 @@ connections = [connect(world.frame_b, rope.frame_a)
5354

5455
@named flexible_rope = ODESystem(connections, t, systems = [world, body, rope])
5556

57+
flexible_rope = complete(flexible_rope)
5658
ssys = structural_simplify(IRSystem(flexible_rope))
5759
prob = ODEProblem(ssys, [], (0, 8))
5860
sol = solve(prob, Rodas4(autodiff=false));
@@ -85,7 +87,7 @@ connections = [connect(world.frame_b, fixed.frame_a, chain.frame_a)
8587
connect(spring.frame_b, fixed.frame_b)]
8688

8789
@named mounted_chain = ODESystem(connections, t, systems = [systems; world])
88-
90+
mounted_chain = complete(mounted_chain)
8991
ssys = structural_simplify(IRSystem(mounted_chain))
9092
prob = ODEProblem(ssys, [
9193
collect(chain.link_8.body.w_a) .=> [0,0,0];

docs/src/examples/spherical_pendulum.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ connections = [connect(world.frame_b, joint.frame_a)
2727
connect(bar.frame_b, body.frame_a)]
2828

2929
@named model = ODESystem(connections, t, systems = [world; systems])
30+
model = complete(model)
3031
ssys = structural_simplify(IRSystem(model))
3132

3233
prob = ODEProblem(ssys, [], (0, 5))

ext/Render.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ function get_all_vars(model, vars = Multibody.collect_all(unknowns(model)))
102102
end
103103

104104

105-
function get_cached(cs::CacheSol, t, idxs)
105+
get_cached(cs::CacheSol, t::AbstractArray, idxs) = cs.sol(t; idxs)
106+
function get_cached(cs::CacheSol, t::Real, idxs)
106107
if ModelingToolkit.isparameter(idxs[1])
107108
return cs.prob.ps[idxs]
108109
end
@@ -861,6 +862,7 @@ end
861862

862863
Multibody.render!(scene, ::typeof(Multibody.URDFRevolute), sys, sol, t) = false
863864
Multibody.render!(scene, ::typeof(Multibody.URDFPrismatic), sys, sol, t) = false
865+
Multibody.render!(scene, ::typeof(Multibody.NullJoint), sys, sol, t) = false
864866

865867
# ==============================================================================
866868
## PlanarMechanics

0 commit comments

Comments
 (0)