diff --git a/src/Blocks/analysis_points.jl b/src/Blocks/analysis_points.jl index c5ee4b3a3..8d73e70f8 100644 --- a/src/Blocks/analysis_points.jl +++ b/src/Blocks/analysis_points.jl @@ -18,6 +18,10 @@ function Base.hash(ap::AnalysisPoint, seed::UInt) h3 ⊻ (0xd29cdc51aa6562d4 % UInt) end +function ModelingToolkit.get_unit(ap::AnalysisPoint) + ModelingToolkit.unitless +end + function ap_var(sys) if hasproperty(sys, :u) # collect to turn symbolic arrays into arrays of symbols diff --git a/test/Blocks/test_analysis_points.jl b/test/Blocks/test_analysis_points.jl index 0d3ac7122..5e245a0f1 100644 --- a/test/Blocks/test_analysis_points.jl +++ b/test/Blocks/test_analysis_points.jl @@ -374,3 +374,27 @@ L = CS.ss(matrices...) |> sminreal matrices, _ = linearize(sys_outer, [:inner_plant_input], [:inner_plant_output]) G = CS.ss(matrices...) |> sminreal @test tf(G) ≈ tf(CS.feedback(Ps, Cs)) + +## unit test +@mtkmodel SingleIntegrator begin + @parameters begin + to_mps = 1, [unit = u"m/s"] + end + @variables begin + (x(t) = 0), [unit = u"m", description = "Position"] + control(t), [unit = u"m/s", description = "Control Velocity"] + end + @components begin + uIn = RealInput() + c1 = Blocks.Constant(k = 1) + end + @equations begin + control ~ (uIn.u) * to_mps + D(x) ~ control + connect(c1.output, :test_point, uIn) + end +end +@mtkbuild single_integrator = SingleIntegrator() +prob = ODEProblem(single_integrator, [], (0, 10)) +sol = solve(prob, Tsit5()) +@test sol(10)[] ≈ 10