[gpaw-users] Saving and restart with custom external potential

Capiod, P.C.B. (Pierre) p.c.b.capiod at uu.nl
Fri Jan 18 15:47:50 CET 2019


Hi all,

I have tried to add a custom external potential (an image potential in the form -1/z). The write of the .gpw reported an error in the beginning until I added "def todict(self):" with a proper definition.

Here is the script added for the ImagePotential:

class ImagePotential(ExternalPotential):
    def calculate_potential(self, gd):
        grid = gd.get_grid_point_coordinates()
        self.vext_g = 1 / (4*(grid[2] - (zpos-wall)))

    def todict(self):
        return {'name': 'ImagePotential',
                'potential': self.vext_g}

This is in a similar fashion as the example provided for the harmonic potential.

Unfortunately I cannot reload the .gpw created with this modification.

The error is the following:

Traceback (most recent call last):
  File "Cu111_1.51.py", line 90, in <module>
    convergence={'bands': 'occupied'})
  File "/home/pierre/.local/lib/python3.7/site-packages/gpaw/calculator.py", line 146, in __init__
    atoms, **kwargs)
  File "/usr/lib/python3.7/site-packages/ase/calculators/calculator.py", line 362, in __init__
    self.read(restart)  # read parameters, atoms and results
  File "/home/pierre/.local/lib/python3.7/site-packages/gpaw/calculator.py", line 220, in read
    self.initialize(reading=True)
  File "/home/pierre/.local/lib/python3.7/site-packages/gpaw/calculator.py", line 692, in initialize
    self.create_hamiltonian(realspace, mode, xc)
  File "/home/pierre/.local/lib/python3.7/site-packages/gpaw/calculator.py", line 906, in create_hamiltonian
    pd2=dens.pd2, pd3=dens.pd3, realpbc_c=self.atoms.pbc, **kwargs)
  File "/home/pierre/.local/lib/python3.7/site-packages/gpaw/wavefunctions/pw.py", line 1546, in __init__
    redistributor=redistributor)
  File "/home/pierre/.local/lib/python3.7/site-packages/gpaw/hamiltonian.py", line 95, in __init__
    vext = create_external_potential(**vext)
  File "/home/pierre/.local/lib/python3.7/site-packages/gpaw/external.py", line 17, in create_external_potential
    return globals()[name](**kwargs)
KeyError: 'ImagePotential'

Any idea how I can solve this issue ?

Best regards,
Pierre
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listserv.fysik.dtu.dk/pipermail/gpaw-users/attachments/20190118/e544dbd4/attachment.html>


More information about the gpaw-users mailing list