[gpaw-users] Saving and restart with custom external potential
Jens Jørgen Mortensen
jjmo at dtu.dk
Mon Jan 21 07:02:48 CET 2019
On 1/18/19 3:47 PM, Capiod, P.C.B. (Pierre) via gpaw-users wrote:
>
> 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 ?
>
There is no good way to do that at the moment. It might work if you
register your potential class like this:
import gpaw.external as ext
ext.__all__.append('ImagePotential')
ext.ImagePotential = ImagePotential
before reloading.
Jens Jørgen
> Best regards,
> Pierre
>
>
> _______________________________________________
> gpaw-users mailing list
> gpaw-users at listserv.fysik.dtu.dk
> https://listserv.fysik.dtu.dk/mailman/listinfo/gpaw-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listserv.fysik.dtu.dk/pipermail/gpaw-users/attachments/20190121/c4fa5f81/attachment.html>
More information about the gpaw-users
mailing list