MonteCarloMoves

Functions

FreeBird.MonteCarloMoves.MC_new_sample!Method
MC_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.
source
FreeBird.MonteCarloMoves.MC_random_swap!Method
MC_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}: The AtomWalker 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 updated AtomWalker.
source
FreeBird.MonteCarloMoves.MC_random_walk!Method
MC_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.
source
FreeBird.MonteCarloMoves.MC_random_walk!Method
MC_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.
source
FreeBird.MonteCarloMoves.MC_random_walk_2D!Method
MC_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.
source
FreeBird.MonteCarloMoves.MC_rejection_sampling!Method
MC_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.
source
FreeBird.MonteCarloMoves.free_component_indexMethod
free_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.
source
FreeBird.MonteCarloMoves.generate_random_new_lattice_sample!Method
generate_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.
source
FreeBird.MonteCarloMoves.mean_sq_displacementMethod
mean_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 current AtomWalker after the random walk.
  • at_orig::AtomWalker{C}: The original AtomWalker before the random walk.

Returns

  • distsq::typeof(0.0u"Å"^2): The mean squared displacement of all free particles.
source
FreeBird.MonteCarloMoves.periodic_boundary_wrap!Method
periodic_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.

source
FreeBird.MonteCarloMoves.single_atom_random_walk!Method
single_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.
source
FreeBird.MonteCarloMoves.two_atoms_swap!Method
two_atoms_swap!(at::AtomWalker{C}, ind1, ind2) where C

Swap the positions of two atoms in the AtomWalker.

Arguments

  • at::AtomWalker{C}: The AtomWalker object.
  • ind1::Int: The index of the first atom.
  • ind2::Int: The index of the second atom.

Returns

  • at::AtomWalker{C}: The updated AtomWalker.
source