4. Electronic wavefunction API¶
4.1. Electronic Wavefunctions¶

class
moldesign.orbitals.wfn.
ElectronicWfn
(mol, num_electrons, model=None, aobasis=None, fock_ao=None, positions=None, civectors=None, description=None, density_matrix_ao=None)[source]¶ Stores the results of a quantum chemistry calculation.
This is necessarily pretty flexible, but generally stores an LCAO wfn and one or more sets of orbitals. Can also store CI vectors, etc.
These objects will usually be created by quantum chemical energy models.
Parameters:  mol (moldesign.Molecule) – Molecule this wavefunction belongs to
 num_electrons (int) – number of electrons in this wavefunction
 model (moldesign.models.base.EnergyModelBase) – The model this wavefunction was created with
 aobasis (moldesign.orbitals.BasisSet) – The basis functions for the enclosed orbitals
 nbasis (int) – number of AO basis functions
 fock_ao (moldesign.units.Array[energy]) – fock matrix in the AO basis
 positions (moldesign.units.Array[length]) – positions of the nuclei for this wfn
 civectors (np.ndarray) – CI vectors (if applicable)
 description (str) – text describing the wfn (e.g. ‘RHF/STO3G’, ‘CAS(2,2)/SA3/631G**’)
 density_matrix_ao (np.ndarray) – density matrix in the ao basis

align_orbital_phases
(other, assert_same=True)[source]¶ Align this wavefunction’s orbitals to have the same phase as those in other. :type other: ElectronicWfn :param assert_same: raise an exception if the two wavefunctions do not have the same kinds of orbitals

molecular_orbitals
¶ A synonym for self.orbitals[‘canonical’], since this is usually what’s wanted
4.2. Molecular Orbital Sets¶

class
moldesign.orbitals.orbitals.
MolecularOrbitals
(orbitals, wfn=None, basis=None, canonical=False, orbtype=None)[source]¶ Stores a wfn of molecular orbitals in an AO wfn Orbitals are accessed as orbs[orbital index, ao index]

align_phases
(other, threshold=0.5, assert_same_type=True)[source]¶ Flip the signs of these orbitals to bring them into maximum coincidence with another set of orbitals
Parameters:  other (MolecularOrbitals) – the “reference” set of orbitals to match phases with
 threshold (float) – only flip orbital if the overlap is less than 1*threshold
 assert_same_type (bool) – require that
self.orbtype == other.orbtype
Note
This function assumes that the overlap matrix is the same for both sets of orbitals  this is a reasonable assumption if the two sets of orbitals were calculated at very similar molecular geometries.

energies
¶ u.Vector[energy] – energies of the molecular orbitals
This is just the diagonal of the fock matrix

fock
¶ u.Array[energy] – Fock matrix for these orbitals

from_ao
(ao_operator)[source]¶ Transform an operator into this orbital basis from the ao basis
Given the matrix elements :math:`hat O_{mu u}` of an operator over AO basis indices
 :math:`mu,
 u`, returns the operator’s matrix elements \(\hat O_{ij}\) over
orbital indices \(i,j\):
 ..math::
 hat O_{ij} =
 left langle i
ight hat O left j ight angle =
sum_{muu}C_{i mu} O_{mu u} C_{j u}
where \(C_{i \mu}\) is the expansion coefficient for AO basis function \(\mu\) in molecular orbital _i_.
 Args:
 ao_operator (u.Array): matrix elements of the operator in the ao basis
 Returns:
 u.Array: matrix elements of the operator in this orbital basis
 Note:
 Assumes that this set of orbitals is orthogonal

h1e
¶ u.Array[energy] – 1electron matrix elements for these orbitals

h2e
¶ u.Array[energy] – 2electron matrix elements for these orbitals

occupations
¶ np.ndarray – orbital occupation numbers

overlap
(other)[source]¶ Calculate overlaps between this and another set of orbitals
Parameters: other (MolecularOrbitals) – Returns: overlaps between the two sets of orbitals Return type: numpy.ndarray Example
>>> canonical = mol.wfn.canonical >>> atomic = mol.wfn.basis >>> overlaps = canonical.overlap(atomic) >>> overlaps[i, j] == canonical.orbitals[i].overlap(atomic.orbitals[j]) True

overlaps
¶ np.array – overlap matrix for these orbitals

to_ao
(mo_operator)[source]¶ Transform an operator from this orbital basis into the AO basis
Given the matrix elements \(\hat O_{ij}\) of an operator over orbital basis indices \(i,j\), returns the operator’s matrix elements :math:`hat O_{mu u}` over
 orbital indices :math:`mu,
u`:
 ..math::
 hat O_{mu
 u} =
 left langle mu
ight hat O left u ight angle =
sum_{i,j,lambda,kappa}S_{mu lambda} C_{i lambda} O_{ij} C_{j kappa} S_{kappau}
where :math:`S_{muu} = left langle mu  u ight angle` is the AO overlap matrix
and \(C_{i \mu}\) is the expansion coefficient for AO basis function \(\mu\) in molecular orbital _i_.
 Args:
 mo_operator (u.Array): matrix elements of the operator in this orbital basis
 Returns:
 u.Array: matrix elements of the operator in the AO basis

4.3. Electronic Orbitals¶

class
moldesign.orbitals.orbitals.
Orbital
(coeffs, basis=None, wfn=None, occupation=None, name='unnamed')[source]¶ Stores a single orbital and its metadata Generally wants to be part of a set of MolecularOrbitals
The orbital is defined as .. math:
\left i \right \rangle = \sum_\mu c_{i \mu} \left \mu \right \rangle
where the coefficients \(c_{i \mu}\) are stored in
self.coeffs
and the basis orbitals \(\left \mu \right \rangle\) are stored atself.basis

energy
¶ u.Scalar[energy] – This orbital’s energy
Note
This is equivalent to self.fock(self)
