MonteCarloMoves
Functions
FreeBird.MonteCarloMoves
— ModuleMonteCarloMoves
Module containing functions for performing Monte Carlo moves on atomistic/lattice systems.
FreeBird.MonteCarloMoves.MC_new_sample!
— MethodMC_new_sample!(lattice::LatticeWalker, h::ClassicalHamiltonian, emax::Float64; energy_perturb::Float64=0.0)
Generate a new sample for the lattice system.
Arguments
lattice::LatticeWalker
: The walker to generate a new sample for.h::ClassicalHamiltonian
: The Hamiltonian containing the on-site and nearest-neighbor interaction energies.emax::Float64
: The maximum energy allowed for accepting a move.energy_perturb::Float64=0.0
: The energy perturbation used to make degenerate configurations distinguishable.
Returns
accept_this_walker::Bool
: Whether the walker is accepted or not.lattice::LatticeWalker
: The updated walker.
FreeBird.MonteCarloMoves.MC_random_swap!
— MethodMC_random_swap!(n_steps::Int, at::AtomWalker{C}, lj::LennardJonesParametersSets, emax::typeof(0.0u"eV"))
Perform a Monte Carlo random swap of two atoms in the AtomWalker
. Only works when there are two or more non-frozen components.
Arguments
n_steps::Int
: The number of Monte Carlo steps to perform.at::AtomWalker{C}
: TheAtomWalker
object.lj::LennardJonesParametersSets
: The Lennard-Jones parameters.emax::typeof(0.0u"eV")
: The maximum energy allowed for accepting a move.
Returns
accept_this_walker::Bool
: Whether the walker is accepted or not.accept_rate::Float64
: The acceptance rate of the random walk.at::AtomWalker{C}
: The updatedAtomWalker
.
FreeBird.MonteCarloMoves.MC_random_walk!
— MethodMC_random_walk!(n_steps::Int, lattice::LatticeWalker, h::ClassicalHamiltonian, emax::Float64; energy_perturb::Float64=0.0)
Perform a Monte Carlo random walk on the lattice system.
Arguments
n_steps::Int
: The number of Monte Carlo steps to perform.lattice::LatticeWalker
: The walker to perform the random walk on.h::ClassicalHamiltonian
: The lattice gas Hamiltonian.emax::Float64
: The maximum energy allowed for accepting a move.energy_perturb::Float64=0.0
: The energy perturbation used to make degenerate configurations distinguishable.
Returns
accept_this_walker::Bool
: Whether the walker is accepted or not.accept_rate::Float64
: The acceptance rate of the random walk.lattice::LatticeWalker
: The updated walker.
FreeBird.MonteCarloMoves.MC_random_walk!
— MethodMC_random_walk!(n_steps::Int, at::AtomWalker, lj::LJParameters, step_size::Float64, emax::typeof(0.0u"eV"))
Perform a Monte Carlo random walk on the atomic/molecular system.
Arguments
n_steps::Int
: The number of Monte Carlo steps to perform.at::AtomWalker{C}
: The walker to perform the random walk on.lj::LennardJonesParametersSets
: The Lennard-Jones potential parameters.step_size::Float64
: The maximum distance an atom can move in any direction.emax::typeof(0.0u"eV")
: The maximum energy allowed for accepting a move.
Returns
accept_this_walker::Bool
: Whether the walker is accepted or not.accept_rate::Float64
: The acceptance rate of the random walk.at::AtomWalker
: The updated walker.
FreeBird.MonteCarloMoves.MC_random_walk_2D!
— MethodMC_random_walk_2D!(n_steps::Int, at::AtomWalker, lj::LJParameters, step_size::Float64, emax::typeof(0.0u"eV"); dims::Vector{Int}=[1,2])
Perform a Monte Carlo random walk on the atomic/molecular system in 2D.
Arguments
n_steps::Int
: The number of Monte Carlo steps to perform.at::AtomWalker{C}
: The walker to perform the random walk on.lj::LennardJonesParametersSets
: The Lennard-Jones potential parameters.step_size::Float64
: The maximum distance an atom can move in any direction.emax::typeof(0.0u"eV")
: The maximum energy allowed for accepting a move.dims::Vector{Int}=[1,2]
: The dimensions in which the random walk is performed.
Returns
accept_this_walker::Bool
: Whether the walker is accepted or not.accept_rate::Float64
: The acceptance rate of the random walk.at::AtomWalker
: The updated walker.
FreeBird.MonteCarloMoves.MC_rejection_sampling!
— MethodMC_rejection_sampling!(lattice::LatticeWalker, h::ClassicalHamiltonian, emax::Float64; energy_perturb::Float64=0.0, max_iter=10_000)
Perform a Monte Carlo rejection sampling on the lattice system.
Arguments
lattice::LatticeWalker
: The walker to perform the rejection sampling on.h::ClassicalHamiltonian
: The Hamiltonian containing the on-site and nearest-neighbor interaction energies.emax::Float64
: The maximum energy allowed for accepting a move.energy_perturb::Float64=0.0
: The energy perturbation used to make degenerate configurations distinguishable.max_iter::Int=10_000
: The maximum number of iterations to perform.
Returns
accept_this_walker::Bool
: Whether the walker is accepted or not.lattice::LatticeWalker
: The updated walker.
FreeBird.MonteCarloMoves.free_component_index
— Methodfree_component_index(at::AtomWalker{C}) where C
Get the indices of the free particles in each component of the AtomWalker
.
Returns
ind_free_parts::Array{Vector{Int}}
: An array of vectors containing the indices of the free particles in each component.
FreeBird.MonteCarloMoves.free_par_index
— Methodfree_par_index(at::AtomWalker{C}) where C
Get the indices of the free particles in the AtomWalker
.
FreeBird.MonteCarloMoves.generate_random_new_lattice_sample!
— Methodgenerate_random_new_lattice_sample!(lattice::SLattice)
Generate a new random sample for the single-component lattice system.
FreeBird.MonteCarloMoves.generate_random_new_lattice_sample!
— Methodgenerate_random_new_lattice_sample!(lattice::MLattice{C}) where C
Generate a new random sample for the multi-component lattice system.
Arguments
lattice::MLattice{C}
: The lattice system to generate a new sample for.
Returns
lattice::MLattice{C}
: The updated lattice system.
FreeBird.MonteCarloMoves.mean_sq_displacement
— Methodmean_sq_displacement(at::AtomWalker, at_orig::AtomWalker)
Calculate the mean squared displacement before and after random walk(s). Note that due to the current implementation of the periodic boundary wrap, this function is not appropriate to use for calculating mean displacements in a propagation.
Arguments
at::AtomWalker{C}
: The currentAtomWalker
after the random walk.at_orig::AtomWalker{C}
: The originalAtomWalker
before the random walk.
Returns
distsq::typeof(0.0u"Å"^2)
: The mean squared displacement of all free particles.
FreeBird.MonteCarloMoves.periodic_boundary_wrap!
— Methodperiodic_boundary_wrap!(pos::SVector{3,T}, system::AbstractSystem) where T
Wrap the position vector pos
according to the periodic boundary conditions of the system
. If the boundary condition is Periodic()
, the position is wrapped using the modulo operator. If the boundary condition is DirichletZero()
, the position is wrapped by reflecting the position vector across the boundary.
Arguments
pos::SVector{3,T}
: The position vector to be wrapped.system::AbstractSystem
: The system containing the periodic boundary conditions.
Returns
The wrapped position vector.
FreeBird.MonteCarloMoves.single_atom_random_walk!
— Methodsingle_atom_random_walk!(pos::SVector{3,T}, step_size::Float64) where T
Perform a single atom random walk by updating the position pos
in each direction by a random amount. The step_size
determines the maximum distance the atom can move in any direction.
Arguments
pos::SVector{3,T}
: The current position of the atom as a 3D vector.step_size::Float64
: The maximum distance the atom can move in any direction.
Returns
pos
: The updated position of the atom.
FreeBird.MonteCarloMoves.two_atoms_swap!
— Methodtwo_atoms_swap!(at::AtomWalker{C}, ind1, ind2) where C
Swap the positions of two atoms in the AtomWalker
.
Arguments
at::AtomWalker{C}
: TheAtomWalker
object.ind1::Int
: The index of the first atom.ind2::Int
: The index of the second atom.
Returns
at::AtomWalker{C}
: The updatedAtomWalker
.