예제 #1
0
def genTabPotentials(tabfilesnb):
    potentials = {}
    for fg in tabfilesnb:
        fe = fg.split(".")[0]+".tab" # name of espresso file
        gromacs.convertTable(fg, fe, sigma, epsilon, c6, c12)
        pot = espresso.interaction.Tabulated(itype=spline, filename=fe, cutoff=rc)
        t1, t2 = fg[6], fg[8] # type 1, type 2
        potentials.update({t1+"_"+t2: pot})
    return potentials
예제 #2
0
comm = MPI.COMM_WORLD
nodeGrid = decomp.nodeGrid(comm.size)
cellGrid = decomp.cellGrid(size, nodeGrid, rc, skin)
system.storage = espresso.storage.DomainDecomposition(system, nodeGrid, cellGrid)


# add particles to the system and then decompose
for pid in range(num_particles):
    #system.storage.addParticle(pid + 1, Real3D(x[pid], y[pid], z[pid]))
    system.storage.addParticles([[pid + 1, Real3D(x[pid], y[pid], z[pid]), types[pid]]], "id", "pos", "type")
system.storage.decompose()


# convert gromacs tabulated files to espresso++ format
gromacs.convertTable(tabAAg, tabAA, sigma, epsilon, c6, c12)
gromacs.convertTable(tabABg, tabAB, sigma, epsilon, c6, c12)
gromacs.convertTable(tabBBg, tabBB, sigma, epsilon, c6, c12)
gromacs.convertTable(tab2bg, tab2b, sigma, epsilon, c6, c12)
gromacs.convertTable(tab3bg, tab3b, sigma, epsilon, c6, c12)



# non-bonded interactions, B is type 0, A is type 1
# Verlet list
vl = espresso.VerletList(system, cutoff = rc + system.skin)
# note: in the previous version of this example, exclusions were treated
# incorrectly. Here the nrexcl=3 parameter is taken into account 
# which excludes all neighbors up to 3 bonds away
vl.exclude(exclusions)
예제 #3
0
# set up LJ interaction according to the parameters read from the .top file
ljinteraction=gromacs.setLennardJonesInteractions(system, defaults, atomtypeparameters, verletlist,rca, hadress=True, ftpl=ftpl)

# set up angle interactions according to the parameters read from the .top file

fpl = espresso.FixedTripleListAdress(system.storage, ftpl)
angleinteractions=gromacs.setAngleInteractions(system, angletypes, angletypeparams, fpl)

# set up coulomb interactions according to the parameters read from the .top file
# !! Warning: this only works for reaction-field now!
qq_interactions=gromacs.setCoulombInteractions(system, verletlist, rca, types, epsilon1=1, epsilon2=80, kappa=0, hadress=True, ftpl=ftpl)

# load CG interaction from table
fe="table_CG_CG.tab"
gromacs.convertTable("table_CG_CG.xvg", fe, 1, 1, 1, 1)
potCG = espresso.interaction.Tabulated(itype=3, filename=fe, cutoff=rca) # CG


# set the CG potential. There are two non-bonded interactions, we pick only the first one 
for n in range(system.getNumberOfInteractions()):
    interaction=system.getInteraction(n)
    if interaction.bondType() == espresso.interaction.Nonbonded:
	print "Setting CG interaction", typeCG
	interaction.setPotentialCG(type1=typeCG, type2=typeCG, potential=potCG)
	break

fpl = espresso.FixedPairListAdress(system.storage, ftpl)
bondedinteractions=gromacs.setBondedInteractions(system, bondtypes, bondtypeparams, fpl)

            force = pot.computeForce(Real3D(r, 0.0, 0.0))[0]
        else: # this is for 3- and 4-body potentials
            force = pot.computeForce(r)
        outfile.write("%15.8g %15.8g %15.8g\n"%(r, energy, force))
     
    outfile.close()

# write the espresso++ tabulated file for a LJ potential
print 'Generating potential file ... (%2s)' % tabfile
potLJ = espresso.interaction.LennardJones(epsilon=1.0, sigma=1.0, shift=0.0, cutoff=cutoff)
writeTabFile(potLJ, tabfile, N=1500, low=0.01, high=potLJ.cutoff)


# convert gromacs tabulated file to espresso++ format
print 'Converting GROMACS file to ESPResSo++ file ... (%2s -> %2s)' % (filein, fileout)
gromacs.convertTable(filein, fileout, sigma, epsilon, c6, c12)

#exit() # exit if you just want to convert a file

# compute the number of cells on each node
def calcNumberCells(size, nodes, cutoff):
    ncells = 1
    while size / (ncells * nodes) >= cutoff:
       ncells = ncells + 1
    return ncells - 1


#start_time = time.clock()

# run simulation for all tabulated potential files
for potfile in files: