# GAMESS-UK HF optimisation

from numpy        import copy as np_copy
from chemsh       import *
from chemsh.utils import testutils

ethane = Fragment(coords="ethane.xyz")
coords0 = np_copy(ethane.coords)

gamess = GAMESS_UK(frag=ethane, method="hf", basis="3-21g")

opt = Opt(theory=gamess,
          algorithm="lbfgs", tolerance=0.0003, trust_radius="energy",
          maxcycle=100, maxene=100, maxstep=1.0)
          
#opt.run()

ecalc = opt.result.energy

qm = GAMESS_UK(frag=ethane, method='hf', basis='6-31g*')

qfit = ChargeFitting(theory    =  qm,
                     method    = 'resp',
                     npoints   =  120,
                     maxcycles =  200,
                     maxinners =  10,
                     type      = 'shell',
                     nlayers   =  4,
                     vdw_scale =  1.0,
                     vdw_incr =   0.0)

qfit.run()

print("### charges =", ethane.charges)


print("### conn =", ethane.alldihedrals)
#print("### optimised =", ethane.coords-coords0)



print("### Scanning dihedral 2-0-1-5", ethane.coords[2], ethane.coords[0], ethane.coords[1], ethane.coords[5])
#scan = Scan(theory=gamess, coord=[2,0,1,5], range=0.1, step=0.01).run()
