pub struct LatticeStateDefault<const D: usize> { /* private fields */ }
Expand description

Represent a simulation state at a set time.

It has the default pure gauge hamiltonian

Implementations§

source§

impl<const D: usize> LatticeStateDefault<D>

source

pub fn new_cold( size: Real, beta: Real, number_of_points: usize ) -> Result<Self, StateInitializationError>

Create a cold configuration. i.e. all the links are set to the unit matrix.

With the lattice of size size and dimension number_of_points ( see LatticeCyclic::new ) and beta parameter beta.

Errors

Returns StateInitializationError::LatticeInitializationError if the parameter is invalid for LatticeCyclic. Or propagate the error form Self::new.

source

pub fn new_determinist( size: Real, beta: Real, number_of_points: usize, rng: &mut impl Rng ) -> Result<Self, StateInitializationError>

Create a “hot” configuration, i.e. the link matrices are chosen randomly.

With the lattice of size size and dimension number_of_points ( see LatticeCyclic::new ) and beta parameter beta.

The creation is determinists meaning that it is reproducible:

Errors

Returns StateInitializationError::LatticeInitializationError if the parameter is invalid for LatticeCyclic. Or propagate the error form Self::new.

Example

This example demonstrate how to reproduce the same configuration

use rand::{rngs::StdRng, SeedableRng};

let mut rng_1 = StdRng::seed_from_u64(0);
let mut rng_2 = StdRng::seed_from_u64(0);
// They have the same seed and should generate the same numbers
assert_eq!(
    LatticeStateDefault::<4>::new_determinist(1_f64, 1_f64, 4, &mut rng_1).unwrap(),
    LatticeStateDefault::<4>::new_determinist(1_f64, 1_f64, 4, &mut rng_2).unwrap()
);

Correct the numerical drift, reprojecting all the link matrices to SU(3). see LinkMatrix::normalize.

Example
use lattice_qcd_rs::error::ImplementationError;
use lattice_qcd_rs::prelude::*;
use rand::SeedableRng;

let mut rng = rand::rngs::StdRng::seed_from_u64(0); // change with your seed

let size = 1_f64;
let number_of_pts = 3;
let beta = 1_f64;

let mut simulation =
    LatticeStateDefault::<4>::new_determinist(size, beta, number_of_pts, &mut rng)?;

let spread_parameter = 0.1_f64;
let mut mc = MetropolisHastingsSweep::new(1, spread_parameter, rng)
    .ok_or(ImplementationError::OptionWithUnexpectedNone)?;

for _ in 0..2 {
    for _ in 0..10 {
        simulation = simulation.monte_carlo_step(&mut mc)?;
    }
    // the more we advance te more the link matrices
    // will deviate form SU(3), so we reproject to SU(3)
    // every 10 steps.
    simulation.normalize_link_matrices();
}

Get a mutable reference to the link matrix at link

Absorbs self anf return the link_matrix as owned

Trait Implementations§

source§

impl<const D: usize> Clone for LatticeStateDefault<D>

source§

fn clone(&self) -> LatticeStateDefault<D>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<const D: usize> Debug for LatticeStateDefault<D>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de, const D: usize> Deserialize<'de> for LatticeStateDefault<D>

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<const D: usize> LatticeState<D> for LatticeStateDefault<D>

The link matrices of this state.

Panic

Panic if the length of link_matrix is different from lattice.get_number_of_canonical_links_space()

Get the default pure gauge Hamiltonian.

Panic

Panic if plaquettes cannot be found

source§

const CA: Real = 3f64

C_A constant of the model, usually it is 3.
source§

fn lattice(&self) -> &LatticeCyclic<D>

Get the lattice into which the state exists.
source§

fn beta(&self) -> Real

Returns the beta parameter of the states.
source§

fn monte_carlo_step<M>(self, m: &mut M) -> Result<Self, M::Error>where Self: Sized, M: MonteCarlo<Self, D> + ?Sized,

Do one monte carlo step with the given method. Read more
source§

fn average_trace_plaquette(&self) -> Option<Complex>

Take the average of the trace of all plaquettes. Read more
source§

impl<const D: usize> LatticeStateNew<D> for LatticeStateDefault<D>

§

type Error = StateInitializationError

Error type
source§

fn new( lattice: LatticeCyclic<D>, beta: Real, link_matrix: LinkMatrix ) -> Result<Self, Self::Error>

Create a new simulation state. Read more
source§

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

§

type Error = Never

Error returned while getting the next element.
source§

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

Do one Monte Carlo simulation step. Read more
source§

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

§

type Error = Never

Error returned while getting the next element.
source§

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

Do one Monte Carlo simulation step. Read more
source§

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

§

type Error = Never

Error returned while getting the next element.
source§

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

Do one Monte Carlo simulation step. Read more
source§

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

§

type Error = Never

Error returned while getting the next element.
source§

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

Do one Monte Carlo simulation step. Read more
source§

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

§

type Error = Never

Error returned while getting the next element.
source§

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

Do one Monte Carlo simulation step. Read more
source§

impl<const D: usize> PartialEq<LatticeStateDefault<D>> for LatticeStateDefault<D>

source§

fn eq(&self, other: &LatticeStateDefault<D>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<const D: usize> Serialize for LatticeStateDefault<D>

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<const D: usize> StructuralPartialEq for LatticeStateDefault<D>

Auto Trait Implementations§

§

impl<const D: usize> RefUnwindSafe for LatticeStateDefault<D>

§

impl<const D: usize> Send for LatticeStateDefault<D>

§

impl<const D: usize> Sync for LatticeStateDefault<D>

§

impl<const D: usize> Unpin for LatticeStateDefault<D>

§

impl<const D: usize> UnwindSafe for LatticeStateDefault<D>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,

source§

impl<T> Scalar for Twhere T: 'static + Clone + PartialEq<T> + Debug,