Skip to content

Commit

Permalink
Merge pull request #133 from johhell/jh_springforces
Browse files Browse the repository at this point in the history
speedup SpringDamperPtP
  • Loading branch information
GerhardHippmann authored Jan 8, 2024
2 parents 552e89c + 434770e commit 18ebcaf
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/Composition/ForceElements/SpringDamperPtP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,22 @@ mutable struct SpringDamperPtP{F <: Modia3D.VarFloatType} <: Modia3D.AbstractFor

nomLength = Modia3D.convertAndStripUnit(F, u"m", nominalLength)
nomForce = Modia3D.convertAndStripUnit(F, u"N", nominalForce)

if (!isa(springForceLaw, Function))
stiffness = Modia3D.convertAndStripUnit(F, u"N/m", springForceLaw)
fsymb = Symbol(path, "_", "fc")
springForceLaw = eval(:($fsymb(pos) = $stiffness * pos))
fkt1(_x) = stiffness*_x
else
fkt1 = springForceLaw
end

if (!isa(damperForceLaw, Function))
damping = Modia3D.convertAndStripUnit(F, u"N*s/m", damperForceLaw)
fsymb = Symbol(path, "_", "fd")
damperForceLaw = eval(:($fsymb(vel) = $damping * vel))
fkt2(_x) = damping*_x
else
fkt2 = damperForceLaw
end

return new(path, obj1, obj2, nomLength, nomForce, springForceLaw, damperForceLaw)
return new(path, obj1, obj2, nomLength, nomForce, fkt1, fkt2)
end
end
SpringDamperPtP(; kwargs...) = SpringDamperPtP{Float64}(; kwargs...)
Expand Down

0 comments on commit 18ebcaf

Please sign in to comment.