How do I change the Oedometric compression test to tract particle orientation?

Asked by Kieran

I've been trying to adjust the open source (https://gitlab.com/yade-dev/trunk/blob/master/doc/sphinx/tutorial/03-oedometric-test.py) test to track Cartesian coordinates of each particle during a uniaxial compression test.

I have already been using a .py program in Yade that simply tracks the Cartesian coordinates of a generated particle cloud that falls into a volume element. What I have been struggling with was implementing the tracking portion of the code I am comfortable with, into the "03-oedometric-test.py" linked above.

The "03-oedometric-test.py" program collects different data than what I want and I have not been successful using the following lines that I see fit:

{
def myaddData():
   if (O.iter%8==0):
      # open file
      fil=open("timeStep."+str(O.iter),"a+")
      fil.write ('id \t x \t y \t z \t vz \t radius \t force \n')
      for b in O.bodies:
         if (type(b.shape)==Sphere):
            number,rad=b.id,b.shape.radius
            x,y,z=b.state.pos[0],b.state.pos[1],b.state.pos[2]
            veloc,force=b.state.vel[2],O.forces.f(b.id)
            fil.write("{:d}\t{:.3g}\t{:.3g}\t{:.3g}\t{:.3g}\t{:.3g}\t{}\n".format(number,x,y,z,veloc,rad,force)) # ( .format = % )
}

Using the code above, I've been mainly thinking how I need to replace the following code seen in the linked program:
{
def addPlotData():
 if not isinstance(O.bodies[-1].shape,Wall):
  plot.addData(); return
 Fz=O.forces.f(plate.id)[2]
 plot.addData(Fz=Fz,w=plate.state.pos[2]-plate.state.refPos[2],unbalanced=unbalancedForce(),i=O.iter)

# besides unbalanced force evolution, also plot the displacement-force diagram
plot.plots={'i':('unbalanced',),'w':('Fz',)}
plot.plot()
}

I'm generally struggling on the how to add/remove the necessary lines of code to collect the Cartesian coordinates within the "03-oedometric-test.py" program while still conducting the uniaxial compression test.

Any suggestions?

Question information

Language:
English Edit question
Status:
Expired
For:
Yade Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Jan Stránský (honzik) said :
#1

Hello,

there is "orientation" in the title, but "Cartesian coordinates" in the question. Please be consistent and explain what actually you want.

> I have already been using a .py program

please provide the code

> I have not been successful using the following lines

please be more specific. Do you get error? do you get unexpected output? ... ?

The code seems OK.
please provide a MWE [1], without it we can just guess..

> x,y,z=b.state.pos[0],b.state.pos[1],b.state.pos[2]

x,y,z=b.state.pos
does the same job in more readable way

> def myaddData(): ...

have a look at export.textExt [2], with it you can save the spheres with much less code, something like:
###
def myaddData():
   if (O.iter%8==0):
      fn = "timeStep."+str(O.iter)
      comment = "id vz force_x force_y force_z"
      export.textExt(fn,"x_y_z_r_attrs",comment=comment,attrs=["b.id","b.state.vel[2]","O.forces.f(b.id)"])
###

cheers
Jan

[1] https://www.yade-dem.org/wiki/Howtoask
[2] https://yade-dem.org/doc/yade.export.html#yade.export.textExt

Revision history for this message
Kieran (kifu8880) said :
#2

Sorry for the late reply Jan. After reviewing your constructive advice, I revisited my work and got the model to work for me. This question can be closed for the mean time.

Revision history for this message
Launchpad Janitor (janitor) said :
#3

This question was expired because it remained in the 'Needs information' state without activity for the last 15 days.