Imports
/- Copyright (c) 2025 Alex Meiburg. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Alex Meiburg -/ module public import Physlib.StatisticalMechanics.MicroCanonicalEnsemble.Basic public import QuantumInfo.ForMathlib.ComplexLaplaceTransform

The theormodynamical quantities of a microcanonical ensemble

@[expose] public section

The partition function corresponding to a given MicroHamiltonian. This is a function taking a thermodynamic β, not a temperature. It also depends on the data D defining the system extrinsincs.

    Ideally this would be an NNReal, but ∫ (NNReal) doesn't work right now, so it would just be a separate proof anyway

def partitionZ (β : ) : := (config : H.dim d ), let E := H.H config if h : E = then 0 else Real.exp (-β * (E.untop h))

The complexified partition function, viewed as a Laplace transform.

def PartitionZComplex (z : ) : := ComplexLaplaceTransform (fun config : H.dim d => H.H config) z

The complex convergence domain of the partition-function Laplace transform.

def ZComplexConvergenceDomain : Set := ComplexLaplaceConvergenceDomain (fun config : H.dim d => H.H config)
D:TypeH:MicroHamiltonian Dd:Dβ::β H.ZComplexConvergenceDomain dhInt:MeasureTheory.Integrable (ComplexLaplaceIntegrand (fun config => H.H config) β) MeasureTheory.volume( (config : H.dim d ), have E := H.H config; if h : E = then 0 else Real.exp (-β * E.untop h)) = ( (x : H.dim d ), ComplexLaplaceIntegrand (fun config => H.H config) (↑β) x).re calc ( (config : H.dim d ), have E := H.H config if h : E = then 0 else Real.exp (-β * E.untop h)) = x, RCLike.re (ComplexLaplaceIntegrand (fun config : H.dim d => H.H config) (β : ) x) := D:TypeH:MicroHamiltonian Dd:Dβ::β H.ZComplexConvergenceDomain dhInt:MeasureTheory.Integrable (ComplexLaplaceIntegrand (fun config => H.H config) β) MeasureTheory.volume( (config : H.dim d ), have E := H.H config; if h : E = then 0 else Real.exp (-β * E.untop h)) = (x : H.dim d ), RCLike.re (ComplexLaplaceIntegrand (fun config => H.H config) (↑β) x) D:TypeH:MicroHamiltonian Dd:Dβ::β H.ZComplexConvergenceDomain dhInt:MeasureTheory.Integrable (ComplexLaplaceIntegrand (fun config => H.H config) β) MeasureTheory.volume(fun a => have E := H.H a; if h : E = then 0 else Real.exp (-β * E.untop h)) =ᵐ[MeasureTheory.volume] fun a => RCLike.re (ComplexLaplaceIntegrand (fun config => H.H config) (↑β) a) D:TypeH:MicroHamiltonian Dd:Dβ::β H.ZComplexConvergenceDomain dhInt:MeasureTheory.Integrable (ComplexLaplaceIntegrand (fun config => H.H config) β) MeasureTheory.volumeconfig:H.dim d (have E := H.H config; if h : E = then 0 else Real.exp (-β * E.untop h)) = RCLike.re (ComplexLaplaceIntegrand (fun config => H.H config) (↑β) config) D:TypeH:MicroHamiltonian Dd:Dβ::β H.ZComplexConvergenceDomain dhInt:MeasureTheory.Integrable (ComplexLaplaceIntegrand (fun config => H.H config) β) MeasureTheory.volumeconfig:H.dim d (have E := H.H config; if h : E = then 0 else Real.exp (-β * E.untop h)) = RCLike.re (if h : (fun config => H.H config) config = then 0 else Complex.exp (-β * (((fun config => H.H config) config).untop h))) D:TypeH:MicroHamiltonian Dd:Dβ::β H.ZComplexConvergenceDomain dhInt:MeasureTheory.Integrable (ComplexLaplaceIntegrand (fun config => H.H config) β) MeasureTheory.volumeconfig:H.dim d h:H.H config = (have E := H.H config; if h : E = then 0 else Real.exp (-β * E.untop h)) = RCLike.re (if h : (fun config => H.H config) config = then 0 else Complex.exp (-β * (((fun config => H.H config) config).untop h)))D:TypeH:MicroHamiltonian Dd:Dβ::β H.ZComplexConvergenceDomain dhInt:MeasureTheory.Integrable (ComplexLaplaceIntegrand (fun config => H.H config) β) MeasureTheory.volumeconfig:H.dim d h:¬H.H config = (have E := H.H config; if h : E = then 0 else Real.exp (-β * E.untop h)) = RCLike.re (if h : (fun config => H.H config) config = then 0 else Complex.exp (-β * (((fun config => H.H config) config).untop h))) D:TypeH:MicroHamiltonian Dd:Dβ::β H.ZComplexConvergenceDomain dhInt:MeasureTheory.Integrable (ComplexLaplaceIntegrand (fun config => H.H config) β) MeasureTheory.volumeconfig:H.dim d h:H.H config = (have E := H.H config; if h : E = then 0 else Real.exp (-β * E.untop h)) = RCLike.re (if h : (fun config => H.H config) config = then 0 else Complex.exp (-β * (((fun config => H.H config) config).untop h))) All goals completed! 🐙 D:TypeH:MicroHamiltonian Dd:Dβ::β H.ZComplexConvergenceDomain dhInt:MeasureTheory.Integrable (ComplexLaplaceIntegrand (fun config => H.H config) β) MeasureTheory.volumeconfig:H.dim d h:¬H.H config = (have E := H.H config; if h : E = then 0 else Real.exp (-β * E.untop h)) = RCLike.re (if h : (fun config => H.H config) config = then 0 else Complex.exp (-β * (((fun config => H.H config) config).untop h))) D:TypeH:MicroHamiltonian Dd:Dβ::β H.ZComplexConvergenceDomain dhInt:MeasureTheory.Integrable (ComplexLaplaceIntegrand (fun config => H.H config) β) MeasureTheory.volumeconfig:H.dim d h:¬H.H config = Real.exp (-β * (H.H config).untop ) = RCLike.re (Complex.exp (-β * ((H.H config).untop ))) All goals completed! 🐙 _ = RCLike.re ( x, ComplexLaplaceIntegrand (fun config : H.dim d => H.H config) (β : ) x) := integral_re hInt

The partition function as a function of temperature T instead of β.

def partitionZT (T : ) : := partitionZ H d (1/T)

The Internal Energy, U or E, defined as -∂(ln Z)/∂β. Parameterized here with β.

def internalU (β : ) : := -deriv (fun β' (partitionZ H d β').log) β

The Helmholtz Free Energy, -T * ln Z. Also denoted F. Parameterized here with temperature T, not β.

def helmholtzA (T : ) : := -T * (partitionZT H d T).log

The entropy, defined as the -∂A/∂T. Function of T.

def entropyS (T : ) : := -deriv (helmholtzA H d) T

The entropy, defined as ln Z + β*U. Function of β.

def entropySβ (β : ) : := (partitionZ H d β).log + β * internalU H d β

To be able to compute or define anything from a Hamiltonian, we need its partition function to be a computable integral. A Hamiltonian is ZIntegrable at β if PartitionZ is Lesbegue integrable and nonzero.

def ZIntegrable (β : ) : Prop := MeasureTheory.Integrable (fun (config : H.dim d ) let E := H.H config; if h : E = then 0 else Real.exp (-β * (E.untop h))) (H.partitionZ d β 0)

This Prop defines the most common case of ZIntegrable, that it is integrable at all finite temperatures (aka all positive β).

def PositiveβIntegrable : Prop := β > 0, H.ZIntegrable d β

The two definitions of entropy, in terms of T or β = 1 / T, are equivalent.

D:TypeH:MicroHamiltonian Dd:DT:hT:T 0hZne:H.partitionZ d (1 / T) 0hZint:(1 / T) interior (H.ZComplexConvergenceDomain d)hZdiff:DifferentiableAt (H.partitionZ d) (1 / T)DifferentiableAt (fun β => Real.log (H.partitionZ d β)) (1 / T) All goals completed! 🐙 D:TypeH:MicroHamiltonian Dd:DT:hT:T 0hZne:H.partitionZ d (1 / T) 0hZint:(1 / T) interior (H.ZComplexConvergenceDomain d)hZdiff:DifferentiableAt (H.partitionZ d) (1 / T)DifferentiableAt (fun T => T⁻¹) T All goals completed! 🐙 D:TypeH:MicroHamiltonian Dd:DT:hT:T 0hZne:H.partitionZ d (1 / T) 0hZint:(1 / T) interior (H.ZComplexConvergenceDomain d)hZdiff:DifferentiableAt (H.partitionZ d) (1 / T)DifferentiableAt Neg.neg T All goals completed! 🐙 D:TypeH:MicroHamiltonian Dd:DT:hT:T 0hZne:H.partitionZ d (1 / T) 0hZint:(1 / T) interior (H.ZComplexConvergenceDomain d)hZdiff:DifferentiableAt (H.partitionZ d) (1 / T)DifferentiableAt (fun T => Real.log (H.partitionZT d T)) T simp_rw D:TypeH:MicroHamiltonian Dd:DT:hT:T 0hZne:H.partitionZ d (1 / T) 0hZint:(1 / T) interior (H.ZComplexConvergenceDomain d)hZdiff:DifferentiableAt (H.partitionZ d) (1 / T)DifferentiableAt (fun T => Real.log (H.partitionZT d T)) TD:TypeH:MicroHamiltonian Dd:DT:hT:T 0hZne:H.partitionZ d (1 / T) 0hZint:(1 / T) interior (H.ZComplexConvergenceDomain d)hZdiff:DifferentiableAt (H.partitionZ d) (1 / T)DifferentiableAt (fun T => Real.log (H.partitionZ d (1 / T))) T] All goals completed! 🐙
--! Specializing to a system of particles in space namespace NVEHamiltonian

Pressure, as a function of T. Defined as the conjugate variable to volume.

def pressure (T : ) : := let (n, V) := d; - deriv (fun V' helmholtzA H (n, V') T) V