-
Notifications
You must be signed in to change notification settings - Fork 8
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
performance topic: SpringDamperPtP #132
Comments
Merged
an additional MWE (without module T1
mutable struct SpringDamperPtP
path::String
springForceFunction::Function
damperForceFunction::Function
function SpringDamperPtP(; path::String = "",
springForceLaw::Union{Real, Function} = 0.0,
damperForceLaw::Union{Real, Function} = 0.0 )
if (!isa(springForceLaw, Function))
# stiffness = Modia3D.convertAndStripUnit(F, u"N/m", springForceLaw)
stiffness = springForceLaw
fkt1(_x) = stiffness*_x
else
fkt1 = springForceLaw
end
if (!isa(damperForceLaw, Function))
# damping = Modia3D.convertAndStripUnit(F, u"N*s/m", damperForceLaw)
damping = damperForceLaw
fkt2(_x) = damping*_x
else
fkt2 = damperForceLaw
end
return new(path, fkt1, fkt2)
end
end
function evaluateForceElement(force::SpringDamperPtP, )
pos = 100.0
vel = 10.0
fc = force.springForceFunction(pos)
fd = force.damperForceFunction(vel)
println("$(force.path) fc = $(fc) fd = $(fd)")
println()
nothing
end
fc(x) = 100.0*x
fd(x) = 1.111*x
A = SpringDamperPtP(;path="function + function ", springForceLaw=fc, damperForceLaw=fd)
B = SpringDamperPtP(;path="parameter + parameter ", springForceLaw=33.0, damperForceLaw=0.999)
C = SpringDamperPtP(;path="function + parameter ", springForceLaw=fc, damperForceLaw=0.999)
D = SpringDamperPtP(;path="parameter + function ", springForceLaw=33.0, damperForceLaw=fd)
evaluateForceElement(A)
evaluateForceElement(B)
evaluateForceElement(C)
evaluateForceElement(D)
end
|
Merged
Fixed by #133 |
the same code block (with |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I tried to run a Modia3D model several times and found differences in simulation time
test 1: using explicit functions for spring and damping
test 2: using parameters for spring and damping
takes longer, due to additional compilation time for
eval()
test 3: using parameters for spring and damping with modified
SpringDamperPtP.jl
a PR will be opened soon. It works, but I'm not the expert - check it carefully. Danke.
code sniplet below:
The text was updated successfully, but these errors were encountered: