Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
from __future__ import print_function, division
import os,unittest,numpy as np
try:
from ase import Atoms
from gpaw import GPAW
fname = os.path.dirname(os.path.abspath(__file__))+'/h2o.gpw'
from gpaw import PoissonSolver
atoms = Atoms('H2O', positions=[[0.0,-0.757,0.587], [0.0,+0.757,0.587], [0.0,0.0,0.0]])
atoms.center(vacuum=3.5)
convergence = {'density': 1e-7} # Increase accuracy of density for ground state
poissonsolver = PoissonSolver(eps=1e-14, remove_moment=1 + 3) # Increase accuracy of Poisson Solver and apply multipole corrections up to l=1
# hgh and sg15 setups works only with minimal basis set!
calc = GPAW(xc='LDA', h=0.3, nbands=6,
convergence=convergence, poissonsolver=poissonsolver,
mode='lcao', txt=None, setups="hgh") # nbands must be equal to norbs (in this case 6)
atoms.set_calculator(calc)
atoms.get_potential_energy() # Do SCF the ground state
calc.write(fname, mode='all') # write DFT output
except:
calc = None
class KnowValues(unittest.TestCase):
'DM.Tolerance': 1e-4,
'DM.MixingWeight': 0.01,
'MaxSCFIterations': 150,
'DM.NumberPulay': 4})
H2O.set_calculator(siesta_calc)
efree_siesta = H2O.get_potential_energy()
# run gpaw
from gpaw import GPAW, PoissonSolver
H2O_gp = Atoms("H2O", np.array([[0.0, -0.757, 0.587],
[0.0, +0.757, 0.587],
[0.0, 0.0, 0.0]]))
H2O_gp.center(vacuum=3.5)
convergence = {'density': 1e-7}
poissonsolver = PoissonSolver(eps=1e-14, remove_moment=1 + 3)
gpaw_calc = GPAW(xc='PBE', h=0.3, nbands=6,
convergence=convergence, poissonsolver=poissonsolver,
mode='lcao', setups="sg15", txt=None)
H2O_gp.set_calculator(gpaw_calc)
efree_gpaw = H2O_gp.get_potential_energy()
dft = True
except:
dft = False
class KnowValues(unittest.TestCase):
def test_gpaw_vs_siesta_tddft_iter(self):