Struct lattice_qcd_rs::simulation::state::LatticeStateDefault
source · 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>
impl<const D: usize> LatticeStateDefault<D>
sourcepub fn new_cold(
size: Real,
beta: Real,
number_of_points: usize
) -> Result<Self, StateInitializationError>
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
.
sourcepub fn new_determinist(
size: Real,
beta: Real,
number_of_points: usize,
rng: &mut impl Rng
) -> Result<Self, StateInitializationError>
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()
);
sourcepub fn normalize_link_matrices(&mut self)
pub fn normalize_link_matrices(&mut self)
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();
}
sourcepub fn link_mut(
&mut self,
link: &LatticeLinkCanonical<D>
) -> Option<&mut CMatrix3>
pub fn link_mut( &mut self, link: &LatticeLinkCanonical<D> ) -> Option<&mut CMatrix3>
Get a mutable reference to the link matrix at link
sourcepub fn link_matrix_owned(self) -> LinkMatrix
pub fn link_matrix_owned(self) -> LinkMatrix
Absorbs self anf return the link_matrix as owned
Trait Implementations§
source§impl<const D: usize> Clone for LatticeStateDefault<D>
impl<const D: usize> Clone for LatticeStateDefault<D>
source§fn clone(&self) -> LatticeStateDefault<D>
fn clone(&self) -> LatticeStateDefault<D>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<const D: usize> Debug for LatticeStateDefault<D>
impl<const D: usize> Debug for LatticeStateDefault<D>
source§impl<'de, const D: usize> Deserialize<'de> for LatticeStateDefault<D>
impl<'de, const D: usize> Deserialize<'de> for LatticeStateDefault<D>
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
source§impl<const D: usize> LatticeState<D> for LatticeStateDefault<D>
impl<const D: usize> LatticeState<D> for LatticeStateDefault<D>
source§fn link_matrix(&self) -> &LinkMatrix
fn link_matrix(&self) -> &LinkMatrix
The link matrices of this state.
source§fn set_link_matrix(&mut self, link_matrix: LinkMatrix)
fn set_link_matrix(&mut self, link_matrix: LinkMatrix)
Panic
Panic if the length of link_matrix is different from lattice.get_number_of_canonical_links_space()
source§fn hamiltonian_links(&self) -> Real
fn hamiltonian_links(&self) -> Real
source§fn lattice(&self) -> &LatticeCyclic<D>
fn lattice(&self) -> &LatticeCyclic<D>
source§fn monte_carlo_step<M>(self, m: &mut M) -> Result<Self, M::Error>where
Self: Sized,
M: MonteCarlo<Self, D> + ?Sized,
fn monte_carlo_step<M>(self, m: &mut M) -> Result<Self, M::Error>where Self: Sized, M: MonteCarlo<Self, D> + ?Sized,
source§impl<const D: usize> LatticeStateNew<D> for LatticeStateDefault<D>
impl<const D: usize> LatticeStateNew<D> for LatticeStateDefault<D>
§type Error = StateInitializationError
type Error = StateInitializationError
source§fn new(
lattice: LatticeCyclic<D>,
beta: Real,
link_matrix: LinkMatrix
) -> Result<Self, Self::Error>
fn new( lattice: LatticeCyclic<D>, beta: Real, link_matrix: LinkMatrix ) -> Result<Self, Self::Error>
source§impl<Rng, const D: usize> MonteCarlo<LatticeStateDefault<D>, D> for HeatBathSweep<Rng>where
Rng: Rng,
impl<Rng, const D: usize> MonteCarlo<LatticeStateDefault<D>, D> for HeatBathSweep<Rng>where Rng: Rng,
source§fn next_element(
&mut self,
state: LatticeStateDefault<D>
) -> Result<LatticeStateDefault<D>, Self::Error>
fn next_element( &mut self, state: LatticeStateDefault<D> ) -> Result<LatticeStateDefault<D>, Self::Error>
source§impl<Rng, const D: usize> MonteCarlo<LatticeStateDefault<D>, D> for MetropolisHastingsDeltaDiagnostic<Rng>where
Rng: Rng,
impl<Rng, const D: usize> MonteCarlo<LatticeStateDefault<D>, D> for MetropolisHastingsDeltaDiagnostic<Rng>where Rng: Rng,
source§fn next_element(
&mut self,
state: LatticeStateDefault<D>
) -> Result<LatticeStateDefault<D>, Self::Error>
fn next_element( &mut self, state: LatticeStateDefault<D> ) -> Result<LatticeStateDefault<D>, Self::Error>
source§impl<Rng, const D: usize> MonteCarlo<LatticeStateDefault<D>, D> for MetropolisHastingsSweep<Rng>where
Rng: Rng,
impl<Rng, const D: usize> MonteCarlo<LatticeStateDefault<D>, D> for MetropolisHastingsSweep<Rng>where Rng: Rng,
source§fn next_element(
&mut self,
state: LatticeStateDefault<D>
) -> Result<LatticeStateDefault<D>, Self::Error>
fn next_element( &mut self, state: LatticeStateDefault<D> ) -> Result<LatticeStateDefault<D>, Self::Error>
source§impl<const D: usize> MonteCarlo<LatticeStateDefault<D>, D> for OverrelaxationSweepReverse
impl<const D: usize> MonteCarlo<LatticeStateDefault<D>, D> for OverrelaxationSweepReverse
source§fn next_element(
&mut self,
state: LatticeStateDefault<D>
) -> Result<LatticeStateDefault<D>, Self::Error>
fn next_element( &mut self, state: LatticeStateDefault<D> ) -> Result<LatticeStateDefault<D>, Self::Error>
source§impl<const D: usize> MonteCarlo<LatticeStateDefault<D>, D> for OverrelaxationSweepRotation
impl<const D: usize> MonteCarlo<LatticeStateDefault<D>, D> for OverrelaxationSweepRotation
source§fn next_element(
&mut self,
state: LatticeStateDefault<D>
) -> Result<LatticeStateDefault<D>, Self::Error>
fn next_element( &mut self, state: LatticeStateDefault<D> ) -> Result<LatticeStateDefault<D>, Self::Error>
source§impl<const D: usize> PartialEq<LatticeStateDefault<D>> for LatticeStateDefault<D>
impl<const D: usize> PartialEq<LatticeStateDefault<D>> for LatticeStateDefault<D>
source§fn eq(&self, other: &LatticeStateDefault<D>) -> bool
fn eq(&self, other: &LatticeStateDefault<D>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<const D: usize> Serialize for LatticeStateDefault<D>
impl<const D: usize> Serialize for LatticeStateDefault<D>
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§
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.