yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #29276
Re: [Question #706302]: How to move O.bodies.append(facet()) to a circle or complex trajectory
Question #706302 on Yade changed:
https://answers.launchpad.net/yade/+question/706302
Status: Open => Answered
Jan Stránský proposed the following answer:
Hello,
yes, you can use TranslationEngine to simulate any velocityVector(time) function, and therefore any trajectory.
Use PyRunner and set translationAxis and velocity of the TranslationEngine:
###
O.engines = [
TranslationEngine(...,label="translation"),
PyRunner(iterPeriod=1,command="setTranslation()"),
]
def setTranslation():
t = O.time
a = ... # any function of time
v = ... # any function of time
translation.translationAxis = a
translation.velocity = v
###
Specifically for circular motion (with variable velocity):
###
r = 5
sph = sphere((r,0,0),1)
O.bodies.append(sph)
O.engines = [
ForceResetter(),
TranslationEngine(ids=[0],label="translation"),
PyRunner(iterPeriod=1,command="setTranslation()"),
NewtonIntegrator(),
]
O.dt = 1e-4
def setTranslation():
x,y,z = sph.state.pos
angle = atan2(y,x)
v = sin(angle) + 1.4
a = Vector3(-sin(angle),cos(angle),0)
translation.translationAxis = a
translation.velocity = v
view = yade.qt.View()
view.eyePosition = (0,0,20)
view.lookAt = (0,0,0)
###
Note that here a tangent of sphere is specified at each step, so
technically the result is not exact circle, but "little" spiral.
Cheers
Jan
--
You received this question notification because your team yade-users is
an answer contact for Yade.