← Back to team overview

yade-users team mailing list archive

Re: [Question #201064]: Newton Integrator updating of position and velocity

 

Question #201064 on Yade changed:
https://answers.launchpad.net/yade/+question/201064

    Status: Open => Answered

Anton Gladky proposed the following answer:
Hi,

add initRun=True to PyRunner:

PyRunner(initRun=True,command='addData()',iterPeriod=1),


Running script test.py
0.0 -0.981 0.9019
0.1 -1.962 0.7057
0.2 -2.943 0.4114
0.3 -3.924 0.019
0.4 -4.905 -0.4715
0.5 -5.886 -1.0601
0.6 -6.867 -1.7468
0.7 -7.848 -2.5316
0.8 -8.829 -3.4145
0.9 -9.81 -4.3955


Anton


2012/6/21 Mukesh Tiwari <question201064@xxxxxxxxxxxxxxxxxxxxx>:
> New question #201064 on Yade:
> https://answers.launchpad.net/yade/+question/201064
>
> Hi
> I am trying to look at how Yade updates postion and velocity through a simple example of a body falling freely under gravity. The code is:
>
> O.bodies.append([utils.sphere((0,0,1),.5)])
>
> b = O.bodies[0]
> #b.state.vel=(0,0,0)
> print O.time,b.state.vel[2],b.state.pos[2]
>
>
> O.engines=[
>   ForceResetter(),
>   NewtonIntegrator(damping=0,gravity=(0,0,-9.81)),
>   PyRunner(command='addData()',iterPeriod=1),
> ]
>
> O.dt = 0.1
>
>
> def addData():
>    print O.time,b.state.vel[2],b.state.pos[2]
>
> O.run(10,True)
>
> Now the output which I obtain is :
>
> 0.0    0.0     1.0
> 0.1  -1.962  0.7057
> 0.2  -2.943  0.4114
> 0.3  -3.924  0.019
> 0.4  -4.905  -0.4715
> 0.5  -5.886  -1.0601
> 0.6  -6.867  -1.7468
> 0.7  -7.848  -2.5316
> 0.8  -8.829  -3.4145
> 0.9  -9.81   -4.3955
>
> The velocity at dt =0.1  should be -0.981 but it gives the expected value at 2*dt. Similarly the position at dt=0.1 is what one expects at 6*dt. I am not sure if there is something wrong in what I do or if there is some other issue.
>
> Thanks
> Mukesh
>
> --
> You received this question notification because you are a member of
> yade-users, which is an answer contact for Yade.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~yade-users
> Post to     : yade-users@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~yade-users
> More help   : https://help.launchpad.net/ListHelp

-- 
You received this question notification because you are a member of
yade-users, which is an answer contact for Yade.