Skip to content

Commit 1756b53

Browse files
author
Sathvik Bhagavan
committed
test: add tests for AccelerationSensor
1 parent 23f75ed commit 1756b53

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test/Mechanical/translational.jl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,4 +153,24 @@ end
153153
s_b = 2 - delta_s + 1
154154

155155
@test sol[s.pos_value.u][end]s_b atol=1e-3
156+
157+
@testset "AccelerationSensor" begin
158+
@named acc = TV.AccelerationSensor()
159+
m = 4
160+
@named mass = TV.Mass(m = m)
161+
@named force = TV.Force()
162+
@named source = Sine(frequency = 2, amplitude = 1)
163+
@named acc_output = RealOutput()
164+
eqs = [
165+
connect(force.f, source.output),
166+
connect(force.flange, mass.flange),
167+
connect(acc.flange, mass.flange),
168+
connect(acc_output, acc.output)
169+
]
170+
@named sys = ODESystem(eqs, t, [], []; systems = [force, source, mass, acc, acc_output])
171+
s = complete(structural_simplify(sys))
172+
prob = ODEProblem(s, [], (0.0, pi))
173+
sol = solve(prob, Tsit5())
174+
@test sol[sys.acc_output.u] (sol[sys.mass.f] ./ m)
175+
end
156176
end

0 commit comments

Comments
 (0)