pub trait MonteCarlo<State, const D: usize> where
    State: LatticeState<D>, 
{ type Error; 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

Associated Types

Error returned while getting the next element.

Required methods

Do one Monte Carlo simulation step.

Errors

Return an error if the simulation failed

Implementors