Skip to content

Commit 73e0d2e

Browse files
Fix rotational mechanics initialization and balance
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
1 parent 2a9fc95 commit 73e0d2e

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

src/Mechanical/Rotational/sensors.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ Ideal sensor to measure the torque between two flanges (`= flange_a.tau`)
8383
end
8484

8585
equations = Equation[
86+
0 ~ flange_a.tau + flange_b.tau,
8687
flange_a.phi ~ flange_b.phi,
8788
tau.u ~ flange_a.tau,
8889
]

test/rotational.jl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,13 @@ end
104104
@test SciMLBase.successful_retcode(sol)
105105

106106
prob = ODEProblem(
107-
sys, [D(D(sys.inertia2.phi)) => 0.0, sys.spring.flange_b.phi => 0.0], (0, 1.0)
107+
sys,
108+
[
109+
sys.inertia1.w => 0.0,
110+
sys.inertia2.w => 0.0,
111+
sys.spring.flange_b.phi => 0.0,
112+
],
113+
(0, 1.0)
108114
)
109115
sol = solve(prob, Rodas4())
110116
@test SciMLBase.successful_retcode(sol)
@@ -287,7 +293,7 @@ end
287293
@test all(sol[sys.inertia1.w] .== sol[sys.speed_sensor.w.u])
288294
@test sol[sys.inertia2.w][end] 0 atol = 1.0e-3 # all energy has dissipated
289295
@test all(sol[sys.rel_speed_sensor.w_rel.u] .== sol[sys.speed_sensor.w.u])
290-
@test all(sol[sys.torque_sensor.tau.u] .== -sol[sys.inertia1.flange_b.tau])
296+
@test all(sol[sys.torque_sensor.tau.u] .== -sol[sys.fixed.flange.tau])
291297

292298
prob = DAEProblem(
293299
sys, D.(unknowns(sys)) .=> prob.f(sol.u[1], prob.p, 0.0), (0, 10.0)
@@ -298,7 +304,7 @@ end
298304
@test all(sol[sys.inertia1.w] .== sol[sys.speed_sensor.w.u])
299305
@test sol[sys.inertia2.w][end] 0 atol = 1.0e-3 # all energy has dissipated
300306
@test all(sol[sys.rel_speed_sensor.w_rel.u] .== sol[sys.speed_sensor.w.u])
301-
@test all(sol[sys.torque_sensor.tau.u] .== -sol[sys.inertia1.flange_b.tau])
307+
@test all(sol[sys.torque_sensor.tau.u] .== -sol[sys.fixed.flange.tau])
302308

303309
# Plots.plot(sol; vars=[inertia1.w, inertia2.w])
304310
end

0 commit comments

Comments
 (0)