Exemplo n.º 1
0
    def test_real_units(self):
        L = PyLammps()
        L.units('real') # angstrom, kcal/mol, femtoseconds
        L.atom_style('atomic')
        L.boundary('p p p')

        L.lattice('none', 1.0)

        # create simulation cell
        L.region('r1 block', -15.0, 15.0, -15.0, 15.0, -15.0, 15.0)
        L.create_box(1, 'r1')

        # argon
        L.mass(1, 39.948002)
        L.pair_style('lj/cut', 8.5)
        L.pair_coeff(1, 1, 0.2379, 3.405)

        L.timestep(10.0)

        L.create_atoms(1, 'single', -1.0, 0.0, 0.0)
        L.create_atoms(1, 'single',  1.0, 0.0, 0.0)

        L.velocity('all create', 250.0, 54321, 'mom no rot no')

        L.minimize(1.0e-10, 1.0e-10, 100, 1000)

        L.reset_timestep(0)

        L.thermo(100)
        L.fix('f1 all nve')
        L.run(1000)
Exemplo n.º 2
0
    def test_melt_using_groups(self):
        """ 3d Lennard-Jones melt with two atom types """
        L = PyLammps()
        L.units('lj')
        L.atom_style('atomic')
        L.lattice('fcc', 0.8442) # NOTE: lattice command is different in LJ units
        L.region('whole block', 0.0, 10.0, 0, 10, 0, 10)
        L.create_box(2, 'whole')
        L.region('upper block', 4.9, 10.1, 'EDGE EDGE EDGE EDGE')
        L.region('lower block', 0.0,  4.9, 'EDGE EDGE EDGE EDGE')

        # fill box with atoms according to lattice positions
        L.create_atoms(1, 'region upper')
        L.create_atoms(2, 'region lower')

        L.mass(1, 1.0)
        L.mass(2, 2.0)

        L.group('gu', 'type', 1)
        L.group('gl', 'type', 2)

        L.velocity('gu', 'create 2.0 12345 mom no rot no')
        L.velocity('gl', 'create 4.0 54321 mom no rot no')


        L.timestep(0.002)
        L.pair_style('lj/cut', 2.5)
        L.pair_coeff('* *', 1.0, 1.0, 2.5)
        L.fix('f1 all nve')

        #L.dump('d1 all image 500 snap-03.*.jpg type type')

        L.thermo(50)
        L.run(500)
Exemplo n.º 3
0
    def test_melt(self):
        """ 3d Lennard-Jones melt """
        L = PyLammps()
        L.units('lj')
        L.atom_style('atomic')

        L.lattice('fcc', 0.8442)   # NOTE: lattice command is different in LJ units
                                   #       0.8442 is density fraction
        L.region('r1 block', 0, 10, 0, 10, 0, 10)
        L.create_box(1, 'r1')

        # fill box with atoms according to lattice positions
        L.create_atoms(1, 'box')
        L.mass(1, 1.0)
        L.velocity('all create', 3.0, 87287, 'mom no')

        L.timestep(0.002)

        L.pair_style('lj/cut', 2.5)
        L.pair_coeff(1, 1, 1.0, 1.0, 2.5)
        L.fix('f1 all nve')

        L.dump('d1 all image 500 snap-01.*.jpg type type')

        L.thermo(50)
        L.run(500)

        self.assertTrue(os.path.exists('snap-01.0.jpg'))
        self.assertTrue(os.path.exists('snap-01.500.jpg'))
        os.remove('snap-01.0.jpg')
        os.remove('snap-01.500.jpg')
Exemplo n.º 4
0
    def setUp(self):
        """create 3d rocksalt-like structure"""
        L = PyLammps()
        L.units('real')         # kcal/mol, Angstrom, picoseconds
        L.atom_style('charge')  # atomic + charge

        # lattice for Na+ ions and box
        L.lattice('fcc', 6.0, 'origin', 0.0, 0.0, 0.0)
        L.region('r1', 'block', -3, 3,-3, 3,-3, 3)
        L.create_box(2, 'r1')

        # fill box with Na+ ions according to lattice positions
        L.create_atoms(1, 'box')

        # new lattice for Cl- ions shifted by half box diagonal
        L.lattice('fcc', 6.0, 'origin', 0.5, 0.5, 0.5)
        L.create_atoms(2, 'box')

        L.mass(1, 22.989770)
        L.mass(2, 35.453)
        L.set('type', 1, 'charge',  1.0)
        L.set('type', 2, 'charge', -1.0)

        L.group('na type', 1)
        L.group('cl type', 2)

        L.velocity('all create', 800.0, 12345, 'mom no rot no')
        L.timestep(0.001)
        self.L = L
Exemplo n.º 5
0
def data(i):
    lmp1 = lammps()
    polymer = PyLammps(ptr=lmp1)
    x = 60
    y = 30
    z = 30
    t = 1
    polymer.units("lj")
    polymer.dimension(3)
    polymer.atom_style("bond")
    polymer.bond_style("harmonic")
    polymer.pair_style("lj/cut", 3)
    polymer.read_data("data.polymer")
    polymer.region("void cylinder x", 15, 15, 2, 29, 31)
    polymer.pair_coeff(1, 2, 2.5, 3)
    polymer.pair_coeff(1, 3, 2.5, 1.12)
    polymer.pair_coeff(2, 3, 2.5, 1.12)
    polymer.velocity("all create", t, 97287)
    polymer.group("polymer type", 1, 2)
    polymer.group("first type", 1)
    polymer.region("box block", 0, x, 0, y, 0, z)
    polymer.region("spherein sphere", 29, 15, 15, 2)
    polymer.region("boxin block", 27, 29, 13, 17, 13, 17)
    polymer.region("hemiin intersect", 2, "boxin spherein")
    x0 = polymer.atoms[0].position[0]
    y0 = polymer.atoms[0].position[1]
    z0 = polymer.atoms[0].position[2]
    r = lambda x0, y0, z0: np.sqrt((x0 - 29)**2 + (y0 - 15)**2 + (z0 - 15)**2)
    fx = lambda x0, y0, z0: 5 * (x0 - 29) / r(x0, y0, z0)
    fy = lambda x0, y0, z0: 5 * (y0 - 15) / r(x0, y0, z0)
    fz = lambda x0, y0, z0: 5 * (z0 - 15) / r(x0, y0, z0)
    polymer.fix(1, "polymer nve")
    polymer.fix(2, "polymer langevin", t, t, 1.5,
                np.random.randint(2, high=200000))
    polymer.fix(3, "polymer spring tether", 10, i, "NULL NULL", 0)
    polymer.timestep(0.01)
    polymer.compute("com polymer com")
    polymer.variable("ftotal equal fcm(polymer,x)")
    polymer.variable("c equal c_com[1]")
    polymer.thermo_style("custom v_ftotal v_c")
    polymer.thermo(1)
    polymer.run(500000)
    l = polymer.runs[0][0][1][20000:] + [i]
    u = [np.mean(polymer.runs[0][0][0][20000:]), i]
    np.savetxt("trial%dmean.txt" % i, u)
    np.savetxt("trial%dall.txt" % i, l)
    return u
Exemplo n.º 6
0
continueprevsim = False

#reset geometry after every run?
resetgeom = False
selectfromNIST = True

# MD PARAMETERS:
L.units("metal")
L.atom_style("atomic")
L.atom_modify("map array")

latticeconst = 4.08
dispthresh = (4.08 + 3.52) / 2 / math.sqrt(2) * 0.90
NNthresh = (4.08 + 3.52) / 2 / math.sqrt(2) * 1.2

L.timestep(0.0005)  # time-step in ps (metal units)
dsub = 10

density = 2000
Amass = 12.011 * 1.660538E-27
nPartsub = int(round(Lsub * Lsub * dsub * 1e-30 * density / Amass))
print(nPartsub)

#Au-C: (Lewis.2000)
sigAuC = 2.74  # in A
epsAuC = 0.022  # in eV

#Ni-C: (Huang.2003, Ryu2010)
sigNiC = 2.852
epsNiC = 0.023049
Exemplo n.º 7
0
py_lmp.boundary("p p p")
py_lmp.lattice("sc", 1 / (run_args.cell_size**3))
py_lmp.region("box", "block", -run_args.num_cells / 2, run_args.num_cells / 2,
              -run_args.num_cells / 2, run_args.num_cells / 2,
              -run_args.num_cells / 2, run_args.num_cells / 2)
simulation.setup("box")
simulation.create_rods(box=None)

# ROD DYNAMICS
py_lmp.fix("thermostat", "all", "langevin", run_args.temp, run_args.temp,
           run_args.damp, seed)  #, "zero yes")

simulation.set_rod_dynamics("nve", opt=["mol", model.rod_states[0]])

py_lmp.neigh_modify("every 1 delay 1")
py_lmp.timestep(run_args.dt)

# THERMALIZE INITIAL CONFIGURATION
simulation.deactivate_state(0, vx_eps=5.0)
py_lmp.run(1000)
simulation.activate_state(0)
py_lmp.reset_timestep(0)

# GROUPS & COMPUTES
if hasattr(run_args, 'label_micelles'):
    micelle_group = 'sol_tips'
    sol_tip_bead_type = model.state_structures[0][0][-1]
    py_lmp.variable(micelle_group, 'atom',
                    '"type == {:d}"'.format(sol_tip_bead_type))
    py_lmp.group(micelle_group, 'dynamic', simulation.rods_group, 'var',
                 micelle_group, 'every', out_freq)
Exemplo n.º 8
0
    def test_use_data_file(self):
        L = PyLammps()
        L.units('real') # angstrom, kcal/mol, femtoseconds
        L.atom_style('atomic')
        L.boundary('p p p')

        L.lattice('none', 1.0)

        # create simulation cell
        L.region('r1 block', -15.0, 15.0, -15.0, 15.0, -15.0, 15.0)
        L.create_box(1, 'r1')

        # argon
        L.mass(1, 39.948002)
        L.pair_style('lj/cut', 8.5)
        L.pair_coeff(1, 1, 0.2379, 3.405)

        L.timestep(10.0)

        L.create_atoms(1, 'single', -1.0, 0.0, 0.0)
        L.create_atoms(1, 'single',  1.0, 0.0, 0.0)

        L.velocity('all create', 250.0, 54321, 'mom no rot no')

        L.minimize(1.0e-10, 1.0e-10, 100, 1000)

        L.reset_timestep(0)

        L.thermo(100)
        L.fix('f1 all nve')
        L.run(1000)

        L.write_restart('run.restart')
        L.write_data('run.data')

        L2 = PyLammps()
        L2.units('real')           # angstrom, kcal/mol, femtoseconds
        L2.atom_style('atomic')
        L2.boundary('p p p')

        L2.pair_style('lj/cut', 8.5)
        L2.read_data('run.data')

        L2.timestep(10.0)

        L2.thermo(100)
        L2.fix('f1 all nve')
        L2.run(1000)

        # reset status. forget all settings. delete system
        L2.clear()

        L2.read_restart('run.restart')

        L2.thermo(100)
        L2.fix('f1 all nve')
        L2.run(1000)

        os.remove('run.restart')
        os.remove('run.data')

        self.assertEqual(L.system, L2.system)