HMC.hmc_sampler module

class ParaMol.HMC.hmc_sampler.HMCSampler

Bases: ParaMol.Tasks.task.Task

ParaMol HMC task.

static _get_parameters_rmsd(old_params, new_params)

Method that computes the RMSD between the old and new set of parameters. :param old_params: List of the old parameters. :type old_params: list :param new_params: List of the new parameters :type new_params: list

Returns

rmsd (float) – Value of the RMSD.

_hmc_acceptance_criterion_mm(pot_final, pot_initial, kin_final, kin_initial, temperature_pot, temperature_kin)

Method that accepts or rejects a configuration generated by a short MD simulation.

Parameters
  • pot_final (unit.Quantity) – Final potential energy.

  • pot_initial (unit.Quantity) – Initial potential energy.

  • kin_final (unit.Quantity) – Final kinetic energy.

  • kin_initial (unit.Quantity) – Initial kinetic energy.

  • temperature_pot (unit.Quantity) – Temperature used for the potential part.

  • temperature_kin (unit.Quantity) – Temperature used for the kinetic part.

Returns

self._last_accepted_mm (bool) – Whether or not this trial move was accepted.

_hmc_acceptance_criterion_qm(pot_final_qm, pot_initial_qm, pot_final_mm, pot_initial_mm, temperature_pot_qm, temperature_pot_mm)

Method that accepts or rejects a configuration generated into the QM Markov chain.

Parameters
  • pot_final_qm (unit.Quantity) – Final QM potential energy.

  • pot_initial_qm (unit.Quantity) – Initial QM potential energy.

  • pot_final_mm (unit.Quantity) – Final MM potential energy.

  • pot_initial_mm (unit.Quantity) – Initial MM potential energy.

  • temperature_pot_qm (unit.Quantity) – Temperature used for the QM potential part.

  • temperature_pot_mm (unit.Quantity) – Temperature used for the MM potential part.

Returns

self._last_accepted_qm (bool) – Whether or not this trial move was accepted.

_run_parametrization(settings, system, parameter_space, objective_function, optimizer, calculate_forces)

Method that performs parametrization.

Parameters
Returns

system, parameter_space, objective_function, optimizer

run_task(settings, systems, n_sweeps, n_steps_per_sweep=100, verbose_freq=10, temperature_pot_qm=Quantity(value=300, unit=kelvin), temperature_pot_mm=Quantity(value=300, unit=kelvin), temperature_kin_mm=Quantity(value=300, unit=kelvin), label='0', optimize_mm=False, ase_calculator_low_level=None, calculate_forces=False, checkpoint_freq=100, parametrization=False, sampling_mm=True, sampling_freq_mm=10, sampling_freq_qm=50, parametrization_freq=100, restart=False, seed=300204110)

Method that runs a HMC sampler.

Parameters
  • settings (dict) – Dictionary containing global ParaMol settings.

  • systems (list of ParaMol.System.system.ParaMolSystem) – List containing instances of ParaMol systems.

  • n_sweeps (int) – Number of MC sweeps to perform.

  • n_steps_per_sweep (int) – Number of MD steps per MC sweep.

  • verbose_freq (int) – Verbose frequency.

  • temperature_pot_qm (unit.Quantity) – Temperature used for the QM potential part.

  • temperature_pot_mm (unit.Quantity) – Temperature used for the MM potential part.

  • temperature_kin_mm (unit.Quantity) – Temperature used for the MM kinetic part.

  • label (int) – HMC sampler label. It has to be an integer number.

  • optimize_mm (bool) – Flag that controls whether an MM optimization is performed before the HMC run. Only used if ase_calculator_low_level is None.

  • ase_calculator_low_level (ase.calculator.*.*) – ASE calculator used for the low level chain. Useful if one wants to sample from ML potential to QM level, or from one QM level to another.

  • calculate_forces (bool) – Flag that signals whether or not to calculate forces when a structure is accepted. Only relevant for parametrization purposes (does not affect the nMC-MC algorithm in itself).

  • checkpoint_freq (int) – Frequency at which checkpoint restart files are written.

  • parametrization (bool) – Flag that controls whether parametrization is to be performed.

  • sampling_mm (bool) – Flag that controls whether or not to sample rejected MM structures for parametrization purposes.

  • sampling_freq_mm (int) – Frequency at which MM structures rejected in the QM ensemble are sampled for parametrization purposes (currently not implemented).

  • sampling_freq_qm (int) – Frequency at which QM structures accepted into QM ensemble are sampled for parametrization purposes.

  • parametrization_freq (int) – Number of structures that have to be collected before performing a parametrization step.

  • restart (bool) – Flag that controls whether or not to start from a restart file.

  • seed (int) – Numpy random seed.

Returns

systems (list) – List with the updated instances of ParaMol System.

run_task_ase_one_layer(settings, systems, n_sweeps, n_steps_per_sweep=100, verbose_freq=1, temperature_pot_mm=Quantity(value=300, unit=kelvin), temperature_kin_mm=Quantity(value=300, unit=kelvin), label='0', checkpoint_freq=100, restart=False)

Method that runs a HMC sampler.

Parameters
  • settings (dict) – Dictionary containing global ParaMol settings.

  • systems (list of ParaMol.System.system.ParaMolSystem) – List containing instances of ParaMol systems.

  • n_sweeps (int) – Number of MC sweeps to perform.

  • n_steps_per_sweep (int) – Number of MD steps per MC sweep.

  • verbose_freq (int) – Verbose frequency.

  • temperature_pot_mm (unit.Quantity) – Temperature used for the MM potential part.

  • temperature_kin_mm (unit.Quantity) – Temperature used for the MM kinetic part.

  • label (int) – HMC sampler label. It has to be an integer number.

  • checkpoint_freq (int) – Frequency at which checkpoint restart files are written.

  • restart (bool) – Flag that controls whether or not to perform a restart.

Returns

systems (list) – List with the updated instances of ParaMol System.