write a geometry file

Asked by ceguo

Hello everyone,

After I prepared the packing (isotropic compression), I want to write a geometry file which can be read for further simulation using "readGeometry". What is the data format of this sort of geometry file? I notice it contains particle information first then connect information. What is connect information (from beginConnect to endConnect, 3 data in each line) and how to extract them and export them?

Or maybe I can use mntable. But in the preparation stage, my packing is got using the conventional mean given in the tutorial, i.e. using "geoRandomBlock = RandomBoxPacker()" and "geoRandomBlock.generate()". Then how to use mntable to write the geometry file which seems much easier?

Tks,

Ning

Question information

Language:
English Edit question
Status:
Solved
For:
ESyS-Particle Edit question
Assignee:
No assignee Edit question
Solved by:
SteffenAbe
Solved:
Last query:
Last reply:
Revision history for this message
Anton Gladky (gladky-anton) said :
#1

Hi,

please, read https://answers.launchpad.net/esys-particle/+faq/877

Hope, it will be useful.

Revision history for this message
ceguo (hhh-guo) said :
#2

Thanks Anton,

This solved my question.

I still have a question about fieldsaver. Using interactionvectorfieldsaver, we can extract data of particle interactions. Is there any way to get particle-wall interaction info, like force vector, contact point, and particle radius, etc?

Tks,

Ning

Revision history for this message
Best SteffenAbe (s-abe) said :
#3

> After I prepared the packing (isotropic compression), I want to write a geometry file which can be read for further
> simulation using "readGeometry".
The easier way may be to dump the packing as normal checkpoint and then convert it to a geometry file using the Python script attached below. Usage is "python dump2geo.py checkpoint_0.txt output.geo" where "checkpoint_0.txt" is the _0.txt file of the appropriate checkpoint and "output.geo" the name the geometry file should have. The ususal rule about reading checkpoint from the same directory from where the were written applies.

> Is there any way to get particle-wall interaction info, like force vector, contact point, and particle radius, etc?
No, not at the moment. You can only get cumulative data (i.e. total force on the wall).

---- dump2geo.py -----

from GenGeo import *
import sys

hfilename=sys.argv[1] # input file name
ofilename=sys.argv[2] # output file name

hfile=open(hfilename)

# read & throw away header lines
for i in range(5):
    hfile.readline()

# bounding box
l=hfile.readline().split()

pxmin=float(l[1])
pymin=float(l[2])
pzmin=float(l[3])
pxmax=float(l[4])
pymax=float(l[5])
pzmax=float(l[6])

# read & throw away header lines
for i in range(2):
    hfile.readline()

fnames=hfile.readline().split()
hfile.close()

# set grid spacing for ntable
grid_spacing=2.5

# setup ntable using read bouding box
ntable = MNTable3D (Vec3(pxmin,pymin,pzmin),
                    Vec3(pxmax,pymax,pzmax),
                    grid_spacing,1)

print fnames

for name in fnames:
    # open file
    infile=open(name)

    # read nr. of particles
    l=infile.readline().split()
    nparts=int(l[0])

    print nparts, " particles"

    # read particles
    for i in range(nparts):
        l=infile.readline().split()
        # position
        x=float(l[0])
        y=float(l[1])
        z=float(l[2])
        r=float(l[3])
        id=int(l[4])
        tag=int(l[5])

        sph=Sphere(Vec3(x,y,z),r)
        sph.setTag(tag)
        sph.setId(id)
        ntable.insert(sph,0)

    # read nr. of bond groups
    l=infile.readline().split()
    nbgroups=int(l[0])

    print "nr. of bond groups: ", nbgroups
    for i in range(nbgroups):
        # read & throw away interaction type
        l=infile.readline()
        # read nr. of bonds
        l=infile.readline().split()
        nbonds=int(l[0])
        print "bonds: ", nbonds
        for j in range(nbonds):
            # read bond
            l=infile.readline().split()
            ntable.insertBond(int(l[0]),int(l[1]),int(l[2]))

ntable.write(ofilename,1)

--- end of file ----

Revision history for this message
ceguo (hhh-guo) said :
#4

Thanks SteffenAbe, that solved my question.