def makeGPAWcalc(): from gpaw import GPAW, PW, Davidson, Mixer, MixerSum, FermiDirac, setup_paths if p['psp'] == 'oldpaw': setup_paths.insert( 0, '/scratch/users/ksb/gpaw/oldpaw/gpaw-setups-0.6.6300/') psp = 'paw' else: psp = p['psp'] return GPAW( mode=PW(p['pw']), xc=p['xc'], kpts=json.loads(p['kpts']), spinpol=p['spinpol'], convergence={'energy': p['econv']} #eV/electron , mixer=((MixerSum(beta=p['mixing'], nmaxold=p['nmix'], weight=100)) if p['spinpol'] else (Mixer(beta=p['mixing'], nmaxold=p['nmix'], weight=100))), maxiter=p['maxstep'], nbands=p['nbands'], occupations=FermiDirac(p['sigma']), setups=psp, eigensolver=Davidson(5), poissonsolver=None, txt='log', symmetry={'do_not_symmetrize_the_density': True})
def run(): subprocess.check_call('cd ase; git pull -q > git.out', shell=True) subprocess.check_call('cd gpaw; git pull -q > git.out', shell=True) os.chdir('gpaw') sys.path[:0] = [op.join(dir, 'ase'), op.join(dir, 'lib', 'python')] subprocess.check_call('python3 setup.py install --home=.. > build.out', shell=True) from gpaw import setup_paths setup_paths.insert(0, datasets) from gpaw.test import TestRunner, tests with open('test.out', 'w') as fd: os.mkdir('testing') os.chdir('testing') failed = TestRunner(tests[::-1], fd, jobs=4, show_output=False).run() os.chdir('..') from ase.test import test results = test(calculators=['gpaw'], verbosity=0) failed.extend(results.errors + results.failures) if failed: print(failed, file=sys.stderr) else: shutil.rmtree('testing') os.chdir('..') shutil.rmtree('lib') shutil.rmtree('bin')
def gen(symbol, exx=False, name=None, **kwargs): if mpi.rank == 0: if 'scalarrel' not in kwargs: kwargs['scalarrel'] = True g = Generator(symbol, **kwargs) g.run(exx=exx, name=name, use_restart_file=False, **parameters[symbol]) mpi.world.barrier() if setup_paths[0] != '.': setup_paths.insert(0, '.')
def create_gpaw(comm): from gpaw import GPAW, FermiDirac, PoissonSolver, setup_paths from gpaw import Mixer setup_paths.insert(0, '.') calc = GPAW(xc='PBE', occupations=FermiDirac(width=0.02), mixer=Mixer(beta=0.10, nmaxold=5, weight=100.0), communicator=comm) return calc
def gen(symbol, exx=False, name=None, **kwargs): if mpi.rank == 0: if 'scalarrel' not in kwargs: kwargs['scalarrel'] = True g = Generator(symbol, **kwargs) g.run(exx=exx, name=name, use_restart_file=False, **parameters[symbol]) mpi.world.barrier() if setup_paths[0] != '.': setup_paths.insert(0, '.')
def create_gpaw(comm): from gpaw import GPAW, FermiDirac, PoissonSolver, setup_paths from gpaw import Mixer setup_paths.insert(0,'.') calc = GPAW(xc='PBE', occupations=FermiDirac(width=0.02), mixer = Mixer(beta=0.10, nmaxold=5, weight=100.0), communicator=comm) return calc
def create_gpaw(comm): from gpaw import GPAW, FermiDirac, PoissonSolver, setup_paths from gpaw import Mixer setup_paths.insert(0, '.') # gpaw calculator: convergence = {'energy': 0.001, 'density': 1e-2, 'eigenstates': 1e-5} #calc = GPAW(xc='PBE', # h=.30, # nbands=-8, # txt='gpaw_%i.txt'%world.rank, # convergence=convergence, # occupations=FermiDirac(width=0.05), # mixer = Mixer(beta=0.10, nmaxold=5, weight=100.0), # communicator=comm) from ase.calculators.emt import EMT calc = EMT() return calc
def test(): # Generate setup symbol = 'He' if rank == 0: g = Generator(symbol, 'revPBE', scalarrel=True, nofiles=True) g.run(exx=True, **parameters[symbol]) barrier() setup_paths.insert(0, '.') a = 7.5 * Bohr n = 16 atoms = Atoms([Atom('He', (0.0, 0.0, 0.0))], cell=(a, a, a), pbc=True) calc = Calculator(gpts=(n, n, n), nbands=1, xc='revPBE') atoms.set_calculator(calc) e1 = atoms.get_potential_energy() calc.write('He') e2 = e1 + calc.get_xc_difference('vdWDF') print e1, e2
def test(): # Generate setup symbol = 'He' if rank == 0: g = Generator(symbol, 'revPBE', scalarrel=True, nofiles=True) g.run(exx=True, **parameters[symbol]) barrier() setup_paths.insert(0, '.') a = 7.5 * Bohr n = 16 atoms = Atoms([Atom('He', (0.0, 0.0, 0.0))], cell=(a, a, a), pbc=True) calc = Calculator(gpts=(n, n, n), nbands=1, xc='revPBE') atoms.set_calculator(calc) e1 = atoms.get_potential_energy() calc.write('He') e2 = e1 + calc.get_xc_difference('vdWDF') print e1, e2
def gen(symbol, exx=False, name=None, **kwargs): setup = None if mpi.rank == 0: if 'scalarrel' not in kwargs: kwargs['scalarrel'] = True g = Generator(symbol, **kwargs) if 'orbital_free' in kwargs: setup = g.run(exx=exx, name=name, use_restart_file=False, **tf_parameters.get(symbol, {'rcut': 0.9})) else: setup = g.run(exx=exx, name=name, use_restart_file=False, **parameters[symbol]) setup = mpi.broadcast(setup, 0) if setup_paths[0] != '.': setup_paths.insert(0, '.') return setup
def create_gpaw(comm): from gpaw import GPAW, FermiDirac, PoissonSolver, setup_paths from gpaw import Mixer setup_paths.insert(0,'.') # gpaw calculator: convergence = { 'energy':0.001, 'density':1e-2, 'eigenstates':1e-5 } #calc = GPAW(xc='PBE', # h=.30, # nbands=-8, # txt='gpaw_%i.txt'%world.rank, # convergence=convergence, # occupations=FermiDirac(width=0.05), # mixer = Mixer(beta=0.10, nmaxold=5, weight=100.0), # communicator=comm) from ase.calculators.emt import EMT calc = EMT() return calc
from __future__ import print_function from math import pi, cos, sin from ase import Atoms from ase.parallel import paropen from gpaw import GPAW, setup_paths, FermiDirac setup_paths.insert(0, '.') a = 12.0 # use a large cell d = 0.9575 t = pi / 180 * 104.51 atoms = Atoms('OH2', [(0, 0, 0), (d, 0, 0), (d * cos(t), d * sin(t), 0)], cell=(a, a, a)) atoms.center() calc1 = GPAW(h=0.2, txt='h2o_gs.txt', xc='PBE') atoms.set_calculator(calc1) e1 = atoms.get_potential_energy() + calc1.get_reference_energy() calc2 = GPAW(h=0.2, txt='h2o_exc.txt', xc='PBE', charge=-1, spinpol=True, occupations=FermiDirac(0.0, fixmagmom=True), setups={0: 'fch1s'})
from gpaw import setup_paths import os """This calculation has the following structure. 1) Calculate the ground state of Diamond. 2) Calculate the band structure of diamond in order to obtain accurate KS band gap for Diamond. 3) Calculate ground state again, and calculate the potential discontinuity using accurate band gap. 4) Calculate band structure again, and apply the discontinuity to CBM. Compare to reference. """ xc = 'GLLBSC' gen('C',xcname=xc) setup_paths.insert(0, '.') # Calculate ground state atoms = bulk('C', 'diamond', a=3.567) calc = GPAW(h=0.15, kpts=(4,4,4), xc=xc, nbands = 6, eigensolver=Davidson(niter=2)) atoms.set_calculator(calc) atoms.get_potential_energy() calc.write('Cgs.gpw') # Calculate accurate KS-band gap from band structure points = ibz_points['fcc'] # CMB is in G-X G = points['Gamma'] X = points['X']
import os from ase import * from gpaw import GPAW, restart from gpaw.atom.generator import Generator from gpaw.atom.configurations import parameters from gpaw import setup_paths from gpaw.mpi import world from gpaw.test import equal # This test calculates the derivative discontinuity of Ne-atom # first on 3D without restart. Then does restart and recalculates. atom = "Ne" setup_paths.insert(0, ".") for xcname in ["GLLB", "GLLBSC"]: if world.rank == 0: g = Generator(atom, xcname=xcname, scalarrel=False, nofiles=True) g.run(**parameters[atom]) eps = g.e_j[-1] world.barrier() a = 10 Ne = Atoms([Atom(atom, (0, 0, 0))], cell=(a, a, a), pbc=False) Ne.center() calc = GPAW(nbands=10, h=0.2, xc=xcname) Ne.set_calculator(calc) e = Ne.get_potential_energy() response = calc.hamiltonian.xc.xcs["RESPONSE"] response.calculate_delta_xc() KS, dxc = response.calculate_delta_xc_perturbation()
Created on Wed May 29 12:49:38 2019 @author: misa Goal: apply kinetic energy operator to density/sqrt of density (\hat{T} \psi to obtain kinetic energy gradient with respect to density This script compares (\hat{T} \psi using my own formulation of \hat{T} with the kinetic energy operator from gpaw.wavefunctions and a grid object that is used to calculate the kinetic energy during the SCF cycle by looking at slices through the corresponding grids """ import sys sys.path.insert(0, '/home/misa/APDFT/prototyping/gpaw/tools') from gpaw import setup_paths setup_paths.insert(0, '/home/misa/APDFT/prototyping/gpaw/OFDFT') import numpy as np from gpaw import GPAW import processing as pr from matplotlib import pyplot as plt from ase.units import Bohr, Hartree ################################################################################ # contour plots along and orthogonal to bond axis in H2 def get_plots(func_obj, title=None): x_plane_kin_par_bond = func_obj.select_plane('x', 6.0 / Bohr) y_plane_kin_par_bond = func_obj.select_plane('y', 6.0 / Bohr)
os.system('mv ../ase/ase ../lib/python') os.system('wget --no-check-certificate --quiet ' + 'http://wiki.fysik.dtu.dk/gpaw-files/gpaw-setups-latest.tar.gz') os.system('tar xvzf gpaw-setups-latest.tar.gz') setups = tmpdir + '/gpaw/' + glob.glob('gpaw-setups-[0-9]*')[0] sys.path.insert(0, '%s/lib/python' % tmpdir) if day % 4 < 2: sys.argv.append('--debug') from gpaw import setup_paths setup_paths.insert(0, setups) # Run test-suite: from gpaw.test import TestRunner, tests os.mkdir('gpaw-test') os.chdir('gpaw-test') out = open('test.out', 'w') #tests = ['ase3k.py', 'jstm.py'] failed = TestRunner(tests, stream=out).run() out.close() if failed: # Send mail: n = len(failed) if n == 1: subject = 'One failed test: ' + failed[0] else:
"""ARGPARSE""" import argparse parser = argparse.ArgumentParser(description='Process some integers.') parser.add_argument('--path', default='../data/c8/', help='path to data folder') parser.add_argument('--xyzname', default='c8.xyz', help='name of the xyz file') parser.add_argument('--basis', default='sz', help='basis (sz, dzp, ...)') args = parser.parse_args() import os basis = args.basis path = os.path.abspath(args.path) + "/" xyzname = args.xyzname setup_paths.insert(0, '../gpaw_basis/') """ Constants """ xc = 'PBE' FDwidth = 0.1 kpts = (1, 1, 1) mode = 'lcao' h = 0.20 vacuum = 4 basis_full = {'H': 'sz', 'C': basis, 'Si': basis, 'Ge': basis} """ Read molecule """ molecule = read(path + xyzname) view(molecule)