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
示例#2
0
    def test_cap_force_array_group(self):
        # set up normal domain decomposition
        nodeGrid = espressopp.tools.decomp.nodeGrid(
            espressopp.MPI.COMM_WORLD.size)
        cellGrid = espressopp.tools.decomp.cellGrid(self.box, nodeGrid, 1.5,
                                                    0.3)
        self.system.storage = espressopp.storage.DomainDecomposition(
            self.system, nodeGrid, cellGrid)

        # add some particles (normal, coarse-grained particles only)
        particle_list = [
            (1, 0, 0, espressopp.Real3D(4.95, 5.0, 5.0), 1.0, 0, 1.),
            (2, 0, 0, espressopp.Real3D(5.05, 5.0, 5.0), 1.0, 0, 1.),
        ]
        self.system.storage.addParticles(particle_list, 'id', 'type', 'q',
                                         'pos', 'mass', 'adrat', 'radius')
        self.system.storage.decompose()

        # integrator
        integrator = espressopp.integrator.VelocityVerlet(self.system)
        integrator.dt = 0.005

        # Lennard-Jones with Verlet list
        rc_lj = pow(2.0, 1.0 / 6.0)
        vl = espressopp.VerletList(self.system, cutoff=rc_lj)
        potLJ = espressopp.interaction.LennardJones(epsilon=1.,
                                                    sigma=1.,
                                                    cutoff=rc_lj,
                                                    shift=0)
        interLJ = espressopp.interaction.VerletListLennardJones(vl)
        interLJ.setPotential(type1=0, type2=0, potential=potLJ)
        self.system.addInteraction(interLJ)

        # create a ParticleGroup instance
        particle_group = espressopp.ParticleGroup(self.system.storage)
        particle_group.add(1)

        # create a CapForce instance
        capforce = espressopp.integrator.CapForce(
            self.system, espressopp.Real3D(1.0, 1.0, 1.0), particle_group)
        integrator.addExtension(capforce)

        # run 1 step
        integrator.run(1)

        particle1 = self.system.storage.getParticle(1)
        particle2 = self.system.storage.getParticle(2)
        print(particle1.f, particle2.f)

        # run checks
        self.assertTrue(
            math.fabs(particle1.f[0]) == 1.0,
            "The force of particle 1 is not capped.")
        self.assertTrue(
            math.fabs(particle2.f[0]) > 1.0,
            "The force of particle 2 is capped.")
示例#3
0
#                                                                          		     #
##############################################################################################

import espressopp

# create default Lennard Jones (WCA) system with 0 particles and cubic box (L=10)
system, integrator = espressopp.standard_system.LennardJones(
    0, (10 * 1.12, 10 * 1.12, 10 * 1.12))

C_FIXED = 1
C_FREE = 0
# fix x,y and z coord axis
fixMask = espressopp.Int3D(C_FREE, C_FIXED, C_FREE)

# create a particel group that will contain the fixed particles
fixedWall = espressopp.ParticleGroup(system.storage)

# add a particle wall
pid = 1
for k in range(10):
    for l in range(10):
        system.storage.addParticle(pid,
                                   espressopp.Real3D(k * 1.12, 5, l * 1.12))
        fixedWall.add(pid)
        pid += 1

# add also one free particle
system.storage.addParticle(0, espressopp.Real3D(5.8, 9, 5.5))
system.storage.modifyParticle(0, 'v', espressopp.Real3D(0, -0.1, 0))

# don't forget do decompose !
示例#4
0
#add particles to the system
particles     = []
property_list = ['id', 'pos']
for k in range(num_particles):
  particles.append([k, espressopp.Real3D(2*Lx+x[k], y[k], z[k])])
  # add particles in chunks of 1000 (this is faster than doing it one by one)
  if k % 1000 == 0:
    system.storage.addParticles(particles, *property_list)
    system.storage.decompose()
    particles = []
system.storage.addParticles(particles, *property_list)
system.storage.decompose()

# specify particles that will be affected by external field
# if external field should be applied to all particles of the system set ef_particleGroup=None
ef_particleGroup  = espressopp.ParticleGroup(system.storage)
for k in range(num_particles):
  particles.append([k, espressopp.Real3D(x[k], y[k], z[k])])
  if k%N>0 and k%N<N-1 :
    ef_particleGroup.add(k)

# define external force
ext_force = espressopp.integrator.ExtForce(system, espressopp.Real3D(1,0,0), ef_particleGroup)

# add external force to the integrator
integrator.addExtension(ext_force)

sock = espressopp.tools.vmd.connect(system)
for i in range(1000):
  # make 10 Velocity-Verlet integration steps
  integrator.run(10)