I am looking for a way to read .fchk file in psi4, such that I can restart a SCF calculation from such a file. I need this because I am playing with the MO coefficients with an external code, to generate localized orbitals. Then, I would like to check that the SCF calculation indeed converges in only one iteration using psi4. It should be the case because my localization scheme is similar to the Pipek-Mezey one, and implies only (unitary) rotations of pair of orbitals.
I’ve seen on this forum that I am not the only one interested by such a feature, and I am not sure if such option has been provided or not yet.
So my question is simple: is there a way to restart a psi4 calculation using an external .fchk file, and if not is it something that will be provided on a future release ?
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:
for line in f:
if re.search(text, line):
for i in range((n-1)//5+1):
line = next(f)
for j in line.split():
var += [float(j)]
with open("your_fchk_file.fchk","r") as f:
alpha_coeff = read_real_list("Alpha MO coefficients", f)
alpha_MO_coeff = np.zeros((scf_wfn.Ca().np.shape,scf_wfn.Ca().np.shape),dtype=float)
ij = 0
for i in range(scf_wfn.Ca().np.shape):
for j in range(scf_wfn.Ca().np.shape):
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
What do you mean by “the reordering is left out” ? The reordering should be accounted by the back transformation before setting the MO coefficients in the psi4 wavefunction object. I didn’t write the back transformation in this script so maybe that’s confusing, but this back transformation can be simply constructed by looking at the way psi4 writes the FCHK.
I agree with you for the FCHK format. I have kept this feature for my code to have an interface with Gaussian, but I have now built things differently for psi4 and other codes