# How to calculate the Fock matrix in the molecular orbital basis PySCF?

Matter Modeling Asked by Wychh on August 19, 2021

I am interested in calculating the Fock matrix in the molecular orbital basis with PySCF, though I am not clear on the methodology behind this task.

In my attempt, I use the following script (for the example H$$_{2}$$ molecule):

from pyscf import gto, scf
geometry = '''
H   0.000   0.000   0.000
H   0.000   0.000   0.740
'''
mol = gto.Mole()
mol.atom = geometry
mol.basis = '3-21g'
mol.build()
​
mf = scf.RHF(mol)
mf.scf()
​
Fao = mf.get_fock()
Fmo = mf.mo_coeff.T @ Fao @ mf.mo_coeff
​
print('F_mo')
print(Fmo)


In this method, I first calculate the molecular mean-field. I then do matrix multiplication with the molecular coefficient transpose matrix (mf.mo_coeff.T), the Fock matrix in the atomic basis (Fao) and the molecular orbital coefficients (mf.mo_coeff).

The resulting off-diagonal matrix elements are essentially zero for the H$$_{2}$$ molecule and other larger systems taken to 10 decimal places (CH$$_{4}$$, NH$$_{3}$$, H$$_{2}$$O). This has confused me: I have seen other Fock matrices in the molecular orbital basis with off-diagonal elements present.

I am therefore looking for confirmation of my method, and if there is a better way of doing this task?

For canonical MOs, it is expected that the off-diagonal elements of the described product with the Fock matrix are zero (within reasonable accuracy) because they are the result of the diagonalization of the Fock matrix.

However, canonical MOs are not the only possible choice. One can "rotate" the MOs to minimize certain metrics in order to obtain, for instance, localized MOs (LMO). Such rotations will keep the total energy and the electron density intact, but will disallow the interpretation of the diagonal values of the Fock matrix (represented in the LMO basis) as orbital energies.

Correct answer by TAR86 on August 19, 2021

## Related Questions

### LAMMPS code that I wrote not behaving as expected. Some issue with the group & region commands

1  Asked on December 7, 2021 by saismaran-s-b-pes1201701189pes

### Standard values for level of convergence

1  Asked on December 7, 2021

### What are some codes available for Dynamical Mean Field Theory (DMFT)?

3  Asked on December 4, 2021

### What are the types of Quantum Molecular Dynamics (QMD)?

1  Asked on December 4, 2021

### More matter modeling codes or better codes?

2  Asked on December 2, 2021

### Property related with Berry curvature: $Omega_{n,munu}=-Omega_{n,numu}$

1  Asked on December 2, 2021

### Are there properties that can only be calculated with a given set-up?

1  Asked on November 24, 2021

### What thermodynamic data is collected in order to build a CALPHAD model?

3  Asked on November 18, 2021

### Is there a way to obtain solution-phase dielectric constants?

1  Asked on November 18, 2021 by nathanielng

### What measured quantity can be associated to the value of the J parameter in the Heisenberg/Ising hamiltonians?

1  Asked on November 15, 2021

### How can I calculate the Poisson ratio of an amorphous material with LAMMPS?

1  Asked on November 12, 2021

### Examples of matter modeling in fiction

1  Asked on November 10, 2021

### How is SIESTA and TranSIESTA different from plane wave DFT codes?

1  Asked on November 10, 2021

### Supercomputers around the world, which allow access for researchers outside the country

1  Asked on November 10, 2021

### What ab initio methods are better suited to modelling disorder in materials?

3  Asked on November 7, 2021

### How to interpret molden AO/MO coefficients?

1  Asked on November 7, 2021

### How do I extract a molecular structure from a CIF file?

7  Asked on November 7, 2021

### Frameworks for materials modeling at the mesoscopic scale

2  Asked on November 4, 2021

### How to understand the time-reversal symmetry in graphene?

1  Asked on November 4, 2021

### How big should a supercell be in phonon calculations?

3  Asked on August 19, 2021