MonteCarlo

Trait MonteCarlo 

Source
pub trait MonteCarlo<State, const D: usize>
where State: LatticeState<D>,
{ type Error; // Required method fn next_element(&mut self, state: State) -> Result<State, Self::Error>; }
Expand description

Monte-Carlo algorithm, giving the next element in the simulation. It is also a Markov chain.

§Example

use lattice_qcd_rs::error::ImplementationError;
use lattice_qcd_rs::simulation::{
    LatticeState, LatticeStateDefault, MetropolisHastingsSweep, MonteCarlo,
};
use rand::SeedableRng;

let rng = rand::rngs::StdRng::seed_from_u64(0); // change with your seed
let mut mh = MetropolisHastingsSweep::new(1, 0.1_f64, rng)
    .ok_or(ImplementationError::OptionWithUnexpectedNone)?;
// Realistically you want more steps than 10

let mut state = LatticeStateDefault::<3>::new_cold(1_f64, 6_f64, 4)?;
for _ in 0..10 {
    state = mh.next_element(state)?;
    // or state.monte_carlo_step(&mut hmc)?;
    // operation to track the progress or the evolution
}
// operation at the end of the simulation

Required Associated Types§

Source

type Error

Error returned while getting the next element.

Required Methods§

Source

fn next_element(&mut self, state: State) -> Result<State, Self::Error>

Do one Monte Carlo simulation step.

§Errors

Return an error if the simulation failed

Implementors§

Source§

impl<'a, MC, State, ErrorBase, Error, const D: usize> MonteCarlo<State, D> for AdaptorMethodError<'a, MC, State, ErrorBase, Error, D>
where MC: MonteCarlo<State, D, Error = ErrorBase> + ?Sized, ErrorBase: Into<Error>, State: LatticeState<D>,

Source§

type Error = Error

Source§

impl<'a, State, E, const D: usize> MonteCarlo<State, D> for HybridMethodVec<'a, State, E, D>
where State: LatticeState<D>,

Source§

impl<MC1, Error1, MC2, Error2, State, const D: usize> MonteCarlo<State, D> for HybridMethodCouple<MC1, Error1, MC2, Error2, State, D>
where MC1: MonteCarlo<State, D, Error = Error1>, MC2: MonteCarlo<State, D, Error = Error2>, State: LatticeState<D>,

Source§

type Error = HybridMethodCoupleError<Error1, Error2>

Source§

impl<Rng, const D: usize> MonteCarlo<LatticeStateDefault<D>, D> for HeatBathSweep<Rng>
where Rng: Rng,

Source§

impl<Rng, const D: usize> MonteCarlo<LatticeStateDefault<D>, D> for MetropolisHastingsDeltaDiagnostic<Rng>
where Rng: Rng,

Source§

impl<Rng, const D: usize> MonteCarlo<LatticeStateDefault<D>, D> for MetropolisHastingsSweep<Rng>
where Rng: Rng,

Source§

impl<State, Rng, I, const D: usize> MonteCarlo<State, D> for HybridMonteCarlo<State, Rng, I, D>

Source§

impl<State, Rng, I, const D: usize> MonteCarlo<State, D> for HybridMonteCarloDiagnostic<State, Rng, I, D>

Source§

impl<T, State, Rng, const D: usize> MonteCarlo<State, D> for McWrapper<T, State, Rng, D>
where T: MonteCarloDefault<State, D>, State: LatticeState<D>, Rng: Rng,

Source§

type Error = <T as MonteCarloDefault<State, D>>::Error

Source§

impl<const D: usize> MonteCarlo<LatticeStateDefault<D>, D> for OverrelaxationSweepReverse

Source§

impl<const D: usize> MonteCarlo<LatticeStateDefault<D>, D> for OverrelaxationSweepRotation