EField

Struct EField 

Source
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>>>> 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>>>> 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 duplicate 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>

Source§

fn from_iter<T>(iter: T) -> Self
where T: IntoIterator<Item = A>,

Creates a value from an iterator. Read more
Source§

impl<A, const D: usize> FromParallelIterator<A> for EField<D>

Source§

fn from_par_iter<I>(par_iter: I) -> Self
where 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>

Source§

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>

Source§

type IntoIter = <&'a Vec<Matrix<Su3Adjoint, Const<D>, Const<1>, ArrayStorage<Su3Adjoint, D, 1>>> as IntoIterator>::IntoIter

Which kind of iterator are we turning this into?
Source§

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>

Source§

type IntoIter = <&'a mut Vec<Matrix<Su3Adjoint, Const<D>, Const<1>, ArrayStorage<Su3Adjoint, D, 1>>> as IntoIterator>::IntoIter

Which kind of iterator are we turning this into?
Source§

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>

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 for EField<D>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

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> 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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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

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

fn is_in_subset(&self) -> bool

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

fn to_subset_unchecked(&self) -> SS

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

fn from_subset(element: &SS) -> SP

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

impl<T> ToOwned for T
where T: Clone,

Source§

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 T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

fn vzip(self) -> V

Source§

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

Source§

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