Commit 70084506 authored by hebrewsnabla's avatar hebrewsnabla
Browse files

update frag

parent 1b046888
......@@ -13,14 +13,28 @@ gjfhead = '''%nproc=1
title
'''
scrfhead = '''eps=1.0
basis = '''
-O -H
TZVP
****
-Ce 0
SDD
****
-Ce 0
SDD
'''
scrfhead = '''
eps=1.0
epsinf=1.0
'''
wfnpath = 'D:\\xxx\\yyy\\frag'
## the optput wfn will be frag0.wfn, frag1.wfn, ...
# frags charges spins
frag_sol.from_frag(xyz, [[0,1],[2,3]], [0,0], [1,-1], gjfhead, scrfhead, 'frag', wfnpath)
# note that atom in frag count from 0
frag_sol.from_frag(xyz, [[1,2],[3,4]], [0,0],[1,-1], gjfhead, scrfhead, 'frag', basis, wfnpath)
# spin = 0 for singlet, 1 for doublet, ...
# please ensure sum of spins equals spin of the total system
%nproc=1
%mem=1gb
#p b3lyp/cc-pvdz scrf=read out=wfn
title
0 2
H 0.00000 0.00000 0.00000
O 0.00000 0.00000 1.00000
-O -H
TZVP
****
-Ce 0
SDD
****
-Ce 0
SDD
eps=1.0
epsinf=1.0
ExtraSph=2
0.00000 0.00000 2.00000 1.75000
0.00000 0.00000 3.00000 1.44300
D:\xxx\yyy\frag0.wfn
%nproc=1
%mem=1gb
#p b3lyp/cc-pvdz scrf=read out=wfn
title
0 -2
O 0.00000 0.00000 2.00000
H 0.00000 0.00000 3.00000
-O -H
TZVP
****
-Ce 0
SDD
****
-Ce 0
SDD
eps=1.0
epsinf=1.0
ExtraSph=2
0.00000 0.00000 0.00000 1.44300
0.00000 0.00000 1.00000 1.75000
D:\xxx\yyy\frag1.wfn
......@@ -8,7 +8,7 @@ def from_frag(xyz, frags, chgs, spins, gjfhead='', scrfhead='', gjfname='', basi
mol.verbose = 1
mol.build()
guess_frag(mol, frags, chgs, spins, gjfhead, scrfhead, gjfname, basis, wfnpath)
guess_frag(mol, frags, chgs, spins, gjfhead.lstrip('\n'), scrfhead, gjfname, basis, wfnpath)
def spin_p2g(spin):
if spin>0:
......@@ -21,7 +21,7 @@ def spin_p2g(spin):
def guess_frag(mol, frags, chgs, spins, gjfhead, scrfhead, gjfname, basis, wfnpath):
'''
frags: e.g. [[0], [1]] for N2
frags: e.g. [[1], [2]] for N2
chgs: e.g. [0, 0] for N2
spins: e.g. [3, -3] for N2
'''
......@@ -32,14 +32,14 @@ def guess_frag(mol, frags, chgs, spins, gjfhead, scrfhead, gjfname, basis, wfnpa
#fraga, fragb = frags
#chga, chgb = chgs
#spina, spinb = spins
allatom = range(len(atom))
allatom = range(1,len(atom)+1)
for k in range(len(frags)):
frag = frags[k]
chg = chgs[k]
spin = spins[k]
g_spin = spin_p2g(spin)
atomk = [atom[i] for i in frag]
atomother = [atom[i] for i in allatom if i not in frag]
atomk = [atom[i-1] for i in frag]
atomother = [atom[i-1] for i in allatom if i not in frag]
print('fragment %d, chg %d, spin %d' % (k, chg, spin))
#print(atomk)
with open(gjfname+'%d.gjf'%k, 'w') as f:
......@@ -47,10 +47,10 @@ def guess_frag(mol, frags, chgs, spins, gjfhead, scrfhead, gjfname, basis, wfnpa
f.write('%d %d\n' % (chg, g_spin))
for a in atomk:
f.write('%s %10.5f %10.5f %10.5f\n' % (a[0], a[1][0], a[1][1], a[1][2]))
f.write('\n')
#f.write('\n')
if basis is not None:
f.write(basis)
f.write('\n')
#f.write('\n')
f.write(scrfhead)
f.write('ExtraSph=%d\n\n' % len(atomother))
for b in atomother:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment