Esempio n. 1
0
    def test_stability(self):
        s = espressomd.System(box_l=[1.0, 1.0, 1.0])
        s.seed = s.cell_system.get_state()['n_nodes'] * [1234]
        box_yz = 15.
        box_x = 20.
        s.box_l = [box_x, box_yz, box_yz]
        s.time_step = 0.01
        s.cell_system.skin = 0.4

        lj_eps = 1.0
        lj_sig = 1.0
        lj_cut = lj_sig * 2**(1. / 6.)

        s.constraints.add(particle_type=0,
                          penetrable=False,
                          only_positive=False,
                          shape=SimplePore(
                              axis=[1., 0.5, 0.5],
                              radius=3.,
                              smoothing_radius=.1,
                              length=5,
                              center=[.5 * box_x, .5 * box_yz, .5 * box_yz]))
        s.constraints.add(particle_type=0,
                          penetrable=False,
                          only_positive=False,
                          shape=Cylinder(
                              axis=[1., 0.0, 0],
                              radius=0.5 * box_yz,
                              length=4 * lj_cut + box_x,
                              center=[.5 * box_x, .5 * box_yz, .5 * box_yz],
                              direction=-1))

        s.non_bonded_inter[0, 1].lennard_jones.set_params(epsilon=lj_eps,
                                                          sigma=lj_sig,
                                                          cutoff=lj_cut,
                                                          shift="auto")

        for i in range(200):
            rpos = [i * (box_x / 200.), 0.5 * box_yz, 0.5 * box_yz]
            s.part.add(id=i, pos=rpos, type=1, v=[1., 1., 1.])

        start_energy = s.analysis.energy()['total']
        s.integrator.run(1000)
        end_energy = s.analysis.energy()['total']
        rel_diff = abs(end_energy - start_energy) / start_energy

        self.assertLess(rel_diff, 1e-3)
Esempio n. 2
0
system.time_step = TIME_STEP
system.min_global_cut = 0.5
system.thermostat.set_langevin(kT=1.0, gamma=1.0, seed=42)

##########################################################################
#
# Here we use exactly the same parameters for the geometry of the constraints
# that was used for the LB boundaries. This can be done, since the distance
# function used for the constraints is the same as the one used for the
# LB boundaries.
#
##########################################################################

cylinder = Cylinder(center=0.5 * BOX_L,
                    axis=[1, 0, 0],
                    radius=DIAMETER / 2.0,
                    length=LENGTH,
                    direction=-1)
system.constraints.add(shape=cylinder, particle_type=1)

# Setup walls
wall = Wall(dist=PADDING, normal=[1, 0, 0])
system.constraints.add(shape=wall, particle_type=1)

wall = Wall(dist=-(LENGTH + PADDING), normal=[-1, 0, 0])
system.constraints.add(shape=wall, particle_type=1)

# Setup cone
IRAD = 4.0
ANGLE = pi / 4.0
ORAD = (DIAMETER - IRAD) / sin(ANGLE)
Esempio n. 3
0
################################################################################
#
# Now we set up the three LB boundaries that form the rectifying geometry.
# The cylinder boundary/constraint is actually already capped, but we put
# in two planes for safety's sake. If you want to create a cylinder of
# 'infinite length' using the periodic boundaries, then the cylinder must
# extend over the boundary.
#
##########################################################################

# Setup cylinder

cylinder = LBBoundary(
    shape=Cylinder(
        center=[length / 2.0, (diameter + 4) / 2.0, (diameter + 4) / 2.0],
        axis=[1, 0, 0], radius=diameter / 2.0, length=length, direction=-1))
system.lbboundaries.add(cylinder)

# Setup walls

## Exercise 1 ##
# Set up two walls to cap the cylinder a distance of 2 away
# from the edge of the box, with a normal along the x-axis
wall = ...

# Setup cone

irad = 4.0
angle = pi / 4.0
orad = (diameter - irad) / sin(angle)
##########################################################################
#
# Now we set up the three LB boundaries that form the rectifying geometry.
# The cylinder boundary/constraint is actually already capped, but we put
# in two planes for safety's sake. If you want to create a cylinder of
# 'infinite length' using the periodic boundaries, then the cylinder must
# extend over the boundary.
#
##########################################################################

# Setup cylinder

cylinder = LBBoundary(
    shape=Cylinder(
        center=BOX_L / 2.,
        axis=[1, 0, 0], radius=DIAMETER / 2.0, length=LENGTH, direction=-1))
system.lbboundaries.add(cylinder)

# Setup walls

## Exercise 1 ##
# Set up two walls to cap the cylinder respecting the padding
# between them and the edge of the box, with a normal along the x-axis
wall = ...

# Setup cone

IRAD = 4.0
ANGLE = pi / 4.0
ORAD = (DIAMETER - IRAD) / sin(ANGLE)
Esempio n. 5
0
##########################################################################
#
# Here we use exactly the same parameters for the geometry of the constraints
# that was used for the LB boundaries. This can be done, since the distance
# function used for the constraints is the same as the one used for the
# LB boundaries.
#
##########################################################################

## Exercise 2 ##
# Complete the geometry from the LB-based
# script. You need to add types to the walls
# and cone as well.

cylinder = Cylinder(...)
system.constraints.add(shape=cylinder, particle_type=1)

# Setup walls

wall = Wall(...)
system.constraints.add(shape=wall, particle_type=1)

wall = Wall(...)
system.constraints.add(shape=wall, particle_type=1)

# Setup cone

...

hollow_cone = HollowCone(...)