Calculations

ElemCo.ElemCo — Module
       ╭─────────────╮
Electron Correlation methods
       ╰─────────────╯
source

The ElemCo module contains the main macros and functions for running electronic structure calculations. The methods are contained in various submodules and are described in the following sections.

Setting Options

Options can be set using the @set macro. The preferred way to set options is to use local options within the calculation macro itself. This ensures that options are applied only to the specific calculation and are automatically restored afterwards.

Local Options (Recommended)

All calculation macros accept an optional begin...end block as the last argument to set options locally:

@cc ccsd begin
  @set wf charge=-1 ms2=1
  @set cc maxit=100 thr=1.e-12
end

This is equivalent to:

@cc ccsd begin
  wf(charge=-1, ms2=1)
  cc(maxit=100, thr=1.e-12)
end

The options are automatically restored to their previous values after the calculation completes, even if an error occurs. This makes it safe and convenient to run multiple calculations with different settings:

# Run neutral molecule
@dfhf
@cc ccsd

# Run anion with tighter convergence
@dfhf begin
  @set wf charge=-1
end
@cc ccsd begin
  @set wf charge=-1
  @set cc thr=1.e-12
end

# Options are now back to defaults

Global Options

Options can also be set globally using the @set macro outside of calculation blocks:

@set cc maxit=100
@cc ccsd  # Uses maxit=100
@cc dcsd  # Also uses maxit=100

Global options persist until explicitly changed or reset with @reset.

Restarting a coupled-cluster calculation

A coupled-cluster calculation can be restarted from previously converged amplitudes. This is useful to continue an interrupted run, to converge a related calculation faster (e.g. the next point along a geometry scan or a change of basis), or to reuse the optimized orbitals of an orbital-optimized method such as oqv-dcd.

1. Store the amplitudes. Set wf.store to a file name; the orbitals and the converged amplitudes are written there (in TREXIO/HDF5 format). For an orbital-optimized method the optimized orbitals are stored.

@dfhf
@cc dcsd begin
  @set wf store="cc.h5"
end

2. Restart from the amplitudes. Set wf.start to that file; the stored amplitudes are read and used as the starting guess instead of the default (MP2) guess:

@dfhf
@cc dcsd begin
  @set wf start="cc.h5"
end

By default the reference orbitals are taken from the wf.dump file (the current Hartree–Fock orbitals just written by @dfhf), and the stored amplitudes are projected from the orbitals of the start file onto those dump orbitals. This is what you want when the reference should be the new Hartree–Fock orbitals — e.g. a normal method at a displaced geometry: run @dfhf for the new geometry, then restart the amplitudes onto the freshly computed orbitals.

Reusing the stored orbitals (dump=""). If you do not want to use the orbitals on the dump file but instead want to reuse the orbitals stored in the start file — for instance to resume an orbital-optimized calculation from its optimized orbitals — set wf.dump="":

@cc oqv-dcd begin
  @set wf start="cc.h5" dump=""
end

With dump="" the orbitals from the start file become the reference: they are projected onto the current basis and geometry (and re-orthonormalized), and the amplitudes are then projected onto those projected orbitals. If the basis is larger than the stored one, the missing space is filled with orthogonal complementary orbitals; if it is smaller (or redundant), the excess/redundant orbitals are dropped, exactly as in a fresh Hartree–Fock calculation. For an unchanged geometry and basis this reproduces the stored solution and converges in a single iteration.

Who owns the integrals

Molecular integrals come from one of three places, and the difference matters only for how long they live:

  • An FCIDUMP file (fcidump="FCIDUMP" or created from other sources) — a fixed input, used as given.
  • Exact AO integrals (@ints, also generated by @hf) — they depend on the geometry and basis only, so they stay valid for the whole session and are reused by every method that can run AO-direct.
  • MO integrals — either density-fitted (@dfints) or transformed from the exact AO integrals (@moints). These depend on the orbitals, and therefore on what has happened in the session so far.

For the last kind the rule is whoever creates them, owns them:

  • If you call @dfints (or @moints) yourself, the integrals persist and are yours to refresh. Do this when several calculations should share one generation:

    @dfhf
    @dfints            # one generation ...
    @cc ccsd           # ... used by both
    @cc dcsd

    If the orbitals change afterwards (another @dfhf, @localize, an orbital-optimized method), call @dfints again — nothing else will.

  • If you do not, the correlated driver generates what it needs from the current orbitals and discards it when it finishes:

    @dfhf
    @cc ccsd           # generates its own integrals, then drops them
    @localize
    @cc ccsd           # generates again — from the localized orbitals, as it must

    Each run therefore matches the orbitals it was run with, at the price of repeating a generation that is cheap next to the coupled-cluster iterations themselves.

@write_ints writes the integrals currently in memory, so it needs MO integrals that persist — @dfints or @moints (or an FCIDUMP input):

@hf
@moints            # exact AO integrals (generated if needed) → MO integrals
@write_ints "FCIDUMP"

The written file is self-contained — its NELEC and MS2 describe the system as currently set up, with wf.charge applied. Reading it back therefore needs no charge; setting one would ionize it further, because wf.charge is always relative to the electron count of the integral source (a nelec option, an FCIDUMP, or the neutral molecule).

Note that for a method that can run AO-direct (MP2, CCSD, DCSD and friends) @moints is slower than the default: that route contracts the exact AO integrals directly and never forms the MO integrals at all. Use @moints when the MO integrals themselves are what you want — to write them out, or to reuse one transformation across several runs.

Reserved Variables

Various macros are defined and exported to simplify running calculations. The macros use several reserved variable names. The following table lists the reserved variable names and their meanings.


VariableMeaning
EC::ECInfoA global information object containing options, molecular system description, integrals and orbital spaces information, see ElemCo.ECInfo.
geometry::StringMolecular coordinates, either in the xyz format or the file containing the xyz coordinates, see ElemCo.MSystems.
basis::Union{Dict,String}Basis set information, see ElemCo.MSystems
fcidump::StringFile containing the integrals in the FCIDUMP format, see ElemCo.FciDumps.

The driver routines and macros return energies as ordered descriptive dictionaries ElemCo.ODDict. The last energy is always the total energy (can be accessed using last_energy(energies)). The following table lists the keys and their meanings.


KeyMeaning
ETotal energy
EcCorrelation energy
HFHartree-Fock energy
MP2MP2 energy
CCSDCCSD energy
DCSDDCSD energy
SING2D-DCSDsinglet 2D-DCSD energy
TRIP2D-DCSDtriplet 2D-DCSD energy
etc.

One can print the keys of the returned ODDict to see all the available keys:

julia> println(keys(energies))

or display the complete dictionary together with the descriptions as

julia> display(energies)

The values and the descriptions can be accessed using the keys as

julia> energies["E"] # Total energy
julia> energies("E") # Description of the total energy

Macros

ElemCo.@ECinit — Macro
@ECinit(T=DEFAULT_ELTYPE[])

Initialize EC::ECInfo{T} and add molecular system and/or fcidump if variables geometry::String and basis::Dict{String,Any} and/or fcidump::String are defined.

T is the element type for the fcidump integrals (default: DEFAULT_ELTYPE[], which is Float64 unless changed via set_default_eltype! or @set_default_eltype).

If EC is already initialized, it will be overwritten.

Examples

geometry="He 0.0 0.0 0.0"
basis = Dict("ao"=>"cc-pVDZ", "jkfit"=>"cc-pvtz-jkfit", "mpfit"=>"cc-pvdz-mpfit")
@ECinit
# output
Occupied orbitals:[1]
@ECinit ComplexF64  # use complex integrals
source
ElemCo.@bohf — Macro
@bohf(opts_block=nothing)

Run bi-orthogonal HF calculation using FCIDUMP integrals.

The orbital rotations are stored to WfOptions.dump. For open-shell systems (or UHF FCIDUMPs), the BO-UHF energy is calculated.

Optionally, a begin...end block can be provided to set local options for this call. The options are reset after the call completes.

Examples

fcidump = "FCIDUMP"
@bohf
# with local options:
@bohf begin
  @set scf maxit=100
end
source
ElemCo.@bouhf — Macro
@bouhf(opts_block=nothing)

Run bi-orthogonal UHF calculation using FCIDUMP integrals.

Optionally, a begin...end block can be provided to set local options for this call. The options are reset after the call completes.

Examples

fcidump = "FCIDUMP"
@bouhf
# with local options:
@bouhf begin
  @set scf maxit=100
end
source
ElemCo.@cc — Macro
@cc(method, args...)

Run coupled cluster calculation.

The type of the method is determined by the first argument (ccsd/ccsd(t)/dcsd etc). The method can be specified as a string or as a variable, e.g., @cc CCSD or @cc "CCSD" or ccmethod="CCSD"; @cc ccmethod.

Optionally, a begin...end block can be provided as the last argument to set local options for this call. The options are reset after the call completes.

Keyword arguments

  • fcidump::String: fcidump file (default: "", i.e., use integrals from EC).
  • occa::String: occupied α orbitals (default: "-").
  • occb::String: occupied β orbitals (default: "-").

The occupation strings can be given as a + separated list, e.g. occa = 1+2+3 or equivalently 1-3. Additionally, the spatial symmetry of the orbitals can be specified with the syntax orb.sym, e.g. occa = "-5.1+-2.2+-4.3".

Examples

geometry="bohr
O      0.000000000    0.000000000   -0.130186067
H1     0.000000000    1.489124508    1.033245507
H2     0.000000000   -1.489124508    1.033245507"
basis = Dict("ao"=>"cc-pVDZ", "jkfit"=>"cc-pvtz-jkfit", "mpfit"=>"cc-pvdz-mpfit")
@dfhf
@dfints
@cc ccsd
# with local options:
@cc ccsd begin
  @set wf charge=-1 ms2=1
  @set cc maxit=30
end
source
ElemCo.@ciphi — Macro
@ciphi(args...)

Run CIPHI (CIΦ - CI via Perturbative and Heat-Bath Iterative selection) calculation.

Optionally, a begin...end block can be provided as the last argument to set local options for this call. The options are reset after the call completes.

Keyword arguments

  • occa::String: occupied α orbitals (default: "-").
  • occb::String: occupied β orbitals (default: "-").

The occupation strings can be given as a + separated list, e.g. occa = 1+2+3 or equivalently 1-3. Additionally, the spatial symmetry of the orbitals can be specified with the syntax orb.sym, e.g. occa = "-5.1+-2.2+-4.3".

@sci and @ciϕ are aliases for this macro.

Examples

geometry="bohr
O      0.000000000    0.000000000   -0.130186067
H1     0.000000000    1.489124508    1.033245507
H2     0.000000000   -1.489124508    1.033245507"
basis = Dict("ao"=>"6-31g", "jkfit"=>"vdz-jkfit", "mpfit"=>"vdz-mpfit")
@dfhf
@ciphi
# with local options:
@ciphi begin
  @set ciphi epsilon=1.e-4
end
source
ElemCo.@copyfile — Macro
@copyfile(from_file, to_file, kwargs...)

Copy file from_file to to_file in EC.scr directory.

Keyword arguments

  • overwrite::Bool: overwrite existing file (default: false).
source
ElemCo.@copywf — Macro
@copywf(to_file::AbstractString=""; start=false, state=0)

Copy wavefunction data from the current trexio dump file to another dump file.

If to_file is not provided, the wavefunction is copied to EC.options.wf.store file. Note: This does not check the contents of the files.

Keyword Arguments

  • start::Bool=false: If true, copy from wf.start file instead of wf.dump.
  • state::Int=0: State number for determinant files. If 0, copies the main dump file. If >0, copies the state-specific determinant file (e.g., file_state2.h5).

Examples

julia> @copywf  # copy dump to store
julia> @copywf "backup.h5"  # copy dump to backup file
julia> @copywf start=true  # copy start file to store
julia> @copywf "backup.h5" start=true  # copy start file to backup
julia> @copywf state=2  # copy state 2 determinant file to store
julia> @copywf "state2_backup.h5" state=2  # copy state 2 to specific file
source
ElemCo.@dfcc — Macro
@dfcc(method="svd-dcsd", opts_block=nothing)

Run coupled cluster calculation using density fitted integrals.

The type of the method is determined by the first argument. The method can be specified as a string or as a variable, e.g., @dfcc SVD-DCSD or @dfcc "SVD-DCSD" or ccmethod="SVD-DCSD"; @dfcc ccmethod.

Optionally, a begin...end block can be provided to set local options for this call. The options are reset after the call completes.

Examples

geometry="bohr
O      0.000000000    0.000000000   -0.130186067
H1     0.000000000    1.489124508    1.033245507
H2     0.000000000   -1.489124508    1.033245507"
basis = Dict("ao"=>"cc-pVDZ", "jkfit"=>"cc-pvtz-jkfit", "mpfit"=>"cc-pvdz-mpfit")
@dfhf
@dfcc svd-dcsd
# with local options:
@dfcc svd-dcsd begin
  @set cc maxit=30
end
source
ElemCo.@dfhf — Macro
@dfhf(opts_block=nothing)

Run DF-HF calculation. The orbitals are stored to WfOptions.dump.

Optionally, a begin...end block can be provided to set local options for this call. The options are reset after the call completes.

Examples

@dfhf
# with local options:
@dfhf begin
  @set scf maxit=100 thr=1.e-12
  @set wf charge=-1
end
source
ElemCo.@dfints — Macro
@dfints(opts_block=nothing)

Generate 2 and 4-idx MO integrals using density fitting. The MO coefficients are read from WfOptions.dump.

These integrals PERSIST for the rest of the session and are yours to manage: because they are built from a particular set of orbitals, they become stale if the orbitals change (a re-run @dfhf, @localize, an orbital-optimized method), and re-running @dfints is what refreshes them. A correlated driver (@cc, @fci, ...) that finds no integrals creates its own from the current orbitals and deletes them again when it finishes, so it can never use a stale set — use @dfints when you deliberately want ONE generation to serve several driver calls on the same orbitals.

Optionally, a begin...end block can be provided to set local options for this call. The options are reset after the call completes.

source
ElemCo.@dfmcscf — Macro
@dfmcscf(opts_block=nothing)

Run DF-MCSCF calculation. The orbitals are stored to WfOptions.dump.

Optionally, a begin...end block can be provided to set local options for this call. The options are reset after the call completes.

Examples

@dfmcscf
# with local options:
@dfmcscf begin
  @set scf maxit=100
  @set wf active="(4,4)"
end
source
ElemCo.@dfmp2 — Macro
@dfmp2(opts_block=nothing)

Run density-fitted MP2 calculation.

If save is set in CcOptions.save, the MP2 doubles amplitudes are saved to save*"_2" file.

Optionally, a begin...end block can be provided to set local options for this call. The options are reset after the call completes.

Examples

@dfmp2
# with local options:
@dfmp2 begin
  @set cc save="mp2_amplitudes"
end
source
ElemCo.@dfuhf — Macro
@dfuhf(opts_block=nothing)

Run DF-UHF calculation. The orbitals are stored to WfOptions.dump.

Optionally, a begin...end block can be provided to set local options for this call. The options are reset after the call completes.

Examples

@dfuhf
# with local options:
@dfuhf begin
  @set scf maxit=100
end
source
ElemCo.@dummy — Macro
@dummy(atoms)

Set atoms as dummy atoms in the system. atoms is a list of atom indices or atomic symbols.

After running the macro, only the atoms in the list are set as dummy atoms in the system.

Examples

@dummy [1,2,3]
@dummy ["H1","H2"]
@dummy [1,"H2",:H3]
@dummy [] # unset all dummy atoms
source
ElemCo.@fci — Macro
@fci(args...)

Run FCI calculation.

Optionally, a begin...end block can be provided as the last argument to set local options for this call. The options are reset after the call completes.

Keyword arguments

  • occa::String: occupied α orbitals (default: "-").
  • occb::String: occupied β orbitals (default: "-").

The occupation strings can be given as a + separated list, e.g. occa = 1+2+3 or equivalently 1-3. Additionally, the spatial symmetry of the orbitals can be specified with the syntax orb.sym, e.g. occa = "-5.1+-2.2+-4.3".

Examples

geometry="bohr
O      0.000000000    0.000000000   -0.130186067
H1     0.000000000    1.489124508    1.033245507
H2     0.000000000   -1.489124508    1.033245507"
basis = Dict("ao"=>"6-31g", "jkfit"=>"vdz-jkfit", "mpfit"=>"vdz-mpfit")
@dfhf
@fci
# with local options:
@fci begin
  @set wf charge=-1
end
source
ElemCo.@freeze_orbs — Macro
@freeze_orbs(freeze_orbs)

Freeze orbitals in the integrals according to an array or range freeze_orbs.

Alternatively, the orbitals can be specified as a String with the +/- or :/; syntax, e.g., "1-5+7-8", or "1:5;7-8".

Examples

fcidump = "FCIDUMP"
@freeze_orbs 1:5
...
@ECinit
@freeze_orbs [1,2,20,21]
source
ElemCo.@hf — Macro
@hf(opts_block=nothing)

Run closed-shell Hartree-Fock from exact (non-DF) AO integrals. If the AO integral files are not on file yet, they are generated first (equivalent to calling @ints). The orbitals are stored to WfOptions.dump.

Note: if EC.fd holds (MO/FCIDUMP) integrals they are discarded (with a warning) — @hf runs on exact AO integrals, and a leftover MO dump would shadow the AO flow in subsequent correlated calculations. To run HF on existing FCIDUMP integrals, use @bohf instead.

Optionally, a begin...end block can be provided to set local options for this call. The options are reset after the call completes.

source
ElemCo.@import_matrix — Macro
@import_matrix(filename)

Import matrix from file file.

The type of the matrix is determined automatically.

source
ElemCo.@ints — Macro
@ints(opts_block=nothing)

Generate exact (non-density-fitted) AO integrals and store them as scratch files (overlap S_AA, core Hamiltonian h_AA, and the memory-mapped 4-index ⟨μν|ρσ⟩ ao_int2). EC.fd is not used — it holds MO integrals only; MO dumps are derived from the AO files on demand. This is the non-DF AO counterpart of @dfints.

Optionally, a begin...end block can be provided to set local options for this call. The options are reset after the call completes.

source
ElemCo.@loadfile — Macro
@loadfile(filename)

Read file filename from EC.scr directory.

Example

fock = @loadfile("f_mm")
source
ElemCo.@loadwf — Macro
@loadwf(what...; start=false, state=1)

Load wavefunction data from the trexio dump file.

The arguments what can be a vector of strings, a string variable or a list of arguments specifying what to load. Possible values are:

  • all: load everything available (overrides other options)
  • orbital_energies: molecular orbital energies
  • orbital_occupations: molecular orbital occupations
  • amplitudes: restricted CC amplitudes (T1, T2)
  • unrestricted_amplitudes: unrestricted CC amplitudes (T1a, T1b, T2a, T2b, T2ab)
  • determinants: selected CI determinants and coefficients

The loaded data are returned as a dictionary with keys corresponding to the requested data. basis, orbitals and orbital_type are always included in the output.

Keyword Arguments

  • start::Bool=false: If true, read from wf.start file instead of wf.dump
  • state::Int=1: State number for determinants (1 = ground state)
  • OPattern::Type=UInt64: Orbital pattern type for determinants (use UInt128 for >64 orbitals)

Examples

julia> wf = @loadwf orbital_energies orbital_occupations
julia> wf["basis"]  # basis set information
julia> wf = @loadwf ["orbital_energies", "orbital_occupations"]
julia> wf = @loadwf amplitudes  # load CC amplitudes
julia> wf = @loadwf determinants state=2  # load determinants for excited state
julia> wf = @loadwf all start=true  # load everything from start file
source
ElemCo.@localize — Macro
@localize(opts_block=nothing)

Localize the current orbitals using IBO/Pipek-Mezey/Boys (occupied) and optionally OPAO (virtual).

The orbitals are read from WfOptions.start and stored to WfOptions.store. If start or store is not specified, the orbitals are read from and/or stored back to WfOptions.dump.

Optionally, a begin...end block can be provided to set local options for this call. The options are reset after the call completes.

Options (set via @set loc)

  • virtual::Bool: if true (default), also localize virtual orbitals via OPAO.
  • exponent::Int: IBO exponent, 2 for Pipek-Mezey, 4 for fourth-moment (default).

Examples

@dfhf
@localize
# with local options:
@localize begin
  @set loc virtual=false exponent=2
end
source
ElemCo.@mainname — Macro
@mainname(file)

Return the main name of a file, i.e. the part before the last dot and the extension.

Examples

julia> @mainname("~/test.xyz")
("test", "xyz")
source
ElemCo.@moints — Macro
@moints(opts_block=nothing)

Generate 2 and 4-idx MO integrals from exact (non-density-fitted) AO integrals. If the AO integral files are not on file yet, they are generated first (equivalent to calling @ints). The MO coefficients are read from WfOptions.dump. This is the non-DF counterpart of @dfints.

As in @dfints, the dump covers the active space: the frozen core is folded into the one-electron integrals and the core energy, and deleted/frozen virtuals are left out (wf.freeze_nocc=0 keeps the core in the dump).

These integrals PERSIST for the rest of the session and are yours to manage: because they are built from a particular set of orbitals, they become stale if the orbitals change (a re-run @hf, @localize, an orbital-optimized method), and re-running @moints is what refreshes them. Use it when the MO integrals themselves are the point — to write them out with @write_ints, or to have ONE generation serve several driver calls on the same orbitals:

@hf
@moints
@write_ints "FCIDUMP"
@cc ccsd

Note that a correlated method that can run AO-direct (MP2/CCSD/DCSD and friends) is faster without @moints: it contracts the AO integrals directly and never forms the MO integrals.

Optionally, a begin...end block can be provided to set local options for this call. The options are reset after the call completes.

source
ElemCo.@molpro_input — Macro
@molpro_input(filename="elemcoil")

Initialize the Molpro interface with the given filename.

It relies on the Molpro XML file to set up the molecule and basis set. If the basis variable exists, it will be updated with the AO basis set from the XML file.

See MolproInterface for more details on the Molpro interface.

source
ElemCo.@molpro_output — Macro
@molpro_output(ecvariables, kwargs...)

Save key-value pairs from ecvariables to a ECVARIABLES file in the MolproInterface.MolproInfo object.

The ecvariables is a dictionary with the variables to be included in the output. The keyword arguments are passed to the MolproInterface.save_ecvariables_to_file function. Possible keyword arguments include:

  • prefix::String: prefix for each variable in the output file (default: "")
  • new::Bool: if true, create a new file, otherwise append to the existing file (default: true)
source
ElemCo.@print_input — Macro
@print_input(print_init=false)

Print the input file content.

Can be used to print the input file content to the output.

source
ElemCo.@region — Macro
@region(centers=nothing, opts_block=nothing)

Build a region-tagged orbital dump from localized occupied orbitals and fragment OPAOs.

centers is an optional list of atom indices or center labels. When omitted, the requested centers are taken from region.inclusive_centers and region.exclusive_centers. The macro reads orbitals from WfOptions.start when provided, otherwise from WfOptions.dump, and writes the tagged result to WfOptions.store if set, otherwise back to the main dump.

Optionally, a begin...end block can be provided to set local region or loc options for this call.

Examples

@region [1, 2]
@region [:O, :H1] begin
  @set region mode=:exclusive occ_charge_thr=0.25 atom_charge_thr=0.15
end
@region [:C1, :C2, :C3, :C4] begin
  @set region pi=:both pi_occupied=1 pi_virtual=1
end
@region begin
  @set region inclusive_centers=[2] exclusive_centers=[1]
end
source
ElemCo.@rotate_orbs — Macro
@rotate_orbs(orb1, orb2, angle, kwargs...)

Rotate orbitals orb1 and orb2 from WfOptions.dump by angle (in degrees). For UHF, spin can be :α or :β (keyword argument).

The orbitals are stored to WfOptions.store.

Keyword arguments

  • spin::Symbol: spin of the orbitals (default: :α).

Examples

@dfhf
# swap orbitals 1 and 2
@rotate_orbs 1, 2, 90
source
ElemCo.@savefile — Macro
@savefile(filename, arr, kwargs...)

Save array or tuple of arrays arr to file filename in EC.scr directory.

Keyword arguments

  • description::String: description of the file (default: "tmp").
  • overwrite::Bool: overwrite existing file (default: false).
source
ElemCo.@savewf — Macro
@savewf(wf::AbstractDict; state=1)

Save wavefunction data to the trexio dump file.

The argument wf is a dictionary with the data to be saved. Possible keys are:

Orbital data:

  • "basis": basis set information
  • "orbitals": molecular orbitals
  • "rotations": orbital rotations (alternative to "orbitals")
  • "orbital_type": type of the orbitals (e.g., "RHF", "UHF", "ROHF", "MCSCF")
  • "orbital_energies": molecular orbital energies
  • "orbital_occupations": molecular orbital occupations

Restricted CC amplitudes:

  • "T1": singles amplitudes (nvirt × nocc)
  • "T2": doubles amplitudes (nvirt × nvirt × nocc × nocc)

Unrestricted CC amplitudes:

  • "T1a", "T1b": α and β singles amplitudes
  • "T2a", "T2b", "T2ab": αα, ββ, and αβ doubles amplitudes

Selected CI (CIPHI) data:

  • "determinants": vector of determinants
  • "ci_coefficients": CI coefficients (vector for single state, matrix for multi-state)

Keyword Arguments

  • state::Int=1: State number for determinants (used when ci_coefficients is a vector)

Examples

julia> wf = @loadwf orbital_energies orbital_occupations
julia> orbs = wf["orbitals"]
[...]
julia> wf1 = Dict("basis"=>wf["basis"], "orbitals"=>orbs, "orbital_type"=>"modified RHF") 
julia> @savewf wf1

julia> # Save amplitudes
julia> @savewf Dict("T1"=>T1, "T2"=>T2)

julia> # Save determinants for excited state
julia> @savewf Dict("determinants"=>dets, "ci_coefficients"=>coeffs) state=2
source
ElemCo.@set — Macro
@set(opt, kwargs...)

Set options for EC::ECInfo.

The first argument opt is the name of the option (e.g., scf, cc, cholesky), see ECInfos.Options. The keyword arguments are the options to be set (e.g., thr=1.e-14, maxit=10). The current state of the options can be stored in a variable, e.g., opt_cc = @set cc. The state can then be restored by @set cc opt_cc. If EC is not already initialized, it will be done.

Examples

optscf = @set scf thr=1.e-14 maxit=10
@set cc maxit=100
...
@set scf optscf
source
ElemCo.@set_default_eltype — Macro
@set_default_eltype(T)

Set the default element type for new ECInfo objects.

Examples

@set_default_eltype ComplexF64
@ECinit  # will create ECInfo{ComplexF64}
source
ElemCo.@show_orbs — Macro
@show_orbs(range=nothing)

Show orbitals in the integrals according to an array or range range.

Examples

@dfhf
@show_orbs 1:5
source
ElemCo.@transform_ints — Macro
@transform_ints()

Rotate FCIDump integrals using rotations from WfOptions.dump as transformation matrices.

The orbital rotations are read from WfOptions.dump. If type of the rotations contains the word biorthogonal, the bi-orthogonal orbitals are used.

source
ElemCo.@uhf — Macro
@uhf(opts_block=nothing)

Run unrestricted Hartree-Fock from exact (non-DF) AO integrals. If the AO integral files are not on file yet, they are generated first (equivalent to calling @ints). The orbitals are stored to WfOptions.dump.

Note: if EC.fd holds (MO/FCIDUMP) integrals they are discarded (with a warning) — @uhf runs on exact AO integrals, and a leftover MO dump would shadow the AO flow in subsequent correlated calculations. To run UHF on existing FCIDUMP integrals, use @bouhf instead.

Optionally, a begin...end block can be provided to set local options for this call. The options are reset after the call completes.

source
ElemCo.@usewf — Macro
@usewf(from_file::AbstractString=""; start=false, state=0)

Copy wavefunction data to the current trexio dump file from another dump file, i.e., it does the opposite of @copywf.

If from_file is not provided, the wavefunction is copied from EC.options.wf.store file. Note: This does not check the contents of the files.

Keyword Arguments

  • start::Bool=false: If true, copy to wf.start file instead of wf.dump.
  • state::Int=0: State number for determinant files. If 0, copies to the main dump file. If >0, copies to the state-specific determinant file (e.g., file_state2.h5).

Examples

julia> @usewf  # copy store to dump
julia> @usewf "backup.h5"  # copy from backup file to dump
julia> @usewf start=true  # copy store to start file
julia> @usewf "backup.h5" start=true  # copy backup file to start file
julia> @usewf state=2  # copy store file to state 2 determinant file
julia> @usewf "state2_backup.h5" state=2  # copy specific file to state 2
source
ElemCo.@write_ints — Macro
@write_ints(file="FCIDUMP", kwargs...)

Write FCIDump integrals to file file, which can be a string literal or a variable holding one.

The integrals must persist in EC.fd: create them explicitly with @dfints or @moints, or read an FCIDUMP — the integrals a correlated driver creates for itself are deleted again when it finishes.

The written file is self-contained: its NELEC (and MS2) describe the system as currently set up, i.e. with WfOptions.charge applied. Reading such a file back therefore needs no charge — and setting one would ionize it further, since wf.charge is always relative to the electron count of the integral source.

Keyword arguments

  • tol::Float64: tolerance for writing integrals (default: -1.0 - all integrals are written).
  • format::Symbol: format for writing integrals (default: :ascii). Can be :npy for NumPy format.
source

Exported functions

Internal functions

ElemCo.__init__ — Method
__init__()

Print the header with the version and the git hash of the current commit.

source