Basis set
The basis set is defined as a dictionary, where the keys are the types of the basis sets, and the values are the basis set:
basis = Dict("ao"=>"cc-pVTZ",
"jkfit"=>"cc-pvtz-jkfit",
"mpfit"=>"cc-pvtz-mpfit")The basis set dictionary contains three keys: ao, jkfit, and mpfit. The ao key contains the basis set for the AO integrals, the jkfit key contains the basis set for the density fitting integrals in the Hartree-Fock calculations, and the mpfit key contains the fitting basis set for the correlated calculations.
Alternatively, you can define the basis set using a string that defines the AO basis. In this case, the jkfit and mpfit basis names will be generated automatically. Here's an example of how you can define the basis set using a string:
basis = "cc-pVDZ"Common acronyms are also supported for the basis set names, e.g., cc-pVDZ can be written as vdz, and aug-cc-pVTZ can be written as avtz.
Additionally to the default basis, it is possible to specify basis sets for each element/center:
basis = Dict("ao"=>"avdz; O=avtz; H1=vdz; H2=vtz",
"jkfit"=>"cc-pvtz-jkfit",
"mpfit"=>"cc-pvtz-mpfit")In this case, the basis set for the AO integrals is avdz for all elements, except for oxygen (irrespective of the name in the geometry, i.e., "O", "O1", etc), which uses avtz, and hydrogen, which uses vdz and vtz for the centers named "H1" and "H2", respectively.
Moreover, it is possible to define custom basis sets for each element/center using the Molpro format:
basis = Dict("ao"=>"cc-pVTZ; o=avdz;
h={! hydrogen
s, H , 13.0100000, 1.9620000, 0.4446000, 0.1220000
c, 1.4, 0.0196850, 0.1379770, 0.4781480, 0.5012400
c, 4.4, 1.0000000
p, H , 0.7270000
c, 1.1, 1.0000000}",
"jkfit"=>"vtz-jkfit",
"mpfit"=>"avtz-mpfit")In this case, the basis set for the AO integrals is cc-pVTZ for all elements, except for oxygen, which uses avdz, and hydrogen, which uses a custom basis set. The Fock density fitting basis set is vtz-jkfit, and the fitting basis set for the correlated calculations is avtz-mpfit.
Even-tempered diffuse (or steep) functions can automatically be added to the basis set by specifying the desired number of functions in the basis set definition:
basis = "vdz+steep+2diffuse"Here, the basis set vdz is augmented with one steep function and two diffuse functions (for each angular momentum). The exponents are calculated as follows:
- For the diffuse functions, the exponent is set to $\frac{e_1^2}{e_2}$, where $e_1$ is the most diffuse exponent and $e_2$ is the second-most-diffuse exponent in the angular shell.
If there is only one exponent in the list, the new exponent is set to $\frac{e_1}{2.5}$. - For the steep functions, the exponent is set to $\frac{e_1^2}{e_2}$, where $e_1$ is the steepest exponent and $e_2$ is the second-steepest exponent in the angular shell.
If there is only one exponent in the list, the new exponent is set to $e_1 \times 2.5$.
This works also for explicitly defined basis sets. In this case +diffuse or +steep can be added after the curly brackets.
ElemCo.BasisSets — Module
BasisSetsModule for working with basis sets.
The basis set is stored in the BasisSet instance. The basis set can be generated using the generate_basis function.
Exported functions and types
ElemCo.BasisSets.AngularShell — Type
AngularShellType for angular shells, i.e, subshells with the same angular momentum. For general contracted basis sets, the angular shell is a collection of all subshells with the same l quantum number. For some other basis sets (e.g., the def2-family), the angular shell can be a single subshell with a specific l quantum number. id is the index of the angular shell in the basis set.
element::String: element symbol (e.g., "H")l::Int64: angular momentumexponents::Vector{Float64}: array of exponentssubshells::Vector{ElemCo.BasisSets.BasisContraction}: array of subshells (contractions)id::Int64: index of the angular shell in the basis set
ElemCo.BasisSets.BasisCentre — Type
BasisCentreA basis centre (atom) with basis functions.
name::String: basis centre name (e.g., "H1")position::StaticArraysCore.SVector{3, Float64}: atomic position in Bohr (3D vector)atomic_number::Int64: atomic numbercharge::Int64: nuclear charge (= 0 for dummy atoms)basis::String: name of the basis set (e.g., "cc-pVDZ")shells::Vector{ElemCo.BasisSets.AngularShell}: array of angular shells
ElemCo.BasisSets.BasisContraction — Type
BasisContractionA basis contraction. exprange is the range of primitives (from exponents in the angular shell).
ElemCo.BasisSets.BasisSet — Type
BasisSetA basis set with basis centres (atoms) and basis functions.
centres::Vector{ElemCo.BasisSets.BasisCentre}: array of basis centres (atoms) with basis functions.shell_indices::Vector{CartesianIndex{2}}: indices for angular shells.centre_ranges::Vector{UnitRange{Int64}}: centre ranges for each basis set in a combined set.shell_ranges::Vector{UnitRange{Int64}}: angular shell ranges for each basis sets in a combined set.cartesian::Bool: cartesian basis setlib::ElemCo.BasisSets.ILibcint: infos for integral library (at the moment only libcint is possible).
ElemCo.BasisSets.ILibcint — Type
ILibcintInfos for Libcint integral library.
ElemCo.BasisSets.ILibcint — Method
ILibcint(atoms::Vector{BasisCentre}, cartesian::Bool)Prepare the infos for Libcint integral library.
ElemCo.BasisSets.add_subshell! — Method
add_subshell!(ashell::AngularShell, exprange, contraction)Add a subshell to the angular shell.
ElemCo.BasisSets.ao_list — Function
ao_list(basis::BasisSet, ibas=1)Return the list of atomic orbitals in the basis set.
For a combined basis set, use ibas to select the basis set.
ElemCo.BasisSets.ao_order2internal — Function
ao_order2internal(basis::BasisSet, order4l, back=false)Return the order of the atomic orbitals from an external to the internal order such that μ(external)[order] == μ(internal).
order4l is a vector of orders for each angular momentum (from external to internal order).
ElemCo.BasisSets.basis_name — Function
basis_name(atom::ACentre, type="ao")Return the name of the basis set (or unknown if not found).
ElemCo.BasisSets.centre_range — Function
centre_range(bs::BasisSet, i::Int=1)Return the range of centres for the ith basis set.
The range is used to access the centres in the basis set, e.g., bs.centres[i] for i in centre_range(bs, 1) gives the centres of the first basis set.
ElemCo.BasisSets.coefficients_1mat — Method
coefficients_1mat(ashell::AngularShell, cartesian::Bool)Return a single contraction matrix of the coefficients in the angular shell (nprimitives × nsubshells). The contractions are normalized.
The missing coefficients are set to zero in the matrix.
ElemCo.BasisSets.combine — Method
combine(bs1::BasisSet, bs2::BasisSet)Combine two basis sets.
The centres are concatenated. The centre/shell ranges (centre_ranges/shell_ranges) corresponding to the centres/shells for each basis set can be used to access the centres/shells in the combined basis set, e.g. bs.centres[i] for i in bs.centre_ranges[1] gives the centres of the first basis set in the combined set.
ElemCo.BasisSets.generate_angularshell — Method
generate_angularshell(elem, l, exponents)Generate an angular shell with angular momentum l and exponents. The contractions have to be added later. Return an angular shell of type AngularShell.
ElemCo.BasisSets.generate_basis — Function
generate_basis(ms::MSystem, type="ao"; cartesian=false, basisset::AbstractString="",
use_fallback=false, check_fit_basis=true, split_ashells=true)Generate basis sets for integral calculations.
The basis set is stored in BasisSet object. type can be "ao", "mpfit" or "jkfit". If basisset is provided, it is used as the basis set. If split_ashells is true, independent angular shells are split (important for efficiency).
ElemCo.BasisSets.generate_basis — Function
generate_basis(EC::ECInfo, type="ao"; basisset::AbstractString="")Generate basis sets for integral calculations.
The basis set is stored in BasisSet object. type can be "ao", "mpfit" or "jkfit". If basisset is provided, it is used as the basis set.
ElemCo.BasisSets.get_available_basis_sets — Method
get_available_basis_sets()Get a list of all available basis set names from the basis library. Returns basis set names without version suffixes and file extensions.
ElemCo.BasisSets.get_available_elements4basis — Method
get_available_elements4basis(basisname)Return a list of available elements for the specified basis set.
ElemCo.BasisSets.guess_norb — Method
guess_norb(EC::AbstractECInfo)Guess the number of orbitals in the system.
ElemCo.BasisSets.is_cartesian — Method
is_cartesian(bs::BasisSet)Check if the basis set is Cartesian.
ElemCo.BasisSets.levenshtein_distance — Method
levenshtein_distance(s1::AbstractString, s2::AbstractString)Calculate the Levenshtein distance between two strings. The Levenshtein distance is the minimum number of single-character edits (insertions, deletions, or substitutions) required to change one string into another.
Based on the algorithm suggested in https://github.com/rawrgrr/Levenshtein.jl
ElemCo.BasisSets.max_l — Method
max_l(basis::BasisSet)Return the maximum angular momentum in the basis set.
ElemCo.BasisSets.n_angularshells — Method
n_angularshells(atom::BasisCentre)Return the number of angular shells in the basis set for atom.
ElemCo.BasisSets.n_angularshells — Method
n_angularshells(atoms::BasisSet)Return the number of angular shells in the basis set.
ElemCo.BasisSets.n_ao — Method
n_ao(ashell::AngularShell, cartesian::Bool)Return the number of atomic orbitals in the angular shell.
ElemCo.BasisSets.n_ao — Method
n_ao(atom::BasisCentre, cartesian::Bool)Return the number of atomic orbitals in the basis set for atom.
ElemCo.BasisSets.n_ao — Method
n_ao(atoms::BasisSet)Return the number of atomic orbitals in the basis set.
ElemCo.BasisSets.n_coefficients — Method
n_coefficients(ashell::AngularShell)Return the total number of coefficients in the angular shell.
ElemCo.BasisSets.n_coefficients — Method
n_coefficients(subshell::BasisContraction)Return the number of coefficients for the subshell.
ElemCo.BasisSets.n_coefficients_1mat — Method
n_coefficients_1mat(ashell::AngularShell)Return the number of coefficients in the angular shell for a single contraction matrix.
The missing coefficients will be set to zero.
ElemCo.BasisSets.n_primitives — Method
n_primitives(ashell::AngularShell)Return the total number of primitives in the angular shell.
ElemCo.BasisSets.n_primitives — Method
n_primitives(atom::BasisCentre)Return the number of primitives in the basis set for atom.
ElemCo.BasisSets.n_primitives — Method
n_primitives(subshell::BasisContraction)Return the number of primitives for the subshell.
ElemCo.BasisSets.n_primitives — Method
n_primitives(atoms::BasisSet)Return the number of primitives in the basis set.
ElemCo.BasisSets.n_subshells — Method
n_subshells(ashell::AngularShell)Return the number of subshells in the angular shell.
ElemCo.BasisSets.n_subshells — Method
n_subshells(atom::BasisCentre)Return the number of subshells in the basis set for atom.
ElemCo.BasisSets.n_subshells — Method
n_subshells(atoms::BasisSet)Return the number of subshells in the basis set.
ElemCo.BasisSets.normalize_contraction — Method
normalize_contraction(subshell::BasisContraction, ashell::AngularShell, cartesian::Bool)Normalize the contraction coefficients in subshell.
The subshell has to be part of the angular shell ashell. Return the normalized contraction.
ElemCo.BasisSets.output_basis — Function
output_basis([io::IO,] basisname, list_of_elements=String[])Output the basis set for the specified elements. If the list is empty, generate the basis for all elements available in the basis set.
ElemCo.BasisSets.print_ao — Method
print_ao(ao::AbstractAtomicOrbital, basis::BasisSet)
Print the atomic orbital.
ElemCo.BasisSets.shell_range — Function
shell_range(bs::BasisSet, i::Int=1)Return the range of angular shells for the ith basis set.
The range is used to access the angular shells in the basis set, e.g., bs[i] for i in shell_range(bs, 1) gives the angular shells of the first basis set.
ElemCo.BasisSets.subshell_char — Method
subshell_char(l)Return the character for the subshell with angular momentum l.
ElemCo.BasisSets.suggest_basis_sets — Function
suggest_basis_sets(target::AbstractString, max_suggestions::Int=5, max_distance::Int=3)Suggest basis set names that are similar to the target string using Levenshtein distance. Returns up to max_suggestions suggestions with distance ≤ max_distance, sorted by distance.
Internal functions and types
ElemCo.BasisSets.AbstractILib — Type
AbstractILibAbstract type for infos for integral libraries.
ElemCo.BasisSets.CartesianAtomicOrbital — Type
CartesianAtomicOrbital
Represents an atomic orbital in a cartesian basis set.
icentre::UInt16: index of the centre in the basis set objectiangularshell::UInt16: index of the angular shell in the basis set objectisubshell::UInt8: index of the subshell in the angular shelln::UInt8: principal quantum numberl::UInt8: orbital angular momentum quantum numberml::Int8: magnetic "quantum number" (ml = -l:l(l+1)/2)
ElemCo.BasisSets.SphericalAtomicOrbital — Type
SphericalAtomicOrbital
Represents an atomic orbital in a spherical basis set.
icentre::UInt16: index of the centre in the basis set objectiangularshell::UInt16: index of the angular shell in the basis set objectisubshell::UInt8: index of the contraction in the angular shelln::UInt8: principal quantum numberl::UInt8: orbital angular momentum quantum numberml::Int8: magnetic quantum number (ml = -l:l)
Base.getindex — Method
Base.getindex(bs::BasisSet, i::CartesianIndex{2})Return the the angular shell.
Base.getindex — Method
Base.getindex(bs::BasisSet, i::Int, j::Int)Return the the angular shell.
Base.getindex — Method
Base.getindex(bs::BasisSet, i::Int)Return the the angular shell.
Base.iterate — Function
Base.iterate(bs::BasisSet, state=1)Iterate over the basis angular shells in the basis set.
Base.length — Method
Base.length(bs::BasisSet)Return the number of angular shells in the basis set.
ElemCo.BasisSets.add_diffuse_exponent! — Method
add_diffuse_exponent!(exponents, nexp)Add nexp diffuse even-tempered exponents to the list of exponents.
Each new exponent is generated as e = e1^2/e2, where e1 is the most diffuse and e2 the second most diffuse exponent (the list of exponents is not necessarily ordered). If only one exponent is in the list, the new exponent is set to e1/2.5. The new exponents are added to the end of the list.
ElemCo.BasisSets.add_steep_exponent! — Method
add_steep_exponent!(exponents, nexp)Add nexp steep even-tempered exponents to the list of exponents.
Each new exponent is generated as e = e1^2/e2, where e1 is the steepest and e2 the second steepest exponent (the list of exponents is not necessarily ordered). If only one exponent is in the list, the new exponent is set to e1*2.5. The new exponents are added to the end of the list.
ElemCo.BasisSets.add_uncontracted! — Method
add_uncontracted!(ashell::AngularShell)Exponents not covered by contractions are added as uncontracted subshells.
ElemCo.BasisSets.basis_file — Method
basis_file(basis_name::AbstractString)Return the full path to the basis set file.
ElemCo.BasisSets.check_fit_basis_name — Method
check_fit_basis_name(basis_name, type, err)Check if the basis name is a valid fit basis (to catch a common mistake of using AO basis as a fitting basis).
ElemCo.BasisSets.full_basis_name — Method
full_basis_name(basis_name::AbstractString)Return the full basis name and version number (if given as *.v[0-2], otherwise -1 is returned).
I.e,
[a][wc/c]vXz*->[aug-]cc-p[wc/c]vXz*svp*->def2-svp*[tq]zvp*->def2-[tq]zvp*
Additionally check for version number (e.g., vdz.v2)
ElemCo.BasisSets.gen_ls_string — Method
gen_ls_string(num4l::Vector{Int})Generate a string representation of the number of functions for each angular momentum.
ElemCo.BasisSets.guess_basis_name — Method
guess_basis_name(atom::ACentre, type)Guess the name of the basis set. type can be "ao", "mpfit" or "jkfit".
ElemCo.BasisSets.id_not_set — Method
id_not_set(centres::AbstractArray{BasisCentre})Check if the id is not set for angular shells in the array of centres. Return true if the id is not set.
ElemCo.BasisSets.n_ao4subshell — Method
n_ao4subshell(ashell::AngularShell, cartesian::Bool)Return the number of atomic orbitals for the subshell.
ElemCo.BasisSets.normalize_cartesian_contraction — Method
normalize_cartesian_contraction(contraction, exponents, l)Normalize the subshell.
Return the normalized contraction.
ElemCo.BasisSets.normalize_spherical_contraction — Method
normalize_spherical_contraction(contraction, exponents, l)Normalize the spherical subshell.
Return the normalized contraction.
ElemCo.BasisSets.number_of_primitives_for_l — Method
number_of_primitives_for_l(bc::BasisCentre)Return an array with the number of primitives for each angular momentum.
ElemCo.BasisSets.parse_basis — Method
parse_basis(basis_name::String, atom::ACentre; fallback="", split_ashells=true)Search and parse the basis set for a given atom. If fallback is non-empty, use as a fallback basis set. If split_ashells is true, split independent angular shells (important for efficiency).
Return a list of angular shells AngularShell.
ElemCo.BasisSets.parse_basis_block — Method
parse_basis_block(basis_block::AbstractString, atom::ACentre; add_diffuse=0, add_steep=0, split=true)Parse the basis block for a given atom.
Return a list of angular shells AngularShell. The basis block is in the Molpro format:
!commentss,p,d,f,g,hangular momentumc, <from>.<to>contraction coefficients for primitives
Example cc-pVDZ for H atom:
s, H , 13.0100000, 1.9620000, 0.4446000, 0.1220000
c, 1.4, 0.0196850, 0.1379770, 0.4781480, 0.5012400
c, 4.4, 1.0000000
p, H , 0.7270000
c, 1.1, 1.0000000For generally-contracted basis sets (like the one above), one angular shell is created for each angular momentum type s,p,d,f,g,h with the corresponding exponents and contraction coefficients. For other basis sets, like the def2-SVP, each contraction is a separate angular shell:
! hydrogen (4s,1p) -> [2s,1p]
s, H , 13.0107010, 1.9622572, 0.44453796, 0.12194962
c, 1.3, 0.19682158E-01, 0.13796524, 0.47831935
c, 4.4, 1.0000000
p, H , 0.8000000
c, 1.1, 1.0000000add_diffuse and add_steep are the number of diffuse and steep even-tempered functions to add. If split_ashells is true, independent angular shells will be split (important for efficiency).
ElemCo.BasisSets.parse_contraction — Method
parse_contraction(conline::AbstractString)Parse contraction coefficients from a line in the basis block.
Return the range of exponents and the contraction coefficients as a tuple. The line is in the Molpro format: c, 1.4, 0.0196850, 0.1379770, 0.4781480, 0.5012400 where c is the contraction, 1.4 is the exponent range, and the rest are the coefficients.
ElemCo.BasisSets.parse_diffuse_steep — Method
parse_diffuse_steep(basis_name::AbstractString)Parse the diffuse and steep components from the basis name in the format +<N>diffuse or +diffuse or +<N>steep or +steep.
Returns the modified basis name and the number of diffuse and steep functions to add.
ElemCo.BasisSets.parse_exponents — Method
parse_exponents(expline::AbstractString; add_diffuse=0, add_steep=0)Parse exponents from a line in the basis block.
Return the angular momentum and exponents as a tuple. The line is in the Molpro format: s, H , 13.0100000, 1.9620000, 0.4446000, 0.1220000 where s is the angular momentum, H is the element symbol, and the rest are the exponents.
The add_diffuse and add_steep arguments can be used to add diffuse and steep functions.
ElemCo.BasisSets.read_basis_block — Method
read_basis_block(basisfile::AbstractString, atom::ACentre; fallback="")Read the basis block for a given atom.
The basis library is in the Molpro format:
!comments- basis block starts with
! <elementname> .... - basis block ends with
!or} - basis block contains:
s,p,d,f,g,hangular momentumc, <from>.<to>contraction coefficients for primitives
Example cc-pVDZ for H atom:
!
! hydrogen (4s,1p) -> [2s,1p]
s, H , 13.0100000, 1.9620000, 0.4446000, 0.1220000
c, 1.4, 0.0196850, 0.1379770, 0.4781480, 0.5012400
c, 4.4, 1.0000000
p, H , 0.7270000
c, 1.1, 1.0000000
!If the basis block is not found, the function will attempt to read the fallback basis file.
ElemCo.BasisSets.set_id! — Method
set_id!(ashells::AbstractArray{AngularShell}, start_id)Set the id for each angular shell in the array. Return the next id.
ElemCo.BasisSets.set_id! — Method
set_id!(centres::AbstractArray{BasisCentre}, start_id)Set the id for each angular shell in the array of centres. Return the next id.
ElemCo.BasisSets.split_angular_shell — Method
split_angular_shell(ashell::AngularShell)If the ranges of exponents do not overlap, split the angular shell into separate angular shells for each subshell. The shells are kept together only if one is a subset of the other.