[gpaw-users] external potential for Langevin molecular dynamics
Ask Hjorth Larsen
asklarsen at gmail.com
Sun Aug 12 18:54:27 CEST 2018
Hi,
2018-08-11 10:44 GMT-05:00 Francisco Cano Marchal via gpaw-users
<gpaw-users at listserv.fysik.dtu.dk>:
> Dear GPAW users
>
> I am trying to run a Langevin molecular dynamics simulation of a water dimer
> in a confining potential, which I define using the 'ExternalPotential' class
> and include in the calculator through the 'external' parameter. I can
> calculate the energy of the system. When I try to run the Langevin dynamics
> I get the following error. I am using Anaconda 1.7.0 on Mac OS X 10.10.5 and
> Python 2.7.
>
> TypeError: <__main__.WellTubePotential instance at 0x1166fa710> is not JSON
> serializable
>
> I would like to know if the 'external' parameter for the GPAW calculator can
> be used with Langevin dynamics or if you can give me a hint on where the
> problem could be. I enclose my code.
>
> Kind regards,
>
> Francisco
>
> from ase.units import Bohr
> from gpaw import GPAW, PW
> from gpaw.external import ExternalPotential
> from ase.data import s22
> from ase.md import Langevin
> from ase.io.trajectory import Trajectory
> import ase.units as units
>
>
> a = 4.0
>
> atoms = s22.create_s22_system('Water_dimer')
> atoms.set_cell((2*a,a,a))
> atoms.center()
>
> d = 4 # diameter of the tube
> h = 200 # well depth
>
> class WellTubePotential(ExternalPotential):
> def calculate_potential(self, gd):
> r_vg = gd.get_grid_point_coordinates()
> self.vext_g = (((r_vg[1] - a / Bohr / 2)**2 + (r_vg[2] - a / Bohr /
> 2)**2)**.5 > d/2)*h
Implement a todict() method:
def todict(self):
return {...}
This makes it possible to save a representation of the class in the
traj file. You choose what to put in the dictionary.
Best regards
Ask
>
> calc = GPAW(external=WellTubePotential(), mode=PW(200))
>
> atoms.calc = calc
> atoms.get_potential_energy()
>
> # Langevin Dynamics
>
> tag = 'dimer-in-tubewell'
>
> md = Langevin(atoms, 1 * units.fs, temperature=300 * units.kB,
> friction=0.01, logfile=tag + '.log')
>
> traj = Trajectory(tag + '.traj', 'w', atoms)
> md.attach(traj.write, interval=1)
> md.run(4000)
>
>
> _______________________________________________
> gpaw-users mailing list
> gpaw-users at listserv.fysik.dtu.dk
> https://listserv.fysik.dtu.dk/mailman/listinfo/gpaw-users
More information about the gpaw-users
mailing list