示例#1
0
def returncenters(guvfilename, molar, grcutoff):
    '''Given distribution, returns placed atoms

    Input: guvfilename and molarity
    Returns: Placed centers as Atom objects
    '''

    conc = molar * 6.0221415E-4
    shellindices = grid.readshellindices()
    if guvfilename[-3:] == ".dx":
        (distribution, origin, delta, gridcount) = \
            grid.readdx(guvfilename)
    elif guvfilename[-3:] == ".h5":
        grids = grid.h5ToGrids(guvfilename)
        print "Warning, assuming target molecule is 'O', please contact the developer for more info."
        if 'guv' not in grids['O'].keys():
            exit("Error, guv distribution not found in file")
        gGrid = grids['O']['guv']
        distribution = gGrid.distribution
        origin = gGrid.origin
        delta = gGrid.deltas
        gridcount = gGrid.gridcount
    else:
        exit("Error, incompatible file type! -> {0}".format(guvfilename))

    (popzero, totalpop, gridvolume) = converttopop(distribution,
            delta, conc)
    return doplacement(popzero, conc, gridvolume, origin, delta, shellindices,
        grcutoff)
示例#2
0
文件: test_grid.py 项目: MSugita/grid
import os

testscriptdir = os.getcwd()

# Test reading/writing
print "Testing reading/writing dx files.."
dxfilename = os.path.join(testscriptdir, "data", "dxfiles", 
                          "AlaDP_3DRISM_smallbuffer.dx.gz") 
originalgrid = grid.dx2Grid(dxfilename)

maxvalue = originalgrid.distribution.max()
maxindices = tuple(np.argwhere(originalgrid.distribution == maxvalue)[0])
originalgrid.distribution[maxindices] = maxvalue * 2.0
originalgrid.writedx("modified.dx")
newgrid = grid.dx2Grid("modified.dx")
newmax = newgrid.distribution.max()
assert newmax == maxvalue * 2.0
#cleanup
os.remove("modified.dx")

# Test shells
print "Testing shell-related utilities.."
storedprecomputedshells = grid.readshellindices()
newshells = grid.precomputeshellindices(40)
for storedshell, newshell in zip(storedprecomputedshells, newshells):
    for storedpoint, newpoint in zip(storedshell, newshell):
        for storedindex, newindex in zip(storedpoint, newpoint):
            assert storedindex == newindex


示例#3
0
#matplotlib.pyplot.scatter(xset, rdfnearH, color="silver")
#matplotlib.pyplot.scatter(xset, rdfnearO, color="red")
#matplotlib.pyplot.scatter(xset, rdfnearH2, color="blue")
#matplotlib.pyplot.show()
#quit()

# Test reading/writing
print "Testing reading/writing dx files.."
originalgrid = grid.dx2Grid(dxfilename)

maxvalue = originalgrid.distribution.max()
maxindices = tuple(np.argwhere(originalgrid.distribution == maxvalue)[0])
originalgrid.distribution[maxindices] = maxvalue * 2.0
originalgrid.writedx("modified.dx")
newgrid = grid.dx2Grid("modified.dx")
newmax = newgrid.distribution.max()
assert newmax == maxvalue * 2.0
#cleanup
del originalgrid
del newgrid
os.remove("modified.dx")

# Test shells
print "Testing shell-related utilities.."
storedprecomputedshells = grid.readshellindices()
newshells = grid.precomputeshellindices(40)
for storedshell, newshell in zip(storedprecomputedshells, newshells):
    for storedpoint, newpoint in zip(storedshell, newshell):
        for storedindex, newindex in zip(storedpoint, newpoint):
            assert storedindex == newindex