API
KeldyshContraction
— ModuleKeldyshContraction.jl
KeldyshContraction.jl is a package for the symbolic derivation of the two-point correlator diagrams in Keldysh-Schwinger field theory. The symbolic quantum field theory algebra is implemented using SymbolicUtils.jl and TermInterface.jl of the JuliaSymbolic ecosystem. The typesystem has been heavily inspired by the second quantization algebra defined in QuantumCumulants.jl. For more details on the implementation see the "symbolic quantum field algebra" documentation page.
In developing this package, the work SciPost Phys. Core 8, 014 (2025)
symbolic quantum field algebra was used extensively. Hence, the corresponding conventions and notation are used in this package.
Field Types
Individual Fields
╭───────────────────────── Types hierarchy ───╮
│ │
│ KeldyshContraction.QField │
│ ━━━━━━━━━━━━━━━━━━━━━━━━━━━ │
│ │ │
│ ├── KeldyshContraction.QTerm │
│ └── KeldyshContraction.QSym │
│ ├── Create │
│ └── Destroy │
│ │
╰─────────────────────────────────────────────╯
KeldyshContraction.QField
— TypeQField
Abstract type representing any expression involving Fields.
KeldyshContraction.QSym
— TypeQSym <: QField
Abstract type representing fundamental Field types.
KeldyshContraction.Create
— TypeCreate <: QSym
Bosonic field representing the quantum field creation operator.
KeldyshContraction.Destroy
— TypeDestroy <: QSym
Bosonic field representing the quantum field annihilation operator.
Field Properties
The field properties are determined by the Enum objects:
KeldyshContraction.KeldyshContour
— ModuleKeldyshContour `Quantum` `Classical`
Keldysh contour enum for the Keldysh quantum field. The Keldysh contour is used to distinguish the field on quantum and classical contour.
KeldyshContraction.Regularisation
— ModuleRegularisation `Plus` `Zero` `Minus`
Regularisation enum for the Keldysh quantum field. The regularisation is used to perform tadpole regularisation during the Wick contraction.
And the position of the field is determined by the AbstractPosition
object:
KeldyshContraction.Position
— Typestruct Position
Position type for the Keldysh quantum field. The position is used to determine the coordinate of the field during the wick contraction.
Position has thee cases:
KeldyshContraction.In
— FunctionIn()
Create a Position
representing the input field.
KeldyshContraction.Out
— FunctionOut()
Create a Position
representing the output field.
KeldyshContraction.Bulk
— FunctionBulk(i::Int=1)
Create a Bulk
position with a positive integer index i
.
Field Constructors
It is expected to create the fields using the Create
and Destroy
constructors, together with the @qfields
macro.
KeldyshContraction.@qfields
— Macro@qfields
Convenience macro for the construction of fields.
Examples
julia> using KeldyshContraction: Classical, Quantum
julia> @qnumbers ψ::Destroy(Classical)
(ψ,)
The created fields are callable to change a property of the individual fields:
using KeldyshContraction
using KeldyshContraction: position
@qfields ϕ::Destroy(Classical)
position(ϕ)
KeldyshContraction.Position(1)
Field Algebra
╭──────────────────────────── Types hierarchy ───╮
│ │
│ KeldyshContraction.QField │
│ ━━━━━━━━━━━━━━━━━━━━━━━━━━━ │
│ │ │
│ ├── KeldyshContraction.QSym │
│ └── KeldyshContraction.QTerm │
│ ├── KeldyshContraction.QAdd │
│ └── KeldyshContraction.QMul │
│ │
╰────────────────────────────────────────────────╯
KeldyshContraction.QTerm
— TypeQTerm <: QField
Abstract type representing noncommutative expressions.
KeldyshContraction.QMul
— Typestruct QMul{T<:Number} <: KeldyshContraction.QTerm
Represent a multiplication involving quantum fields of QSym
types.
arg_c
: The commutative prefactor.args_nc
: A vector containing allQSym
types.
KeldyshContraction.QAdd
— TypeQAdd <: QTerm
Represent an addition involving QField
and other types.
TermInterface.arguments
— Methodarguments(a::QMul)
Return the vector of the factors of QMul
.
TermInterface.arguments
— Methodarguments(a::QAdd)
Return the vector of the arguments of QAdd
.
The properties of the expression can be checked using:
KeldyshContraction.is_bulk
— Functionis_bulk(q::QTerm)
Checks if a term is in the bulk. A term is bulk if it has no In
or Out
position fields (Position
).
KeldyshContraction.is_conserved
— Functionis_conserved(a::QTerm)
Checks if an expression [QTerm
])(@ref) is conserved. A conserved expression is one that has equal numbers of creation and annihilation operators.
See also: is_physical
KeldyshContraction.is_physical
— Functionis_physical(a::QTerm)
Checks if an expression [QTerm
])(@ref) is physical. A physical expression is one that if it has an In
position field it also has an Out
position field and vice versa ([Position
])(@ref). Furthermore, In
position field can only creation fields (Create
) and Out
position field can only have annihilation fields (Destroy
).
See also: is_conserved
Systems
KeldyshContraction.InteractionLagrangian
— Typestruct InteractionLagrangian{T}
Represents an interaction Lagrangian
Fields
lagrangian
: The Lagrangian expression as aQTerm
qfield
: The quantum field destruction operatorcfield
: The classical field destruction operatorposition
: The position of the interaction Lagrangianparameter
: Parameters of the perturbation series
Constructor
Constructs an InteractionLagrangian from a given QTerm
expression.
Requirements
The constructor enforces several constraints on the input expression and throws AssertionError
if any of them are not met:
- Must be a bulk term (
is_bulk
) - Must be conserved (
is_conserved
) - Must be physical (
is_physical
) - Can only contain up to two different fields
- Fields must have opposite contours
Wick Contraction
KeldyshContraction.wick_contraction
— Functionwick_contraction(expr::QTerm)
Compute all possible Wick contractions of quantum fields in the expression expr
.
Wick contractions decompose products of quantum field operators into sums of products of propagators (two-point correlation functions). The rules of the contraction are:
- Conservation (equal numbers of creation/annihilation operators)
- Physicality (proper time ordering)
- No quantum-quantum contractions
- If the fields have a
Regularisation
applied, the contractions are regularised. TheRegularisation
property is set to zero after the reguralisation.
The function handles two types of inputs:
QAdd
: Distributes the contraction over sumsQMul
: Contracts products of fields into propagators
The function returns a new expression of propagators of type SymbolicUtils.Symbol
.
Propagator
KeldyshContraction.PropagatorType
— ModulePropagatorType `Keldysh`, `Advanced`, `Retarded`
The type of propagator taken of two fields with the x-y Contour where x
is the Contour of the Destroy
field and y
the contour of the Create
field.
Keldysh
propagator of a Classical-Classical contourAdvanced
propagator of a Quantum-Classical contourRetarded
propagator of a Classical-Quantum contour
The Quantum-Quantum propagator should always be zero.
KeldyshContraction.DressedPropagator
— Typestruct DressedPropagator{E1, E2}
A structure representing dressed propagator in the Retarded-Advanced-Keldysh basis (PropagatorType
).
Fields
keldysh
: The Keldysh component of the propagatorretarded
: The retarded component of the propagatoradvanced
: The advanced component of the propagatororder
: The order of the dressed propagator in the perturbation seriesparameter
: Parameters of the perturbation series
where it assumed that the fields are of type Union{SymbolicUtils.Symbolic{<:Number}, Number}
.
Constructor
Constructs a DressedPropagator
with the given Keldysh, retarded, and advanced components.
KeldyshContraction.matrix
— Methodmatrix(G::DressedPropagator)
Returns the matrix representation of the dressed propagator G
in the Retarded-Advanced-Keldysh basis.
\[\hat{G}\left(x_1, x_2\right) =\left( \begin{array}{cc} G^K\left(x_1, x_2\right) & G^R\left(x_1, x_2\right) \\ G^A\left(x_1, x_2\right) & 0 \end{array} \right)\]
matrix(Σ::SelfEnergy)
Returns the matrix representation of the self energy Σ
in the Retarded-Advanced-Keldysh basis.
\[\hat{\Sigma}\left(y_1, y_2\right)= \left(\begin{array}{cc}0 & \Sigma^A\left(y_1, y_2\right) \\ \Sigma^R\left(y_1, y_2\right) & \Sigma^K\left(y_1, y_2\right) \end{array} \right)\]
Self-Energy
KeldyshContraction.SelfEnergy
— Typestruct SelfEnergy{E1, E2}
A struct representing the self-energy components in the Retarded-Advance-Keldysh basis (PropagatorType
). The self-energy is divided into three components: Keldysh, retarded, and advanced.
Fields
keldysh
: The Keldysh component of the self-energy.retarded
: The retarded component of the self-energy.advanced
: The advanced component of the self-energy.order
: The order of the self-energy in the perturbation seriesparameter
: Parameters of the perturbation series
where it assumed that the fields are of type Union{SymbolicUtils.Symbolic{<:Number}, Number}
.
Constructor
Constructs a SelfEnergy
object from a DressedPropagator
. The self-energy is computed based on the Keldysh Green's function (G.keldysh
) and expanded into its quantum-quantum (qq
), classical-quantum (cq
), and quantum-classical (qc
) components.
KeldyshContraction.matrix
— Methodmatrix(G::DressedPropagator)
Returns the matrix representation of the dressed propagator G
in the Retarded-Advanced-Keldysh basis.
\[\hat{G}\left(x_1, x_2\right) =\left( \begin{array}{cc} G^K\left(x_1, x_2\right) & G^R\left(x_1, x_2\right) \\ G^A\left(x_1, x_2\right) & 0 \end{array} \right)\]
matrix(Σ::SelfEnergy)
Returns the matrix representation of the self energy Σ
in the Retarded-Advanced-Keldysh basis.
\[\hat{\Sigma}\left(y_1, y_2\right)= \left(\begin{array}{cc}0 & \Sigma^A\left(y_1, y_2\right) \\ \Sigma^R\left(y_1, y_2\right) & \Sigma^K\left(y_1, y_2\right) \end{array} \right)\]