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>,

§

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>,

§

type Error = HybridMethodCoupleError<Error1, Error2>

source§

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

§

type Error = Never

source§

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

§

type Error = Never

source§

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

§

type Error = Never

source§

impl<State, Rng, I, const D: usize> MonteCarlo<State, D> for HybridMonteCarlo<State, Rng, I, D>where State: LatticeState<D> + Clone + ?Sized, LatticeStateEFSyncDefault<State, D>: SimulationStateSynchronous<D>, I: SymplecticIntegrator<LatticeStateEFSyncDefault<State, D>, SimulationStateLeap<LatticeStateEFSyncDefault<State, D>, D>, D>, Rng: Rng,

source§

impl<State, Rng, I, const D: usize> MonteCarlo<State, D> for HybridMonteCarloDiagnostic<State, Rng, I, D>where State: LatticeState<D> + Clone + ?Sized, LatticeStateEFSyncDefault<State, D>: SimulationStateSynchronous<D>, I: SymplecticIntegrator<LatticeStateEFSyncDefault<State, D>, SimulationStateLeap<LatticeStateEFSyncDefault<State, D>, D>, D>, Rng: Rng,

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,

§

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

source§

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

§

type Error = Never

source§

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

§

type Error = Never