Describing the molecule
Chapter focus
How do we specify a molecular system and construct the starting wavefunction for the correlated calculation?
Learning objectives
After completing this chapter, you will be able to:
Specify a molecule by its geometry, charge, and spin multiplicity.
Explain the role of a finite atomic-orbital basis set.
Describe the Hartree–Fock approximation and the Slater-determinant form of its wavefunction.
Generate a Hartree–Fock wavefunction with the built-in QDK/Chemistry self-consistent field solver.
Interpret an energy change caused by changing the basis set.
Lab notebook assignment
Complete Molecular input and mean-field calculation in the lab notebook as you work through this chapter. Record the molecular inputs and both Hartree–Fock energies before calculating their difference. Interpret the difference as basis-set sensitivity rather than as the total error of either energy.
Example download
Download tutorial_describe_n2.py and save it in your tutorial working directory.
Open the file in Visual Studio Code and review the complete script, including imports and setup code omitted from the excerpts below.
The sections below explain the inputs and calculations in this complete executable file before you run it.
The molecular system
An electronic-structure calculation requires the identities and positions of the nuclei, the number of electrons, and the target spin state. This chapter specifies those inputs for the stretched N2 molecule introduced on the tutorial landing page.
The molecular geometry contains two nitrogen atoms separated by \(1.85\ \text{Å}\), compared with the equilibrium bond length of \(1.097685\ \text{Å}\). The molecule is neutral, so its net charge is zero and it has 14 electrons. Spin multiplicity is defined as \(2S+1\), where \(S\) is the total electron spin produced by combining the spins of all electrons. Paired electrons contribute no net spin, whereas unpaired electrons can produce \(S>0\). A multiplicity of one, two, or three is called a singlet, doublet, or triplet, respectively. The labels \(\alpha\) and \(\beta\) denote spin projections \(+\tfrac{1}{2}\) (spin up) and \(-\tfrac{1}{2}\) (spin down), respectively. QDK/Chemistry uses the molecular charge and spin multiplicity to determine the numbers of \(\alpha\) and \(\beta\) electrons in the calculation. For the target N2 singlet, \(S=0\), so the multiplicity is one and the calculation contains seven \(\alpha\) and seven \(\beta\) electrons.
QDK/Chemistry represents a molecular geometry with a Structure object.
This example constructs the Structure object from a string in XYZ file format, which contains an atom count, a comment line, and one element symbol with three Cartesian coordinates for each atom:
structure = Structure.from_xyz("""\
2
Stretched N2 molecule for the ground-state QPE tutorial
N 0.000000 0.000000 0.000000
N 0.000000 0.000000 1.850000
""")
# The 1.85-Angstrom bond is substantially longer than the 1.097685-Angstrom
# equilibrium distance, increasing multiconfigurational character.
# The target is neutral N2 in its singlet ground state, where all electrons are
# paired and the spin multiplicity 2S + 1 equals one.
charge = 0
spin_multiplicity = 1
The XYZ format used by QDK/Chemistry interprets coordinates in ångström units. However, this format does not specify molecular charge or spin multiplicity, so the example records these values separately.
The mean-field wavefunction
The Hartree–Fock method approximates the many-electron wavefunction with one Slater determinant. As introduced in the tutorial overview, each occupied spin orbital combines a spatial molecular orbital with an \(\alpha\) or \(\beta\) spin function. Let \(\psi_p(x)\) denote occupied spin orbital \(p\), where \(x=(\mathbf{r},\sigma)\) contains a spatial coordinate \(\mathbf{r}\) and a spin label \(\sigma\in\{\alpha,\beta\}\). For an \(N\)-electron Hartree–Fock state, the occupied spin orbitals form the Slater determinant
Here \(\det\) denotes the determinant of the matrix whose row \(q\) evaluates every occupied spin orbital at electron coordinate \(x_q\). The factor \(1/\sqrt{N!}\) normalizes the wavefunction when the occupied spin orbitals are orthonormal. Exchanging two electron coordinates swaps two matrix rows and changes the sign of \(\Phi_{\mathrm{HF}}\), enforcing fermionic antisymmetry. This determinant is an approximate many-electron wavefunction. Each electron interacts with the average field generated by the other electrons rather than with their instantaneous correlated motion. This mean-field treatment makes Hartree–Fock computationally tractable because it avoids representing all possible electron configurations. The determinant accounts for exchange, an effect of wavefunction antisymmetry that reduces the probability of finding same-spin electrons together, but it omits electron correlation.
The Hartree–Fock energy is the fixed-geometry total energy evaluated with the optimized Hartree–Fock determinant:
where \(\Phi_{\mathrm{HF}}\) is the optimized determinant and \(E_{\mathrm{nuclear}}\) is the repulsion among the fixed nuclei. This energy remains approximate because the determinant cannot represent electron correlation.
Finite-basis orbital representation
The Hartree–Fock wavefunction \(\Phi_{\mathrm{HF}}\) is a determinant constructed from occupied spin orbitals. Each spin orbital combines a spatial molecular orbital with an \(\alpha\) or \(\beta\) spin function. The molecular orbitals are functions of position that provide the spatial parts of these spin orbitals. Changing the occupied molecular orbitals changes the Hartree–Fock determinant and its many-electron wavefunction. Because the Hartree–Fock determinant is built from one-electron functions, optimizing the many-electron wavefunction reduces to optimizing these molecular orbitals. Their spatial shapes and occupations also help identify bonding and antibonding interactions, and the optimized orbitals provide the starting representation for later multi-configurational calculations.
What is a molecular orbital, and why is it useful?
A molecular orbital is a one-electron spatial function used to construct the spin orbitals in a Hartree–Fock determinant. Molecular orbitals make the approximate many-electron wavefunction computationally tractable, help interpret bonding and occupations, and provide the starting representation for later multi-configurational calculations.
Electronic-structure calculations expand each molecular orbital \(\phi_p\) in a finite collection of known basis functions \(\{\chi_\mu\}\):
The index \(p\) labels a molecular orbital, and \(\mu\) labels a basis function. The coefficients \(c_{\mu p}\) determine molecular orbital \(p\), and the self-consistent field calculation optimizes these coefficients. The collection of basis functions is called a basis set.
The following isosurfaces illustrate this construction for stretched N2. Blue and orange distinguish opposite signs of each spatial function; they do not represent positive and negative charge. The purple spheres mark the nitrogen nuclei.
Selected cc-pvdz atomic basis functions (left to right): \(2s\), \(2p_y\), and \(3d_{z^2}\).
Combining atom-centered basis functions with different coefficients produces molecular orbitals that can extend across both nuclei:
Example molecular orbitals formed from linear combinations of atom-centered basis functions.
A finite basis restricts the shapes available to the molecular orbitals and therefore introduces another approximation in the electronic description of the system. Adding suitable basis functions gives the orbitals more flexibility, but it also increases computational cost.
This chapter compares the correlation-consistent polarized valence double-zeta basis set, cc-pvdz, with the related triple-zeta basis set, cc-pvtz [Dun89].
Here, double-zeta and triple-zeta mean that two or three radial functions, respectively, describe each valence atomic orbital.
The larger basis gives the orbitals more radial flexibility but increases computational cost; both basis sets include polarization functions.
This comparison does not determine the exact basis-set error. It measures how much the Hartree–Fock energy changes with basis size while the geometry, method, and basis-set family remain fixed.

Basis functions build molecular orbitals with spin; occupied orbitals define determinants, which form one-determinant or multiconfigurational many-electron wavefunctions.
Which basis set gives a lower energy and why?
The cc-pvtz calculation gives the lower energy.
This result is consistent with its additional radial flexibility, which provides a more flexible representation of the molecular orbitals.
The atomic elements and coordinates, molecular net charge, spin multiplicity, and Hartree–Fock method remain fixed, so the observed difference measures basis-set sensitivity.
Self-consistent wavefunction optimization
The occupied molecular orbitals determine the average distribution of the electrons in the Hartree–Fock determinant. This distribution generates the effective field that represents the average interaction of each electron with the others, as described above. Solving the one-electron equations in that field produces new molecular orbitals and therefore a new electron distribution and field. The self-consistent field (SCF) procedure resolves this dependence iteratively:
Begin with an initial set of molecular orbitals.
Construct the effective one-electron operator generated by those orbitals.
Solve for an updated set of orbitals.
Repeat until the energy and orbitals satisfy the convergence criteria.
The QDK/Chemistry ScfSolver returns the converged fixed-geometry total energy and a wavefunction containing the self-consistent molecular orbitals.
These orbitals provide the starting point for the multi-configurational calculations introduced in Choosing the active space.
Running the calculation
With the Python environment from Before you begin active, run the complete script from the Visual Studio Code integrated terminal:
python tutorial_describe_n2.py
The following code runs the built-in QDK/Chemistry Hartree–Fock solver once for each basis set.
The primary result is the cc-pvdz wavefunction, whose self-consistent molecular orbitals serve as the starting point for the multi-configurational calculation in Choosing the active space.
The cc-pvdz and cc-pvtz Hartree–Fock energies support the basis-set sensitivity exercise that follows.
# Correlation-consistent double- and triple-zeta bases form a controlled sequence:
# cc-pVTZ adds radial/angular flexibility beyond cc-pVDZ at higher cost.
basis_sets = ("cc-pvdz", "cc-pvtz")
# Store each result under its basis-set name so the values from the shared loop
# can be compared afterward without repeating either calculation.
energies = {}
wavefunctions = {}
# Change only the basis set so the energy difference measures basis-set sensitivity.
for basis_set in basis_sets:
solver = create("scf_solver", "qdk")
# basis_or_guess accepts either a basis name or a reusable orbital guess.
# Supplying a string asks the solver to build that basis from the structure.
# run() returns the converged total energy and its Hartree--Fock wavefunction.
energy, wavefunction = solver.run(
structure,
charge=charge,
spin_multiplicity=spin_multiplicity,
basis_or_guess=basis_set,
)
energies[basis_set] = energy
wavefunctions[basis_set] = wavefunction
print(f"{basis_set}: {energy:.12f} Hartree")
# Record the continued workflow's orbital count. The active-space workflow later
# selects a subset, and each retained spatial orbital contributes two spin modes.
num_cc_pvdz_orbitals = (
wavefunctions["cc-pvdz"].get_orbitals().get_num_molecular_orbitals()
)
print(f"cc-pvdz wavefunction: {num_cc_pvdz_orbitals} molecular orbitals")
Run the complete script and record both fixed-geometry total energies and the number of cc-pvdz molecular orbitals in the lab notebook.
The reported energies include both the electronic energy and the repulsion among the fixed nuclei.
What should you observe after running the Hartree–Fock calculations?
The script should report one negative total energy for each basis set and the number of molecular orbitals in the cc-pvdz wavefunction.
The cc-pvtz energy should be lower than the cc-pvdz energy because the larger basis gives the Hartree–Fock orbitals more flexibility in describing the mean-field wavefunction.
The absolute difference between the two energies is the observed basis-set sensitivity. It does not establish the exact error of either energy because both calculations use finite basis sets. Therefore, do not compare this basis-set sensitivity with the \(1\ \mathrm{m}E_{\mathrm{h}}\) teaching target from Energy and accuracy.
For the rest of this tutorial, we use cc-pvdz because it includes polarization functions while keeping the correlated examples small enough to run quickly; this is a teaching-model cost choice, not a claim that cc-pvdz is universally preferable.
The cc-pvtz calculation is used only for the controlled basis-set comparison in this chapter, avoiding its greater cost in every later stage.
Bond stretching can increase static correlation and weaken a one-determinant description.
Choosing the active space next evaluates this effect for the selected N2 geometry and identifies which electrons and orbitals must be treated in a multi-configurational wavefunction.