npl.monte_carlo package

Subpackages

Submodules

npl.monte_carlo.monte_carlo module

npl.monte_carlo.monte_carlo.mc_run(beta, max_steps, start_particle, energy_calculator, local_feature_classifier)[source]
npl.monte_carlo.monte_carlo.run_monte_carlo_for_adsorbates(beta, max_steps, start_particle, adsorbates_energy, n_adsorbates)[source]
npl.monte_carlo.monte_carlo.run_monte_carlo_ordering_adsorbates(beta, max_steps, start_particle, ordering_energy_calculator, adsorbates_energy_calculator, n_adsorbates, local_feature_classifier)[source]
npl.monte_carlo.monte_carlo.setup_monte_carlo(start_particle, energy_calculator, local_feature_classifier)[source]
npl.monte_carlo.monte_carlo.update_atomic_features(exchanges, local_env_calculator, local_feature_classifier, particle)[source]

npl.monte_carlo.monte_carlo_etop module

npl.monte_carlo.monte_carlo_etop.features_to_update(start_particle, exchanges)[source]
npl.monte_carlo.monte_carlo_etop.run_monte_carlo(temperature, max_steps, start_particle, energy_calculator, feature_classifier)[source]
npl.monte_carlo.monte_carlo_etop.setup_monte_carlo(start_particle, energy_calculator, feature_classifier)[source]

npl.monte_carlo.monte_carlo_global_features module

npl.monte_carlo.monte_carlo_global_features.run_monte_carlo(beta, max_steps, start_particle, energy_calculator, feature_classifier)[source]
npl.monte_carlo.monte_carlo_global_features.setup_monte_carlo(start_particle, energy_calculator, feature_classifier)[source]

npl.monte_carlo.random_exchange_operator module

class npl.monte_carlo.random_exchange_operator.RandomExchangeOperator(p_geometric)[source]

Bases: object

bind_adsorbates(particle, n_adsorbates)[source]
bind_particle(particle)[source]
coupled_random_exchange(particle)[source]
random_adsorbate_migration(particle)[source]
random_exchange(particle)[source]

npl.monte_carlo.random_exchange_operator_etop module

class npl.monte_carlo.random_exchange_operator_etop.RandomExchangeOperatorExtended(p_geometric)[source]

Bases: RandomExchangeOperator

bind_particle(particle)[source]
get_swap_porbability(symbols_indices)[source]
random_exchange(particle)[source]

Module contents

class npl.monte_carlo.BaseEnsemble(atoms: Atoms, calculator: Calculator, user_tag: str | None = None, random_seed: int | None = None, traj_file: str = 'traj_test.traj', trajectory_write_interval: int | None = None, outfile: str = 'outfile.out', outfile_write_interval: int = 10)[source]

Bases: ABC

property atoms: Atoms

Current configuration (copy).

initialize_outfile() None[source]

Initializes the output file by overwriting any existing content and writing a header.

property step: int

Current trial step counter.

write_outfile(step: int, energy: float) None[source]

Write the step and energy to the output file.

Args:

step (int): The current step. energy (float): The energy value.

write_traj_file(atoms: Atoms) None[source]

Write the trajectory file.

Args:

atoms (Atoms): The atomic configuration.

class npl.monte_carlo.CanonicalEnsemble(atoms, calculator, random_seed=None, optimizer=None, fmax=0.1, temperature=300, op_list=None, constraints=None, p=1, traj_file: str = 'traj_test.traj', outfile: str = 'outfile.out', outfile_write_interval: int = 10)[source]

Bases: BaseEnsemble

Represents a canonical ensemble for Monte Carlo simulations.

Args:

atoms (Atoms): The initial atomic configuration. calculator (Calculator): The calculator used to compute energies and forces. random_seed (int, optional): The random seed for the PRNG. Defaults to None. optimizer (Optimizer, optional): The optimizer used for relaxation. Defaults to None. fmax (float, optional): The maximum force tolerance for relaxation. Defaults to 0.1. temperature (float, optional): The temperature of the ensemble in Kelvin. Defaults to 300. steps (int, optional): The number of Monte Carlo steps to perform. Defaults to 100. op_list (OperatorList, optional): The list of operators for mutations. Defaults to None. constraints (Constraints, optional): The constraints applied to the system. Defaults to None. traj_file (str, optional): The trajectory file name. Defaults to ‘traj_test.traj’. outfile (str, optional): The output file name. Defaults to ‘outfile.out’. outfile_write_interval (int, optional): The interval at which to write to the output file. Defaults to 10.

Attributes:

lowest_energy (float): The lowest potential energy found during the simulation. atoms (Atoms): The current atomic configuration. constraints (Constraints): The constraints applied to the system. _temperature (float): The temperature of the ensemble in Kelvin. _calculator (Calculator): The calculator used to compute energies and forces. _optimizer (Optimizer): The optimizer used for relaxation. _fmax (float): The maximum force tolerance for relaxation. _steps (int): The number of Monte Carlo steps to perform. _op_list (OperatorList): The list of operators for mutations. _step (int): The current step number. _accepted_trials (int): The number of accepted trials.

do_mutation()[source]

Performs mutations on the current atomic configuration.

Returns:

Atoms: The mutated atomic configuration.

relax(atoms) Atoms[source]

Relaxes the atomic configuration using the specified optimizer.

Args:

atoms (Atoms): The atomic configuration to relax.

Returns:

Atoms: The relaxed atomic configuration.

run(steps: int = 100)[source]

Runs the Monte Carlo simulation.

Returns:

None

trial_step()[source]

Performs a trial step in the Monte Carlo simulation.

Returns:

int: 1 if the trial move is accepted, 0 otherwise.

npl.monte_carlo.mc_run(beta, max_steps, start_particle, energy_calculator, local_feature_classifier)[source]
npl.monte_carlo.run_monte_carlo(temperature, max_steps, start_particle, energy_calculator, feature_classifier)[source]