Create a molecule

In this tutorial we present how to create a molecule and run the SCF calculation. First, the Molecule class must be imported :

[1]:
from qmctorch.scf import Molecule
INFO:QMCTorch|  ____    __  ______________             _
INFO:QMCTorch| / __ \  /  |/  / ___/_  __/__  ________/ /
INFO:QMCTorch|/ /_/ / / /|_/ / /__  / / / _ \/ __/ __/ _ \
INFO:QMCTorch|\___\_\/_/  /_/\___/ /_/  \___/_/  \__/_//_/

This class can interface with pyscf and ADF to perform SCF calculations. Of course both software use different types of atomic orbitals, respectively Gaussian type orbitals for pyscf and Slater type orbitals for ADF.

Geometry of the molecule

The geometry of the molecule can be specified through the atom keyword of the Molecule class. The units of the positions, bohr or angs (default is ‘bohr’) can also be specified via the unit keyword argument. The geometry can be passed as a single string

[2]:
mol = Molecule(atom = 'H 0. 0. 0; H 0. 0. 1.', unit='bohr')
INFO:QMCTorch|
INFO:QMCTorch| SCF Calculation
INFO:QMCTorch|  Running scf  calculation
converged SCF energy = -1.06599946214331
INFO:QMCTorch|  Molecule name       : H2
INFO:QMCTorch|  Number of electrons : 2
INFO:QMCTorch|  SCF calculator      : pyscf
INFO:QMCTorch|  Basis set           : sto-3g
INFO:QMCTorch|  SCF                 : HF
INFO:QMCTorch|  Number of AOs       : 2
INFO:QMCTorch|  Number of MOs       : 2
INFO:QMCTorch|  SCF Energy          : -1.066 Hartree
[2]:
<qmctorch.scf.molecule.Molecule at 0x7f429ed23910>

or via an XYZ file containing the geomtry of the molecular structure. Note that by default QMCTorch will try to reuse previous calculations that might be stored in an hdf5 file. To redo the scf calculation we can use the redo_scf=True argument.

[7]:
mol = Molecule(atom='h2.xyz', unit='bohr', redo_scf=True)
INFO:QMCTorch|
INFO:QMCTorch| SCF Calculation
INFO:QMCTorch|  Removing H2_pyscf_sto-3g.hdf5 and redo SCF calculations
INFO:QMCTorch|  Running scf  calculation
converged SCF energy = -1.06599946214331
INFO:QMCTorch|  Molecule name       : H2
INFO:QMCTorch|  Number of electrons : 2
INFO:QMCTorch|  SCF calculator      : pyscf
INFO:QMCTorch|  Basis set           : sto-3g
INFO:QMCTorch|  SCF                 : HF
INFO:QMCTorch|  Number of AOs       : 2
INFO:QMCTorch|  Number of MOs       : 2
INFO:QMCTorch|  SCF Energy          : -1.066 Hartree

SCF calculations

As mentionned above QMCTorch can use pyscf or ADF to perform SCF calculation on the molecular structure. At the moment only Hartree-Fock calculations are supported but DFT calculations will be implemented later. We present here how to perform these SCF calculations.

Gaussian orbitals with pyscf

As seen above the code use by default pyscf to compute the atomic and molecular orbitals of the system using a sto-3g basis set. The default behavior is equivlament to setting calculator=pyscf and basis='sto-3g'. Let’s switch to another basis, e.g. sto-6g

[10]:
mol = Molecule(atom='H 0. 0. 0; H 0. 0. 1.', unit='bohr', calculator='pyscf', basis='sto-6g', redo_scf=True)
INFO:QMCTorch|
INFO:QMCTorch| SCF Calculation
INFO:QMCTorch|  Running scf  calculation
converged SCF energy = -1.07589040772972
INFO:QMCTorch|  Molecule name       : H2
INFO:QMCTorch|  Number of electrons : 2
INFO:QMCTorch|  SCF calculator      : pyscf
INFO:QMCTorch|  Basis set           : sto-6g
INFO:QMCTorch|  SCF                 : HF
INFO:QMCTorch|  Number of AOs       : 2
INFO:QMCTorch|  Number of MOs       : 2
INFO:QMCTorch|  SCF Energy          : -1.076 Hartree

The exhaustive list of supported basis set can be found here : https://pyscf.org/user/gto.html

Slater orbitals with ADF

If a valid SCM license is found QMCTorch can use ADF. Two calculators are available depending on the version of ADF installed: * ADF 2019 : calculator = 'adf2019' * ADF 2020+ : calculator = 'adf'

So for example if ADF2019 is installed the following command will use ADF to compute the electronic structure of the molecule.

[ ]:
try:
    mol = Molecule(atom='H 0. 0. 0; H 0. 0. 1.', unit='bohr', calculator='adf2019', basis='dzp')
except Exception as expt:
    print(expt)
INFO:QMCTorch|
INFO:QMCTorch| SCF Calculation
INFO:QMCTorch|  Running scf  calculation
[13.04|16:37:54] PLAMS working folder: /home/nico/QMCTorch/notebooks/plams_workdir.002
File ./plams_workdir/HH_dzp/HH_dzp.t21 not found, ADF may have crashed, look into the plams_workdir directory

Here as well the basis keyword argument specifies the basis set used in the scf calculation. The list of supported basis set can be found here : https://www.scm.com/doc/ADF/Input/Basis_sets_and_atomic_fragments.html

Additional basis sets, namely VB1, VB2, VB3, CVB1, CVB2 and CVB3, are available. These are STO valence and core-valence basis set presented by Ema et. al in “Polarized basis sets for Slater-type orbitals: H to Ne atoms”, https://doi.org/10.1002/jcc.10227. Changing the basis keyword argument to : ``basis=VB1``` will for examle use the small VB1 basis set during the SCF calculation.

Loading a SCF calculation

By default QMCTorch will create a HDF5 file containing all the required information about the molecule and SCF calculation. The name of this file is given by the name of the molecule, the calculator name and the basis set, e.g. LiH_adf_dz.hdf5 or water_pyscf_sto3g.xyz. This files can be loaded to instanciate the molecule object through the load keyword argument:

[12]:
mol = Molecule(load='./hdf5/LiH_adf_dz.hdf5')
INFO:QMCTorch|
INFO:QMCTorch| SCF Calculation
INFO:QMCTorch|  Loading data from LiH_adf_dz.hdf5