Example #1
0
    def optimize(self, n_steps):

        # set up initial system
        current_system = System(self.system.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 optimize trajectory
        self.opt_systems.append(current_system)

        # crude optimization
        for i in range(n_steps):
            # generate trial system
            trial_system = MetropolisMonteCarlo.generate_trial_configuration(
                self.opt_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.opt_systems.append(
                MetropolisMonteCarlo.evaluate_trial_configuration_greedy(
                    self.opt_systems[-1], trial_system))

        # interim update_radius
        update_radius = self.parameters.update_radius
        self.parameters.update_radius = update_radius / 10

        # fine optimization
        for i in range(100):
            # generate trial system
            trial_system = MetropolisMonteCarlo.generate_trial_configuration(
                self.opt_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.opt_systems.append(
                MetropolisMonteCarlo.evaluate_trial_configuration_greedy(
                    self.opt_systems[-1], trial_system))

        # resetting update_radius to desired value
        self.parameters.update_radius = update_radius
Example #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))
    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))
    def optimize(self, n_steps):
        raise NotImplementedError()

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

        for i in range(n_steps):
            trial_system = MetropolisMonteCarlo.generate_trial_configuration(
                current_system, self.parameters)
            trial_system.energy = calculate_energy()  # not implemented yet
            current_system = MetropolisMonteCarlo.evaluate_trial_configuration_greedy(
                current_system, trial_system)

        self.opt_system = current_system