Coupled-cluster tools

ElemCo.CCToolsModule
CCTools

A collection of tools for working with coupled cluster theory.

source

Exported functions

ElemCo.CCTools.calc_deco_doubles_normFunction
calc_deco_doubles_norm(T2, tT2=Float64[])

Calculate squared norm of doubles (for decomposed doubles: without contravariant!) T2 are decomposed doubles amplitudes T2[X,Y]=$T_{XY}$ or full doubles amplitudes T2[a,b,i,j]=$T^{ij}_{ab}$.

If the contravariant amplitude tT2 is provided, the norm will be calculated as $T_{XY} T̃_{XY}$.

source
ElemCo.CCTools.calc_singles_energy_using_dfockMethod
calc_singles_energy_using_dfock(EC::ECInfo, T1; fock_only=false)

Calculate coupled-cluster closed-shell singles energy using dressed fock matrix.

if fock_only is true, the energy will be calculated using only non-dressed fock matrix. Returns total energy, SS, OS, and Openshell (0.0) contributions as OutDict with keys (E, ESS, EOS, EO).

source
ElemCo.CCTools.check_projection_rankMethod
check_projection_rank(P, expected_rank::Int, space_name::String)

Check if the projection matrix P has full rank for the expected dimension.

Returns (is_full_rank::Bool, actual_rank::Int). Prints a warning if the rank is less than expected.

source
ElemCo.CCTools.dump_wavefunction_with_amplitudes!Method
dump_wavefunction_with_amplitudes!(EC::ECInfo, T1, T2)

Dump orbitals and CC amplitudes to the TREXIO file specified in wf.store.

Does nothing if EC.options.wf.store is empty or if no orbitals are available (e.g., when running from FCIDUMP without a dump file). For closed-shell case with singles T1 and doubles T2.

source
ElemCo.CCTools.dump_wavefunction_with_amplitudes!Method
dump_wavefunction_with_amplitudes!(EC::ECInfo, T1a, T1b, T2a, T2b, T2ab)

Dump orbitals and unrestricted CC amplitudes to the TREXIO file.

Does nothing if EC.options.wf.store is empty or if no orbitals are available (e.g., when running from FCIDUMP without a dump file).

source
ElemCo.CCTools.dump_wavefunction_with_determinants!Method
dump_wavefunction_with_determinants!(EC::ECInfo, dets, coeffs; nstates=0)

Dump orbitals and CIPHI determinants with CI coefficients to TREXIO file(s).

For single-state (nstates=0 or nstates=1), writes to wf.store. For multi-state, writes each state to a separate file per TREXIO standard:

  • State 1: wf.store
  • State n>1: wf.store with _stateN suffix

Does nothing if EC.options.wf.store is empty.

Arguments

  • dets::Vector{<:AbstractDeterminant}: Determinants
  • coeffs::AbstractVecOrMat{Float64}: CI coefficients (vector for 1 state, matrix for multi-state)
  • nstates::Int=0: Number of states (0 = infer from coeffs)
source
ElemCo.CCTools.project_amplitudesMethod
project_amplitudes(EC::ECInfo, T1_old, T2_old, cMO_old::SpinMatrix, cMO_new::SpinMatrix, 
                   basis_old::BasisSet, basis_new::BasisSet; 
                   classes_old::Tuple{Vector{String},Vector{String}}=(String[], String[]),
                   classes_new::Tuple{Vector{String},Vector{String}}=(String[], String[]))

Project CC amplitudes from an old orbital basis to a new one.

The projection is performed as:

  • Singles: $T_{a}^{i,\text{new}} = P_v^{a'} T_{a'}^{i',\text{old}} P_o^{i'}$
  • Doubles: $T_{ab}^{ij,\text{new}} = P_v^{a'} P_v^{b'} T_{a'b'}^{i'j',\text{old}} P_o^{i'} P_o^{j'}$

where $P$ are projection matrices between old and new orbital spaces.

If classes_old is provided, it is used to determine which orbitals in the old basis were occupied ("Inactive"/"Active") vs virtual ("Virtual"). This is essential when core orbitals are frozen, as the MO coefficient matrix includes all orbitals but amplitudes only involve active orbitals.

If classes_new is provided, it is used similarly for the new basis. Otherwise, EC.space['o'] and EC.space['v'] are used (which may have frozen core indices renumbered from FCIDUMP).

Returns (T1_new, T2_new) for closed-shell case.

source
ElemCo.CCTools.project_amplitudesMethod
project_amplitudes(EC::ECInfo, T1a_old, T1b_old, T2a_old, T2b_old, T2ab_old,
                   cMO_old::SpinMatrix, cMO_new::SpinMatrix,
                   basis_old::BasisSet, basis_new::BasisSet;
                   classes_old=(String[], String[]), occupations_old=(Float64[], Float64[]))

Project unrestricted CC amplitudes from an old orbital basis to a new one.

Arguments

  • classes_old: Tuple of (alphaclasses, betaclasses) orbital class vectors from old calculation. Used to identify Core/Deleted orbitals to exclude.
  • occupations_old: Tuple of (alphaoccupations, betaoccupations) from old calculation. If provided, used to determine occupied/virtual orbitals (more reliable for UHF). If empty, falls back to classes_old or assumes contiguous occupied orbitals.

Returns (T1a_new, T1b_new, T2a_new, T2b_new, T2ab_new).

source
ElemCo.CCTools.read_starting_guess4amplitudesMethod
read_starting_guess4amplitudes(EC::ECInfo, ::Val{level}, spins...)

Read starting guess for excitation level.

The guess will be read from T_vo, T_VO, T_vvoo etc files. If the file does not exist, the guess will be a zeroed-vector.

source
ElemCo.CCTools.save_current_doublesMethod
save_current_doubles(EC::ECInfo, T2a, T2b, T2ab; prefix="T")

Save current doubles amplitudes T2a, T2b, and T2ab to files prefix*"_vvoo", prefix*"_VVOO", and prefix*"_vVoO"

source
ElemCo.CCTools.save_or_start_fileFunction
save_or_start_file(EC::ECInfo, type, excitation_level, save=true)

Return filename and description for saving or starting amplitudes/lagrange multipliers.

type is either "T" for amplitudes or "LM" for Lagrange multipliers. excitation_level is the excitation level of the amplitudes (1, 2 etc.) If save is true, the filename for saving is returned, otherwise the filename for starting.

source
ElemCo.CCTools.spin_project!Method
spin_project!(EC::ECInfo, T1a, T1b, T2a, T2b, T2ab)

Spin-project singles and doubles amplitudes/residuals.

Only possible for high-spin states.

source
ElemCo.CCTools.spin_project_amplitudesFunction
spin_project_amplitudes(EC::ECInfo, with_singles=true)

Spin-project singles (if withsingles) and doubles amplitudes from files `"Tvo","TVO","Tvvoo","TVVOO"and"TvVoO"`.

source
ElemCo.CCTools.try2save_amps!Method
try2save_amps!(EC::ECInfo, ::Val{excitation_level}, amps...; type="T")

Save amplitudes (type="T") or Lagrange multipliers (type="LM") to file EC.options.cc.save[_lm]*"_excitation_level".

source
ElemCo.CCTools.try2save_doubles!Method
try2save_doubles!(EC::ECInfo, doubles...; type="T")

Save doubles amplitudes (type="T") or Lagrange multipliers (type="LM") to file EC.options.cc.save[_lm]*"_2".

source
ElemCo.CCTools.try2save_singles!Method
try2save_singles!(EC::ECInfo, singles...; type="T")

Save singles amplitudes (type="T") or Lagrange multipliers (type="LM") to file EC.options.cc.save[_lm]*"_1".

source
ElemCo.CCTools.try2start_ampsMethod
try2start_amps(EC::ECInfo, ::Val{excitation_level}; type="T")

Read amplitudes (type="T") or Lagrange multipliers (type="LM") from file EC.options.cc.start[_lm]*"_excitation_level".

source
ElemCo.CCTools.try2start_doublesMethod
try2start_doubles(EC::ECInfo; type="T")

Read doubles amplitudes (type="T") or Lagrange multipliers (type="LM") from file EC.options.cc.start[_lm]*"_2".

source
ElemCo.CCTools.try2start_singlesMethod
try2start_singles(EC::ECInfo; type="T")

Read singles amplitudes (type="T") or Lagrange multipliers (type="LM") from file EC.options.cc.start[_lm]*"_1".

source
ElemCo.CCTools.try_fetch_restricted_starting_amplitudesMethod
try_fetch_restricted_starting_amplitudes(EC::ECInfo)

Try to read and project restricted amplitudes from a TREXIO file.

The logic is:

  • If wf.start is not empty: read amplitudes, MOs, and basis from wf.start, then project amplitudes to the current MO basis (obtained via fetch_orbitals from wf.dump).
  • If wf.start is empty: try to read amplitudes from wf.dump (no projection needed).

The occupied space projection rank is checked and a warning is printed if not full rank.

Returns (T1, T2, success::Bool) for closed-shell case.

source
ElemCo.CCTools.try_fetch_starting_determinantsMethod
try_fetch_starting_determinants(EC::ECInfo; OPattern=UInt64, nstates=1)

Try to read determinants and CI coefficients from a TREXIO file for CIPHI restart.

The logic follows CC amplitude restart:

  • If wf.start is not empty: read from wf.start file(s)
  • If wf.start is empty: try to read from wf.dump file(s)

For multi-state, reads from separate files per TREXIO standard.

Returns (dets, coeffs, success::Bool).

source
ElemCo.CCTools.try_fetch_unrestricted_starting_amplitudesMethod
try_fetch_unrestricted_starting_amplitudes(EC::ECInfo)

Try to read and project unrestricted amplitudes from a TREXIO file.

The logic is:

  • If wf.start is not empty: read amplitudes, MOs, and basis from wf.start, then project amplitudes to the current MO basis (obtained via fetch_orbitals from wf.dump).
  • If wf.start is empty: try to read amplitudes from wf.dump (no projection needed).

The occupied space projection rank is checked and a warning is printed if not full rank.

Returns (T1a, T1b, T2a, T2b, T2ab, success::Bool) for unrestricted case.

source
ElemCo.CCTools.update_deco_doublesMethod
update_deco_doubles(EC, R2; use_shift=true)

Update decomposed doubles amplitudes.

If R2 is $R^{ij}_{ab}$, the update is calculated using update_doubles(EC, R2, use_shift=use_shift).

source
ElemCo.CCTools.update_deco_triplesFunction
update_deco_triples(EC, R3, use_shift=true)

Update decomposed triples amplitudes.

Note that the sign of the residual is opposite to the usual definition of the triples residual and therefore the update is calculated using a positive denominator...

source
ElemCo.CCTools.update_doublesMethod
update_doubles(EC::ECInfo, R2; spincase::Symbol=:α, antisymmetrize=false, use_shift=true)

Calculate update for doubles amplitudes for a given spincase∈{,,:αβ}.

source
ElemCo.CCTools.update_singlesMethod
update_singles(EC::ECInfo, R1; spincase::Symbol=:α, use_shift=true)

Calculate update for singles amplitudes for a given spincase∈{,}.

source
ElemCo.CCTools.update_triples!Method
update_triples!(EC::ECInfo, T3a, T3b, T3aab, T3abb, R3a, R3b, R3aab, R3abb)

Update triples amplitudes in T3a, T3b, T3aab and T3abb with R3a, R3b, R3aab and R3abb.

source

Internal functions

ElemCo.CCTools.add_singles2doubles!Method
add_singles2doubles!(T2, T1; make_contravariant=true)

Add singles to doubles amplitudes.

If make_contravariant is true, the amplitudes will be made contravariant.

source
ElemCo.CCTools.update_triplesMethod
update_triples(EC::ECInfo, R3; spincase::Symbol=:α, antisymmetrize=false, use_shift=true)

Calculate update for triples amplitudes for a given spincase∈{,,:ααβ,:αββ}.

source