[gpaw-users] Saving and restart with custom external potential
Capiod, P.C.B. (Pierre)
p.c.b.capiod at uu.nl
Tue Jan 29 16:33:27 CET 2019
Hello,
The fix did the trick. I had to change in the external.py file
return globals()[name](**kwargs)
in order to load the proper external field. The modification was to
remove "**kwargs", otherwise the program was returning an error for
ImagePotential() not taking any arguments. The reload and the rest of
the calculations went fine.
Thank you !
Pierre
On 1/21/19 12:00 PM, gpaw-users-request at listserv.fysik.dtu.dk wrote:
> Send gpaw-users mailing list submissions to
> gpaw-users at listserv.fysik.dtu.dk
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://listserv.fysik.dtu.dk/mailman/listinfo/gpaw-users
> or, via email, send a message with subject or body 'help' to
> gpaw-users-request at listserv.fysik.dtu.dk
>
> You can reach the person managing the list at
> gpaw-users-owner at listserv.fysik.dtu.dk
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of gpaw-users digest..."
>
>
> Today's Topics:
>
> 1. Re: Saving and restart with custom external potential
> (Jens J?rgen Mortensen)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Mon, 21 Jan 2019 07:02:48 +0100
> From: Jens J?rgen Mortensen <jjmo at dtu.dk>
> To: "Capiod, P.C.B. (Pierre)" <p.c.b.capiod at uu.nl>,
> "gpaw-users at listserv.fysik.dtu.dk" <gpaw-users at listserv.fysik.dtu.dk>
> Subject: Re: [gpaw-users] Saving and restart with custom external
> potential
> Message-ID: <b7a6955f-0a2f-176d-f885-09bacda14223 at dtu.dk>
> Content-Type: text/plain; charset="utf-8"; Format="flowed"
>
> 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-0001.html>
>
> ------------------------------
>
> _______________________________________________
> gpaw-users mailing list
> gpaw-users at listserv.fysik.dtu.dk
> https://listserv.fysik.dtu.dk/mailman/listinfo/gpaw-users
>
> End of gpaw-users Digest, Vol 108, Issue 18
> *******************************************
More information about the gpaw-users
mailing list