我输入了一段代码:
LOEWDIN ATOMIC CHARGES
----------------------
0 C : -0.780631
1 H : 0.114577
2 Br: 0.309802
3 Cl: 0.357316
4 F : -0.001065
这是代码:
import numpy as np
name = input("Enter Molecule ID: ")
name_in = name+'.lac.dat'
print(name_in)
atm_chg = []
with open(name_in) as f:
# skip two lines
f.readline()
f.readline()
for line in f.readlines():
if line.strip(): # is the line non-empty, ignoring white space
atm_chg.append(float( line.split()[-1] ))
np.savetxt('atm_chg',atm_chg,delimiter=',')
以上产生:
-7.806309999999999638e-01
1.145769999999999983e-01
3.098020000000000218e-01
3.573160000000000225e-01
-1.064999999999999974e-03
我想对这个文本文件做同样的事情:
* MAYER POPULATION ANALYSIS *
*****************************
NA - Mulliken gross atomic population
ZA - Total nuclear charge
QA - Mulliken gross atomic charge
VA - Mayer's total valence
BVA - Mayer's bonded valence
FA - Mayer's free valence
ATOM NA ZA QA VA BVA FA
0 C 5.8816 6.0000 0.1184 4.2631 4.2631 0.0000
1 H 0.8495 1.0000 0.1505 0.9510 0.9510 0.0000
2 Br 35.0064 35.0000 -0.0064 1.2192 1.2192 -0.0000
3 Cl 17.0401 17.0000 -0.0401 1.2405 1.2405 -0.0000
4 F 9.2225 9.0000 -0.2225 1.0449 1.0449 -0.0000
到目前为止,我尝试过的所有事情都失败了,我真的不知道下一步该尝试什么。
我希望能朝着正确的方向发展。