def setUp(self): system, integrator = espressopp.standard_system.LennardJones( 0, (20, 20, 20)) self.system = system self.integrator = integrator self.ftpl = espressopp.FixedTupleListAdress(self.system.storage) self.system.storage.setFixedTuplesAdress(self.ftpl)
def test_AdResS(self): # set up AdResS domain decomposition nodeGrid = espressopp.tools.decomp.nodeGrid(espressopp.MPI.COMM_WORLD.size) cellGrid = espressopp.tools.decomp.cellGrid((10, 10, 10), nodeGrid, 1.5, 0.3) self.system.storage = espressopp.storage.DomainDecompositionAdress(self.system, nodeGrid, cellGrid) # add some particles (atomistic and coarse-grained particles now) 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, 0, 0, espressopp.Real3D(5.5, 5.0, 5.0), 1.0, 1), (5, 0, 0, espressopp.Real3D(6.5, 5.0, 5.0), 1.0, 1), (6, 0, 0, espressopp.Real3D(7.5, 5.0, 5.0), 1.0, 1), ] tuples = [(1,4),(2,5),(3,6)] 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=1.0, dHy=1.0, adrCenter=[5.0, 5.0, 5.0], sphereAdr=False) # integrator including AdResS integrator = espressopp.integrator.VelocityVerlet(self.system) integrator.dt = 0.01 adress = espressopp.integrator.Adress(self.system, vl, ftpl) integrator.addExtension(adress) # Langevin Thermostat langevin = espressopp.integrator.LangevinThermostat(self.system) langevin.gamma = 1.0 langevin.temperature = 1.0 langevin.adress = True langevin.addExclusions([4]) integrator.addExtension(langevin) # coordinates of particles before integration before = [self.system.storage.getParticle(i).pos[j] for i in range(1,4) for j in range(3)] # run ten steps integrator.run(10) # coordinates of particles after integration after = [self.system.storage.getParticle(i).pos[j] for i in range(1,4) for j in range(3)] # run checks (same as test before) self.assertEqual(before[0], after[0]) self.assertEqual(before[1], after[1]) self.assertEqual(before[2], after[2]) self.assertNotEqual(before[3], after[3]) self.assertNotEqual(before[4], after[4]) self.assertNotEqual(before[5], after[5]) self.assertNotEqual(before[6], after[6]) self.assertNotEqual(before[7], after[7]) self.assertNotEqual(before[8], after[8])
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 test_sphere(self): # add some particles particle_list = [ (1, 1, 0, espressopp.Real3D(5.0, 5.5, 5.0), 1.0, 0), (2, 1, 0, espressopp.Real3D(5.0, 6.5, 5.0), 1.0, 0), (3, 1, 0, espressopp.Real3D(5.0, 7.5, 5.0), 1.0, 0), (4, 1, 0, espressopp.Real3D(5.0, 8.5, 5.0), 1.0, 0), (5, 1, 0, espressopp.Real3D(5.0, 9.5, 5.0), 1.0, 0), (6, 0, 0, espressopp.Real3D(5.0, 5.5, 5.0), 1.0, 1), (7, 0, 0, espressopp.Real3D(5.0, 6.5, 5.0), 1.0, 1), (8, 0, 0, espressopp.Real3D(5.0, 7.5, 5.0), 1.0, 1), (9, 0, 0, espressopp.Real3D(5.0, 8.5, 5.0), 1.0, 1), (10, 0, 0, espressopp.Real3D(5.0, 9.5, 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') 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=True) # initialize lambda values integrator = espressopp.integrator.VelocityVerlet(self.system) integrator.dt = 0.01 adress = espressopp.integrator.Adress(self.system,vl,ftpl) integrator.addExtension(adress) espressopp.tools.AdressDecomp(self.system, integrator) # set up FEC fec = espressopp.integrator.FreeEnergyCompensation(self.system, center=[5.0, 5.0, 5.0], sphereAdr=True) fec.addForce(itype=3,filename="table_fec.tab",type=1) integrator.addExtension(fec) # y coordinates of particles before integration before = [self.system.storage.getParticle(i).pos[1] for i in range(1,6)] # run ten steps integrator.run(10) energy = fec.computeCompEnergy() # y coordinates of particles after integration after = [self.system.storage.getParticle(i).pos[1] for i in range(1,6)] # run checks (as for test with slab-geometry, but check y-coordinates this time. Given the now spherical setup, particles should move as before but along the y-axis). self.assertEqual(before[0], after[0]) self.assertEqual(before[1], after[1]) self.assertAlmostEqual(after[2], 7.598165, places=5) self.assertEqual(before[3], after[3]) self.assertEqual(before[4], after[4]) self.assertAlmostEqual(energy, 6.790157, places=5)
def test_slab(self): # 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, 0, espressopp.Real3D(5.5, 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(7.5, 5.0, 5.0), 1.0, 1), (9, 0, 0, espressopp.Real3D(8.5, 5.0, 5.0), 1.0, 1), (10, 0, 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') 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) integrator.dt = 0.01 adress = espressopp.integrator.Adress(self.system,vl,ftpl) integrator.addExtension(adress) espressopp.tools.AdressDecomp(self.system, integrator) # set up FEC fec = espressopp.integrator.FreeEnergyCompensation(self.system, center=[5.0, 5.0, 5.0]) fec.addForce(itype=3,filename="table_fec.tab",type=1) integrator.addExtension(fec) # x coordinates of particles before integration before = [self.system.storage.getParticle(i).pos[0] for i in range(1,6)] # run ten steps and compute energy integrator.run(10) energy = fec.computeCompEnergy() # x coordinates of particles after integration after = [self.system.storage.getParticle(i).pos[0] for i in range(1,6)] # run checks (only one particle is in hybrid region and should feel the FEC. Also check that its FEC energy is correct) self.assertEqual(before[0], after[0]) self.assertEqual(before[1], after[1]) self.assertAlmostEqual(after[2], 7.598165, places=5) self.assertEqual(before[3], after[3]) self.assertEqual(before[4], after[4]) self.assertAlmostEqual(energy, 6.790157, places=5)
def test_single_moving_sphere(self): # add some particles particle_list = [ (1, 1, 0, espressopp.Real3D(5.0, 5.0, 5.0), espressopp.Real3D(0.0, 1.0, 0.0), 1.0, 0), (2, 1, 0, espressopp.Real3D(5.0, 6.5, 5.0), espressopp.Real3D(0.0, 0.0, 0.0), 1.0, 0), (3, 1, 0, espressopp.Real3D(5.0, 7.5, 5.0), espressopp.Real3D(0.0, 0.0, 0.0), 1.0, 0), (4, 1, 0, espressopp.Real3D(5.0, 8.5, 5.0), espressopp.Real3D(0.0, 0.0, 0.0), 1.0, 0), (5, 1, 0, espressopp.Real3D(5.0, 9.5, 5.0), espressopp.Real3D(0.0, 0.0, 0.0), 1.0, 0), (6, 0, 0, espressopp.Real3D(5.0, 5.0, 5.0), espressopp.Real3D(0.0, 1.0, 0.0), 1.0, 1), (7, 0, 0, espressopp.Real3D(5.0, 6.5, 5.0), espressopp.Real3D(0.0, 0.0, 0.0), 1.0, 1), (8, 0, 0, espressopp.Real3D(5.0, 7.5, 5.0), espressopp.Real3D(0.0, 0.0, 0.0), 1.0, 1), (9, 0, 0, espressopp.Real3D(5.0, 8.5, 5.0), espressopp.Real3D(0.0, 0.0, 0.0), 1.0, 1), (10, 0, 0, espressopp.Real3D(5.0, 9.5, 5.0), espressopp.Real3D(0.0, 0.0, 0.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', 'v', '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=1.0, dHy=1.0, pids=[1], sphereAdr=True) # initialize lambda values integrator = espressopp.integrator.VelocityVerlet(self.system) integrator.dt = 0.01 adress = espressopp.integrator.Adress(self.system,vl,ftpl) integrator.addExtension(adress) espressopp.tools.AdressDecomp(self.system, integrator) # set up TD force thdforce = espressopp.integrator.TDforce(self.system,vl) thdforce.addForce(itype=3,filename="table_tf.tab",type=1) integrator.addExtension(thdforce) # y coordinates of particles before integration before = [self.system.storage.getParticle(i).pos[1] for i in range(1,6)] # run ten steps integrator.run(10) # y coordinates of particles after integration after = [self.system.storage.getParticle(i).pos[1] for i in range(1,6)] # run checks (first particle moves and defines the AdResS region, second particle is in the corresponding hybrid region, others are in coarse-grained region) self.assertAlmostEqual(after[0], 5.100000, places=5) self.assertAlmostEqual(after[1], 6.618377, places=5) self.assertEqual(before[2], after[2]) self.assertEqual(before[3], after[3]) self.assertEqual(before[4], after[4])
def test_slab(self): # 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, 0, espressopp.Real3D(5.5, 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(7.5, 5.0, 5.0), 1.0, 1), (9, 0, 0, espressopp.Real3D(8.5, 5.0, 5.0), 1.0, 1), (10, 0, 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') 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=1.0, dHy=1.0, adrCenter=[5.0, 5.0, 5.0], sphereAdr=False) # initialize lambda values integrator = espressopp.integrator.VelocityVerlet(self.system) integrator.dt = 0.01 adress = espressopp.integrator.Adress(self.system,vl,ftpl) integrator.addExtension(adress) espressopp.tools.AdressDecomp(self.system, integrator) # set up TD force thdforce = espressopp.integrator.TDforce(self.system,vl) thdforce.addForce(itype=3,filename="table_tf.tab",type=1) integrator.addExtension(thdforce) # x coordinates of particles before integration before = [self.system.storage.getParticle(i).pos[0] for i in range(1,6)] # run ten steps integrator.run(10) # x coordinates of particles after integration after = [self.system.storage.getParticle(i).pos[0] for i in range(1,6)] # run checks (only one particle is in hybrid region, should feel the thermodynamic force, and should hence move along the x direction) self.assertEqual(before[0], after[0]) self.assertAlmostEqual(after[1], 6.596913, places=5) self.assertEqual(before[2], after[2]) self.assertEqual(before[3], after[3]) self.assertEqual(before[4], after[4])
def test_fixed_sphere(self): # add some particles particle_list = [ (1, 1, 0, espressopp.Real3D(5.0, 5.5, 5.0), 1.0, 0), (2, 1, 0, espressopp.Real3D(5.0, 6.5, 5.0), 1.0, 0), (3, 1, 0, espressopp.Real3D(5.0, 7.5, 5.0), 1.0, 0), (4, 1, 0, espressopp.Real3D(5.0, 8.5, 5.0), 1.0, 0), (5, 1, 0, espressopp.Real3D(5.0, 9.5, 5.0), 1.0, 0), (6, 0, 0, espressopp.Real3D(5.0, 5.5, 5.0), 1.0, 1), (7, 0, 0, espressopp.Real3D(5.0, 6.5, 5.0), 1.0, 1), (8, 0, 0, espressopp.Real3D(5.0, 7.5, 5.0), 1.0, 1), (9, 0, 0, espressopp.Real3D(5.0, 8.5, 5.0), 1.0, 1), (10, 0, 0, espressopp.Real3D(5.0, 9.5, 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') 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=1.0, dHy=1.0, adrCenter=[5.0, 5.0, 5.0], sphereAdr=True) # initialize lambda values integrator = espressopp.integrator.VelocityVerlet(self.system) integrator.dt = 0.01 adress = espressopp.integrator.Adress(self.system,vl,ftpl) integrator.addExtension(adress) espressopp.tools.AdressDecomp(self.system, integrator) # set up TD force thdforce = espressopp.integrator.TDforce(self.system,vl) thdforce.addForce(itype=3,filename="table_tf.tab",type=1) integrator.addExtension(thdforce) # y coordinates of particles before integration before = [self.system.storage.getParticle(i).pos[1] for i in range(1,6)] # run ten steps integrator.run(10) # y coordinates of particles after integration after = [self.system.storage.getParticle(i).pos[1] for i in range(1,6)] # run checks (as test before, just that particles should move in y-direction given the new setup and the spherical adaptive resolution geometry) self.assertEqual(before[0], after[0]) self.assertAlmostEqual(after[1], 6.596913, places=5) self.assertEqual(before[2], after[2]) self.assertEqual(before[3], after[3]) self.assertEqual(before[4], after[4])
def test_many_moving_spheres_fewupdates(self): # add some particles particle_list = [ (1, 1, 0, espressopp.Real3D(4.0, 5.0, 5.0), espressopp.Real3D(-1.0, 1.0, 0.0), 1.0, 0), (2, 1, 0, espressopp.Real3D(6.0, 5.0, 5.0), espressopp.Real3D(1.0, 1.0, 0.0), 1.0, 0), (3, 1, 0, espressopp.Real3D(5.0, 6.2, 5.0), espressopp.Real3D(0.0, 0.0, 0.0), 1.0, 0), (4, 1, 0, espressopp.Real3D(3.0, 8.5, 5.0), espressopp.Real3D(0.0, 0.0, 0.0), 1.0, 0), (5, 1, 0, espressopp.Real3D(7.0, 9.5, 5.0), espressopp.Real3D(0.0, 0.0, 0.0), 1.0, 0), (6, 0, 0, espressopp.Real3D(4.0, 5.0, 5.0), espressopp.Real3D(-1.0, 1.0, 0.0), 1.0, 1), (7, 0, 0, espressopp.Real3D(6.0, 5.0, 5.0), espressopp.Real3D(1.0, 1.0, 0.0), 1.0, 1), (8, 0, 0, espressopp.Real3D(5.0, 6.2, 5.0), espressopp.Real3D(0.0, 0.0, 0.0), 1.0, 1), (9, 0, 0, espressopp.Real3D(3.0, 8.5, 5.0), espressopp.Real3D(0.0, 0.0, 0.0), 1.0, 1), (10, 0, 0, espressopp.Real3D(7.0, 9.5, 5.0), espressopp.Real3D(0.0, 0.0, 0.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', 'v', '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=1.0, dHy=1.0, pids=[1,2], sphereAdr=True) # initialize lambda values integrator = espressopp.integrator.VelocityVerlet(self.system) integrator.dt = 0.01 adress = espressopp.integrator.Adress(self.system,vl,ftpl,regionupdates = 5) integrator.addExtension(adress) espressopp.tools.AdressDecomp(self.system, integrator) # set up TD force thdforce = espressopp.integrator.TDforce(self.system, vl, startdist = 0.9, enddist = 2.1, edgeweightmultiplier = 20) thdforce.addForce(itype=3,filename="table_tf.tab",type=1) integrator.addExtension(thdforce) # y coordinates of particles before integration before = [self.system.storage.getParticle(i).pos[1] for i in range(1,6)] # run ten steps integrator.run(20) # y coordinates of particles after integration (as test before, but more integration steps and the AdResS region is updated only every 5 steps) after = [self.system.storage.getParticle(i).pos[1] for i in range(1,6)] # run checks self.assertAlmostEqual(after[0], 5.200000, places=5) self.assertAlmostEqual(after[1], 5.200000, places=5) self.assertAlmostEqual(after[2], 6.393199, places=5) self.assertEqual(before[3], after[3]) self.assertEqual(before[4], after[4])
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 test_densitycalculation(self): # 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, 0, espressopp.Real3D(5.5, 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(7.5, 5.0, 5.0), 1.0, 1), (9, 0, 0, espressopp.Real3D(8.5, 5.0, 5.0), 1.0, 1), (10, 0, 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') 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) # calculate density profile densityprofile = espressopp.analysis.AdressDensity(self.system, vl) densityprofile.addExclusions([8]) density_array = densityprofile.compute(5) # run checks self.assertAlmostEqual(density_array[0], 31.250000, places=5) self.assertAlmostEqual(density_array[1], 4.464286, places=5) self.assertAlmostEqual(density_array[2], 0.0, places=5) self.assertAlmostEqual(density_array[3], 0.844595, places=5) self.assertAlmostEqual(density_array[4], 0.512295, places=5)
def test_span_false(self): # 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) # calculate rdfs rdf_nospan = espressopp.analysis.RDFatomistic(system=self.system, type1=0, type2=0, span=1.0, spanbased=False) rdf_nospan_array = rdf_nospan.compute(10) # run checks self.assertAlmostEqual(rdf_nospan_array[1], 136.418523, places=5) self.assertAlmostEqual(rdf_nospan_array[2], 16.753152, places=5)
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 test_slab(self): # add some particles particle_list = [ (1, 1, espressopp.Real3D(5.5, 5.0, 5.0), 1.0, 0), (2, 1, espressopp.Real3D(6.5, 5.0, 5.0), 1.0, 0), (3, 1, espressopp.Real3D(7.5, 5.0, 5.0), 1.0, 0), (4, 1, espressopp.Real3D(8.5, 5.0, 5.0), 1.0, 0), (5, 1, espressopp.Real3D(9.5, 5.0, 5.0), 1.0, 0), (6, 0, espressopp.Real3D(5.5, 5.0, 5.0), 1.0, 1), (7, 0, espressopp.Real3D(6.5, 5.0, 5.0), 1.0, 1), (8, 0, espressopp.Real3D(7.5, 5.0, 5.0), 1.0, 1), (9, 0, espressopp.Real3D(8.5, 5.0, 5.0), 1.0, 1), (10, 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', '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) # add interaction interNB = espressopp.interaction.VerletListAdressLennardJones2( vl, ftpl) potWCA1 = espressopp.interaction.LennardJones(epsilon=1.0, sigma=1.0, shift='auto', cutoff=1.4) potWCA2 = espressopp.interaction.LennardJones(epsilon=0.5, sigma=1.0, shift='auto', cutoff=1.4) interNB.setPotentialAT(type1=0, type2=0, potential=potWCA1) # AT interNB.setPotentialCG(type1=1, type2=1, potential=potWCA2) # CG self.system.addInteraction(interNB) # initialize lambda values integrator = espressopp.integrator.VelocityVerlet(self.system) integrator.dt = 0.01 adress = espressopp.integrator.Adress(self.system, vl, ftpl) integrator.addExtension(adress) espressopp.tools.AdressDecomp(self.system, integrator) # coordinates and non-bonded energy of particles before integration before = [ self.system.storage.getParticle(i).pos[j] for i in range(1, 6) for j in range(3) ] energy_before = interNB.computeEnergy() # run ten steps integrator.run(10) # coordinates and non-bonded energy of particles after integration after = [ self.system.storage.getParticle(i).pos[j] for i in range(1, 6) for j in range(3) ] energy_after = interNB.computeEnergy() # run checks (Particles should move along the x-axis only given their initial configuration. Additionally, check energies) self.assertAlmostEqual(after[0], 5.413171, places=5) self.assertEqual(before[1], after[1]) self.assertEqual(before[2], after[2]) self.assertAlmostEqual(after[3], 6.500459, places=5) self.assertEqual(before[4], after[4]) self.assertEqual(before[5], after[5]) self.assertAlmostEqual(after[6], 7.522099, places=5) self.assertEqual(before[7], after[7]) self.assertEqual(before[8], after[8]) self.assertAlmostEqual(after[9], 8.512569, places=5) self.assertEqual(before[10], after[10]) self.assertEqual(before[11], after[11]) self.assertAlmostEqual(after[12], 9.551701, places=5) self.assertEqual(before[13], after[13]) self.assertEqual(before[14], after[14]) self.assertAlmostEqual(energy_before, 1.266889, places=5) self.assertAlmostEqual(energy_after, -0.209015, places=5)
def test_sphere(self): # add some particles particle_list = [ (1, 1, 0, espressopp.Real3D(5.0, 5.5, 5.0), 1.0, 0), (2, 1, 0, espressopp.Real3D(5.0, 6.5, 5.0), 1.0, 0), (3, 1, 0, espressopp.Real3D(5.0, 7.5, 5.0), 1.0, 0), (4, 1, 0, espressopp.Real3D(5.0, 8.5, 5.0), 1.0, 0), (5, 1, 0, espressopp.Real3D(5.0, 9.5, 5.0), 1.0, 0), (6, 0, 0, espressopp.Real3D(5.0, 5.5, 5.0), 1.0, 1), (7, 0, 0, espressopp.Real3D(5.0, 6.5, 5.0), 1.0, 1), (8, 0, 0, espressopp.Real3D(5.0, 7.5, 5.0), 1.0, 1), (9, 0, 0, espressopp.Real3D(5.0, 8.5, 5.0), 1.0, 1), (10, 0, 0, espressopp.Real3D(5.0, 9.5, 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') 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=True) # add interaction interNB = espressopp.interaction.VerletListHadressLennardJones2(vl, ftpl) potWCA1 = espressopp.interaction.LennardJones(epsilon=1.0, sigma=1.0, shift='auto', cutoff=1.4) potWCA2 = espressopp.interaction.LennardJones(epsilon=0.0, sigma=1.0, shift='auto', cutoff=1.4) interNB.setPotentialAT(type1=0, type2=0, potential=potWCA1) # AT interNB.setPotentialCG(type1=0, type2=0, potential=potWCA2) # CG self.system.addInteraction(interNB) # initialize lambda values integrator = espressopp.integrator.VelocityVerlet(self.system) integrator.dt = 0.01 adress = espressopp.integrator.Adress(self.system,vl,ftpl) integrator.addExtension(adress) espressopp.tools.AdressDecomp(self.system, integrator) # coordinates and non-bonded energy of particles before integration before = [self.system.storage.getParticle(i).pos[j] for i in range(1,6) for j in range(3)] energy_before = interNB.computeEnergy() # run ten steps and compute energy integrator.run(10) # coordinates and non-bonded energy of particles after integration after = [self.system.storage.getParticle(i).pos[j] for i in range(1,6) for j in range(3)] energy_after = interNB.computeEnergy() # run checks (as before, just that particles should now move along the y-axis only, given their setup and the spherical adaptive resolution geometry) self.assertEqual(before[0], after[0]) self.assertAlmostEqual(after[1], 5.413650, places=5) self.assertEqual(before[2], after[2]) self.assertEqual(before[3], after[3]) self.assertAlmostEqual(after[4], 6.507075, places=5) self.assertEqual(before[5], after[5]) self.assertEqual(before[6], after[6]) self.assertAlmostEqual(after[7], 7.551088, places=5) self.assertEqual(before[8], after[8]) self.assertEqual(before[9], after[9]) self.assertAlmostEqual(after[10], 8.531737, places=5) self.assertEqual(before[11], after[11]) self.assertEqual(before[12], after[12]) self.assertEqual(before[13], after[13]) self.assertEqual(before[14], after[14]) self.assertAlmostEqual(energy_before,0.921374, places=5) self.assertAlmostEqual(energy_after, -0.468436, places=5)
def test_ATATCG_template(self): # 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') 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) # add interactions interNB = espressopp.interaction.VerletListAdressATLJReacFieldGenHarmonic( vl, ftpl) potLJ = espressopp.interaction.LennardJones(epsilon=0.650299305951, sigma=0.316549165245, shift='auto', cutoff=1.4) potQQ = espressopp.interaction.ReactionFieldGeneralized( prefactor=138.935485, kappa=0.0, epsilon1=1.0, epsilon2=80.0, cutoff=1.4, shift="auto") potCG = espressopp.interaction.Harmonic(K=500.0, r0=1.4, cutoff=1.4) interNB.setPotentialAT1(type1=0, type2=0, potential=potLJ) interNB.setPotentialAT2(type1=0, type2=0, potential=potQQ) interNB.setPotentialCG(type1=1, type2=1, potential=potCG) self.system.addInteraction(interNB) # set up integrator integrator = espressopp.integrator.VelocityVerlet(self.system) integrator.dt = 0.01 adress = espressopp.integrator.Adress(self.system, vl, ftpl) integrator.addExtension(adress) espressopp.tools.AdressDecomp(self.system, integrator) # coordinates and non-bonded energy of particles before integration before = [ self.system.storage.getParticle(i).pos[j] for i in range(1, 6) for j in range(3) ] energy_before = interNB.computeEnergy() # run ten steps and compute energy integrator.run(10) # coordinates and non-bonded energy of particles after integration after = [ self.system.storage.getParticle(i).pos[j] for i in range(1, 6) for j in range(3) ] energy_after = interNB.computeEnergy() # run checks self.assertAlmostEqual(after[0], 5.004574, places=5) self.assertEqual(before[1], after[1]) self.assertEqual(before[2], after[2]) self.assertAlmostEqual(after[3], 6.009012, places=5) self.assertEqual(before[4], after[4]) self.assertEqual(before[5], after[5]) self.assertAlmostEqual(after[6], 7.129601, places=5) self.assertEqual(before[7], after[7]) self.assertEqual(before[8], after[8]) self.assertAlmostEqual(after[9], 8.787093, places=5) self.assertEqual(before[10], after[10]) self.assertEqual(before[11], after[11]) self.assertAlmostEqual(after[12], 0.569719, places=5) self.assertEqual(before[13], after[13]) self.assertEqual(before[14], after[14]) self.assertAlmostEqual(energy_before, 223.764297, places=5) self.assertAlmostEqual(energy_after, 23.995610, places=5)
def test_potential_decoupling(self): #add particles particle_list = [ (4, 1, 0, espressopp.Real3D(2.0, 2.0, 2.0), 1.0, 0), (5, 1, 0, espressopp.Real3D(2.3, 2.0, 2.0), 1.0, 0), (6, 1, 0, espressopp.Real3D(2.6, 2.0, 2.0), 1.0, 0), (1, 0, 1, espressopp.Real3D(2.0, 2.0, 2.0), 1.0, 1), (2, 0, -1, espressopp.Real3D(2.3, 2.0, 2.0), 1.0, 1), (3, 0, -1, espressopp.Real3D(2.6, 2.0, 2.0), 1.0, 1), ] tuples = [(4, 1), (5, 2), (6, 3)] 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() vl = espressopp.VerletListAdress(self.system, cutoff=1.5, adrcut=1.5, dEx=2.0, dHy=1.0, pids=[4], sphereAdr=True) #add LJ interaction interactionLJ = espressopp.interaction.VerletListAdressLennardJonesSoftcoreTI( vl, ftpl) potLJ = espressopp.interaction.LennardJonesSoftcoreTI(epsilonA=1.0, sigmaA=0.2, epsilonB=0.0, sigmaB=0.2, alpha=0.5, power=1.0, cutoff=1.5, lambdaTI=0.3, annihilate=False) potLJ.addPids([1, 2]) interactionLJ.setPotentialAT(type1=0, type2=0, potential=potLJ) self.system.addInteraction(interactionLJ) #add electrostatic interaction interactionQQ = espressopp.interaction.VerletListAdressReactionFieldGeneralizedTI( vl, ftpl) potQQ = espressopp.interaction.ReactionFieldGeneralizedTI( prefactor=1.0, kappa=0.0, epsilon1=1, epsilon2=80, cutoff=1.5, lambdaTI=0.3, annihilate=False) potQQ.addPids([1, 2]) interactionQQ.setPotentialAT(type1=0, type2=0, potential=potQQ) self.system.addInteraction(interactionQQ) #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) self.assertAlmostEqual(interactionQQ.computeEnergyDeriv(), -1.627412, places=5) self.assertAlmostEqual(interactionLJ.computeEnergyDeriv(), 0.330739, places=5) self.assertAlmostEqual(interactionQQ.computeEnergy(), -1.213441, places=5) self.assertAlmostEqual(interactionLJ.computeEnergy(), -0.545769, places=5)
def test_gromacs_adress(self): # add some particles particle_list = [ (1, 1, 0, espressopp.Real3D(5.0, 5.5, 5.0), 1.0, 0), (2, 1, 0, espressopp.Real3D(5.0, 6.5, 5.0), 1.0, 0), (3, 1, 0, espressopp.Real3D(5.0, 7.5, 5.0), 1.0, 0), (4, 1, 0, espressopp.Real3D(5.0, 8.5, 5.0), 1.0, 0), (5, 1, 0, espressopp.Real3D(5.0, 9.5, 5.0), 1.0, 0), (6, 0, 0, espressopp.Real3D(5.0, 5.5, 5.0), 1.0, 1), (7, 0, 0, espressopp.Real3D(5.0, 6.5, 5.0), 1.0, 1), (8, 0, 0, espressopp.Real3D(5.0, 7.5, 5.0), 1.0, 1), (9, 0, 0, espressopp.Real3D(5.0, 8.5, 5.0), 1.0, 1), (10, 0, 0, espressopp.Real3D(5.0, 9.5, 5.0), 1.0, 1), ] tuples = [(1, 6), (2, 7), (3, 8), (4, 9), (5, 10)] #tuples = [(1,2),(3,4),(5,6),(7,8),(9,10)] 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=True) # add interaction interNB = espressopp.interaction.VerletListHadressLennardJones2( vl, ftpl) potWCA1 = espressopp.interaction.LennardJones(epsilon=1.0, sigma=1.0, shift='auto', cutoff=1.4) potWCA2 = espressopp.interaction.LennardJones(epsilon=0.0, sigma=1.0, shift='auto', cutoff=1.4) interNB.setPotentialAT(type1=0, type2=0, potential=potWCA1) # AT interNB.setPotentialCG(type1=0, type2=0, potential=potWCA2) # CG self.system.addInteraction(interNB) # initialize lambda values integrator = espressopp.integrator.VelocityVerlet(self.system) integrator.dt = 0.01 adress = espressopp.integrator.Adress(self.system, vl, ftpl) integrator.addExtension(adress) espressopp.tools.AdressDecomp(self.system, integrator) file_gro_adress = "test_standard_dumpGROAdress_type_not_hardcoded.gro" dump_gro_adress = espressopp.io.DumpGROAdress(self.system, ftpl, integrator, filename=file_gro_adress) dump_gro_adress.dump() self.assertTrue( filecmp.cmp(file_gro_adress, expected_files[0], shallow=False), "!!! Error! Files are not equal!! They should be equal!")
def test_path_integral(self): # add some particles particle_list = [(1, 1, espressopp.Real3D(1.0, 5.0, 5.0), 0, 0), (2, 1, espressopp.Real3D(1.0, 4.9, 5.0), 1, 1), (3, 1, espressopp.Real3D(1.0, 5.0, 4.9), 1, 2), (4, 1, espressopp.Real3D(1.0, 5.1, 5.0), 1, 3), (5, 1, espressopp.Real3D(1.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), (21, 0, espressopp.Real3D(5.0, 5.0, 5.0), 0, 0), (22, 0, espressopp.Real3D(5.0, 4.8, 5.0), 1, 1), (23, 0, espressopp.Real3D(5.0, 5.0, 4.8), 1, 2), (24, 0, espressopp.Real3D(5.0, 5.2, 5.0), 1, 3), (25, 0, espressopp.Real3D(5.0, 5.0, 5.2), 1, 4), (26, 1, espressopp.Real3D(5.0, 5.0, 5.0), 0, 0), (27, 1, espressopp.Real3D(5.5, 4.5, 5.0), 1, 2), (28, 1, espressopp.Real3D(5.5, 5.0, 4.5), 1, 3), (29, 1, espressopp.Real3D(5.5, 5.5, 5.0), 1, 4), (30, 1, espressopp.Real3D(5.5, 5.0, 5.5), 1, 1)] tuples = [(1, 2, 3, 4, 5), (6, 7, 8, 9, 10), (11, 12, 13, 14, 15), (16, 17, 18, 19, 20), (21, 22, 23, 24, 25), (26, 27, 28, 29, 30)] 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) # 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.PIAdressIntegrator( system=self.system, verletlist=vl, nTrotter=4) espressopp.tools.AdressDecomp(self.system, integrator) # calculate rdfs rdf_pi = espressopp.analysis.RDFatomistic(system=self.system, type1=1, type2=1, span=2.5) rdf_pi_array = rdf_pi.computePathIntegral(10) # run checks self.assertAlmostEqual(rdf_pi_array[1], 49.121896, places=5) self.assertAlmostEqual(rdf_pi_array[2], 26.525824, places=5) self.assertAlmostEqual(rdf_pi_array[3], 15.898631, places=5) self.assertAlmostEqual(rdf_pi_array[4], 0.0, places=5)
def test_PIAdResS(self): print 'param =', self.param constkinmass = self.param['constkinmass'] PILE = self.param['PILE'] realkinmass = self.param['realkinmass'] centroidthermostat = self.param['centroidthermostat'] KTI = self.param['KTI'] speedupInterAtom = self.param['speedupInterAtom'] speedupFreezeRings = self.param['speedupFreezeRings'] spherical_adress = self.param['spherical_adress'] nb_forcefield_setup = self.param['nb_forcefield_setup'] energy_before = self.param['energy_before'] energy_after = self.param['energy_after'] steps = 10 timestep_short = 0.001 / 16.0 multiplier_short_to_medium = 4 multiplier_medium_to_long = 4 interaction_cutoff = 0.84 potential_cutoff = 0.78 skin = 0.1 gamma = 0.0 temp = 2.50266751 if KTI: ex_size = 100.0 else: ex_size = 1.0 hy_size = 1.5 nTrotter = 4 clmassmultiplier = 100.0 PILElambda = 0.0 CMDparameter = 1.0 tabFEC_H = "FEC_H.dat" tabFEC_O = "FEC_O.dat" tabTHDF_H = "ThdForce_H.dat" tabTHDF_O = "ThdForce_O.dat" tabAngle = "tableESP_angle.dat" tabBondHH = "tableESP_bondHH.dat" tabBondOH = "tableESP_bondOH.dat" tabHW_HW = "tableESP_HW_HW.dat" tabHW_OW = "tableESP_HW_OW.dat" tabOW_OW = "tableESP_OW_OW.dat" pid, types, x, y, z, vx, vy, vz, Lx, Ly, Lz = espressopp.tools.readxyz( "input_test.xyz") masses = [] for item in types: if item == 1: masses.append(15.9994) else: masses.append(1.008) num_Trotter_beads = len(x) num_atoms = len(x) / nTrotter size = (Lx, Ly, Lz) system = espressopp.System() system.bc = espressopp.bc.OrthorhombicBC(system.rng, size) system.skin = skin comm = MPI.COMM_WORLD nodeGrid = decomp.nodeGrid(comm.size) cellGrid = decomp.cellGrid(size, nodeGrid, interaction_cutoff, skin) system.rng = espressopp.esutil.RNG() system.storage = espressopp.storage.DomainDecompositionAdress( system, nodeGrid, cellGrid) props = ['id', 'pos', 'v', 'f', 'pib', 'type', 'mass', 'adrat'] allParticlesAT = [] allParticles = [] tuples = [] for pid_trotter in range(num_Trotter_beads): allParticlesAT.append([ pid_trotter + 1, Real3D(x[pid_trotter], y[pid_trotter], z[pid_trotter]), Real3D(vx[pid_trotter], vy[pid_trotter], vz[pid_trotter]), Real3D(0, 0, 0), pid_trotter % nTrotter + 1, types[pid_trotter], masses[pid_trotter], 1 ]) for pid_atom in range(num_atoms): tmptuple = [pid_atom + num_Trotter_beads + 1] for pid_trotter in range(nTrotter): pid = pid_atom * nTrotter + pid_trotter tmptuple.append((allParticlesAT[pid])[0]) firstParticleId = tmptuple[1] cmp = allParticlesAT[firstParticleId - 1][1] cmv = allParticlesAT[firstParticleId - 1][2] allParticles.append([ pid_atom + num_Trotter_beads + 1, Real3D(cmp[0], cmp[1], cmp[2]), Real3D(cmv[0], cmv[1], cmv[2]), Real3D(0, 0, 0), 0, types[pid_atom * nTrotter], masses[pid_atom * nTrotter], 0 ]) for pid_trotter in range(nTrotter): pid = pid_atom * nTrotter + pid_trotter allParticles.append([(allParticlesAT[pid])[0], (allParticlesAT[pid])[1], (allParticlesAT[pid])[2], (allParticlesAT[pid])[3], (allParticlesAT[pid])[4], (allParticlesAT[pid])[5], (allParticlesAT[pid])[6], (allParticlesAT[pid])[7]]) tuples.append(tmptuple) system.storage.addParticles(allParticles, *props) ftpl = espressopp.FixedTupleListAdress(system.storage) ftpl.addTuples(tuples) system.storage.setFixedTuplesAdress(ftpl) system.storage.decompose() bondsOH = [] bondsHH = [] for part in range(num_atoms / 3): bondsOH.append((num_Trotter_beads + 1 + 3 * part, num_Trotter_beads + 1 + 3 * part + 1)) bondsOH.append((num_Trotter_beads + 1 + 3 * part, num_Trotter_beads + 1 + 3 * part + 2)) bondsHH.append((num_Trotter_beads + 1 + 3 * part + 1, num_Trotter_beads + 1 + 3 * part + 2)) fplOH = espressopp.FixedPairList(system.storage) fplHH = espressopp.FixedPairList(system.storage) fplOH.addBonds(bondsOH) fplHH.addBonds(bondsHH) angles = [] for part in range(num_atoms / 3): angles.append((num_Trotter_beads + 1 + 3 * part + 1, num_Trotter_beads + 1 + 3 * part, num_Trotter_beads + 1 + 3 * part + 2)) ftl = espressopp.FixedTripleList(system.storage) ftl.addTriples(angles) vl = espressopp.VerletListAdress(system, cutoff=interaction_cutoff, adrcut=interaction_cutoff, dEx=ex_size, dHy=hy_size, adrCenter=[Lx / 2, Ly / 2, Lz / 2], exclusionlist=bondsOH + bondsHH, sphereAdr=spherical_adress) if nb_forcefield_setup == 1: interNB = espressopp.interaction.VerletListPIadressTabulatedLJ( vl, ftpl, nTrotter, speedupInterAtom) elif nb_forcefield_setup == 2: interNB = espressopp.interaction.VerletListPIadressNoDriftTabulated( vl, ftpl, nTrotter, speedupInterAtom) elif nb_forcefield_setup == 3: interNB = espressopp.interaction.VerletListPIadressTabulated( vl, ftpl, nTrotter, speedupInterAtom) else: raise ValueError( "Wrong nb_forcefield_setup integer (only 1,2,3 accepted.") potOOqm = espressopp.interaction.Tabulated(itype=3, filename=tabOW_OW, cutoff=potential_cutoff) potHOqm = espressopp.interaction.Tabulated(itype=3, filename=tabHW_OW, cutoff=potential_cutoff) potHHqm = espressopp.interaction.Tabulated(itype=3, filename=tabHW_HW, cutoff=potential_cutoff) if nb_forcefield_setup == 1: interNB.setPotentialQM(type1=1, type2=1, potential=potOOqm) interNB.setPotentialQM(type1=1, type2=0, potential=potHOqm) interNB.setPotentialQM(type1=0, type2=0, potential=potHHqm) potOOcl = espressopp.interaction.LennardJones( epsilon=temp, sigma=0.25, shift='auto', cutoff=1.122462048309373 * 0.25) interNB.setPotentialCL(type1=1, type2=1, potential=potOOcl) elif nb_forcefield_setup == 2: interNB.setPotential(type1=1, type2=1, potential=potOOqm) interNB.setPotential(type1=1, type2=0, potential=potHOqm) interNB.setPotential(type1=0, type2=0, potential=potHHqm) elif nb_forcefield_setup == 3: interNB.setPotentialQM(type1=1, type2=1, potential=potOOqm) interNB.setPotentialQM(type1=1, type2=0, potential=potHOqm) interNB.setPotentialQM(type1=0, type2=0, potential=potHHqm) interNB.setPotentialCL(type1=1, type2=1, potential=potOOqm) interNB.setPotentialCL(type1=1, type2=0, potential=potHOqm) interNB.setPotentialCL(type1=0, type2=0, potential=potHHqm) system.addInteraction(interNB) potBondHH = espressopp.interaction.Tabulated(itype=3, filename=tabBondHH) potBondOH = espressopp.interaction.Tabulated(itype=3, filename=tabBondOH) interBondedHH = espressopp.interaction.FixedPairListPIadressTabulated( system, fplHH, ftpl, potBondHH, nTrotter, speedupInterAtom) interBondedOH = espressopp.interaction.FixedPairListPIadressTabulated( system, fplOH, ftpl, potBondOH, nTrotter, speedupInterAtom) system.addInteraction(interBondedHH) system.addInteraction(interBondedOH) potAngle = espressopp.interaction.TabulatedAngular(itype=3, filename=tabAngle) interAngle = espressopp.interaction.FixedTripleListPIadressTabulatedAngular( system, ftl, ftpl, potAngle, nTrotter, speedupInterAtom) system.addInteraction(interAngle) integrator = espressopp.integrator.PIAdressIntegrator( system=system, verletlist=vl, timestep=timestep_short, sSteps=multiplier_short_to_medium, mSteps=multiplier_medium_to_long, nTrotter=nTrotter, realKinMass=realkinmass, constKinMass=constkinmass, temperature=temp, gamma=gamma, centroidThermostat=centroidthermostat, CMDparameter=CMDparameter, PILE=PILE, PILElambda=PILElambda, CLmassmultiplier=clmassmultiplier, speedup=speedupFreezeRings, KTI=KTI) if not KTI: fec = espressopp.integrator.FreeEnergyCompensation( system, center=[Lx / 2, Ly / 2, Lz / 2], ntrotter=nTrotter) fec.addForce(itype=3, filename=tabFEC_O, type=1) fec.addForce(itype=3, filename=tabFEC_H, type=0) integrator.addExtension(fec) thdf = espressopp.integrator.TDforce(system, vl) thdf.addForce(itype=3, filename=tabTHDF_O, type=1) thdf.addForce(itype=3, filename=tabTHDF_H, type=0) integrator.addExtension(thdf) if KTI: for i in range(1, num_Trotter_beads + num_atoms + 1): system.storage.modifyParticle(i, 'lambda_adrd', 0.0) system.storage.modifyParticle(i, 'lambda_adr', 0.0) system.storage.modifyParticle( i, 'varmass', clmassmultiplier * system.storage.getParticle(i).mass) system.storage.decompose() espressopp.tools.AdressDecomp(system, integrator) Eb = interBondedOH.computeEnergy() + interBondedHH.computeEnergy() EAng = interAngle.computeEnergy() ELj = interNB.computeEnergy() Ek = integrator.computeKineticEnergy() EPI = integrator.computeRingEnergy() if KTI == False: Ecorr = fec.computeCompEnergy() + thdf.computeTDEnergy() else: Ecorr = 0.0 energy_before_thistest = Ek + Eb + EAng + ELj + EPI + Ecorr integrator.run(steps) Eb = interBondedOH.computeEnergy() + interBondedHH.computeEnergy() EAng = interAngle.computeEnergy() ELj = interNB.computeEnergy() Ek = integrator.computeKineticEnergy() EPI = integrator.computeRingEnergy() if KTI == False: Ecorr = fec.computeCompEnergy() + thdf.computeTDEnergy() else: Ecorr = 0.0 energy_after_thistest = Ek + Eb + EAng + ELj + EPI + Ecorr self.assertAlmostEqual(energy_before_thistest, energy_before, places=5) self.assertAlmostEqual(energy_after_thistest, energy_after, places=5)
allParticles.append([pid, # now the AT particles can be added (allParticlesAT[pid])[1], # pos (allParticlesAT[pid])[2], # vel (allParticlesAT[pid])[3], # force (allParticlesAT[pid])[4], # type (allParticlesAT[pid])[5], # mass (allParticlesAT[pid])[6]]) # is AT particle # append tuple to tuplelist tuples.append(tmptuple) # add particles to system system.storage.addParticles(allParticles, "id", "pos", "v", "f", "type", "mass", "adrat") # create FixedTupleList object ftpl = espressopp.FixedTupleListAdress(system.storage) # and add the tuples ftpl.addTuples(tuples) system.storage.setFixedTuplesAdress(ftpl) # add bonds between AT particles fpl = espressopp.FixedPairListAdress(system.storage, ftpl) bonds = Tetracryst.makebonds(len(x)) fpl.addBonds(bonds) # decompose after adding tuples and bonds print "Added tuples and bonds, decomposing now ..." system.storage.decompose() print "done decomposing"
def test_rattle(self): #add particles # 4-3-5 # | # | # 2-1 particle_list = [(6, 1, espressopp.Real3D(3.2, 3.3, 3.0), espressopp.Real3D(0, 0, 0), 9.0, 0), (1, 0, espressopp.Real3D(3.2, 3.1, 3.0), espressopp.Real3D(0.27, -0.07, 0.10), 3.0, 1), (2, 0, espressopp.Real3D(3.1, 3.1, 3.0), espressopp.Real3D(0.23, 0.22, 0.00), 1.0, 1), (3, 0, espressopp.Real3D(3.2, 3.3, 3.0), espressopp.Real3D(0.24, -0.37, -0.10), 3.0, 1), (4, 0, espressopp.Real3D(3.1, 3.3, 3.0), espressopp.Real3D(0.14, 0.20, -0.05), 1.0, 1), (5, 0, espressopp.Real3D(3.3, 3.3, 3.0), espressopp.Real3D(0.04, 0.17, -0.20), 1.0, 1)] tuples = [(6, 1, 2, 3, 4, 5)] constrainedBondsList = [[1, 2, 0.1, 3.0, 1.0], [3, 4, 0.1, 3.0, 1.0], [3, 5, 0.1, 3.0, 1.0]] #pid1,pid2,constraintDist,mass1,mass2 constraintDist2 = [] for bond in constrainedBondsList: constraintDist2.append(bond[2] * bond[2]) self.system.storage.addParticles(particle_list, 'id', 'type', 'pos', 'v', 'mass', 'adrat') ftpl = espressopp.FixedTupleListAdress(self.system.storage) ftpl.addTuples(tuples) self.system.storage.setFixedTuplesAdress(ftpl) self.system.storage.decompose() vl = espressopp.VerletListAdress(self.system, cutoff=1.5, adrcut=1.5, dEx=2.0, dHy=1.0, pids=[6], sphereAdr=True) #one unconstrained bond fpl = espressopp.FixedPairListAdress(self.system.storage, ftpl) fpl.addBonds([(1, 3)]) pot = espressopp.interaction.Harmonic(K=5.0, r0=0.2) interB = espressopp.interaction.FixedPairListHarmonic( self.system, fpl, pot) self.system.addInteraction(interB) #some angles ftl = espressopp.FixedTripleListAdress(self.system.storage, ftpl) ftl.addTriples([(2, 1, 3), (1, 3, 4), (1, 3, 5)]) pot = espressopp.interaction.AngularHarmonic(K=5.0, theta0=math.pi / 2.0) interA = espressopp.interaction.FixedTripleListAngularHarmonic( self.system, ftl, pot) self.system.addInteraction(interA) #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) rattle = espressopp.integrator.Rattle(self.system, maxit=1000, tol=1e-6, rptol=1e-6) rattle.addConstrainedBonds(constrainedBondsList) integrator.addExtension(rattle) integrator.run(5) #check if bond lengths are the same as constraint lengths for i, bond in enumerate(constrainedBondsList): pid1 = bond[0] pid2 = bond[1] dist2 = sqrlen( self.system.bc.getMinimumImageVector( self.system.storage.getParticle(pid1).pos, self.system.storage.getParticle(pid2).pos)) self.assertAlmostEqual(constraintDist2[i], dist2, places=6) #check velocities after 5 steps of deterministic simulation vsum = 0.0 for pid in xrange(1, 6): part = self.system.storage.getParticle(pid) vsum += sqrlen(part.v) self.assertAlmostEqual(vsum, 0.3842668659, places=6)