Skip to content

Commit 87cb42f

Browse files
Fix force law function check in Bushing
1 parent aece232 commit 87cb42f

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/Composition/ForceElements/Bushing.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ mutable struct Bushing <: Modia3D.AbstractForceElement
7575
rotDamperForceLaw::AbstractVector = Modia3D.ZeroVector3D,
7676
largeAngles::Bool = false )
7777
for dir in 1:3
78-
@assert(typeof(springForceLaw[dir]) == Float64 || typeof(springForceLaw[dir]) == Function)
79-
@assert(typeof(damperForceLaw[dir]) == Float64 || typeof(damperForceLaw[dir]) == Function)
80-
@assert(typeof(rotSpringForceLaw[dir]) == Float64 || typeof(rotSpringForceLaw[dir]) == Function)
81-
@assert(typeof(rotDamperForceLaw[dir]) == Float64 || typeof(rotDamperForceLaw[dir]) == Function)
78+
@assert(typeof(springForceLaw[dir]) == Float64 || isa(springForceLaw[dir], Function))
79+
@assert(typeof(damperForceLaw[dir]) == Float64 || isa(damperForceLaw[dir], Function))
80+
@assert(typeof(rotSpringForceLaw[dir]) == Float64 || isa(rotSpringForceLaw[dir], Function))
81+
@assert(typeof(rotDamperForceLaw[dir]) == Float64 || isa(rotDamperForceLaw[dir], Function))
8282
end
8383

8484
nomForce = Modia3D.convertAndStripUnit(SVector{3,Float64}, u"N" , nominalForce)

test/ForceElements/BoxBushing.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ if largeAngles
1111
else
1212
startAngles = [0.12, 0.06, 0.03]
1313
end
14+
fc(p) = 50.0 * p
15+
fd(v) = 2.0 * v
16+
mc(a) = 20.0 * a
17+
md(w) = 0.2 * w
1418

1519
BoxBushing = Model(
1620
Length = 0.1,
@@ -25,8 +29,8 @@ BoxBushing = Model(
2529
visualMaterial=:(visualMaterial))),
2630
joint = FreeMotion(obj1=:world, obj2=:box, r=Var(init=[0.2, 0.1, 0.05]), rot=Var(init=startAngles)),
2731
force = Bushing(obj1=:world, obj2=:box,
28-
springForceLaw=[50.0, 100.0, 200.0], damperForceLaw=[1.0, 2.0, 4.0],
29-
rotSpringForceLaw=[5.0, 10.0, 20.0], rotDamperForceLaw=[0.1, 0.2, 0.4], largeAngles=largeAngles)
32+
springForceLaw=[fc, 100.0, 200.0], damperForceLaw=[1.0, fd, 4.0],
33+
rotSpringForceLaw=[5.0, 10.0, mc], rotDamperForceLaw=[0.1, md, 0.4], largeAngles=largeAngles)
3034
)
3135

3236
boxBushing = @instantiateModel(buildModia3D(BoxBushing), aliasReduction=false, unitless=true)

0 commit comments

Comments
 (0)