Ejemplo n.º 1
0
    def test_read_restart(self):
        L = self.L
        pe = L.eval("pe")

        L.write_restart('/tmp/test_read_restart.restart')
        del L

        L2 = PyLammps()
        L2.read_restart('/tmp/test_read_restart.restart')
        L2.run(0)
        os.remove('/tmp/test_read_restart.restart')

        self.assertEqual(L2.system.natoms, 2)
        self.assertEqual(L2.atoms[0].position, (-1.0, 0.0, 0.0))
        self.assertEqual(L2.atoms[1].position,  (1.0, 0.0, 0.0))
        self.assertEqual(L2.eval("pe"), pe)
Ejemplo n.º 2
0
    starttime = time.time()
    L.run(20000)
    print("dt at start: {} fs".format(L.eval("dt") * 1000))
    print("T at start: {} K".format(L.eval("temp")))
    print("elapsed time: {} s".format(time.time() - starttime))
    L.unfix("thermofix2")

    #initial equilibration procedure finished:
    print("****************************************")
    print("initial equilibration procedure finished, writing restart file")
    print("****************************************")

    L.write_restart("restart.equil")
    L.write_restart("restartfromprevdispl.equil")
else:
    L.read_restart("restart.equil")

L.velocity("all", "create", Temp, 12345, "dist", "gaussian", "mom", "yes",
           "rot", "yes")
#L.fix("mainvartimestep","clustergr","dt/reset",10,"NULL","NULL",latticeconst/30,"emax",0.1,"units","box")
L.fix("mainvartimestep", "clustergr", "dt/reset", 1, "NULL", "NULL", 0.1,
      "units", "box")
L.fix("linmomfix", "clustergr", "momentum", 1, "linear", 1, 1,
      1)  # remove linear momentum for better displacement detection

#L.fix("thermofix3","clustergr","langevin",Temp,Temp,0.05, 2614,"zero","yes")
#L.fix("thermofix3","clustergr","temp/csvr",Temp,Temp,0.1,12345)

nodispl = 0
nosputt = 0
displacement = False
Ejemplo n.º 3
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)
    starttime = time.time()
    L.run(20000)
    print("dt at start: {} fs".format(L.eval("dt") * 1000))
    print("T at start: {} K".format(L.eval("temp")))
    print("elapsed time: {} s".format(time.time() - starttime))
    L.unfix("thermofix2")

    #initial equilibration procedure finished:
    print("****************************************")
    print("initial equilibration procedure finished, writing restart file")
    print("****************************************")

    L.write_restart("restart.equil")
else:
    L.read_restart("restart.equil")

L.velocity("all", "create", Temp, 12345, "dist", "gaussian", "mom", "yes",
           "rot", "yes")
#L.fix("mainvartimestep","clustergr","dt/reset",10,"NULL","NULL",latticeconst/30,"emax",0.1,"units","box")
L.fix("mainvartimestep", "clustergr", "dt/reset", 1, "NULL", "NULL", 0.1,
      "units", "box")
L.fix("linmomfix", "clustergr", "momentum", 1, "linear", 1, 1,
      1)  # remove linear momentum for better displacement detection

#L.fix("thermofix3","clustergr","langevin",Temp,Temp,0.05, 2614,"zero","yes")
#L.fix("thermofix3","clustergr","temp/csvr",Temp,Temp,0.1,12345)

nodispl = 0
nosputt = 0
displacement = False