Reading from .fchk files

If one is still interested by this feature, look at the way psi4 writes a FCHK file here (with renormalization factors and reordering).

So if you read a FCHK file, then you should create the back transformation matrices by simply taking 1/pf factors instead of pf and the transpose.

To read the coefficients from a FCHK file, do as follow:

def read_real_list(text,f):
   for line in f:
      if re.search(text, line):
         n=int(line.rsplit(None, 1)[-1])
         var=[]
         for i in range((n-1)//5+1):
             line = next(f)
             for j in line.split():
                 var += [float(j)]
         return var

with open("your_fchk_file.fchk","r") as f:
      alpha_coeff = read_real_list("Alpha MO coefficients", f)
f.close()
   
alpha_MO_coeff = np.zeros((scf_wfn.Ca().np.shape[0],scf_wfn.Ca().np.shape[1]),dtype=float)
ij = 0
for i in range(scf_wfn.Ca().np.shape[1]):
   for j in range(scf_wfn.Ca().np.shape[0]):
           alpha_MO_coeff[j,i] = alpha_coeff[ij]
           ij += 1
   
# then apply the back transformation from FCHK to PSI4 ordering with prefactors.
# Only when this is done you can fill the coefficients back to PSI4:
scf_wfn.Ca().np[:] = alpha_MO_coeff