Exemplo n.º 1
0
Arquivo: rhf.py Projeto: zzy2014/pyscf
    def optimizer(self, solver='geometric'):
        '''Geometry optimization solver

        Kwargs:
            solver (string) : geometry optimization solver, can be "geomeTRIC"
            (default) or "berny".
        '''
        if solver.lower() == 'geometric':
            from pyscf.geomopt import geometric_solver
            return geometric_solver.GeometryOptimizer(self.as_scanner())
        elif solver.lower() == 'berny':
            from pyscf.geomopt import berny_solver
            return berny_solver.GeometryOptimizer(self.as_scanner())
        else:
            raise RuntimeError('Unknown geometry optimization solver %s' % solver)
def optimize(mf, callback=None, max_cycle=50, check_conv=True):
    opt = geometric_solver.GeometryOptimizer(mf)
    opt.params = geomeTRIC_params
    if callable(callback):
        opt.callback = functools.partial(callback, solver="geomeTRIC")
    opt.max_cycle = max_cycle
    opt.kernel()

    if check_conv and not opt.converged:
        mf.stdout.write('geomeTRIC is not converged. Switch to berny solver\n')
        mf.mol = opt.mol
        opt = berny_solver.GeometryOptimizer(mf)
        opt.params = berny_params
        if callable(callback):
            opt.callback = functools.partial(callback, solver="berny")
        opt.max_cycle = max_cycle
        opt.kernel()

    if check_conv and not opt.converged:
        raise RuntimeError('geomopt not converged')
    return opt
Exemplo n.º 3
0
 def test_optimize_high_cost(self):
     mol = gto.M(
     atom = [
     ['H',(  0.000000,    2.484212,    0.000000)],
     ['H',(  0.000000,   -2.484212,    0.000000)],
     ['H',(  2.151390,    1.242106,    0.000000)],
     ['H',( -2.151390,   -1.242106,    0.000000)],
     ['H',( -2.151390,    1.242106,    0.000000)],
     ['H',(  2.151390,   -1.242106,    0.000000)],
     ['C',(  0.000000,    1.396792,    0.000000)],
     ['C',(  0.000000,   -1.396792,    0.000000)],
     ['C',(  1.209657,    0.698396,    0.000000)],
     ['C',( -1.209657,   -0.698396,    0.000000)],
     ['C',( -1.209657,    0.698396,    0.000000)],
     ['C',(  1.209657,   -0.698396,    0.000000)], ],
         symmetry = True,
     )
     mf = scf.RHF(mol)
     sol = geometric_solver.GeometryOptimizer(mf)
     sol.max_cycle = 5
     sol.kernel()
     self.assertTrue(sol.converged)