def setUp(self): system = espressopp.System() box = (10, 10, 10) system.bc = espressopp.bc.OrthorhombicBC(system.rng, box) system.skin = 0.3 system.comm = MPI.COMM_WORLD nodeGrid = espressopp.tools.decomp.nodeGrid( espressopp.MPI.COMM_WORLD.size) cellGrid = espressopp.tools.decomp.cellGrid(box, nodeGrid, 1.5, 0.3) system.storage = espressopp.storage.DomainDecomposition( system, nodeGrid, cellGrid) self.system = system #add particles particle_list = [ (1, 1, 0.1, espressopp.Real3D(3.0, 1.0, 4.0), 2.0), (2, 1, -0.5, espressopp.Real3D(2.0, 2.0, 4.0), 2.0), (3, 1, -0.5, espressopp.Real3D(1.0, 1.0, 4.5), 2.0), (4, 1, 0.5, espressopp.Real3D(4.0, 1.0, 4.0), 2.0), (5, 1, -0.5, espressopp.Real3D(5.0, 2.0, 4.0), 2.0), (6, 1, 0.2, espressopp.Real3D(6.0, 1.0, 4.5), 2.0), ] self.system.storage.addParticles(particle_list, 'id', 'type', 'q', 'pos', 'mass') self.system.storage.decompose()
def setUp(self): # set up system system = espressopp.System() system.rng = espressopp.esutil.RNG() system.bc = espressopp.bc.OrthorhombicBC(system.rng, size) system.skin = skin comm = MPI.COMM_WORLD nodeGrid = Int3D(1, 1, comm.size) cellGrid = Int3D(calcNumberCells(size[0], nodeGrid[0], cutoff), calcNumberCells(size[1], nodeGrid[1], cutoff), calcNumberCells(size[2], nodeGrid[2], cutoff)) system.storage = espressopp.storage.DomainDecomposition( system, nodeGrid, cellGrid) pid = 0 system.storage.addParticle( 0, Real3D(6.1162456968, 3.9088541374, 9.4409851324)) system.storage.addParticle( 1, Real3D(5.9516473019, 4.2535440563, 9.4778266528)) system.storage.addParticle( 2, Real3D(5.8160837525, 4.1043280354, 9.8101428319)) system.storage.addParticle( 3, Real3D(6.0145256344, 4.0133146160, 9.4982604364)) system.storage.decompose() self.system = system
def setUp(self): self.system = espressopp.System() box = (10, 10, 10) self.system.rng = espressopp.esutil.RNG() self.system.bc = espressopp.bc.OrthorhombicBC(self.system.rng, box) nodeGrid = espressopp.tools.decomp.nodeGrid(MPI.COMM_WORLD.size) cellGrid = espressopp.tools.decomp.cellGrid(box, nodeGrid, rc=1.5, skin=0.5) self.system.storage = espressopp.storage.DomainDecomposition( self.system, nodeGrid, cellGrid) particle_list = [(1, 1, espressopp.Real3D(3.0, 5.0, 5.0)), (2, 1, espressopp.Real3D(4.0, 5.0, 5.0)), (3, 0, espressopp.Real3D(5.0, 5.0, 5.0)), (4, 1, espressopp.Real3D(6.0, 5.0, 5.0)), (5, 1, espressopp.Real3D(7.0, 5.0, 5.0)), (6, 0, espressopp.Real3D(8.0, 5.0, 5.0)), (7, 1, espressopp.Real3D(5.0, 3.0, 5.0)), (8, 1, espressopp.Real3D(5.0, 4.0, 5.0)), (9, 1, espressopp.Real3D(5.0, 6.0, 5.0)), (10, 1, espressopp.Real3D(5.0, 7.0, 5.0)), (11, 1, espressopp.Real3D(5.0, 8.0, 5.0)), (12, 0, espressopp.Real3D(5.0, 5.0, 3.0)), (13, 1, espressopp.Real3D(5.0, 5.0, 4.0)), (14, 1, espressopp.Real3D(5.0, 5.0, 6.0)), (15, 0, espressopp.Real3D(5.0, 5.0, 7.0)), (16, 0, espressopp.Real3D(5.0, 5.0, 8.0))] self.system.storage.addParticles(particle_list, 'id', 'type', 'pos') self.system.storage.decompose()
def setUp(self): system = espressopp.System() system.bc = espressopp.bc.OrthorhombicBC(system.rng, (10, 10, 10)) system.rng = espressopp.esutil.RNG(54321) system.skin = 0.3 system.comm = MPI.COMM_WORLD self.system = system system.storage = espressopp.storage.DomainDecomposition(system) particle_lists = [ (1, espressopp.Real3D(0, 1, 2), espressopp.Real3D(0, 0, 0)), (2, espressopp.Real3D(0, 1, 2), espressopp.Real3D(0, 0, 0)), (3, espressopp.Real3D(0, 1, 2), espressopp.Real3D(0, 0, 0)), (4, espressopp.Real3D(0, 1, 2), espressopp.Real3D(0, 0, 0)), (5, espressopp.Real3D(0, 1, 2), espressopp.Real3D(0, 0, 0)) ] self.thermo_group_pids = [1, 2, 3] self.non_thermo_group_pids = [4, 5] system.storage.addParticles(particle_lists, 'id', 'pos', 'v') self.thermo_group = espressopp.ParticleGroup(system.storage) for p in self.thermo_group_pids: self.thermo_group.add(p) self.integrator = espressopp.integrator.VelocityVerlet(system) self.integrator.dt = 0.001
def Default(box, rc=1.12246, skin=0.3, dt=0.005, temperature=None, halfCellInt=1): system = espressopp.System() system.rng = espressopp.esutil.RNG() system.bc = espressopp.bc.OrthorhombicBC(system.rng, box) system.skin = skin nodeGrid = espressopp.tools.decomp.nodeGrid(MPI.COMM_WORLD.size, box, rc, skin) cellGrid = espressopp.tools.decomp.cellGrid(box, nodeGrid, rc, skin, halfCellInt) system.storage = espressopp.storage.DomainDecomposition( system, nodeGrid, cellGrid, halfCellInt) print "nodeGrid: ", nodeGrid, " cellGrid: ", cellGrid, "half cell: ", halfCellInt integrator = espressopp.integrator.VelocityVerlet(system) integrator.dt = dt if (temperature != None): thermostat = espressopp.integrator.LangevinThermostat(system) thermostat.gamma = 1.0 thermostat.temperature = temperature integrator.addExtension(thermostat) return system, integrator
def generate_system(add_particles_array): rc = 2.5 skin = 0.3 timestep = 0.005 temperature = 1.0 comm = MPI.COMM_WORLD particles_per_direction = 64 x, y, z, Lx, Ly, Lz, vx, vy, vz = generate_particles( particles_per_direction) num_particles = len(x) density = num_particles / (Lx * Ly * Lz) size = (Lx, Ly, Lz) system = espressopp.System() system.rng = espressopp.esutil.RNG() system.bc = espressopp.bc.OrthorhombicBC(system.rng, size) system.skin = skin nodeGrid = decomp.nodeGrid(comm.size, size, rc, skin) cellGrid = decomp.cellGrid(size, nodeGrid, rc, skin) system.storage = espressopp.storage.DomainDecomposition( system, nodeGrid, cellGrid) if add_particles_array: tstart = time.time() props = [ 'id', 'type', 'mass', 'posx', 'posy', 'posz', 'vx', 'vy', 'vz' ] ids = np.arange(1, num_particles + 1) types = np.zeros(num_particles) mass = np.ones(num_particles) new_particles = np.stack((ids, types, mass, x, y, z, vx, vy, vz), axis=-1) tprep = time.time() - tstart tstart = time.time() system.storage.addParticlesArray(new_particles, *props) tadd = time.time() - tstart else: tstart = time.time() props = ['id', 'type', 'mass', 'pos', 'v'] new_particles = [] for i in range(num_particles): new_particles.append([ i + 1, 0, 1.0, Real3D(x[i], y[i], z[i]), Real3D(vx[i], vy[i], vz[i]) ]) tprep = time.time() - tstart tstart = time.time() system.storage.addParticles(new_particles, *props) tadd = time.time() - tstart return num_particles, tprep, tadd
def setUp(self): system = espressopp.System() system.bc = espressopp.bc.OrthorhombicBC(system.rng, (10, 10, 10)) system.skin = 0.3 system.comm = MPI.COMM_WORLD system.storage = espressopp.storage.DomainDecomposition(system) self.system = system
def __init__(self, num_chains, chain_len): self._num_chains = num_chains self._chain_len = chain_len self._num_particles = num_chains * chain_len self._density = 0.8449 self._L = pow(self._num_particles / self._density, 1.0 / 3.0) self._box = (self._L, self._L, self._L) self._system = espressopp.System()
def setUp(self): # set up system system = espressopp.System() box = (10, 10, 10) system.bc = espressopp.bc.OrthorhombicBC(system.rng, box) system.skin = 0.3 system.comm = MPI.COMM_WORLD nodeGrid = espressopp.tools.decomp.nodeGrid( espressopp.MPI.COMM_WORLD.size, box, rc=1.5, skin=system.skin) cellGrid = espressopp.tools.decomp.cellGrid(box, nodeGrid, rc=1.5, skin=system.skin) system.storage = espressopp.storage.DomainDecompositionAdress( system, nodeGrid, cellGrid) self.system = system # add some particles particle_list = [ (1, 1, 0, espressopp.Real3D(5.5, 5.0, 5.0), 1.0, 0), (2, 1, 0, espressopp.Real3D(6.5, 5.0, 5.0), 1.0, 0), (3, 1, 0, espressopp.Real3D(7.5, 5.0, 5.0), 1.0, 0), (4, 1, 0, espressopp.Real3D(8.5, 5.0, 5.0), 1.0, 0), (5, 1, 0, espressopp.Real3D(9.5, 5.0, 5.0), 1.0, 0), (6, 0, 1.0, espressopp.Real3D(5.5, 5.0, 5.0), 1.0, 1), (7, 0, 1.0, espressopp.Real3D(6.5, 5.0, 5.0), 1.0, 1), (8, 0, 1.0, espressopp.Real3D(7.5, 5.0, 5.0), 1.0, 1), (9, 0, 1.0, espressopp.Real3D(8.5, 5.0, 5.0), 1.0, 1), (10, 0, 1.0, espressopp.Real3D(9.5, 5.0, 5.0), 1.0, 1), ] tuples = [(1, 6), (2, 7), (3, 8), (4, 9), (5, 10)] self.system.storage.addParticles(particle_list, 'id', 'type', 'q', 'pos', 'mass', 'adrat') self.ftpl = espressopp.FixedTupleListAdress(self.system.storage) self.ftpl.addTuples(tuples) self.system.storage.setFixedTuplesAdress(self.ftpl) self.system.storage.decompose() # set up a verlet list self.vl = espressopp.VerletListAdress(self.system, cutoff=1.5, adrcut=1.5, dEx=2.0, dHy=1.0, adrCenter=[5.0, 5.0, 5.0], sphereAdr=False) # set up integrator self.integrator = espressopp.integrator.VelocityVerletRESPA( self.system) self.integrator.dt = 0.01 self.integrator.multistep = 4 adress = espressopp.integrator.Adress(self.system, self.vl, self.ftpl, multistep=4) self.integrator.addExtension(adress)
def setUp(self): # set up system system = espressopp.System() rng = espressopp.esutil.RNG() rng.seed(1) system.rng = rng system.bc = espressopp.bc.OrthorhombicBC(system.rng, box) system.skin = 0.3 system.comm = MPI.COMM_WORLD self.system = system
def test0get(self): system = espressopp.System() system.rng = espressopp.esutil.RNG() system.bc = espressopp.bc.OrthorhombicBC(system.rng, (10.0, 10.0, 10.0)) system.storage = espressopp.storage.DomainDecomposition( system=system, nodeGrid=(1,1,1), cellGrid=(2,2,2)) p = system.storage.addParticle(0, (1.0, 1.0, 1.0)) p.v = espressopp.Real3D(1.0, 1.0, 1.0) self.assertAlmostEqualReal3D(p.v, espressopp.Real3D(1.0, 1.0, 1.0))
def setUp(self): # set up system system = espressopp.System() box = (10, 10, 10) system.bc = espressopp.bc.OrthorhombicBC(system.rng, box) system.skin = 0.3 system.comm = MPI.COMM_WORLD nodeGrid = espressopp.tools.decomp.nodeGrid(espressopp.MPI.COMM_WORLD.size) cellGrid = espressopp.tools.decomp.cellGrid(box, nodeGrid, 1.5, 0.3) system.storage = espressopp.storage.DomainDecompositionAdress(system, nodeGrid, cellGrid) self.system = system
def setUp(self): self.system = espressopp.System() box = (10, 10, 10) self.system.rng = espressopp.esutil.RNG() self.system.bc = espressopp.bc.OrthorhombicBC(self.system.rng, box) nodeGrid = espressopp.tools.decomp.nodeGrid(MPI.COMM_WORLD.size) cellGrid = espressopp.tools.decomp.cellGrid(box, nodeGrid, rc=1.5, skin=0.5) self.system.storage = espressopp.storage.DomainDecompositionAdress( self.system, nodeGrid, cellGrid) particle_list = [(1, 1, espressopp.Real3D(3.0, 5.0, 5.0), 0, 0), (2, 1, espressopp.Real3D(3.0, 4.9, 5.0), 1, 1), (3, 1, espressopp.Real3D(3.0, 5.0, 4.9), 1, 2), (4, 1, espressopp.Real3D(3.0, 5.1, 5.0), 1, 3), (5, 1, espressopp.Real3D(3.0, 5.0, 5.1), 1, 4), (6, 1, espressopp.Real3D(6.0, 5.0, 5.0), 0, 0), (7, 1, espressopp.Real3D(6.0, 4.8, 5.0), 1, 1), (8, 1, espressopp.Real3D(6.0, 5.0, 4.8), 1, 2), (9, 1, espressopp.Real3D(6.0, 5.2, 5.0), 1, 3), (10, 1, espressopp.Real3D(6.0, 5.0, 5.2), 1, 4), (11, 1, espressopp.Real3D(7.0, 5.0, 5.0), 0, 0), (12, 1, espressopp.Real3D(7.0, 4.8, 5.0), 1, 1), (13, 1, espressopp.Real3D(7.0, 5.0, 4.8), 1, 2), (14, 1, espressopp.Real3D(7.0, 5.2, 5.0), 1, 3), (15, 1, espressopp.Real3D(7.0, 5.0, 5.2), 1, 4), (16, 0, espressopp.Real3D(9.0, 5.0, 5.0), 0, 0), (17, 0, espressopp.Real3D(9.0, 4.8, 5.0), 1, 1), (18, 0, espressopp.Real3D(9.0, 5.0, 4.8), 1, 2), (19, 0, espressopp.Real3D(9.0, 5.2, 5.0), 1, 3), (20, 0, espressopp.Real3D(9.0, 5.0, 5.2), 1, 4)] tuples = [(1, 2, 3, 4, 5), (6, 7, 8, 9, 10), (11, 12, 13, 14, 15), (16, 17, 18, 19, 20)] self.system.storage.addParticles(particle_list, 'id', 'type', 'pos', 'adrat', 'pib') ftpl = espressopp.FixedTupleListAdress(self.system.storage) ftpl.addTuples(tuples) self.system.storage.setFixedTuplesAdress(ftpl) vl = espressopp.VerletListAdress(self.system, cutoff=1.5, adrcut=1.5, dEx=2.0, dHy=1.0, adrCenter=[5.0, 5.0, 5.0], sphereAdr=False) integrator = espressopp.integrator.PIAdressIntegrator( system=self.system, verletlist=vl, nTrotter=4) espressopp.tools.AdressDecomp(self.system, integrator)
def setUp(self): # Initialize the espressopp system box = (10, 10, 10) system = espressopp.System() self.system = system system.kb = 1.0 system.rng = espressopp.esutil.RNG() system.bc = espressopp.bc.OrthorhombicBC(system.rng, box) system.skin = 0.3 nodeGrid = espressopp.tools.decomp.nodeGrid(MPI.COMM_WORLD.size) cellGrid = espressopp.tools.decomp.cellGrid(box, nodeGrid, 2.5, system.skin) system.storage = espressopp.storage.DomainDecomposition( system, nodeGrid, cellGrid) # Adding ten nodes self.N = 8 particle_list = [] for pid in range(1, self.N + 1): pos = system.bc.getRandomPos() particle_list.append((pid, pos, 1 if pid < 5 else 2)) system.storage.addParticles(particle_list, 'id', 'pos', 'res_id') system.storage.decompose() self.integrator = espressopp.integrator.VelocityVerlet(system) self.integrator.dt = 0.0025 self.fpl1 = espressopp.FixedPairList(system.storage) self.fpl1.addBonds([(1, 2), (2, 3), (2, 4)]) self.fpl2 = espressopp.FixedPairList(system.storage) self.fpl2.addBonds([(5, 6), (6, 7), (6, 8)]) self.fpl3 = espressopp.FixedPairList(system.storage) self.ftl = espressopp.FixedTripleList(system.storage) self.ftl.addTriples([(1, 2, 3), (1, 2, 4), (5, 6, 7), (5, 6, 8)]) self.fql = espressopp.FixedQuadrupleList(system.storage) self.fql2 = espressopp.FixedQuadrupleList(system.storage) topology_manager = espressopp.integrator.TopologyManager(system) self.topology_manager = topology_manager topology_manager.observe_tuple(self.fpl1) topology_manager.observe_tuple(self.fpl2) topology_manager.observe_tuple(self.fpl3) topology_manager.register_triplet(self.ftl, 0) topology_manager.register_quadruplet(self.fql, 0) topology_manager.register_quadruplet(self.fql2, 0, 0, 0, 1) topology_manager.register_tuple(self.fpl3, 0, 0) topology_manager.initialize_topology() self.integrator.addExtension(topology_manager)
def setUp(self): # set up system self.system = espressopp.System() box = (10, 10, 10) self.system.bc = espressopp.bc.OrthorhombicBC(self.system.rng, box) self.system.rng = espressopp.esutil.RNG() self.system.skin = 0.5 nodeGrid = espressopp.tools.decomp.nodeGrid( espressopp.MPI.COMM_WORLD.size, box, rc=1.5, skin=self.system.skin) cellGrid = espressopp.tools.decomp.cellGrid(box, nodeGrid, rc=1.5, skin=self.system.skin) self.system.storage = espressopp.storage.DomainDecompositionAdress( self.system, nodeGrid, cellGrid)
def setUp(self): system = espressopp.System() box = (10, 10, 10) self.box = box cutoff = 2.0 skin = 1.0 system.bc = espressopp.bc.OrthorhombicBC(system.rng, box) system.skin = skin system.comm = MPI.COMM_WORLD nodeGrid = espressopp.tools.decomp.nodeGrid( espressopp.MPI.COMM_WORLD.size, box, cutoff, skin) cellGrid = espressopp.tools.decomp.cellGrid(box, nodeGrid, cutoff, skin) system.storage = espressopp.storage.DomainDecomposition( system, nodeGrid, cellGrid) self.system = system
def generate_system(): rc = 2.5 skin = 0.3 timestep = 0.005 temperature = 1.0 comm = MPI.COMM_WORLD density = num_particles / (Lx * Ly * Lz) size = (Lx, Ly, Lz) system = espressopp.System() system.rng = espressopp.esutil.RNG() system.bc = espressopp.bc.OrthorhombicBC(system.rng, size) system.skin = skin nodeGrid = decomp.nodeGrid(comm.size, size, rc, skin) cellGrid = decomp.cellGrid(size, nodeGrid, rc, skin) system.storage = espressopp.storage.DomainDecomposition(system, nodeGrid, cellGrid) return system
def create_system(self): box = (10, 10, 10) system = espressopp.System() system.kb = 1.0 system.rng = espressopp.esutil.RNG(12345) system.bc = espressopp.bc.OrthorhombicBC(system.rng, box) system.skin = 0.3 nodeGrid = espressopp.tools.decomp.nodeGrid(MPI.COMM_WORLD.size) cellGrid = espressopp.tools.decomp.cellGrid(box, nodeGrid, 2.5, system.skin) system.storage = espressopp.storage.DomainDecomposition( system, nodeGrid, cellGrid) integrator = espressopp.integrator.VelocityVerlet(system) integrator.dt = 0.0025 return system, integrator
def setUp(self): system = espressopp.System() box = (10, 10, 10) system.bc = espressopp.bc.OrthorhombicBC(system.rng, box) system.skin = 0.3 system.comm = MPI.COMM_WORLD nodeGrid = espressopp.tools.decomp.nodeGrid(espressopp.MPI.COMM_WORLD.size,box,rc=1.5,skin=system.skin) cellGrid = espressopp.tools.decomp.cellGrid(box, nodeGrid,rc= 1.5, skin=system.skin) system.storage = espressopp.storage.DomainDecomposition(system, nodeGrid, cellGrid) self.system = system #add particles particle_list = [ (1, 1, 0.178, espressopp.Real3D(2.0, 3.0, 4.0), 1.008), (2, 2, -0.513, espressopp.Real3D(2.0, 3.0, 4.0), 41.54), ] self.system.storage.addParticles(particle_list, 'id', 'type', 'q', 'pos', 'mass') self.system.storage.decompose()
def setUp(self): # Initialize the espressopp system box = (10, 10, 10) system = espressopp.System() self.system = system system.kb = 1.0 system.rng = espressopp.esutil.RNG() system.bc = espressopp.bc.OrthorhombicBC(system.rng, box) system.skin = 0.3 nodeGrid = espressopp.tools.decomp.nodeGrid(MPI.COMM_WORLD.size) cellGrid = espressopp.tools.decomp.cellGrid(box, nodeGrid, 2.5, system.skin) system.storage = espressopp.storage.DomainDecomposition( system, nodeGrid, cellGrid) # Adding ten nodes self.N = 6 particle_prop = ['id', 'pos', 'type', 'res_id', 'mass', 'state'] particle_list = [[1, None, 1, 1, 1.0, 2], [2, None, 1, 1, 1.0, 2], [3, None, 3, 1, 1.0, 3], [4, None, 2, 1, 1.0, 9], [5, None, 4, 1, 1.0, 8], [6, None, 3, 1, 1.0, 7]] for pid in range(0, self.N): pos = system.bc.getRandomPos() particle_list[pid][1] = pos system.storage.addParticles(particle_list, *particle_prop) system.storage.decompose() self.integrator = espressopp.integrator.VelocityVerlet(system) self.integrator.dt = 0.0025 bonds = [(1, 2), (1, 5), (1, 6), (2, 3), (2, 4)] self.fpl1 = espressopp.FixedPairList(system.storage) self.fpl1.addBonds(bonds) self.fpl3 = espressopp.FixedPairList(system.storage) topology_manager = espressopp.integrator.TopologyManager(system) self.topology_manager = topology_manager topology_manager.observe_tuple(self.fpl1) topology_manager.observe_tuple(self.fpl3) topology_manager.register_tuple(self.fpl3, 0, 0) topology_manager.initialize_topology() self.integrator.addExtension(topology_manager)
def Minimal(num_particles, box, rc=1.12246, skin=0.3, dt=0.005, temperature=None): system = espressopp.System() system.rng = espressopp.esutil.RNG() system.bc = espressopp.bc.OrthorhombicBC(system.rng, box) system.skin = skin nodeGrid = espressopp.tools.decomp.nodeGrid(MPI.COMM_WORLD.size) cellGrid = espressopp.tools.decomp.cellGrid(box, nodeGrid, rc, skin) system.storage = espressopp.storage.DomainDecomposition( system, nodeGrid, cellGrid) integrator = espressopp.integrator.VelocityVerlet(system) integrator.dt = dt if (temperature != None): thermostat = espressopp.integrator.LangevinThermostat(system) thermostat.gamma = 1.0 thermostat.temperature = temperature integrator.addExtension(thermostat) props = ['id', 'type', 'mass', 'pos', 'v'] new_particles = [] pid = 1 while pid <= num_particles: type = 0 mass = 1.0 pos = system.bc.getRandomPos() vel = espressopp.Real3D(0.0, 0.0, 0.0) part = [pid, type, mass, pos, vel] new_particles.append(part) if pid % 1000 == 0: system.storage.addParticles(new_particles, *props) system.storage.decompose() new_particles = [] pid += 1 system.storage.addParticles(new_particles, *props) system.storage.decompose() return system, integrator
def setUp(self): # set up system system = espressopp.System() box = (10, 10, 10) system.bc = espressopp.bc.OrthorhombicBC(system.rng, box) system.skin = 0.3 system.comm = MPI.COMM_WORLD nodeGrid = espressopp.tools.decomp.nodeGrid(espressopp.MPI.COMM_WORLD.size) cellGrid = espressopp.tools.decomp.cellGrid(box, nodeGrid, 1.5, 0.3) system.storage = espressopp.storage.DomainDecompositionAdress(system, nodeGrid, cellGrid) self.system = system # add some particles particle_list = [ (1, 1, 0, espressopp.Real3D(5.0, 5.0, 5.0), 1.0, 0), (2, 1, 0, espressopp.Real3D(6.0, 5.0, 5.0), 1.0, 0), (3, 1, 0, espressopp.Real3D(6.5, 5.0, 5.0), 1.0, 0), (4, 1, 0, espressopp.Real3D(6.5, 5.5, 5.0), 1.0, 0), (5, 0, 0, espressopp.Real3D(5.0, 5.0, 5.0), 1.0, 1), (6, 0, 0, espressopp.Real3D(6.0, 5.0, 5.0), 1.0, 1), (7, 0, 0, espressopp.Real3D(6.5, 5.0, 5.0), 1.0, 1), (8, 0, 0, espressopp.Real3D(6.5, 5.5, 5.0), 1.0, 1), ] tuples = [(1,5),(2,6),(3,7),(4,8)] self.system.storage.addParticles(particle_list, 'id', 'type', 'q', 'pos', 'mass','adrat') ftpl = espressopp.FixedTupleListAdress(self.system.storage) ftpl.addTuples(tuples) self.system.storage.setFixedTuplesAdress(ftpl) self.system.storage.decompose() # generate a verlet list vl = espressopp.VerletListAdress(self.system, cutoff=1.5, adrcut=1.5, dEx=2.0, dHy=1.0, adrCenter=[5.0, 5.0, 5.0], sphereAdr=False) # initialize lambda values integrator = espressopp.integrator.VelocityVerlet(self.system) adress = espressopp.integrator.Adress(self.system,vl,ftpl) integrator.addExtension(adress) espressopp.tools.AdressDecomp(self.system, integrator)
def setUp(self): box = (10, 10, 10) system = espressopp.System() system.kb = 1.0 system.rng = espressopp.esutil.RNG() system.bc = espressopp.bc.OrthorhombicBC(system.rng, box) system.skin = 0.3 self.system = system nodeGrid = espressopp.tools.decomp.nodeGrid(MPI.COMM_WORLD.size) cellGrid = espressopp.tools.decomp.cellGrid(box, nodeGrid, 2.5, system.skin) system.storage = espressopp.storage.DomainDecomposition( system, nodeGrid, cellGrid) self.integrator = espressopp.integrator.VelocityVerlet(system) self.integrator.dt = 0.0025 vl = espressopp.VerletList(system, cutoff=1.0) self.part_prop = ('id', 'type', 'pos', 'res_id', 'state') particle_list = [(1, 1, espressopp.Real3D(2.0, 2.0, 2.0), 1, 1), (2, 2, espressopp.Real3D(2.5, 2.0, 2.0), 2, 1), (3, 2, espressopp.Real3D(2.5, 2.0, 2.0), 2, 2), (4, 4, espressopp.Real3D(2.5, 2.0, 2.0), 2, 1)] system.storage.addParticles(particle_list, *self.part_prop) self.fpl1 = espressopp.FixedPairList(system.storage) topology_manager = espressopp.integrator.TopologyManager(system) topology_manager = topology_manager topology_manager.observe_tuple(self.fpl1) topology_manager.initialize_topology() self.topology_manager = topology_manager self.integrator.addExtension(topology_manager) self.ar = espressopp.integrator.ChemicalReaction( system, vl, system.storage, topology_manager, 1) self.integrator.addExtension(self.ar)
def setUp(self) : system = espressopp.System() rng = espressopp.esutil.RNG() N = 4 SIZE = float(N) box = Real3D(SIZE) bc = espressopp.bc.OrthorhombicBC(None, box) system.bc = bc # a small skin avoids rounding problems system.skin = 0.001 cutoff = SIZE/2. - system.skin comm = espressopp.MPI.COMM_WORLD nodeGrid = espressopp.tools.decomp.nodeGrid(espressopp.MPI.COMM_WORLD.size,box,cutoff,system.skin) cellGrid = espressopp.tools.decomp.cellGrid(box, nodeGrid, cutoff, system.skin) print 'NodeGrid = %s'%(nodeGrid,) print 'CellGrid = %s'%cellGrid system.storage = espressopp.storage.DomainDecomposition(system, nodeGrid, cellGrid) pid = 0 for i in xrange(N): for j in xrange(N): for k in xrange(N): r = 0.5 x = (i + r) / N * SIZE y = (j + r) / N * SIZE z = (k + r) / N * SIZE system.storage.addParticle(pid, Real3D(x, y, z)) pid = pid + 1 for i in xrange(N): for j in xrange(N): for k in xrange(N): r = 0.25 x = (i + r) / N * SIZE y = (j + r) / N * SIZE z = (k + r) / N * SIZE system.storage.addParticle(pid, Real3D(x, y, z)) pid = pid + 1 system.storage.decompose() # now build Fixed Local Tuple List tuplelist = espressopp.FixedLocalTupleList(system.storage) self.system = system self.N = N self.tuplelist = tuplelist
def setUp(self): # globals global Ni, temperature # constants rc = pow(2, 1. / 6.) skin = 0.3 epsilon = 1. # system set up system = espressopp.System() system.rng = espressopp.esutil.RNG() global Npart if (os.path.isfile(mdoutput)): pid, ptype, x, y, z, vx, vy, vz, Lx, Ly, Lz = espressopp.tools.readxyz( mdoutput) Npart = len(pid) sigma = 1. timestep = 0.005 box = (Lx, Ly, Lz) else: sigma = 0. timestep = 0.001 box = (Ni, Ni, Ni) system.bc = espressopp.bc.OrthorhombicBC(system.rng, box) system.skin = skin nodeGrid = espressopp.tools.decomp.nodeGrid( espressopp.MPI.COMM_WORLD.size) cellGrid = espressopp.tools.decomp.cellGrid(box, nodeGrid, rc, skin) system.storage = espressopp.storage.DomainDecomposition( system, nodeGrid, cellGrid) # interaction interaction = espressopp.interaction.VerletListLennardJones( espressopp.VerletList(system, cutoff=rc)) potLJ = espressopp.interaction.LennardJones(epsilon, sigma, rc) interaction.setPotential(type1=0, type2=0, potential=potLJ) system.addInteraction(interaction) # integrator integrator = espressopp.integrator.VelocityVerlet(system) integrator.dt = timestep # thermostat thermostat = espressopp.integrator.LangevinThermostat(system) thermostat.gamma = 1.0 thermostat.temperature = temperature integrator.addExtension(thermostat) if (os.path.isfile(mdoutput)): props = ['id', 'type', 'mass', 'pos', 'v'] new_particles = [] for pid in range(Npart): part = [ pid + 1, 0, 1.0, Real3D(x[pid], y[pid], z[pid]), Real3D(vx[pid], vy[pid], vz[pid]) ] new_particles.append(part) system.storage.addParticles(new_particles, *props) system.storage.decompose() else: # make dense system particle_list = [] mass = 1. for k in range(Npart): pid = k + 1 pos = system.bc.getRandomPos() v = Real3D(0.) ptype = 0 part = [pid, ptype, mass, pos, v] particle_list.append(part) system.storage.addParticles(particle_list, 'id', 'type', 'mass', 'pos', 'v') system.storage.decompose() print "Warm up. Sigma will be increased from 0. to 1." new_sigma = sigma for k in range(50): integrator.run(100) new_sigma += 0.02 if (new_sigma > 0.8): integrator.dt = 0.005 potLJ = espressopp.interaction.LennardJones( epsilon, new_sigma, rc) interaction.setPotential(type1=0, type2=0, potential=potLJ) espressopp.tools.fastwritexyz(mdoutput, system) # LB will control thermostatting now thermostat.disconnect() integrator.step = 0 # set up LB fluid lb = espressopp.integrator.LatticeBoltzmann(system, nodeGrid) integrator.addExtension(lb) # set initial populations global initDen, initVel initPop = espressopp.integrator.LBInitPopUniform(system, lb) initPop.createDenVel(initDen, Real3D(initVel)) # set up LB profiler global runSteps lb.profStep = int(.5 * runSteps) lboutputScreen = espressopp.analysis.LBOutputScreen(system, lb) ext_lboutputScreen = espressopp.integrator.ExtAnalyze( lboutputScreen, lb.profStep) integrator.addExtension(ext_lboutputScreen) # lb parameters: viscosities, temperature, time contrast b/w MD and LB lb.visc_b = 3. lb.visc_s = 3. lb.lbTemp = temperature lb.nSteps = 5 # set self self.system = system self.lb = lb self.integrator = integrator self.lboutput = lboutputScreen
cellGrid = espressopp.tools.decomp.cellGrid(box, nodeGrid, rspacecutoff, skin) print '' print 'density = %.4f' % (rho) print 'NodeGrid = %s' % (nodeGrid, ) print 'CellGrid = %s' % (cellGrid, ) print '' ''' Below two systems for Ewald summation and PPPM methods will be created. ''' ####################################################################################### # system for Ewald ####################################################################################### systemEwald = espressopp.System() systemEwald.rng = espressopp.esutil.RNG() systemEwald.bc = espressopp.bc.OrthorhombicBC(systemEwald.rng, box) systemEwald.skin = skin systemEwald.storage = espressopp.storage.DomainDecomposition( systemEwald, nodeGrid, cellGrid) ####################################################################################### # system for PPPM ####################################################################################### systemPPPM = espressopp.System() systemPPPM.rng = espressopp.esutil.RNG() systemPPPM.bc = espressopp.bc.OrthorhombicBC(systemPPPM.rng, box) systemPPPM.skin = skin systemPPPM.storage = espressopp.storage.DomainDecomposition(
def PolymerMelt(num_chains, monomers_per_chain, box=(0, 0, 0), bondlen=0.97, rc=1.12246, skin=0.3, dt=0.005, epsilon=1.0, sigma=1.0, shift='auto', temperature=None, xyzfilename=None, xyzrfilename=None): if xyzfilename and xyzrfilename: print "ERROR: only one of xyzfilename (only xyz data) or xyzrfilename (additional particle radius data) can be provided." sys.exit(1) if xyzrfilename: pidf, typef, xposf, yposf, zposf, xvelf, yvelf, zvelf, Lxf, Lyf, Lzf, radiusf = espressopp.tools.readxyzr( xyzrfilename) box = (Lxf, Lyf, Lzf) elif xyzfilename: pidf, typef, xposf, yposf, zposf, xvelf, yvelf, zvelf, Lxf, Lyf, Lzf = espressopp.tools.readxyz( xyzfilename) box = (Lxf, Lyf, Lzf) else: if box[0] <= 0 or box[1] <= 0 or box[2] <= 0: print "WARNING: no valid box size specified, box size set to (100,100,100) !" box = (100, 100, 100) system = espressopp.System() system.rng = espressopp.esutil.RNG() system.bc = espressopp.bc.OrthorhombicBC(system.rng, box) system.skin = skin nodeGrid = espressopp.tools.decomp.nodeGrid(MPI.COMM_WORLD.size, box, rc, skin) cellGrid = espressopp.tools.decomp.cellGrid(box, nodeGrid, rc, skin) system.storage = espressopp.storage.DomainDecomposition( system, nodeGrid, cellGrid) interaction = espressopp.interaction.VerletListLennardJones( espressopp.VerletList(system, cutoff=rc)) interaction.setPotential(type1=0, type2=0, potential=espressopp.interaction.LennardJones( epsilon, sigma, rc, shift)) system.addInteraction(interaction) integrator = espressopp.integrator.VelocityVerlet(system) integrator.dt = dt if (temperature != None): thermostat = espressopp.integrator.LangevinThermostat(system) thermostat.gamma = 1.0 thermostat.temperature = temperature integrator.addExtension(thermostat) mass = 1.0 if xyzrfilename: props = ['id', 'type', 'mass', 'pos', 'v', 'radius'] bondlist = espressopp.FixedPairList(system.storage) for i in xrange(num_chains): chain = [] bonds = [] for k in xrange(monomers_per_chain): idx = i * monomers_per_chain + k part = [ pidf[idx], typef[idx], mass, espressopp.Real3D(xposf[idx], yposf[idx], zposf[idx]), espressopp.Real3D(xvelf[idx], yvelf[idx], zvelf[idx]), radiusf[idx] ] chain.append(part) if k > 0: bonds.append((pidf[idx - 1], pidf[idx])) system.storage.addParticles(chain, *props) system.storage.decompose() bondlist.addBonds(bonds) elif xyzfilename: props = ['id', 'type', 'mass', 'pos', 'v'] bondlist = espressopp.FixedPairList(system.storage) for i in xrange(num_chains): chain = [] bonds = [] for k in xrange(monomers_per_chain): idx = i * monomers_per_chain + k part = [ pidf[idx], typef[idx], mass, espressopp.Real3D(xposf[idx], yposf[idx], zposf[idx]), espressopp.Real3D(xvelf[idx], yvelf[idx], zvelf[idx]) ] chain.append(part) if k > 0: bonds.append((pidf[idx - 1], pidf[idx])) system.storage.addParticles(chain, *props) system.storage.decompose() bondlist.addBonds(bonds) else: props = ['id', 'type', 'mass', 'pos', 'v'] vel_zero = espressopp.Real3D(0.0, 0.0, 0.0) bondlist = espressopp.FixedPairList(system.storage) pid = 1 type = 0 chain = [] for i in xrange(num_chains): startpos = system.bc.getRandomPos() positions, bonds = espressopp.tools.topology.polymerRW( pid, startpos, monomers_per_chain, bondlen) for k in xrange(monomers_per_chain): part = [pid + k, type, mass, positions[k], vel_zero] chain.append(part) pid += monomers_per_chain type += 1 system.storage.addParticles(chain, *props) system.storage.decompose() chain = [] bondlist.addBonds(bonds) system.storage.decompose() # FENE bonds potFENE = espressopp.interaction.FENE(K=30.0, r0=0.0, rMax=1.5) interFENE = espressopp.interaction.FixedPairListFENE( system, bondlist, potFENE) system.addInteraction(interFENE) return system, integrator class KGMelt: def __init__(self, num_chains, chain_len): self._num_chains = num_chains self._chain_len = chain_len self._num_particles = num_chains * chain_len self._density = 0.8449 self._L = pow(self._num_particles / self._density, 1.0 / 3.0) self._box = (L, L, L) self._system = espress.System()
def setUp(self): # set up system system = espressopp.System() system.rng = espressopp.esutil.RNG() system.bc = espressopp.bc.OrthorhombicBC(system.rng, size) system.skin = skin comm = MPI.COMM_WORLD nodeGrid = Int3D(1, 1, comm.size) cellGrid = Int3D(calcNumberCells(size[0], nodeGrid[0], cutoff), calcNumberCells(size[1], nodeGrid[1], cutoff), calcNumberCells(size[2], nodeGrid[2], cutoff)) system.storage = espressopp.storage.DomainDecomposition( system, nodeGrid, cellGrid) pid = 0 system.storage.addParticle(0, Real3D(0.15, 0.1, 0)) system.storage.addParticle(1, Real3D(0.4, 0.1, 0)) system.storage.decompose() # integrator integrator = espressopp.integrator.VelocityVerlet(system) integrator.dt = 0.001 # now build Verlet List # ATTENTION: you must not add the skin explicitly here logging.getLogger("Interpolation").setLevel(logging.INFO) vl = espressopp.VerletList(system, cutoff=cutoff) scaling_cv = 1.5 alpha = 0.1 # ATTENTION: auto shift was enabled # bonds writeTabFile(tabBonds[0], k=100000, x0=0.26, N=500, low=0.01, high=0.6) writeTabFile(tabBonds[1], k=50000, x0=0.24, N=500, low=0.01, high=0.6) fpl = espressopp.FixedPairList(system.storage) fpl.addBonds([(0, 1)]) potBond = espressopp.interaction.TabulatedSubEns() potBond.addInteraction( 1, tabBonds[0], espressopp.RealND([0.262, 0., 0., scaling_cv * 0.424, 0., 0.])) potBond.addInteraction(1, tabBonds[1], espressopp.RealND([0., 0., 0., 0., 0., 0.])) potBond.alpha_set(alpha) cv_bl = espressopp.FixedPairList(system.storage) cv_bl.addBonds([]) potBond.colVarBondList = cv_bl cv_al = espressopp.FixedTripleList(system.storage) cv_al.addTriples([]) potBond.colVarAngleList = cv_al # Renormalize the CVs potBond.colVarSd_set(0, 0.0119) # Target probabilities potBond.targetProb_set(0, tgt_probs[0]) potBond.targetProb_set(1, tgt_probs[1]) interBond = espressopp.interaction.FixedPairListTabulatedSubEns( system, fpl, potBond) system.addInteraction(interBond) temp = espressopp.analysis.Temperature(system) temperature = temp.compute() Ek = 0.5 * temperature * (2 * numParticles) Ep = interBond.computeEnergy() # langevin thermostat langevin = espressopp.integrator.LangevinThermostat(system) integrator.addExtension(langevin) langevin.gamma = 1.0 langevin.temperature = 2.479 # in kJ/mol # sock = espressopp.tools.vmd.connect(system) configurations = espressopp.analysis.Configurations(system) self.configuration = configurations self.system = system self.temp = temp self.integrator = integrator self.interBond = interBond self.potBond = potBond
ptrng.seed(335977) if espressopp.MPI.COMM_WORLD.size != 4: print "currently this example can only be run with 4 CPUs" sys.exit(0) # Parallel Tempering (replica exchange) integrator ptthermostats=[] pt = espressopp.ParallelTempering(NumberOfSystems = 4, RNG = ptrng) for i in range(0, pt.getNumberOfSystems()): pt.startDefiningSystem(i) pid, type, x, y, z, vx, vy, vz, Lx, Ly, Lz = espressopp.tools.readxyz('parallel_tempering.xyz') num_particles = len(pid) boxsize = (Lx, Ly, Lz) rho = num_particles / (Lx * Ly * Lz) system = espressopp.System() rng = espressopp.esutil.RNG() bc = espressopp.bc.OrthorhombicBC(rng, boxsize) system.bc = bc system.rng = rng system.skin = skin nodeGrid = espressopp.tools.decomp.nodeGrid(pt.getNumberOfCPUsPerSystem()) cellGrid = espressopp.tools.decomp.cellGrid(boxsize,nodeGrid,rc,skin) storage = espressopp.storage.DomainDecomposition(system, nodeGrid, cellGrid, nocheck=True) system.storage = storage vl = espressopp.VerletList(system,cutoff=rc) potLJ = espressopp.interaction.LennardJones(epsilon, sigma, rc, shift) interLJ = espressopp.interaction.VerletListLennardJones(vl) integrator = espressopp.integrator.VelocityVerlet(system) integrator.dt = dt langevin = espressopp.integrator.LangevinThermostat(system)
def PolymerMelt(num_chains, nsolvents, monomers_per_chain, box=(0, 0, 0), bondlen=0.97, rc=1.12246, skin=0.3, dt=0.005, epsilon=1.0, sigma=1.0, shift='auto', temperature=None, xyzfilename=None, monomer_type=0, solvent_type=1): if xyzfilename: pidf, typef, xposf, yposf, zposf, xvelf, yvelf, zvelf, Lxf, Lyf, Lzf = espressopp.tools.readxyz( xyzfilename) box = (Lxf, Lyf, Lzf) else: if box[0] <= 0 or box[1] <= 0 or box[2] <= 0: print "WARNING: no valid box size specified, box size set to (100,100,100) !" box = (100, 100, 100) system = espressopp.System() system.rng = espressopp.esutil.RNG() system.bc = espressopp.bc.OrthorhombicBC(system.rng, box) system.skin = skin nodeGrid = espressopp.tools.decomp.nodeGrid(MPI.COMM_WORLD.size) cellGrid = espressopp.tools.decomp.cellGrid(box, nodeGrid, rc, skin) system.storage = espressopp.storage.DomainDecomposition( system, nodeGrid, cellGrid) # LJ interaction vl = espressopp.VerletList(system, cutoff=rc) interaction = espressopp.interaction.VerletListLennardJones(vl) interaction.setPotential( type1=monomer_type, type2=monomer_type, potential=espressopp.interaction.LennardJones(epsilon, sigma, rc, shift)) interaction.setPotential( type1=solvent_type, type2=solvent_type, potential=espressopp.interaction.LennardJones(epsilon, sigma, rc, shift)) interaction.setPotential( type1=monomer_type, type2=solvent_type, potential=espressopp.interaction.LennardJones(epsilon, sigma, rc, shift)) system.addInteraction(interaction, 'lj') integrator = espressopp.integrator.VelocityVerlet(system) integrator.dt = dt if (temperature != None): thermostat = espressopp.integrator.LangevinThermostat(system) thermostat.gamma = 1.0 thermostat.temperature = temperature integrator.addExtension(thermostat) mass = 1.0 if xyzfilename: props = ['id', 'type', 'mass', 'pos', 'v'] bondlist = espressopp.FixedPairList(system.storage) particles = [] bonds = [] for i in xrange(num_chains): for k in xrange(monomers_per_chain): idx = i * monomers_per_chain + k part = [pidf[idx], typef[idx], mass, espressopp.Real3D(xposf[idx], yposf[idx], zposf[idx]), espressopp.Real3D(xvelf[idx], yvelf[idx], zvelf[idx])] particles.append(part) if k > 0: bonds.append((pidf[idx - 1], pidf[idx])) # Read solvent for i in xrange(0, nsolvents): idx = num_chains * monomers_per_chain + i part = [pidf[idx], typef[idx], mass, espressopp.Real3D(xposf[idx], yposf[idx], zposf[idx]), espressopp.Real3D(xvelf[idx], yvelf[idx], zvelf[idx])] particles.append(part) system.storage.addParticles(particles, *props) system.storage.decompose() vl.exclude(bonds) bondlist.addBonds(bonds) else: props = ['id', 'type', 'mass', 'pos', 'v'] vel_zero = espressopp.Real3D(0.0, 0.0, 0.0) bondlist = espressopp.FixedPairList(system.storage) pid = 1 particles = [] bonds = [] for i in xrange(num_chains): startpos = system.bc.getRandomPos() positions, b = espressopp.tools.topology.polymerRW( pid, startpos, monomers_per_chain, 1.2) for k in xrange(monomers_per_chain): part = [pid + k, monomer_type, mass, positions[k], vel_zero] particles.append(part) pid += monomers_per_chain bonds.extend(b) for i in xrange(1, nsolvents + 1): startpos = system.bc.getRandomPos() particles.append([pid, solvent_type, mass, startpos, vel_zero]) pid += 1 system.storage.addParticles(particles, *props) system.storage.decompose() vl.exclude(bonds) bondlist.addBonds(bonds) # FENE bonds potFENE=espressopp.interaction.FENELennardJones(K=30.0, r0=0.0, rMax=1.5) interFENE=espressopp.interaction.FixedPairListFENELennardJones( system, bondlist, potFENE) system.addInteraction(interFENE, 'fene') return system, integrator, vl