mirror of
https://github.com/QuantumPackage/qp2.git
synced 2024-12-22 03:23:29 +01:00
added write_pt_charges.py
This commit is contained in:
parent
656709b7c1
commit
ef3a52f54d
@ -34,23 +34,28 @@ cat > hcn_charges.xyz << EOF
|
|||||||
0.5 -2.0 0.0 0.0
|
0.5 -2.0 0.0 0.0
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
rm -rf hcn.ezfio
|
EZFIO=hcn_pt_charges
|
||||||
qp create_ezfio -b def2-svp hcn.xyz
|
rm -rf $EZFIO
|
||||||
|
qp create_ezfio -b def2-svp hcn.xyz -o $EZFIO
|
||||||
qp run scf
|
qp run scf
|
||||||
mv hcn_charges.xyz hcn.ezfio_point_charges.xyz
|
mv hcn_charges.xyz ${EZFIO}_point_charges.xyz
|
||||||
python write_pt_charges.py hcn.ezfio
|
python write_pt_charges.py ${EZFIO}
|
||||||
qp set nuclei point_charges True
|
qp set nuclei point_charges True
|
||||||
qp run scf | tee hcn.ezfio.pt_charges.out
|
qp run scf | tee ${EZFIO}.pt_charges.out
|
||||||
energy="$(ezfio get hartree_fock energy)"
|
energy="$(ezfio get hartree_fock energy)"
|
||||||
rm -rf hcn.ezfio
|
|
||||||
good=-92.76613324421798
|
good=-92.76613324421798
|
||||||
eq $energy $good $thresh
|
eq $energy $good $thresh
|
||||||
|
rm -rf $EZFIO
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "point charges" {
|
@test "point charges" {
|
||||||
run_pt_charges
|
run_pt_charges
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "HCN" { # 7.792500 8.51926s
|
||||||
|
run hcn.ezfio -92.88717500035233
|
||||||
|
}
|
||||||
|
|
||||||
@test "B-B" { # 3s
|
@test "B-B" { # 3s
|
||||||
run b2_stretched.ezfio -48.9950585434279
|
run b2_stretched.ezfio -48.9950585434279
|
||||||
}
|
}
|
||||||
@ -124,9 +129,6 @@ good=-92.76613324421798
|
|||||||
run ch4.ezfio -40.19961807784367
|
run ch4.ezfio -40.19961807784367
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "HCN" { # 7.792500 8.51926s
|
|
||||||
run hcn.ezfio -92.88717500035233
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "N2" { # 8.648100 13.754s
|
@test "N2" { # 8.648100 13.754s
|
||||||
run n2.ezfio -108.9834897852979
|
run n2.ezfio -108.9834897852979
|
||||||
|
80
src/nuclei/write_pt_charges.py
Normal file
80
src/nuclei/write_pt_charges.py
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
# First argument is the EZFIO file
|
||||||
|
# It reads a file EZFIO_point_charges.xyz written in this way:
|
||||||
|
# charge x y z (Angstrom)
|
||||||
|
# for all charges
|
||||||
|
|
||||||
|
|
||||||
|
def zip_in_ezfio(ezfio,tmp):
|
||||||
|
tmpzip=tmp+".gz"
|
||||||
|
cmdzip="gzip -c "+tmp+" > "+tmpzip
|
||||||
|
os.system(cmdzip)
|
||||||
|
os.system("rm "+tmp)
|
||||||
|
cmdmv="mv "+tmpzip+" "+EZFIO+"/nuclei/"+tmpzip
|
||||||
|
os.system(cmdmv)
|
||||||
|
|
||||||
|
def mv_in_ezfio(ezfio,tmp):
|
||||||
|
cmdmv="mv "+tmp+" "+EZFIO+"/nuclei/"+tmp
|
||||||
|
os.system(cmdmv)
|
||||||
|
|
||||||
|
|
||||||
|
# Getting the EZFIO
|
||||||
|
EZFIO=sys.argv[1]
|
||||||
|
EZFIO=EZFIO.replace("/", "")
|
||||||
|
print(EZFIO)
|
||||||
|
|
||||||
|
# Reading the point charges and convert the Angstrom geometry in Bohr for QP
|
||||||
|
f = open(EZFIO+'_point_charges.xyz','r')
|
||||||
|
lines = f.readlines()
|
||||||
|
convert_angs_to_bohr=1.8897259885789233
|
||||||
|
|
||||||
|
n_charges=0
|
||||||
|
coord_x=[]
|
||||||
|
coord_y=[]
|
||||||
|
coord_z=[]
|
||||||
|
charges=[]
|
||||||
|
for line in lines:
|
||||||
|
data = line.split()
|
||||||
|
if(len(data)>0):
|
||||||
|
n_charges += 1
|
||||||
|
charges.append(str(data[0]))
|
||||||
|
coord_x.append(str(convert_angs_to_bohr*float(data[1])))
|
||||||
|
coord_y.append(str(convert_angs_to_bohr*float(data[2])))
|
||||||
|
coord_z.append(str(convert_angs_to_bohr*float(data[3])))
|
||||||
|
|
||||||
|
# Write the file containing the number of charges and set in EZFIO folder
|
||||||
|
tmp="n_pts_charge"
|
||||||
|
fncharges = open(tmp,'w')
|
||||||
|
fncharges.write(" "+str(n_charges)+'\n')
|
||||||
|
fncharges.close()
|
||||||
|
mv_in_ezfio(EZFIO,tmp)
|
||||||
|
|
||||||
|
# Write the file containing the charges and set in EZFIO folder
|
||||||
|
tmp="pts_charge_z"
|
||||||
|
fcharges = open(tmp,'w')
|
||||||
|
fcharges.write(" 1\n")
|
||||||
|
fcharges.write(" "+str(n_charges)+'\n')
|
||||||
|
for i in range(n_charges):
|
||||||
|
fcharges.write(charges[i]+'\n')
|
||||||
|
fcharges.close()
|
||||||
|
zip_in_ezfio(EZFIO,tmp)
|
||||||
|
|
||||||
|
# Write the file containing the charge coordinates and set in EZFIO folder
|
||||||
|
tmp="pts_charge_coord"
|
||||||
|
fcoord = open(tmp,'w')
|
||||||
|
fcoord.write(" 2\n")
|
||||||
|
fcoord.write(" "+str(n_charges)+' 3\n')
|
||||||
|
#fcoord.write(" "+' 3 '+str(n_charges)+' \n')
|
||||||
|
for i in range(n_charges):
|
||||||
|
fcoord.write(' '+coord_x[i]+'\n')
|
||||||
|
for i in range(n_charges):
|
||||||
|
fcoord.write(' '+coord_y[i]+'\n')
|
||||||
|
for i in range(n_charges):
|
||||||
|
fcoord.write(' '+coord_z[i]+'\n')
|
||||||
|
fcoord.close()
|
||||||
|
zip_in_ezfio(EZFIO,tmp)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user