@@ -20,24 +20,24 @@ i.e. the orientation of `obj2` does not influence the resulting forces.
2020 positive axis directions at `obj1` and in opposite directions at `obj2`.
2121- `springForceLaw` defines the force law of the spring in x-, y- and
2222 z-direction:
23- - A `Float64` value represents a linear stiffness coefficient.
23+ - A `Real` number represents a linear stiffness coefficient.
2424 - An univariate `Function` is used to compute the spring force
2525 dependent of its deflection.
2626- `damperForceLaw` defines the force law of the damper in x-, y- and
2727 z-direction:
28- - A `Float64` value represents a linear damping coefficient.
28+ - A `Real` number represents a linear damping coefficient.
2929 - An univariate `Function` is used to compute the damper force
3030 dependent of its deflection velocity.
3131- `nominalTorque` defines nominal torques about alpha, beta and gamma
3232 directions.
3333- `rotSpringForceLaw` defines the force law of the rotational spring
3434 about alpha-, beta- and gamma-direction:
35- - A `Float64` value represents a linear damping coefficient.
35+ - A `Real` number represents a linear damping coefficient.
3636 - An univariate `Function` is used to compute the spring force
3737 dependent of its deflection.
3838- `rotDamperForceLaw` defines the force law of the rotational damper
3939 about alpha-, beta- and gamma-direction:
40- - A `Float64` value represents a linear damping coefficient.
40+ - A `Real` number represents a linear damping coefficient.
4141 - An univariate `Function` is used to compute the damper force
4242 dependent of its deflection velocity.
4343- `largeAngles` can be used to enable large angle mode.
@@ -74,13 +74,6 @@ mutable struct Bushing <: Modia3D.AbstractForceElement
7474 rotSpringForceLaw:: AbstractVector = Modia3D. ZeroVector3D,
7575 rotDamperForceLaw:: AbstractVector = Modia3D. ZeroVector3D,
7676 largeAngles:: Bool = false )
77- for dir in 1 : 3
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))
82- end
83-
8477 nomForce = Modia3D. convertAndStripUnit (SVector{3 ,Float64}, u " N" , nominalForce)
8578 nomTorque = Modia3D. convertAndStripUnit (SVector{3 ,Float64}, u " N*m" , nominalTorque)
8679 springForceFunction = Vector {Function} (undef, 3 )
@@ -89,33 +82,33 @@ mutable struct Bushing <: Modia3D.AbstractForceElement
8982 rotDamperForceFunction = Vector {Function} (undef, 3 )
9083 irand = rand (Int)
9184 for dir in 1 : 3
92- if (typeof (springForceLaw[dir]) == Float64)
85+ if (isa (springForceLaw[dir], Function))
86+ springForceFunction[dir] = springForceLaw[dir]
87+ else
9388 stiffness = Modia3D. convertAndStripUnit (Float64, u " N/m" , springForceLaw[dir])
9489 fsymb = Symbol (" fc" , dir, " _" , irand) # todo: replace irand by force.path
9590 springForceFunction[dir] = eval (:($ fsymb (pos) = $ stiffness * pos))
96- else
97- springForceFunction[dir] = springForceLaw[dir]
9891 end
99- if (typeof (damperForceLaw[dir]) == Float64)
92+ if (isa (damperForceLaw[dir], Function))
93+ damperForceFunction[dir] = damperForceLaw[dir]
94+ else
10095 damping = Modia3D. convertAndStripUnit (Float64, u " N*s/m" , damperForceLaw[dir])
10196 fsymb = Symbol (" fd" , dir, " _" , irand) # todo: replace irand by force.path
10297 damperForceFunction[dir] = eval (:($ fsymb (vel) = $ damping * vel))
103- else
104- damperForceFunction[dir] = damperForceLaw[dir]
10598 end
106- if (typeof (rotSpringForceLaw[dir]) == Float64)
99+ if (isa (rotSpringForceLaw[dir], Function))
100+ rotSpringForceFunction[dir] = rotSpringForceLaw[dir]
101+ else
107102 stiffness = Modia3D. convertAndStripUnit (Float64, u " N*m/rad" , rotSpringForceLaw[dir])
108103 fsymb = Symbol (" mc" , dir, " _" , irand) # todo: replace irand by force.path
109104 rotSpringForceFunction[dir] = eval (:($ fsymb (ang) = $ stiffness * ang))
110- else
111- rotSpringForceFunction[dir] = rotSpringForceLaw[dir]
112105 end
113- if (typeof (rotDamperForceLaw[dir]) == Float64)
106+ if (isa (rotDamperForceLaw[dir], Function))
107+ rotDamperForceFunction[dir] = rotDamperForceLaw[dir]
108+ else
114109 damping = Modia3D. convertAndStripUnit (Float64, u " N*m*s/rad" , rotDamperForceLaw[dir])
115110 fsymb = Symbol (" md" , dir, " _" , irand) # todo: replace irand by force.path
116111 rotDamperForceFunction[dir] = eval (:($ fsymb (angd) = $ damping * angd))
117- else
118- rotDamperForceFunction[dir] = rotDamperForceLaw[dir]
119112 end
120113 end
121114
0 commit comments