How to use the gpaw.GPAW function in gpaw

To help you get started, we’ve selected a few gpaw examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pyscf / pyscf / test / test_0013_gpaw_overlap.py View on Github external
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):

  def test_sv_after_gpaw(self):
    """ init ao_log_c with it radial orbitals from GPAW """
    from pyscf.nao import system_vars_c, prod_basis_c
github pyiron / pyiron / pyiron / gpaw / gpaw.py View on Github external
def run_if_interactive(self):
        if self.structure.calc is None:
            kpoints = self.input["kpoints"]
            if isinstance(kpoints, str):
                kpoints = (
                    self.input["kpoints"].replace("[", "").replace("]", "").split()
                )
            self._create_working_directory()
            calc = GPAW(
                mode=PW(float(self.input["encut"])),
                xc=self.input["potential"],
                occupations=MethfesselPaxton(width=float(self.input["sigma"])),
                kpts=kpoints,
                txt=self.working_directory + "/" + self.job_name + ".txt",
            )
            self.structure.set_calculator(calc)
        self.status.running = True
        self.structure.calc.calculate(self.structure)
        self.interactive_collect()
github rosswhitfield / ase / ase / gui / calculator.py View on Github external
gpaw_param = {}
        for s in use:
            gpaw_param[s] = p[s]
        if p["use mixer"]:
            mx = getattr(gpaw, p["mixer"])
            mx_args = {}
            mx_arg_n = ["beta", "nmaxold", "weight"]
            if p["mixer"] == "MixerDiff":
                mx_arg_n.extend(["beta_m", "nmaxold_m", "weight_m"])
            for s in mx_arg_n:
                mx_args[s] = p[s]
            gpaw_param["mixer"] = mx(**mx_args)
        progress = GpawProgressIndicator()
        self.gui.simulation["progress"] = progress
        gpaw_param["txt"] = progress.get_gpaw_stream()
        gpaw_calc = gpaw.GPAW(**gpaw_param)

        def gpaw_factory(calc=gpaw_calc):
            return calc

        self.gui.simulation["calc"] = gpaw_factory
github rosswhitfield / ase / ase / examples / stm.py View on Github external
from ase import Atoms
from ase.dft import STM
from gpaw import GPAW
calc = GPAW('Al100.gpw')
a0 = calc.get_atoms()
stm = STM(calc, [0, 1, 2])
c = stm.get_averaged_current(2.5)
h = stm.scan(c)
print h[8]-h[:, 8]
github rosswhitfield / ase / doc / gettingstarted / tut04_bulk / solution / bulk_part5_rutile_bands.py View on Github external
from gpaw import GPAW

calc = GPAW('groundstate.rutile.gpw')
atoms = calc.get_atoms()
path = atoms.cell.bandpath(density=7)
path.write('path.rutile.json')

calc.set(kpts=path, fixdensity=True,
         symmetry='off')

atoms.get_potential_energy()
bs = calc.band_structure()
bs.write('bs.rutile.json')
github rosswhitfield / ase / doc / ase / calculators / socketio / example_client_gpaw.py View on Github external
from __future__ import print_function
from ase.io import read
from ase.calculators.socketio import SocketClient
from gpaw import GPAW, Mixer

# The atomic numbers are not transferred over the socket, so we have to
# read the file
atoms = read('initial.traj')
unixsocket = 'ase_server_socket'

atoms.calc = GPAW(mode='lcao',
                  basis='dzp',
                  txt='gpaw.client.txt',
                  mixer=Mixer(0.7, 7, 20.0))

client = SocketClient(unixsocket=unixsocket)

# Each step of the loop changes the atomic positions, but the generator
# yields None.
for i, _ in enumerate(client.irun(atoms, use_stress=False)):
    print('step:', i)
github rosswhitfield / ase / doc / gettingstarted / tut06_database / solution / solution.py View on Github external
for row in db.select():
    atoms = row.toatoms()
    calc = GPAW(mode=PW(400),
                kpts=(4, 4, 4),
                txt=f'{row.formula}-gpaw.txt', xc='LDA')
    atoms.calc = calc
    atoms.get_stress()
    filter = ExpCellFilter(atoms)
    opt = BFGS(filter)
    opt.run(fmax=0.05)
    db.write(atoms=atoms, relaxed=True)


for row in db.select(relaxed=True):
    atoms = row.toatoms()
    calc = GPAW(mode=PW(400),
                kpts=(4, 4, 4),
                txt=f'{row.formula}-gpaw.txt', xc='LDA')
    atoms.calc = calc
    atoms.get_potential_energy()
    bg, _, _ = bandgap(calc=atoms.calc)
    db.update(row.id, bandgap=bg)
github rosswhitfield / ase / tutorials / 2_LGPMin / 3_GPAW / gpawmin.py View on Github external
from ase.io import read
from gpaw import GPAW
from ase.optimize.activelearning.lgpmin import LGPMin
from ase.optimize.lbfgs import LBFGS
from ase.calculators.gp.calculator import GPCalculator

atoms = read('molecule.xyz')
atoms.center(vacuum=4.5)
calc = GPAW(mode='lcao', basis='sz(dzp)', h=0.3,
            txt='gpaw_output.txt',
            convergence=dict(density=1e-3))
atoms.calc = calc

# gp_model = GPCalculator(scale=0.4, max_train_data=20,
#                         max_train_data_strategy='nearest_train')
# opt = LGPMin(atoms, model_calculator=gp_model)
opt = LBFGS(atoms, trajectory='opt_LBFGS.traj')
opt.run(fmax=0.01)
github andersborges / natural-orbitals / NO.py View on Github external
"""
    from gpaw import GPAW
    from gpaw import setup_paths
    from os.path import exists
    from subprocess import call
    from numpy import ascontiguousarray as asc
    from ase.io import write

    if exists(folder_name)==False:
        print "making folder for basis functions"
        call('mkdir %s'%folder_name, shell=True)

    symbols = atoms.get_chemical_symbols()
    ns=np.array(ns)
    atoms.center(vacuum=vacuum)
    calc = GPAW(h = h, mode='lcao',
        basis= basis,
        txt='basis.txt')
    atoms.set_calculator(calc)
    calc.initialize(atoms)
    calc.set_positions(atoms)
    c_fo_xi = asc(r.real.T)#coefficients
    phi_xG = calc.wfs.basis_functions.gd.zeros(len(c_fo_xi))
    calc.wfs.basis_functions.lcao_to_grid(c_fo_xi, phi_xG, -1)
    for n, phi in zip(ns, phi_xG.take(ns, axis=0)):
        print "writing %d of %d" %(n, len(ns)), 
        write('%s/%d.cube' % (folder_name,n), atoms, data=phi)
    summ = np.zeros(phi_xG[0,:,:,:].shape)
    print "sum", summ.shape
    for n, phi in zip(ns, phi_xG.take(ns, axis=0)):
        summ+= phi
    write('%s/sum.cube'%folder_name, atoms, data=summ)