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

Write out coordinates of centers of spheres

0 votes
asked Jan 23, 2018 by Student74 (220 points)

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):
    with open('capsules.txt','w') as out:
       for p in S.dem.par:
          if not isinstance(p.shape,woo.dem.Capsule): continue
          out.write('%g %g %g %g %g %g %g\n'%(a[0],a[1],a[2],b[0],b[1],b[2],r))
    vtk(S) # trigger manually writing Paraview data files
    # write paraview script and run it

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, 2018 by eudoxos (49,150 points)
selected Jan 30, 2018 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