Example #1
0
 def test_potential(self):
     import copy
     si = Simulation(self.backend,
                     output_path='/tmp/test_rumd_single/trajectory',
                     steps=2000,
                     checkpoint_interval=100,
                     restart=False)
     pos0 = si.system.particle[0].position[0]
     s = copy.deepcopy(si.system)
     si.run(100)
     pos1 = si.system.particle[0].position[0]
     si.system = s
     si.run(100)
     pos2 = si.system.particle[0].position[0]
     self.assertTrue(abs(pos1 - pos0) > 1e-2)
     self.assertTrue(abs(pos1 - pos2) < 1e-4)
Example #2
0
    def test_copy_and_run(self):
        self.skipTest('skipped test')
        import copy
        import atooms.trajectory.ram
        from atooms.backends.rumd import RUMD
        import rumd
        potential = rumd.Pot_LJ_12_6(cutoff_method=rumd.ShiftedPotential)
        potential.SetVerbose(False)
        potential.SetParams(i=0, j=0, Epsilon=1.0, Sigma=1.0, Rcut=2.5)
        potential.SetParams(i=1, j=0, Epsilon=1.5, Sigma=0.8, Rcut=2.5)
        potential.SetParams(i=0, j=1, Epsilon=1.5, Sigma=0.8, Rcut=2.5)
        potential.SetParams(i=1, j=1, Epsilon=0.5, Sigma=0.88, Rcut=2.5)
        input_file = os.path.join(os.path.dirname(__file__),
                                  '../data/ka_N256_rho1.185_rumd.xyz.gz')
        backend = RUMD(input_file,
                       integrator='nvt',
                       temperature=0.8,
                       dt=0.002,
                       forcefield=[potential])
        sim = Simulation(backend,
                         output_path='/tmp/test_rumd_single/trajectory',
                         steps=100,
                         restart=False)

        # First set if runs
        # print sim.system.particle[0].position[0]
        tr = atooms.trajectory.ram.TrajectoryRamFull()
        th = atooms.trajectory.ram.TrajectoryRamFull()
        tr[0] = sim.system
        # print tr[0].particle[0].position[0]
        sim.run(1000)  # sometimes is nan, depending on steps

        # Ram does not work with rumd because of change in System init
        th[0] = sim.system
        # print sim.system.particle[0].position, sim.system.potential_energy(per_particle=True)

        sim.run(100)
        # print sim.system.particle[0].position[0]
        # this assignment leads to trouble, BUT ONLY IF WE STORE THE SAMPLES IN tr TRAJECTORY
        # assigning tr[0] above also leads to a different trajectory...!!
        sim.system = th[0]
Example #3
0
    def test_leakage(self):
        #self.skipTest('skipped test')
        from atooms.backends.rumd import System
        from atooms.trajectory.ram import TrajectoryRamFull
        from atooms.backends.rumd import unfold
        si = Simulation(self.backend,
                        output_path='/tmp/test_rumd_single/trajectory',
                        steps=2000,
                        checkpoint_interval=100,
                        restart=False)
        # self.backend.rumd_simulation.sample.__swig_destroy__(self.backend.rumd_simulation.sample)
        #del self.backend.rumd_simulation.sample

        # This does not leak memory
        trj = TrajectoryRamFull()
        trj[0] = si.system
        for i in range(5):
            si.system = trj[0]
            si.run()
            unfold(si.system).particle[0].position[0], unfold(
                trj[0]).particle[0].position[0]
Example #4
0
 def test_simulation(self):
     s = Simulation(self.backend, self.dout, steps=1)
     system = System(self.sim.sample)
     s.system = system
     s.run()