Calculus of Variations – Implementation

Base.diffFunction
diff(ab::OrbitalOverlap, o::O)

Vary the orbital overlap ⟨a|b⟩ with respect to |o⟩.

source
diff(ab::OrbitalOverlap, o::Conjugate{O})

Vary the orbital overlap ⟨a|b⟩ with respect to ⟨o|.

source
diff(ome::OrbitalMatrixElement, o::O)

Vary the orbital overlap ⟨abc...|Ω|xyz...⟩ with respect to |o⟩.

source
diff(ome::OrbitalMatrixElement, o::Conjugate{O})

Vary the orbital overlap ⟨abc...|Ω|xyz...⟩ with respect to ⟨o|.

source
diff(me::NBodyMatrixElement, o::O)

Vary the NBodyMatrixElement me with respect to the orbital o.

source
diff(E::Matrix{NBodyMatrixElement}, o::O)

Vary the matrix of NBodyMatrixElements with respect to the orbital o.

Examples

julia> E = Matrix(OneBodyHamiltonian()+CoulombInteraction(),
                  SlaterDeterminant.([[:a, :b], [:c, :d]]))
2×2 Array{EnergyExpressions.NBodyMatrixElement,2}:
 (a|a) + (b|b) - G(a,b) + F(a,b)  - [a b|d c] + [a b|c d]
 - [c d|b a] + [c d|a b]          (c|c) + (d|d) - G(c,d) + F(c,d)

julia> diff(E, :a)
2×2 SparseArrays.SparseMatrixCSC{LinearCombinationEquation,Int64} with 2 stored entries:
  [1, 1]  =  ⟨a|ĥ + -⟨b|[a|b] + ⟨a|[b|b]
  [2, 1]  =  -⟨d|[c|b] + ⟨c|[d|b]

julia> diff(E, Conjugate(:b))
2×2 SparseArrays.SparseMatrixCSC{LinearCombinationEquation,Int64} with 2 stored entries:
  [1, 1]  =  ĥ|b⟩ + -[a|b]|a⟩ + [a|a]|b⟩
  [1, 2]  =  -[a|d]|c⟩ + [a|c]|d⟩
source
diff(energy_expression, orbitals)

Derive the integro-differential equations for all orbitals, from energy_expression. Returns a MCEquationSystem, that gathers information on which integrals are common to all equations, for efficient equation solving.

source