Struct lattice_qcd_rs::field::EField
source · pub struct EField<const D: usize> { /* private fields */ }
Expand description
Represent an electric field.
Implementations§
source§impl<const D: usize> EField<D>
impl<const D: usize> EField<D>
sourcepub fn new(data: Vec<SVector<Su3Adjoint, D>>) -> Self
pub fn new(data: Vec<SVector<Su3Adjoint, D>>) -> Self
Create a new “Electrical” field.
sourcepub const fn data(&self) -> &Vec<SVector<Su3Adjoint, D>>
pub const fn data(&self) -> &Vec<SVector<Su3Adjoint, D>>
Get the raw data.
sourcepub fn data_mut(&mut self) -> &mut Vec<SVector<Su3Adjoint, D>>
pub fn data_mut(&mut self) -> &mut Vec<SVector<Su3Adjoint, D>>
Get a mut ref to the data data.
sourcepub const fn as_vec(&self) -> &Vec<SVector<Su3Adjoint, D>>
pub const fn as_vec(&self) -> &Vec<SVector<Su3Adjoint, D>>
Get the e_field as a Vec of Vector of Su3Adjoint
sourcepub fn as_slice(&self) -> &[SVector<Su3Adjoint, D>]
pub fn as_slice(&self) -> &[SVector<Su3Adjoint, D>]
Get the e_field as a slice of Vector of Su3Adjoint
sourcepub fn as_slice_mut(&mut self) -> &mut [SVector<Su3Adjoint, D>]
pub fn as_slice_mut(&mut self) -> &mut [SVector<Su3Adjoint, D>]
Get the e_field as mut ref to slice of Vector of Su3Adjoint
sourcepub fn new_determinist<Rng: Rng + ?Sized>(
l: &LatticeCyclic<D>,
rng: &mut Rng,
d: &impl Distribution<Real>
) -> Self
pub fn new_determinist<Rng: Rng + ?Sized>( l: &LatticeCyclic<D>, rng: &mut Rng, d: &impl Distribution<Real> ) -> Self
Single threaded generation with a given random number generator. useful to reproduce a set of data.
Example
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
let distribution = rand::distributions::Uniform::from(-1_f64..1_f64);
let lattice = LatticeCyclic::<4>::new(1_f64, 4)?;
assert_eq!(
EField::new_determinist(&lattice, &mut rng_1, &distribution),
EField::new_determinist(&lattice, &mut rng_2, &distribution)
);
sourcepub fn new_random(l: &LatticeCyclic<D>, d: &impl Distribution<Real>) -> Self
pub fn new_random(l: &LatticeCyclic<D>, d: &impl Distribution<Real>) -> Self
Single thread generation by seeding a new rng number.
To create a seedable and reproducible set use EField::new_determinist
.
Example
use lattice_qcd_rs::{field::EField, lattice::LatticeCyclic};
let distribution = rand::distributions::Uniform::from(-1_f64..1_f64);
let lattice = LatticeCyclic::<3>::new(1_f64, 4)?;
let e_field = EField::new_random(&lattice, &distribution);
assert!(!e_field.is_empty());
sourcepub fn new_cold(l: &LatticeCyclic<D>) -> Self
pub fn new_cold(l: &LatticeCyclic<D>) -> Self
Create a new cold configuration for the electrical field, i.e. all E ar set to 0.
Example
use lattice_qcd_rs::{field::EField, lattice::LatticeCyclic};
let lattice = LatticeCyclic::<3>::new(1_f64, 4)?;
let e_field = EField::new_cold(&lattice);
assert!(!e_field.is_empty());
sourcepub fn e_vec(
&self,
point: &LatticePoint<D>,
l: &LatticeCyclic<D>
) -> Option<&SVector<Su3Adjoint, D>>
pub fn e_vec( &self, point: &LatticePoint<D>, l: &LatticeCyclic<D> ) -> Option<&SVector<Su3Adjoint, D>>
Get E(point) = [E_x(point), E_y(point), E_z(point)]
.
sourcepub fn e_field(
&self,
point: &LatticePoint<D>,
dir: &Direction<D>,
l: &LatticeCyclic<D>
) -> Option<&Su3Adjoint>
pub fn e_field( &self, point: &LatticePoint<D>, dir: &Direction<D>, l: &LatticeCyclic<D> ) -> Option<&Su3Adjoint>
Get E_{dir}(point)
. The sign of the direction does not change the output. i.e.
E_{-dir}(point) = E_{dir}(point)
.
sourcepub fn gauss(
&self,
link_matrix: &LinkMatrix,
point: &LatticePoint<D>,
lattice: &LatticeCyclic<D>
) -> Option<CMatrix3>
pub fn gauss( &self, link_matrix: &LinkMatrix, point: &LatticePoint<D>, lattice: &LatticeCyclic<D> ) -> Option<CMatrix3>
Return the Gauss parameter G(x) = \sum_i E_i(x) - U_{-i}(x) E_i(x - i) U^\dagger_{-i}(x)
.
sourcepub fn gauss_sum_div(
&self,
link_matrix: &LinkMatrix,
lattice: &LatticeCyclic<D>
) -> Option<Real>
pub fn gauss_sum_div( &self, link_matrix: &LinkMatrix, lattice: &LatticeCyclic<D> ) -> Option<Real>
Get the deviation from the Gauss law
sourcepub fn project_to_gauss(
&self,
link_matrix: &LinkMatrix,
lattice: &LatticeCyclic<D>
) -> Option<Self>
pub fn project_to_gauss( &self, link_matrix: &LinkMatrix, lattice: &LatticeCyclic<D> ) -> Option<Self>
project to that the gauss law is approximately respected ( up to f64::EPSILON * 10
per point).
It is mainly use internally but can be use to correct numerical drift in simulations.
Example
use lattice_qcd_rs::error::ImplementationError;
use lattice_qcd_rs::integrator::SymplecticEulerRayon;
use lattice_qcd_rs::simulation::{
LatticeState, LatticeStateDefault, LatticeStateEFSyncDefault, LatticeStateWithEField,
SimulationStateSynchronous,
};
use rand::SeedableRng;
let mut rng = rand::rngs::StdRng::seed_from_u64(0); // change with your seed
let distribution =
rand::distributions::Uniform::from(-std::f64::consts::PI..std::f64::consts::PI);
let mut state = LatticeStateEFSyncDefault::new_random_e_state(
LatticeStateDefault::<3>::new_determinist(1_f64, 6_f64, 4, &mut rng)?,
&mut rng,
); // <- here internally when choosing randomly the EField it is projected.
let integrator = SymplecticEulerRayon::default();
for _ in 0..2 {
for _ in 0..10 {
state = state.simulate_sync(&integrator, 0.0001_f64)?;
}
// we correct the numerical drift of the EField.
let new_e_field = state
.e_field()
.project_to_gauss(state.link_matrix(), state.lattice())
.ok_or(ImplementationError::OptionWithUnexpectedNone)?;
state.set_e_field(new_e_field);
}
Trait Implementations§
source§impl<const D: usize> AsMut<[Matrix<Su3Adjoint, Const<D>, Const<1>, ArrayStorage<Su3Adjoint, D, 1>>]> for EField<D>
impl<const D: usize> AsMut<[Matrix<Su3Adjoint, Const<D>, Const<1>, ArrayStorage<Su3Adjoint, D, 1>>]> for EField<D>
source§fn as_mut(&mut self) -> &mut [SVector<Su3Adjoint, D>]
fn as_mut(&mut self) -> &mut [SVector<Su3Adjoint, D>]
source§impl<const D: usize> AsMut<Vec<Matrix<Su3Adjoint, Const<D>, Const<1>, ArrayStorage<Su3Adjoint, D, 1>>, Global>> for EField<D>
impl<const D: usize> AsMut<Vec<Matrix<Su3Adjoint, Const<D>, Const<1>, ArrayStorage<Su3Adjoint, D, 1>>, Global>> for EField<D>
source§impl<const D: usize> AsRef<[Matrix<Su3Adjoint, Const<D>, Const<1>, ArrayStorage<Su3Adjoint, D, 1>>]> for EField<D>
impl<const D: usize> AsRef<[Matrix<Su3Adjoint, Const<D>, Const<1>, ArrayStorage<Su3Adjoint, D, 1>>]> for EField<D>
source§fn as_ref(&self) -> &[SVector<Su3Adjoint, D>]
fn as_ref(&self) -> &[SVector<Su3Adjoint, D>]
source§impl<const D: usize> AsRef<Vec<Matrix<Su3Adjoint, Const<D>, Const<1>, ArrayStorage<Su3Adjoint, D, 1>>, Global>> for EField<D>
impl<const D: usize> AsRef<Vec<Matrix<Su3Adjoint, Const<D>, Const<1>, ArrayStorage<Su3Adjoint, D, 1>>, Global>> for EField<D>
source§impl<'de, const D: usize> Deserialize<'de> for EField<D>
impl<'de, const D: usize> Deserialize<'de> for EField<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<A, const D: usize> Extend<A> for EField<D>where
Vec<SVector<Su3Adjoint, D>>: Extend<A>,
impl<A, const D: usize> Extend<A> for EField<D>where Vec<SVector<Su3Adjoint, D>>: Extend<A>,
source§fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = A>,
fn extend<T>(&mut self, iter: T)where T: IntoIterator<Item = A>,
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)source§impl<A, const D: usize> FromIterator<A> for EField<D>where
Vec<SVector<Su3Adjoint, D>>: FromIterator<A>,
impl<A, const D: usize> FromIterator<A> for EField<D>where Vec<SVector<Su3Adjoint, D>>: FromIterator<A>,
source§fn from_iter<T>(iter: T) -> Selfwhere
T: IntoIterator<Item = A>,
fn from_iter<T>(iter: T) -> Selfwhere T: IntoIterator<Item = A>,
source§impl<A, const D: usize> FromParallelIterator<A> for EField<D>where
Vec<SVector<Su3Adjoint, D>>: FromParallelIterator<A>,
A: Send,
impl<A, const D: usize> FromParallelIterator<A> for EField<D>where Vec<SVector<Su3Adjoint, D>>: FromParallelIterator<A>, A: Send,
source§fn from_par_iter<I>(par_iter: I) -> Selfwhere
I: IntoParallelIterator<Item = A>,
fn from_par_iter<I>(par_iter: I) -> Selfwhere I: IntoParallelIterator<Item = A>,
par_iter
. Read moresource§impl<const D: usize> Index<usize> for EField<D>
impl<const D: usize> Index<usize> for EField<D>
§type Output = Matrix<Su3Adjoint, Const<D>, Const<1>, ArrayStorage<Su3Adjoint, D, 1>>
type Output = Matrix<Su3Adjoint, Const<D>, Const<1>, ArrayStorage<Su3Adjoint, D, 1>>
source§impl<'a, const D: usize> IntoIterator for &'a EField<D>
impl<'a, const D: usize> IntoIterator for &'a EField<D>
§type IntoIter = <&'a Vec<Matrix<Su3Adjoint, Const<D>, Const<1>, ArrayStorage<Su3Adjoint, D, 1>>, Global> as IntoIterator>::IntoIter
type IntoIter = <&'a Vec<Matrix<Su3Adjoint, Const<D>, Const<1>, ArrayStorage<Su3Adjoint, D, 1>>, Global> as IntoIterator>::IntoIter
§type Item = &'a Matrix<Su3Adjoint, Const<D>, Const<1>, ArrayStorage<Su3Adjoint, D, 1>>
type Item = &'a Matrix<Su3Adjoint, Const<D>, Const<1>, ArrayStorage<Su3Adjoint, D, 1>>
source§impl<'a, const D: usize> IntoIterator for &'a mut EField<D>
impl<'a, const D: usize> IntoIterator for &'a mut EField<D>
§type IntoIter = <&'a mut Vec<Matrix<Su3Adjoint, Const<D>, Const<1>, ArrayStorage<Su3Adjoint, D, 1>>, Global> as IntoIterator>::IntoIter
type IntoIter = <&'a mut Vec<Matrix<Su3Adjoint, Const<D>, Const<1>, ArrayStorage<Su3Adjoint, D, 1>>, Global> as IntoIterator>::IntoIter
§type Item = &'a mut Matrix<Su3Adjoint, Const<D>, Const<1>, ArrayStorage<Su3Adjoint, D, 1>>
type Item = &'a mut Matrix<Su3Adjoint, Const<D>, Const<1>, ArrayStorage<Su3Adjoint, D, 1>>
source§impl<T, const D: usize> ParallelExtend<T> for EField<D>where
Vec<SVector<Su3Adjoint, D>>: ParallelExtend<T>,
T: Send,
impl<T, const D: usize> ParallelExtend<T> for EField<D>where Vec<SVector<Su3Adjoint, D>>: ParallelExtend<T>, T: Send,
source§fn par_extend<I>(&mut self, par_iter: I)where
I: IntoParallelIterator<Item = T>,
fn par_extend<I>(&mut self, par_iter: I)where I: IntoParallelIterator<Item = T>,
par_iter
. Read moresource§impl<const D: usize> PartialEq<EField<D>> for EField<D>
impl<const D: usize> PartialEq<EField<D>> for EField<D>
impl<const D: usize> StructuralPartialEq for EField<D>
Auto Trait Implementations§
impl<const D: usize> RefUnwindSafe for EField<D>
impl<const D: usize> Send for EField<D>
impl<const D: usize> Sync for EField<D>
impl<const D: usize> Unpin for EField<D>
impl<const D: usize> UnwindSafe for EField<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.