pub struct MatsubaraFreq<S: StatisticsType> { /* private fields */ }Expand description
Matsubara frequency for a specific statistics type
This represents the Matsubara frequency ν = nπ/β, where:
- n is the stored integer (the reduced Matsubara frequency, returned by
n): odd for fermionic statistics (n = ±1, ±3, …) and even for bosonic statistics (n = 0, ±2, ±4, …) - β is the inverse temperature, passed to
valueandvalue_imaginary
In terms of the conventional Matsubara index m of ν = (2m + ζ)π/β, with
ζ = 1 for fermionic and ζ = 0 for bosonic statistics, the stored integer is
n = 2m + ζ; it is not m itself. new rejects an n whose
parity does not match the statistics.
The statistics type S is checked at compile time to ensure type safety.
§Examples
use sparse_ir::{BosonicFreq, FermionicFreq};
use std::f64::consts::PI;
let beta = 10.0;
// n = 1 is the lowest positive fermionic frequency, ω = π/β (k = 0).
let w = FermionicFreq::new(1).unwrap();
assert_eq!(w.n(), 1);
assert!((w.value(beta) - PI / beta).abs() < 1e-15);
// n = 2 is the lowest positive bosonic frequency, ω = 2π/β (k = 1).
let nu = BosonicFreq::new(2).unwrap();
assert!((nu.value(beta) - 2.0 * PI / beta).abs() < 1e-15);
// The parity of n must match the statistics.
assert!(FermionicFreq::new(2).is_err());
assert!(BosonicFreq::new(1).is_err());Adding or subtracting frequencies gives the statistics of the result:
FermionicFreq ± FermionicFreq is a BosonicFreq, and a fermionic and
a bosonic frequency (in either order) give a FermionicFreq.
Implementations§
Source§impl<S: StatisticsType> MatsubaraFreq<S>
impl<S: StatisticsType> MatsubaraFreq<S>
Sourcepub fn n(&self) -> i64
pub fn n(&self) -> i64
Get the reduced Matsubara frequency n, where ν = nπ/β
n is odd for fermionic and even for bosonic statistics.
Sourcepub fn new(n: i64) -> Result<Self, Error>
pub fn new(n: i64) -> Result<Self, Error>
Create a new Matsubara frequency
§Arguments
n- The reduced Matsubara frequency n of ν = nπ/β: odd for fermionic statistics, even for bosonic statistics
§Errors
Error::InvalidMatsubaraIndex if n is even for fermionic or odd
for bosonic statistics
§Examples
use sparse_ir::freq::{FermionicFreq, BosonicFreq};
let fermionic = FermionicFreq::new(1).unwrap(); // OK: odd n for fermionic
let bosonic = BosonicFreq::new(0).unwrap(); // OK: even n for bosonicSourcepub unsafe fn new_unchecked(n: i64) -> Self
pub unsafe fn new_unchecked(n: i64) -> Self
Create a Matsubara frequency without validation
§Safety
This function bypasses the validation in new(). Only use when you’re
certain the frequency is valid for the statistics type.
Sourcepub fn value_imaginary(&self, beta: f64) -> Complex64
pub fn value_imaginary(&self, beta: f64) -> Complex64
Sourcepub fn statistics(&self) -> Statistics
pub fn statistics(&self) -> Statistics
Get the statistics type
Trait Implementations§
Source§impl Add<MatsubaraFreq<Bosonic>> for FermionicFreq
impl Add<MatsubaraFreq<Bosonic>> for FermionicFreq
Source§type Output = MatsubaraFreq<Fermionic>
type Output = MatsubaraFreq<Fermionic>
+ operator.Source§fn add(self, other: BosonicFreq) -> FermionicFreq
fn add(self, other: BosonicFreq) -> FermionicFreq
+ operation. Read moreSource§impl Add<MatsubaraFreq<Fermionic>> for BosonicFreq
impl Add<MatsubaraFreq<Fermionic>> for BosonicFreq
Source§type Output = MatsubaraFreq<Fermionic>
type Output = MatsubaraFreq<Fermionic>
+ operator.Source§fn add(self, other: FermionicFreq) -> FermionicFreq
fn add(self, other: FermionicFreq) -> FermionicFreq
+ operation. Read moreSource§impl<S: Clone + StatisticsType> Clone for MatsubaraFreq<S>
impl<S: Clone + StatisticsType> Clone for MatsubaraFreq<S>
Source§fn clone(&self) -> MatsubaraFreq<S>
fn clone(&self) -> MatsubaraFreq<S>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl<S: Copy + StatisticsType> Copy for MatsubaraFreq<S>
Source§impl<S: Debug + StatisticsType> Debug for MatsubaraFreq<S>
impl<S: Debug + StatisticsType> Debug for MatsubaraFreq<S>
Source§impl<S: StatisticsType> Display for MatsubaraFreq<S>
impl<S: StatisticsType> Display for MatsubaraFreq<S>
impl<S: StatisticsType> Eq for MatsubaraFreq<S>
Source§impl<S: StatisticsType> From<MatsubaraFreq<S>> for i64
impl<S: StatisticsType> From<MatsubaraFreq<S>> for i64
Source§fn from(freq: MatsubaraFreq<S>) -> Self
fn from(freq: MatsubaraFreq<S>) -> Self
Source§impl<S: StatisticsType> Hash for MatsubaraFreq<S>
impl<S: StatisticsType> Hash for MatsubaraFreq<S>
Source§impl<S: StatisticsType> Neg for MatsubaraFreq<S>
impl<S: StatisticsType> Neg for MatsubaraFreq<S>
Source§impl<S: StatisticsType> Ord for MatsubaraFreq<S>
impl<S: StatisticsType> Ord for MatsubaraFreq<S>
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<S: StatisticsType> PartialEq for MatsubaraFreq<S>
impl<S: StatisticsType> PartialEq for MatsubaraFreq<S>
Source§impl<S: StatisticsType> PartialOrd for MatsubaraFreq<S>
impl<S: StatisticsType> PartialOrd for MatsubaraFreq<S>
Source§impl Sub<MatsubaraFreq<Bosonic>> for FermionicFreq
impl Sub<MatsubaraFreq<Bosonic>> for FermionicFreq
Source§type Output = MatsubaraFreq<Fermionic>
type Output = MatsubaraFreq<Fermionic>
- operator.Source§fn sub(self, other: BosonicFreq) -> FermionicFreq
fn sub(self, other: BosonicFreq) -> FermionicFreq
- operation. Read moreSource§impl Sub<MatsubaraFreq<Fermionic>> for BosonicFreq
impl Sub<MatsubaraFreq<Fermionic>> for BosonicFreq
Source§type Output = MatsubaraFreq<Fermionic>
type Output = MatsubaraFreq<Fermionic>
- operator.Source§fn sub(self, other: FermionicFreq) -> FermionicFreq
fn sub(self, other: FermionicFreq) -> FermionicFreq
- operation. Read moreAuto Trait Implementations§
impl<S> Freeze for MatsubaraFreq<S>
impl<S> RefUnwindSafe for MatsubaraFreq<S>where
S: RefUnwindSafe,
impl<S> Send for MatsubaraFreq<S>where
S: Send,
impl<S> Sync for MatsubaraFreq<S>where
S: Sync,
impl<S> Unpin for MatsubaraFreq<S>where
S: Unpin,
impl<S> UnsafeUnpin for MatsubaraFreq<S>
impl<S> UnwindSafe for MatsubaraFreq<S>where
S: UnwindSafe,
Blanket Implementations§
impl<T> Boilerplate for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> Twhere
Self: Distribution<T>,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.impl<T, U> Imply<T> for U
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 more