← Back to team overview

yade-users team mailing list archive

Re: [Question #681105]: particle position

 

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

Description changed to:
Hi,

I want to export each particle's position in txt.In def addPlotData():,I
used  x,y,z = b.state.pos and plot.saveDataTxt to save positon,but I
found that it only saved just one x/y/z.I think maybe saveDataTxt  can
only save int type.How can I save all  particle's positons in txt?

Thanks

James

#################
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from yade import pack,plot,qt

sphere=O.materials.append(FrictMat(young=6e6,poisson=0.3,density=2600,frictionAngle=float(atan(0.4)),label='sphere'))
wall=O.materials.append(FrictMat(young=6e6,poisson=0.3,density=2600,frictionAngle=float(atan(0.1)),label='wall'))

r=2.2275e-3
sp=pack.SpherePack()
ylength=r*2*45
zlength=r*2*200
sp.makeCloud(minCorner=(0,0,0),maxCorner=(0,ylength,zlength),rMean=r,distributeMass=False)
sp.toSimulation(material='sphere')

for b in O.bodies:
    if isinstance(b.shape,Sphere): b.state.blockedDOFs = 'ZxY' 

wallbutton=O.bodies.append(utils.wall(0,axis=2,sense=0,color=(1,0,0),material='wall')) 
wallleft=O.bodies.append(utils.wall(0,axis=1,sense=0,color=(1,0,0),material='wall'))
wallright=O.bodies.append(utils.wall(ylength,axis=1,sense=0,color=(1,0,0),material='wall'))

O.engines=[
   ForceResetter(),
   InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb(),Bo1_Wall_Aabb()]),
   InteractionLoop(
      [Ig2_Sphere_Sphere_ScGeom(),Ig2_Facet_Sphere_ScGeom(),Ig2_Wall_Sphere_ScGeom()],
      [Ip2_FrictMat_FrictMat_FrictPhys()],
      [Law2_ScGeom_FrictPhys_CundallStrack()]
   ),
   NewtonIntegrator(gravity=(0,0,-9.81),damping=0.2,label='newton'),
   VTKRecorder(fileName='3d-vtk-',recorders=['all'],virtPeriod=0.2),#save data for Paraview
   PyRunner(command='addPlotData()',iterPeriod=1000, label="apd"), 
]

O.dt=1*PWaveTimeStep()

O.trackEnergy=True

cut=0.4

x=y=z=0

def addPlotData():   
    for b in O.bodies:
        	if isinstance(b.shape,Sphere): 
			x,y,z = b.state.pos
    			print(x,y,z)
    plot.addData(i=O.iter,kineticEnergy=utils.kineticEnergy(),y=y) 
    plot.saveDataTxt('f.txt',vars=('i','y'))            

plot.plots={'i':(('unbalancedForce','g'),None,'kineticEnergy')}
plot.plot()

qt.Controller()
O.saveTmp()
O.run()

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