做一个问题和一个部分涉及使用numpy将一组PES数据拟合到E(R) = summation(Ck*(r - rg))
的N-1多项式,其中rg
是对PES最小点的猜测。我从导入的PES中获取了所有数据,只需要弄清楚如何将其拟合到多项式
import numpy as np
with open("hf_ccsdt_cbs45.txt", "r") as File:
inputData = File.read()
lines = inputData.splitlines()
captions = lines[0]
distances = []
energies = []
for line in lines[1:]:
if line.strip() == "":
continue
parts = line.split()
distances.append(float(parts[0]))
energies.append(float(parts[1]))
import pylab as pl
pl.plot(distances, energies)
pl.xlabel('Interatmoic Distance R (Bohr)')
pl.ylabel('Energy E[R]/(HARTREE')
pl.show()
r_guess = distances[np.argmin(energies)]