Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Mechanical/Rotational/sensors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ Ideal sensor to measure the torque between two flanges (`= flange_a.tau`)
end

equations = Equation[
0 ~ flange_a.tau + flange_b.tau,
flange_a.phi ~ flange_b.phi,
tau.u ~ flange_a.tau,
]
Expand Down
3 changes: 3 additions & 0 deletions test/piston.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
using ModelingToolkit, Test
using ModelingToolkitBase: @independent_variables
using SciCompDSL
using SciMLBase
using ModelingToolkitStandardLibrary.Thermal
using ModelingToolkitStandardLibrary.Blocks

@independent_variables t

# Tests ConvectiveResistor and includes FixedTemperature and ThermalResistor

@testset "Piston cylinder wall" begin
Expand Down
12 changes: 9 additions & 3 deletions test/rotational.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,13 @@ end
@test SciMLBase.successful_retcode(sol)

prob = ODEProblem(
sys, [D(D(sys.inertia2.phi)) => 0.0, sys.spring.flange_b.phi => 0.0], (0, 1.0)
sys,
[
sys.inertia1.w => 0.0,
sys.inertia2.w => 0.0,
sys.spring.flange_b.phi => 0.0,
],
(0, 1.0)
)
sol = solve(prob, Rodas4())
@test SciMLBase.successful_retcode(sol)
Expand Down Expand Up @@ -287,7 +293,7 @@ end
@test all(sol[sys.inertia1.w] .== sol[sys.speed_sensor.w.u])
@test sol[sys.inertia2.w][end] ≈ 0 atol = 1.0e-3 # all energy has dissipated
@test all(sol[sys.rel_speed_sensor.w_rel.u] .== sol[sys.speed_sensor.w.u])
@test all(sol[sys.torque_sensor.tau.u] .== -sol[sys.inertia1.flange_b.tau])
@test all(sol[sys.torque_sensor.tau.u] .== -sol[sys.fixed.flange.tau])

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

# Plots.plot(sol; vars=[inertia1.w, inertia2.w])
end
Expand Down
Loading