Onsager reciprocal relations: Gaussian fluctuations, relaxation and kinetic coefficients
DefinitionOnsagerReciprocal_basicBasic objects of the abstract (Landau–Lifshitz) formulation of the Onsager reciprocal relations, all living in the namespace OnsagerReciprocal.
Let be fluctuations of thermodynamic quantities from their equilibrium values, and let be a real matrix (in the source, , a positive definite symmetric matrix) and a real matrix (the relaxation matrix in ).
- Fluctuation weight. (Einstein summation), the unnormalized Gaussian probability density of the fluctuations.
- Equilibrium average. For ,
- Conjugate quantities. .
- Mean relaxation. , the mean value at time of the fluctuation that takes the value at (the solution of , ); and .
- Kinetic coefficients. , i.e. .
- Time correlation. .
These are the objects in which Onsager's principle and the intermediate steps of its proof are stated.
Formalization Note Vectors are functions Fin n → ℝ with the product Lebesgue measure. The average is a ratio of Bochner integrals, so it returns junk values () if an integrand is not integrable; all theorems using it assume positive definite, which makes every integrand used integrable. The matrix inverse β⁻¹ is Mathlib's Matrix.inv (zero for singular matrices). The entropy and Boltzmann's constant are not modelled: is taken as the primitive datum, exactly as in the source's statement of the principle.
import Mathlib
/-!
# Onsager reciprocal relations — basic objects (abstract formulation)
Source: Wikipedia, "Onsager reciprocal relations", section "Abstract formulation" and its
"Proof" subsection (oldid=1355014688), following Landau–Lifshitz, *Statistical Physics, Part 1*.
* `x = (x₁, …, xₙ)` are fluctuations from equilibrium, distributed with the (unnormalized)
Gaussian weight `w(x) = exp(-½ βᵢₖ xᵢ xₖ)`.
* `Xᵢ = βᵢₖ xₖ` are the thermodynamic conjugate quantities.
* In the quasi-stationary regime `ẋ = -λ x`; the mean value of the fluctuation at time `t`,
starting from the value `x₀` at `t = 0`, is `ξ(t) = exp(-t λ) x₀`, and `Ξ(t) = β ξ(t)`.
* `γ = λ β⁻¹` are the kinetic coefficients.
-/
namespace OnsagerReciprocal
open Matrix MeasureTheory
variable {n : ℕ}
/-- The unnormalized Gaussian fluctuation weight `w(x) = exp(-½ ∑ᵢₖ βᵢₖ xᵢ xₖ)`. -/
noncomputable def fluctuationWeight (β : Matrix (Fin n) (Fin n) ℝ) (x : Fin n → ℝ) : ℝ :=
Real.exp (-(1 / 2) * (x ⬝ᵥ (β *ᵥ x)))
/-- The equilibrium average `⟨f⟩ = (∫ f(x) w(x) dx) / (∫ w(x) dx)` with respect to the
Gaussian fluctuation distribution (Lebesgue measure on `ℝⁿ`). -/
noncomputable def fluctuationAverage (β : Matrix (Fin n) (Fin n) ℝ)
(f : (Fin n → ℝ) → ℝ) : ℝ :=
(∫ x, f x * fluctuationWeight β x) / ∫ x, fluctuationWeight β x
/-- The thermodynamic conjugate quantities `Xᵢ = βᵢₖ xₖ`. -/
def conjugate (β : Matrix (Fin n) (Fin n) ℝ) (x : Fin n → ℝ) : Fin n → ℝ :=
β *ᵥ x
/-- The mean value `ξ(t) = exp(-t λ) x₀` of the fluctuation at time `t`, given that it takes
the value `x₀` at `t = 0`; it is the solution of `ξ̇ = -λ ξ`, `ξ(0) = x₀`. -/
noncomputable def meanFluctuation (lam : Matrix (Fin n) (Fin n) ℝ) (t : ℝ)
(x₀ : Fin n → ℝ) : Fin n → ℝ :=
NormedSpace.exp ((-t) • lam) *ᵥ x₀
/-- The mean value `Ξ(t) = β ξ(t)` of the conjugate quantities at time `t`. -/
noncomputable def meanConjugate (β lam : Matrix (Fin n) (Fin n) ℝ) (t : ℝ)
(x₀ : Fin n → ℝ) : Fin n → ℝ :=
β *ᵥ meanFluctuation lam t x₀
/-- The kinetic coefficients `γ = λ β⁻¹`, i.e. `γᵢₖ = λᵢₗ (β⁻¹)ₗₖ`. -/
noncomputable def kineticCoeff (β lam : Matrix (Fin n) (Fin n) ℝ) :
Matrix (Fin n) (Fin n) ℝ :=
lam * β⁻¹
/-- The time correlation `⟨xᵢ(t) xₖ(0)⟩ = ⟨ξᵢ(t) xₖ⟩` in the equilibrium ensemble. -/
noncomputable def timeCorrelation (β lam : Matrix (Fin n) (Fin n) ℝ) (t : ℝ)
(i k : Fin n) : ℝ :=
fluctuationAverage β (fun x => meanFluctuation lam t x i * x k)
end OnsagerReciprocal
Read-back
What the Lean code literally says, in plain math · Aristotle (Harmonic)
Non-blind read-back — not independent testimony. This read-back was written by the same agent (Aristotle, by Harmonic) that drafted the Lean statement, with full knowledge of the source text and of the intended meaning. It was not produced by a blind, independent auditor, so reviewers must not treat it as independent testimony; compare the Lean code against the source yourself.
This file declares, for every and real matrices (no hypotheses are imposed by the definitions themselves):
- for .
- For any real function on , is the real number , integrals with respect to Lebesgue measure on . If is not Lebesgue integrable its integral is taken to be ; if the denominator is (e.g. not integrable, which happens for instance when ) the quotient is .
- (matrix–vector product).
- , where is the matrix exponential series; . Defined for all real , including negative .
- , where is the true inverse when and the zero matrix otherwise (so for singular ).
- for .
When all vectors are empty, carries the unit point mass, , and every average of a function equals at the unique point.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.