← Back to team overview

yade-users team mailing list archive

Re: [Question #702411]: Calculation of a time averaging of a physical quantity

 

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

evagb54 posted a new comment:
Sorry Bruno if it was not clear.
 Using your answer, I wrote the program like this: 

while O.iter<t0+itround:
    O.run(nSteps=itround,wait=True)

    for i in range(0,19):

        teta0=i*dteta
        global listcase
        listcase=[]
            #global listcase
        for b in O.bodies:
            if isinstance(b.shape,Sphere):
                rayon=sqrt((b.state.pos[0])**2 +(b.state.pos[1])**2)
                dr=d
                teta=atan(b.state.pos[1]/b.state.pos[0])

                if (b.state.pos[1]>0 and b.state.pos[0]<0) or (b.state.pos[1]<0 and b.state.pos[0]<0):
                    teta=pi-teta
                                   
                if (b.state.pos[1]<0 and b.state.pos[0]>0):
                    teta=2*pi+teta
                                   
                if (rayon<rcylint+dr and rayon>rcylint) and (teta>teta0 and teta<teta0+dteta):
                    c=b.id
                    listcase.append(c)
       
                           
        veltot=0
        for im in listcase:
            b = O.bodies[im]
            veltot = veltot + O.bodies[im].state.vel.norm()
                           
        if len(listcase)!=0:
            velmoy = veltot/len(listcase)
                               
        else:
            velmoy = 0
                           
        timeSeries.append(velmoy)

        timeAverage=np.average(timeSeries)   
        if velmoy==0:
            timeAverage=0           
                                   
        print('len(listcase)=',len(listcase))
        print('teta0=',teta0)
        print('velmoy=',velmoy)
        print('timeAverage=',timeAverage)

The values of timeAverage are not too close of velmoy. Therefore, I was
wondering what are the values  considered in timeSeries=[].


Ps: I am new in programming

Thanks

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.