def monomer_system(num_particles, density=0.8, seed=None): num_particles = num_particles L = pow(num_particles/density, 1./3.) box = (L, L, L) # Initialize the espresso system system = espresso.System() if seed is not None: system.rng = espresso.esutil.RNG(seed) else: system.rng = espresso.esutil.RNG() system.bc = espresso.bc.OrthorhombicBC(system.rng, box) system.skin = skin nodeGrid = espresso.tools.decomp.nodeGrid(MPI.COMM_WORLD.size) cellGrid = espresso.tools.decomp.cellGrid(box, nodeGrid, rc, skin) system.storage = espresso.storage.DomainDecomposition(system, nodeGrid, cellGrid) def normal_v(): return espresso.Real3D(system.rng.normal()*0.5, system.rng.normal()*0.5, system.rng.normal()*0.5) # Add the individual particles Xs = [] pid = 0 for i in range(num_particles): pos = system.bc.getRandomPos() v = espresso.Real3D(system.rng.normal(),system.rng.normal(),system.rng.normal()) Xs.append([pid, pos, v]) pid += 1 system.storage.addParticles(Xs, 'id', 'pos', 'v') # Define capped LJ potential verletList = espresso.VerletList(system, cutoff=rc) LJCapped = espresso.interaction.VerletListLennardJonesCapped(verletList) LJCapped.setPotential(type1=0, type2=0, potential=espresso.interaction.LennardJonesCapped(epsilon=epsilon, sigma=sigma, cutoff=rc, caprad=caprad_LJ)) system.addInteraction(LJCapped) # Define integrator and StochasticVelocityRescaling thermostat integrator = espresso.integrator.VelocityVerlet(system) thermostat = espresso.integrator.StochasticVelocityRescaling(system) thermostat.temperature = 1.0 integrator.addExtension(thermostat) system.storage.decompose() return system, integrator, LJCapped, verletList, thermostat, num_particles
# run with "tlj tfene tcos" to activate tabulated potentials tabfileLJ = "pot-lj.txt" tabfileFENE = "pot-fene.txt" tabfileCosine = "pot-cosine.txt" spline = 2 # spline interpolation type (1, 2, 3) ###################################################################### ## IT SHOULD BE UNNECESSARY TO MAKE MODIFICATIONS BELOW THIS LINE ## ###################################################################### sys.stdout.write('Setting up simulation ...\n') bonds, angles, x, y, z, Lx, Ly, Lz = lammps.read( 'espressopp_polymer_melt.start') num_particles = len(x) density = num_particles / (Lx * Ly * Lz) size = (Lx, Ly, Lz) system = espresso.System() system.rng = espresso.esutil.RNG(54321) system.bc = espresso.bc.OrthorhombicBC(system.rng, size) system.skin = skin 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.decompose() # Lennard-Jones with Verlet list
def chains_x_system(num_chains, monomers_per_chain, num_X, density=0.8, seed=None): num_particles = num_chains * monomers_per_chain + num_X L = pow(num_particles / density, 1. / 3.) box = (L, L, L) # Initialize the espresso system system = espresso.System() if seed is not None: system.rng = espresso.esutil.RNG(seed) else: system.rng = espresso.esutil.RNG() system.bc = espresso.bc.OrthorhombicBC(system.rng, box) system.skin = skin nodeGrid = espresso.tools.decomp.nodeGrid(MPI.COMM_WORLD.size) cellGrid = espresso.tools.decomp.cellGrid(box, nodeGrid, rc, skin) system.storage = espresso.storage.DomainDecomposition( system, nodeGrid, cellGrid) def normal_v(): return espresso.Real3D(system.rng.normal() * 0.5, system.rng.normal() * 0.5, system.rng.normal() * 0.5) # Add the chains chainFPL = espresso.FixedPairList(system.storage) pid = 0 for i in range(num_chains): chain = [] startpos = system.bc.getRandomPos() positions, bonds = espresso.tools.topology.polymerRW( pid, startpos, monomers_per_chain, bondlen) for k in range(monomers_per_chain): part = [pid + k, positions[k], normal_v()] chain.append(part) pid += monomers_per_chain system.storage.addParticles(chain, 'id', 'pos', 'v') chainFPL.addBonds(bonds) # Add the individual particles Xs = [] for i in range(num_X): pos = system.bc.getRandomPos() v = espresso.Real3D(system.rng.normal(), system.rng.normal(), system.rng.normal()) Xs.append([pid, pos, v]) pid += 1 system.storage.addParticles(Xs, 'id', 'pos', 'v') # Define capped LJ potential verletList = espresso.VerletList(system, cutoff=rc) LJCapped = espresso.interaction.VerletListLennardJonesCapped(verletList) LJCapped.setPotential(type1=0, type2=0, potential=espresso.interaction.LennardJonesCapped( epsilon=epsilon, sigma=sigma, cutoff=rc, caprad=caprad_LJ)) system.addInteraction(LJCapped) # Define capped FENE potential potFENE = espresso.interaction.FENECapped(K=K, r0=0.0, rMax=rMax, caprad=caprad_FENE) FENECapped = espresso.interaction.FixedPairListFENECapped( system, chainFPL, potFENE) system.addInteraction(FENECapped) # Define integrator and StochasticVelocityRescaling thermostat integrator = espresso.integrator.VelocityVerlet(system) thermostat = espresso.integrator.StochasticVelocityRescaling(system) thermostat.temperature = 1.0 integrator.addExtension(thermostat) system.storage.decompose() return system, integrator, LJCapped, verletList, FENECapped, chainFPL, thermostat, num_particles