Skip to content

Commit

Permalink
fix api bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanwsr committed Nov 15, 2022
1 parent 0ec97b6 commit be24567
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ uno.out
/examples/scan/
/examples/*out*
/examples/*/*out*
/examples/tutorial/mokit/
/dist/
*egg-info/
12 changes: 6 additions & 6 deletions automr/guess.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ def _from_fchk(mol, fch, xc=None, no=False):

return mf

def mix_tight(xyz, bas, charge=0, xc=None):
return mix(xyz, bas, charge, 'tight', xc=xc)
def mix_tight(xyz, bas, charge=0, *args, **kwargs):
return mix(xyz, bas, charge=charge, conv='tight', **kwargs)

def mix(xyz, bas, charge=0, *args, **kwargs
):
Expand Down Expand Up @@ -246,15 +246,15 @@ def check_stab(mf_mix, newton=False, goal='uhf', debug=False):
mf_mix.mo_coeff = mo
return mf_mix

def from_frag_tight(xyz, bas, frags, chgs, spins, newton):
def from_frag_tight(xyz, bas, frags, chgs, spins, newton=False, **kwargs):
if not isinstance(spins[0], list):
spins = [spins]
lowest_mf = None
lowest_e = 0.0
lowest_spin = None
for s in spins:
print('Attempt spins ', s)
mf = from_frag(xyz, bas, frags, chgs, s, cycle=70)
mf = from_frag(xyz, bas, frags, chgs, s, cycle=70, **kwargs)
mf = check_stab(mf, newton=newton)
if mf.e_tot < lowest_e:
lowest_e = mf.e_tot
Expand All @@ -263,15 +263,15 @@ def from_frag_tight(xyz, bas, frags, chgs, spins, newton):
print('Lowest UHF energy %.6f from spin guess ' % lowest_e, lowest_spin)
return lowest_mf

def from_frag(xyz, bas, *args, **kwargs):
def from_frag(xyz, bas, frags, chgs, spins, **kwargs):
mol = gto.Mole()
mol.atom = xyz
mol.basis = bas
mol.verbose = 4
mol.charge = sum(chgs)
mol.spin = sum(spins)
mol.build()
return _from_frag(mol, *args, **kwargs)
return _from_frag(mol, frags, chgs, spins, **kwargs)


def _from_frag(mol_or_mf, frags, chgs, spins, cycle=2, xc=None, verbose=4, rmdegen=False, bgchg=None):
Expand Down
6 changes: 6 additions & 0 deletions examples/tutorial/00-mix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from automr import guess

xyz = '''H 0.0 0.0 0.0; H 0.0 0.0 2.0'''
bas = 'def2-svp'
mf = guess.mix(xyz, bas) # only do 5 cycle SCF
mf = guess.mix_tight(xyz, bas) # normal SCF and stable=opt
9 changes: 9 additions & 0 deletions examples/tutorial/02-from_frag.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from automr import guess

xyz = '''N 0.0 0.0 0.0; N 0.0 0.0 4.0'''
bas = 'cc-pvtz'
mf = guess.from_frag(xyz, bas, [[0],[1]], [0,0], [3,-3])
mf = guess.from_frag_tight(xyz, bas, [[0],[1]], [0,0], [3,-3])



0 comments on commit be24567

Please sign in to comment.