Ejemplo n.º 1
0
    def test_shift_position(self):
        particle_type = ParticleType(name="Hydrogen",
                                     mass=1.008,
                                     charge=1.602,
                                     lj_epsilon=0.21,
                                     lj_sigma=2.5)
        particle_type = np.array([particle_type])

        parameters = Parameters(temperature=0,
                                box=np.array([12., 13., 14.]),
                                es_sigma=0.5,
                                update_radius=1,
                                particle_types=particle_type,
                                cutoff_radius=3,
                                K_cutoff=1)
        reference_pos1 = np.array([1.5, 1.0, 1.5])
        reference_pos2 = np.array([10.5, 12.0, 5.5])
        particle_position_1 = np.array([13.5, 14., 15.5])
        shifted_position_1 = MetropolisMonteCarlo._shift_position(
            particle_position_1, parameters)
        particle_position_2 = np.array([-1.5, -1., 5.5])
        shifted_position_2 = MetropolisMonteCarlo._shift_position(
            particle_position_2, parameters)
        npt.assert_equal(reference_pos1,
                         shifted_position_1,
                         'Failed',
                         verbose=True)
        npt.assert_equal(reference_pos2,
                         shifted_position_2,
                         'Failed',
                         verbose=True)
    def test_shift_position_1(self):

        position = np.array([0.5, 0.5, 0.5])

        # set test parameters
        charges = np.ones(10).astype(np.float32)
        lj_sigmas = np.ones(10).astype(np.float32)
        lj_epsilons = np.ones(10).astype(np.float32)

        para = Parameters(temperature=1,
                          box=np.array([1, 1, 1]),
                          update_radius=1,
                          charges=charges,
                          lj_sigmas=lj_sigmas,
                          lj_epsilons=lj_epsilons,
                          update_probability=0.5,
                          accuracy=1)

        actual = MetropolisMonteCarlo._shift_position(position, para)

        npt.assert_array_equal(actual, position)
Ejemplo n.º 3
0
    def test_shift_position_4(self):

        position = np.array([-1.3, 2.4, -3.4])

        # set test parameters
        charges = np.ones(10).astype(np.float32)
        lj_sigmas = np.ones(10).astype(np.float32)
        lj_epsilons = np.ones(10).astype(np.float32)

        para = Parameters(temperature=1,
                          box=np.array([1, 1, 1]),
                          es_sigma=1,
                          update_radius=1,
                          charges=charges,
                          lj_sigmas=lj_sigmas,
                          lj_epsilons=lj_epsilons,
                          update_probability=0.5,
                          accuracy=1)

        actual = MetropolisMonteCarlo._shift_position(position, para)
        reference = np.array([0.7, 0.4, 0.6])

        npt.assert_array_almost_equal(actual, reference)