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

Represent an electric field.

Implementations§

source§

impl<const D: usize> EField<D>

source

pub fn new(data: Vec<SVector<Su3Adjoint, D>>) -> Self

Create a new “Electrical” field.

source

pub const fn data(&self) -> &Vec<SVector<Su3Adjoint, D>>

Get the raw data.

source

pub fn data_mut(&mut self) -> &mut Vec<SVector<Su3Adjoint, D>>

Get a mut ref to the data data.

source

pub const fn as_vec(&self) -> &Vec<SVector<Su3Adjoint, D>>

Get the e_field as a Vec of Vector of Su3Adjoint

source

pub fn as_slice(&self) -> &[SVector<Su3Adjoint, D>]

Get the e_field as a slice of Vector of Su3Adjoint

source

pub fn as_slice_mut(&mut self) -> &mut [SVector<Su3Adjoint, D>]

Get the e_field as mut ref to slice of Vector of Su3Adjoint

source

pub fn len(&self) -> usize

Return the number of elements.

source

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)
);
source

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());
source

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());
source

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)].

source

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).

source

pub fn is_empty(&self) -> bool

Returns wether there is no data

source

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).

source

pub fn gauss_sum_div( &self, link_matrix: &LinkMatrix, lattice: &LatticeCyclic<D> ) -> Option<Real>

Get the deviation from the Gauss law

source

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>

source§

fn as_mut(&mut self) -> &mut [SVector<Su3Adjoint, D>]

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl<const D: usize> AsMut<Vec<Matrix<Su3Adjoint, Const<D>, Const<1>, ArrayStorage<Su3Adjoint, D, 1>>, Global>> for EField<D>

source§

fn as_mut(&mut self) -> &mut Vec<SVector<Su3Adjoint, D>>

Converts this type into a mutable reference of the (usually inferred) input type.
source§

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

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<const D: usize> AsRef<Vec<Matrix<Su3Adjoint, Const<D>, Const<1>, ArrayStorage<Su3Adjoint, D, 1>>, Global>> for EField<D>

source§

fn as_ref(&self) -> &Vec<SVector<Su3Adjoint, D>>

Converts this type into a shared reference of the (usually inferred) input type.
source§

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

source§

fn clone(&self) -> EField<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 EField<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 EField<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<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>,

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

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

Creates a value from an iterator. Read more
source§

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

Creates an instance of the collection from the parallel iterator par_iter. Read more
source§

impl<const D: usize> Index<usize> for EField<D>

§

type Output = Matrix<Su3Adjoint, Const<D>, Const<1>, ArrayStorage<Su3Adjoint, D, 1>>

The returned type after indexing.
source§

fn index(&self, pos: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl<const D: usize> IndexMut<usize> for EField<D>

source§

fn index_mut(&mut self, pos: usize) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
source§

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

Which kind of iterator are we turning this into?
§

type Item = &'a Matrix<Su3Adjoint, Const<D>, Const<1>, ArrayStorage<Su3Adjoint, D, 1>>

The type of the elements being iterated over.
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

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

Which kind of iterator are we turning this into?
§

type Item = &'a mut Matrix<Su3Adjoint, Const<D>, Const<1>, ArrayStorage<Su3Adjoint, D, 1>>

The type of the elements being iterated over.
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

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

Extends an instance of the collection with the elements drawn from the parallel iterator par_iter. Read more
source§

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

source§

fn eq(&self, other: &EField<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 EField<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 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§

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,