Welcome to ask.woodem.org. You may post when you login through your GitHub account.

Write out coordinates of centers of spheres

0 votes
13 views
asked Jan 23 by Student74 (200 points)
Hi,

I genereated a cylinder with spheres with the PsDSphereGenerator, and want to have the coordinates of all the centers of each sphere. How can I get a text file with all these coordinates? A similar question asked earlier for the spherocylinder case used the p.shape.endPt parameter to write out the point A and point B position. I want it the same way as in that case but now with the coordinates of the centers of spheres.

The code for spherocylinder points A and B that is analogous to what I want for the sphere case is the following:

def done(S):
    S.stop()
    with open('capsules.txt','w') as out:
       for p in S.dem.par:
          if not isinstance(p.shape,woo.dem.Capsule): continue
          a,b,r=p.shape.endPt(0),p.shape.endPt(1),p.shape.radius
          out.write('%g %g %g %g %g %g %g\n'%(a[0],a[1],a[2],b[0],b[1],b[2],r))
    vtk=woo.dem.VtkExport(out='capsules-')
    vtk(S) # trigger manually writing Paraview data files
    # write paraview script and run it
    woo.paraviewscript.write('capsules.py',**woo.paraviewscript.kwFromVtkExport(vtk))
    woo.paraviewscript.launchPV('capsules.py')
S.run()

I think there should be a 'center' parameter for this somehow, but didn't manage yet to write out these coordinates. Can someone help with this?

Thanks in advance :)

1 Answer

+1 vote
answered Jan 24 by eudoxos (46,390 points)
selected Jan 30 by Student74
 
Best answer
Hi, in the particle loop, you can either use `p.pos` for position (particles with one node only have their position accessible using this shortcut), or use `p.shape.nodes[0].pos`. The `Capsule.endPt(i)` is a function call which computes the coordinate on-demand. HTH, Vaclav
...