def sq_test(): """Use Seqquest to test the GDIIS optimization""" from SeqQuest import get_energy_forces from Constants import Ang2Bohr #optimizer = GDIIS(1,0.05) optimizer = SD(0.1) h2o = [(8,(0,0,0)),(1,(1.,0,0)),(1,(0,1,0))] # Convert Angstroms to bohr for i in range(len(h2o)): atno,(x,y,z) = h2o[i] h2o[i] = atno,(Ang2Bohr(x),Ang2Bohr(y),Ang2Bohr(z)) gconv = 0.004 for i in range(50): energy,forces = get_energy_forces('quest.in',h2o, [[20,0,0],[0,20,0],[0,0,20]], 0,(40,40,40)) err = max(abs(ravel(forces))) if err < gconv: print "Geometry converged to ",gconv," Ry/bohr" break print "G iteration ",i+1,err for i in range(len(h2o)): atno,(x,y,z) = h2o[i] fx,fy,fz = forces[i] print "%2d %10.4f %10.4f %10.4f %10.4f %10.4f %10.4f " %\ (atno,x,y,z,fx,fy,fz) r12,r13,a123 = dist_angle(h2o[0][1],h2o[1][1],h2o[2][1]) print r12,r13,a123 h2o = optimizer.newgeo(h2o,forces,energy) return
def mindo_test(): """Test the geometry optimization using MINDO forces""" from PyQuante.Molecule import Molecule from PyQuante.MINDO3 import get_energy_forces h2o = Molecule('H2O',atomlist=[(8,(0,0,0)),(1,(1.,0,0)),(1,(0,1.,0))]) optimizer = GDIIS(60,0.0001) for i in range(25): energy,forces = get_energy_forces(h2o) forces *= -1 for i in range(len(h2o)): atno,(x,y,z) = h2o[i].atuple() fx,fy,fz = forces[i] print "%2d %10.4f %10.4f %10.4f %10.4f %10.4f %10.4f " %\ (atno,x,y,z,fx,fy,fz) newgeo = optimizer.newgeo(h2o.atuples(),forces) h2o.update_from_atuples(newgeo)