pub struct PartitionFunction {
pub kind: EnsembleKind,
pub energy_levels: Vec<f64>,
pub degeneracies: Vec<f64>,
pub temperature: f64,
pub chemical_potential: f64,
pub particle_numbers: Vec<f64>,
}Expand description
Partition function for statistical mechanical ensembles.
Stores a discrete energy spectrum and computes thermodynamic quantities such as free energy, entropy, and average energy.
Fields§
§kind: EnsembleKindEnsemble type.
energy_levels: Vec<f64>Energy levels of the system.
degeneracies: Vec<f64>Degeneracy of each energy level.
temperature: f64Temperature in units where k_B = 1.
chemical_potential: f64Chemical potential (used for grand canonical ensemble).
particle_numbers: Vec<f64>Particle numbers for each state (grand canonical).
Implementations§
Source§impl PartitionFunction
impl PartitionFunction
Sourcepub fn canonical(
energy_levels: Vec<f64>,
degeneracies: Vec<f64>,
temperature: f64,
) -> Self
pub fn canonical( energy_levels: Vec<f64>, degeneracies: Vec<f64>, temperature: f64, ) -> Self
Constructs a canonical partition function from energy levels and degeneracies.
§Arguments
energy_levels- Vector of energy eigenvalues.degeneracies- Degeneracy of each level (same length asenergy_levels).temperature- Temperature (k_B = 1 units).
Sourcepub fn grand_canonical(
energy_levels: Vec<f64>,
degeneracies: Vec<f64>,
particle_numbers: Vec<f64>,
temperature: f64,
chemical_potential: f64,
) -> Self
pub fn grand_canonical( energy_levels: Vec<f64>, degeneracies: Vec<f64>, particle_numbers: Vec<f64>, temperature: f64, chemical_potential: f64, ) -> Self
Constructs a grand canonical partition function.
Sourcepub fn microcanonical(energy_levels: Vec<f64>, degeneracies: Vec<f64>) -> Self
pub fn microcanonical(energy_levels: Vec<f64>, degeneracies: Vec<f64>) -> Self
Constructs a microcanonical partition function (density of states).
Sourcepub fn canonical_z(&self) -> f64
pub fn canonical_z(&self) -> f64
Returns the canonical partition function Z = Σ g_i exp(-β E_i).
Returns 0.0 if temperature is non-positive.
Sourcepub fn grand_canonical_z(&self) -> f64
pub fn grand_canonical_z(&self) -> f64
Returns the grand canonical partition function Ξ = Σ g_i exp(-β(E_i - μ N_i)).
Sourcepub fn density_of_states(&self, target_energy: f64, tolerance: f64) -> f64
pub fn density_of_states(&self, target_energy: f64, tolerance: f64) -> f64
Returns the microcanonical density of states Ω(E) for a target energy within tolerance.
Sums degeneracies of levels within ±tolerance of target_energy.
Sourcepub fn free_energy(&self) -> f64
pub fn free_energy(&self) -> f64
Returns the Helmholtz free energy F = -k_B T ln Z (canonical).
Sourcepub fn average_energy(&self) -> f64
pub fn average_energy(&self) -> f64
Returns the average energy ⟨E⟩ = -∂ ln Z / ∂β (canonical).
Sourcepub fn heat_capacity(&self) -> f64
pub fn heat_capacity(&self) -> f64
Returns the heat capacity C_V = ∂⟨E⟩/∂T = (⟨E²⟩ - ⟨E⟩²) / (k_B T²).
Trait Implementations§
Source§impl Clone for PartitionFunction
impl Clone for PartitionFunction
Source§fn clone(&self) -> PartitionFunction
fn clone(&self) -> PartitionFunction
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for PartitionFunction
impl RefUnwindSafe for PartitionFunction
impl Send for PartitionFunction
impl Sync for PartitionFunction
impl Unpin for PartitionFunction
impl UnsafeUnpin for PartitionFunction
impl UnwindSafe for PartitionFunction
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<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.