def genTabPotentials(tabfilesnb): potentials = {} for fg in tabfilesnb: fe = fg.split(".")[0]+".tab" # name of espressopp file gromacs.convertTable(fg, fe, sigma, epsilon, c6, c12) pot = espressopp.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
# set up coulomb interactions according to the parameters read from the .top file print '#Note: Reaction Field method is used for Coulomb interactions' qq_adres_interaction = gromacs.setCoulombInteractions(system, verletlist, intCutoff, atTypes, epsilon1=1, epsilon2=67.5998, kappa=0, adress=True, ftpl=ftpl) # set the CG potential for water. Set for LJ interaction, and QQ interaction has no CG equivalent, also prot has no CG potential, is always in adres region # load CG interaction from table fe = "table_CGwat_CGwat.tab" gromacs.convertTable("table_CGwat_CGwat.xvg", fe, 1, 1, 1, 1) potCG = espressopp.interaction.Tabulated(itype=3, filename=fe, cutoff=intCutoff) lj_adres_interaction.setPotentialCG(type1=typeCG, type2=typeCG, potential=potCG) ## bonded (fixed list) interactions for protein (actually between CG particles in AA region) ## ## set up LJ 1-4 interactions cgOnefourpairslist = [] for (a1, a2) in atOnefourpairslist: cgOnefourpairslist.append((mapAtToCgIndex[a1], mapAtToCgIndex[a2])) print '# ', len(cgOnefourpairslist), ' 1-4 pairs in aa-hybrid region' onefourlist = espressopp.FixedPairList(system.storage)
# 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 = espressopp.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() == espressopp.interaction.Nonbonded: print "Setting CG interaction", typeCG interaction.setPotentialCG(type1=typeCG, type2=typeCG, potential=potCG) break # set up bonded interactions according to the parameters read from the .top file bondedinteractions = gromacs.setBondedInteractionsAdress( system, bondtypes, bondtypeparams, ftpl)
comm = MPI.COMM_WORLD nodeGrid = decomp.nodeGrid(comm.size,size,rc,skin) cellGrid = decomp.cellGrid(size, nodeGrid, rc, skin) system.storage = espressopp.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 espressopp++ 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 = espressopp.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)
outfile.close() # write the espressopp++ tabulated file for a LJ potential print 'Generating potential file ... (%2s)' % tabfile potLJ = espressopp.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 espressopp++ 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