示例#1
0
    def test_evaluate_trial_configuration_1(self):

        # 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)

        particle1 = Particle(np.array([0.5, 0.5, 0.5]))
        particle2 = Particle(np.array([0.5, 0.5, 0.1]))
        particles = [particle1, particle2]

        system = System(particles=particles, parameters=para)
        system.energy.overall_energy = 1
        trial_system = System(particles=particles, parameters=para)
        trial_system.energy.overall_energy = 1

        actual = MetropolisMonteCarlo.evaluate_trial_configuration(
            system, trial_system, para)

        npt.assert_equal(actual, trial_system)
示例#2
0
    def simulate(self, n_steps):

        # set up initial system from optimized system
        current_system = System(self.opt_systems[-1].particles,
                                self.parameters)
        # pass particle positions and neighbourlist to the energy calculator class
        self.energy_calculator.set_system(
            current_system.neighbourlist.particle_positions,
            current_system.neighbourlist.cell_list,
            current_system.neighbourlist.particle_neighbour_list)
        # calculate energy of initial system
        current_system.energy = self._calculate_overall_energy()
        # append to trajectory
        self.sim_systems.append(current_system)

        for i in range(n_steps):

            # generate trial system
            trial_system = MetropolisMonteCarlo.generate_trial_configuration(
                self.sim_systems[-1], self.parameters)

            # update particle positions and neighbourlist
            self.energy_calculator.set_system(
                trial_system.neighbourlist.particle_positions,
                trial_system.neighbourlist.cell_list,
                trial_system.neighbourlist.particle_neighbour_list)

            # calculate energy of trial system
            trial_system.energy = self._calculate_overall_energy()

            # evaluate system and trial system and append the accepted system to the trajectory
            self.sim_systems.append(
                MetropolisMonteCarlo.evaluate_trial_configuration(
                    self.sim_systems[-1], trial_system, self.parameters))
示例#3
0
    def simulate(self, n_steps):
        raise NotImplementedError()

        current_system = System(self.system.particles, self.parameters)
        current_system.energy = calculate_energy()  # not implemented yet
        self.sim_systems.append(current_system)

        for i in range(n_steps):
            trial_system = MetropolisMonteCarlo.generate_trial_configuration(
                self.sim_systems[-1], self.parameters)
            trial_system.energy = calculate_energy()  # not implemented yet
            self.sim_systems.append(
                MetropolisMonteCarlo.evaluate_trial_configuration(
                    self.sim_systems[-1], trial_system))