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

    Status: Answered => Open

AnnaMaria is still having a problem:
Jan Thank you very much for your effort!!!!
I really appreciate it.
I have only changed  elatTot / nTot to elat_avg=elatTot / nTot
And then return  elat_avg # average elat so that I can plot.

def lateral():
    elatTot = 0.0 # sum of elat of all suitable particles
    nTot = 0 # number of suitable particles
    for p in O.bodies:
        x=p.state.refPos[0]
        z=p.state.refPos[2]
        d=sqrt(pow(x,2)+pow(z,2))
        if d>r1 and d<r2:
            xnew=p.state.pos[0]
            znew=p.state.pos[2]
            dnew=sqrt(pow(xnew,2)+pow(znew,2))
            elat=(d-dnew)/d
            elatTot += elat
            nTot += 1
            elat_avg=elatTot / nTot
    return  elat_avg # average elat

def recorder():
        lateral()
        
yade.plot.addData({'i':O.iter,'eps':abs(strainer.strain),'elateral':(elat_avg),'sigma':abs(strainer.avgStress)})
        plot.saveDataTxt(OUT)

#### Plot During Simulation
plot.plots={'elateral':('sigma')}
plot.plot()

I also changed the recorder part. But when I run the code, I get the following 
Error:
File "<string>", line 1, in <module>
File "UCS.py", line 87, in recorder
yade.plot.addData({'i':O.iter,'eps':abs(strainer.strain),'elateral':(elat_avg),'sigma':abs(strainer.avgStress)})
NameError: global name 'elat_avg' is not defined

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

_______________________________________________
Mailing list: https://launchpad.net/~yade-users
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp

Reply via email to