From 55bc8802585d2631cea4e8a9ff10c8c32af4fbe6 Mon Sep 17 00:00:00 2001 From: ChrisRackauckas-Claude Date: Mon, 13 Jul 2026 10:40:35 -0400 Subject: [PATCH 1/2] Define the piston test independent variable Co-Authored-By: Chris Rackauckas --- test/piston.jl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/piston.jl b/test/piston.jl index a6bd0985..7dccc85a 100644 --- a/test/piston.jl +++ b/test/piston.jl @@ -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 From 93ebf68d552c62e7476c6d69d9a719edd4f83a92 Mon Sep 17 00:00:00 2001 From: ChrisRackauckas-Claude Date: Mon, 13 Jul 2026 11:42:13 -0400 Subject: [PATCH 2/2] Fix rotational mechanics initialization and balance Co-Authored-By: Chris Rackauckas --- src/Mechanical/Rotational/sensors.jl | 1 + test/rotational.jl | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Mechanical/Rotational/sensors.jl b/src/Mechanical/Rotational/sensors.jl index 618f66dd..9e837a9d 100644 --- a/src/Mechanical/Rotational/sensors.jl +++ b/src/Mechanical/Rotational/sensors.jl @@ -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, ] diff --git a/test/rotational.jl b/test/rotational.jl index c4d530c6..0cd6ba8a 100644 --- a/test/rotational.jl +++ b/test/rotational.jl @@ -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) @@ -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) @@ -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