Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed up Bushing #135

Merged
merged 2 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ julia -JModia3D_sysimage.so (otherwise)
### Forthcoming version

- Enable kinematic chain flipping for structure variable systems
- Avoid function code generation for linear stiffness and damping in SpringDamperPtP and Bushing


### Version 0.12.2
Expand Down
24 changes: 12 additions & 12 deletions src/Composition/ForceElements/Bushing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -122,30 +122,30 @@ mutable struct Bushing{F <: Modia3D.VarFloatType} <: Modia3D.AbstractForceElemen
if (isa(springForceLaw[dir], Function))
springForceFunction[dir] = springForceLaw[dir]
else
stiffness = Modia3D.convertAndStripUnit(F, u"N/m", springForceLaw[dir])
fsymb = Symbol(path, "_", "fc", dir)
springForceFunction[dir] = eval(:($fsymb(pos) = $stiffness * pos))
stiffness::F = Modia3D.convertAndStripUnit(F, u"N/m", springForceLaw[dir])
stiffnessFunction(pos::F) = stiffness * pos
springForceFunction[dir] = stiffnessFunction
end
if (isa(damperForceLaw[dir], Function))
damperForceFunction[dir] = damperForceLaw[dir]
else
damping = Modia3D.convertAndStripUnit(F, u"N*s/m", damperForceLaw[dir])
fsymb = Symbol(path, "_", "fd", dir)
damperForceFunction[dir] = eval(:($fsymb(vel) = $damping * vel))
damping::F = Modia3D.convertAndStripUnit(F, u"N*s/m", damperForceLaw[dir])
dampingFunction(vel::F) = damping * vel
damperForceFunction[dir] = dampingFunction
end
if (isa(rotSpringForceLaw[dir], Function))
rotSpringForceFunction[dir] = rotSpringForceLaw[dir]
else
stiffness = Modia3D.convertAndStripUnit(F, u"N*m/rad", rotSpringForceLaw[dir])
fsymb = Symbol(path, "_", "mc", dir)
rotSpringForceFunction[dir] = eval(:($fsymb(ang) = $stiffness * ang))
rotStiffness::F = Modia3D.convertAndStripUnit(F, u"N*m/rad", rotSpringForceLaw[dir])
rotStiffnessFunction(ang::F) = rotStiffness * ang
rotSpringForceFunction[dir] = rotStiffnessFunction
end
if (isa(rotDamperForceLaw[dir], Function))
rotDamperForceFunction[dir] = rotDamperForceLaw[dir]
else
damping = Modia3D.convertAndStripUnit(F, u"N*m*s/rad", rotDamperForceLaw[dir])
fsymb = Symbol(path, "_", "md", dir)
rotDamperForceFunction[dir] = eval(:($fsymb(angd) = $damping * angd))
rotDamping::F = Modia3D.convertAndStripUnit(F, u"N*m*s/rad", rotDamperForceLaw[dir])
rotDampingFunction(om::F) = rotDamping * om
rotDamperForceFunction[dir] = rotDampingFunction
end
end

Expand Down
18 changes: 9 additions & 9 deletions src/Composition/ForceElements/SpringDamperPtP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,21 @@ 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)
fkt1(_x) = stiffness*_x
if (isa(springForceLaw, Function))
springForceFunction = springForceLaw
else
fkt1 = springForceLaw
stiffness::F = Modia3D.convertAndStripUnit(F, u"N/m", springForceLaw)
springForceFunction(pos::F) = stiffness * pos
end

if (!isa(damperForceLaw, Function))
damping = Modia3D.convertAndStripUnit(F, u"N*s/m", damperForceLaw)
fkt2(_x) = damping*_x
if (isa(damperForceLaw, Function))
damperForceFunction = damperForceLaw
else
fkt2 = damperForceLaw
damping::F = Modia3D.convertAndStripUnit(F, u"N*s/m", damperForceLaw)
damperForceFunction(vel::F) = damping * vel
end

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