Skip to content

Commit

Permalink
Pyscf/Pyberny interface (pyscf#115)
Browse files Browse the repository at this point in the history
* update gitignore

* add pyscf.geomopt.optimize (wraps pyberny.optimize)
  • Loading branch information
jhrmnn authored and sunqm committed Aug 20, 2017
1 parent 73a987b commit d5c8f5c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ CMakeCache.txt
CMakeFiles
Makefile
cmake_install.cmake
lib/deps
lib/config.h
pyscf/lib/deps
pyscf/lib/config.h

settings.py

Expand Down
13 changes: 10 additions & 3 deletions pyscf/geomopt/berny_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
'''
from __future__ import absolute_import
try:
from berny import Berny, geomlib, Logger
from berny import Berny, geomlib, Logger, optimize as optimize_berny
except ImportError:
raise ImportError('Geometry optimizer pyberny not found.\npyberny library '
'can be found on github https://github.com/azag0/pyberny')
Expand Down Expand Up @@ -51,10 +51,14 @@ def as_berny_solver(method, mol=None):
atom = yield energy, gradients


def optimize(method, mol, **kwargs):
optimize_berny(as_berny_solver(method), to_berny_geom(mol), **kwargs)
return method.mol


if __name__ == '__main__':
from pyscf import gto
from pyscf import scf, dft, cc
from berny import optimize
mol = gto.M(atom='''
C 1.1879 -0.3829 0.0000
C 0.0000 0.5526 0.0000
Expand All @@ -71,7 +75,10 @@ def as_berny_solver(method, mol=None):

mf = scf.RHF(mol)
print(kernel(mf).dumps('xyz'))
print(optimize(as_berny_solver(mf), to_berny_geom(mol)).dumps('xyz'))
print(optimize_berny(as_berny_solver(mf), to_berny_geom(mol)).dumps('xyz'))
mol0 = optimize(mf, mol1)
scf.RHF(mol1).kernel()
scf.RHF(mol0).kernel()

mf = dft.RKS(mol)
mf.xc = 'pbe'
Expand Down

0 comments on commit d5c8f5c

Please sign in to comment.