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 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§impl<const D: usize> AsMut<Vec<Matrix<Su3Adjoint, Const<D>, Const<1>, ArrayStorage<Su3Adjoint, D, 1>>>> for EField<D>
impl<const D: usize> AsMut<Vec<Matrix<Su3Adjoint, Const<D>, Const<1>, ArrayStorage<Su3Adjoint, D, 1>>>> 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§impl<const D: usize> AsRef<Vec<Matrix<Su3Adjoint, Const<D>, Const<1>, ArrayStorage<Su3Adjoint, D, 1>>>> for EField<D>
impl<const D: usize> AsRef<Vec<Matrix<Su3Adjoint, Const<D>, Const<1>, ArrayStorage<Su3Adjoint, D, 1>>>> 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>
impl<A, const D: usize> Extend<A> for EField<D>
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>
impl<A, const D: usize> FromIterator<A> for EField<D>
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>
impl<A, const D: usize> FromParallelIterator<A> for EField<D>
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>
Source§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>
Source§type IntoIter = <&'a Vec<Matrix<Su3Adjoint, Const<D>, Const<1>, ArrayStorage<Su3Adjoint, D, 1>>> as IntoIterator>::IntoIter
type IntoIter = <&'a Vec<Matrix<Su3Adjoint, Const<D>, Const<1>, ArrayStorage<Su3Adjoint, D, 1>>> as IntoIterator>::IntoIter
Source§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>
Source§type IntoIter = <&'a mut Vec<Matrix<Su3Adjoint, Const<D>, Const<1>, ArrayStorage<Su3Adjoint, D, 1>>> as IntoIterator>::IntoIter
type IntoIter = <&'a mut Vec<Matrix<Su3Adjoint, Const<D>, Const<1>, ArrayStorage<Su3Adjoint, D, 1>>> as IntoIterator>::IntoIter
Source§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>
impl<T, const D: usize> ParallelExtend<T> for EField<D>
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 moreimpl<const D: usize> StructuralPartialEq for EField<D>
Auto Trait Implementations§
impl<const D: usize> Freeze for EField<D>
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§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§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).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.