[ase-users] Problem Restarting Constrained Relaxation with Vasp Calculator

Eric Hermes ehermes at chem.wisc.edu
Tue Jan 9 00:44:00 CET 2018


The issue with the VaspInteractive calculator is that it is using an undocumented feature of VASP to update ion coordinates. Using ASE optimizers with the Vasp calculator has a different problem, specifically that it must start and stop VASP between every ionic step. The number of SCF iterations per ionic step will depend on your WAVECAR/CHGCAR settings (lwave, lcharg, istart, icharg), but it will generally take more SCF iterations than if you use built-in VASP optimizers (or Graeme Henkelman’s optimizers, which can be patched into VASP).

That said, even if you fully write and read the WAVECAR at every step (lwave=True, istart=1, icharg=0) with an ASE optimizer, this will still take more SCF iterations per ionic step than using optimizers built into VASP. This is for two reasons: first, VASP uses the electron density from previous ionic iterations in its mixer history if maxmix is positive (the default is -45), and second, VASP *extrapolates* the wavefunction and charge density from the previous converged ionic step according to the new ion coordinates, which results in a better initial guess than simply using the previously converged wavefunction and charge density. Neither of these things are done if you use ASE optimizers with the Vasp calculator, and it would appear as though VASP doesn’t properly extrapolate (or maybe it doesn’t extrapolate at all) the wavefunction/charge density with interactive=True (VaspInteractive). If you set maxmix to a positive number, VaspInteractive should properly keep mixing across ionic steps though. I question whether this is a good idea in general (it’s not the default behavior, after all).

In any case, I would advise most workflows to simply use the built-in optimizers (or Graeme Henkelman’s LBFGS and FIRE optimizers, they are better) with ASE by passing the appropriate geometry optimization flags to the Vasp calculator and then running my_atoms.get_potential_energy(). This is an abuse of syntax, and ASE won’t natively return the optimization trajectory (though you can still parse it from the OUTCAR or vasprun.xml file yourself), but it’s much more efficient for normal geometry minimizations. If you need atypical constraints that aren’t supported by VASP, such as fixing bond lengths or angles or doing a scan in internal coordinates, then you’re out of luck. Use the ASE optimizers with whichever seems more performant for your purposes, Vasp or VaspInteractive. If you need to do NEB, use Graeme Henkelman’s NEB patches rather than the ASE NEB routines.

I wish VaspInteractive worked better than it did, but as it stands the most reliable way to use VASP in ASE is to leave all dynamics to VASP.

(Re-added to list. I understand this is an old thread, but some people may still find this relevant.)

Eric

From: Andrew Rosen [mailto:rosen at u.northwestern.edu]
Sent: Monday, January 8, 2018 4:26 PM
To: Eric Hermes <ehermes at chem.wisc.edu>
Subject: Re: [ase-users] Problem Restarting Constrained Relaxation with Vasp Calculator

I know I'm reviving an old thread here, but have you noticed increased number of SCF iterations when using ASE's optimizers with Vasp (not just with VaspInteractive)? I have noticed this for a few test systems I'm working on but haven't dug into whether this is merely something on the user side or not. I figured I'd ask. I imagine if you found that to be the case with VaspInteractive it probably would be the case for regular Vasp too, right?
On Mon, Oct 16, 2017 at 11:50 AM Eric Hermes via ase-users <ase-users at listserv.fysik.dtu.dk<mailto:ase-users at listserv.fysik.dtu.dk>> wrote:
On Mon, 2017-10-16 at 16:35 +0000, Andrew Rosen wrote:
> Eric,
> Just chiming in here out of interest. Would you suggest using the
> VaspInteractive calculator when using the ASE Vibrations module as
> well? I've noticed the significant overhead associated with using the
> regular VASP calculator and the ASE optimizers but never thought much
> of it since I switched to using IBRION keywords for geometry
> optimizations.
> Andrew

Yes, that would be a good use of VaspInteractive. Personally, I just
use the integrated VASP vibrations routines (IBRION=5,6,7, or 8). I
will note that in general, VaspInterative seems to take more SCF
iterations to converge than internal VASP routines do. I'm still not
entirely sure why this is, but I think it might have something to do
with how VASP extrapolates the charge density when atoms move.

Eric

>
> On Mon, Oct 16, 2017, 11:13 AM Eric Hermes via ase-users <ase-users at l
> istserv.fysik.dtu.dk<http://istserv.fysik.dtu.dk>> wrote:
> > On Mon, 2017-10-16 at 11:49 -0400, Dennis Trujillo wrote:
> > > I tried to reproduce the error again myself and it seems to work
> > now
> > > strangely enough. Is it possible to have the restarted
> > calculation
> > > write to the original trajectory file?
> >
> > That depends on how you are creating the trajectory. If you are
> > using
> > Trajectory directly, you can pass "mode='a'", e.g. my_trajectory =
> > Trajectory('existing.traj', mode='a'). If you are using an ASE
> > optimizer, then I don't believe you can.
> >
> > I would strongly advise against using an ASE optimizer with the
> > regular
> > VASP calculator though, as there is a substantial overhead involved
> > with constantly stopping/starting VASP (I/O overhead if you
> > read/write
> > CHGCAR/WAVECAR files, CPU time overhead if you don't). I would
> > suggest
> > either using the built-in VASP optimizers (the IBRION tag), or
> > using
> > the VaspInteractive calculator with the ASE optimizers. The
> > VaspInteractive calculator works basically the same as the normal
> > Vasp
> > calculator, except it forbids the use of VASP keywords that cause
> > VASP
> > to move atoms internally (e.g. IBRION), and instead it gets updated
> > positions from ASE.
> >
> > Eric
> >
> > >
> > >
> > > > On Oct 16, 2017, at 11:40 AM, Eric Hermes via ase-users <ase-
> > users@
> > > > listserv.fysik.dtu.dk<http://listserv.fysik.dtu.dk>> wrote:
> > > >
> > > > On Mon, 2017-10-16 at 15:37 +0000, Dennis Trujillo wrote:
> > > > > Here is the ase-sort.dat,
> > > > >
> > > >
> > > > Please keep replies on-list.
> > > >
> > > > As I suspected, these two files match, and should not lead to
> > the
> > > > error
> > > > message you are seeing. Can you please verify that this error
> > is
> > > > reproducible with the exact CONTCAR and ase-sort.dat files you
> > sent
> > > > me
> > > > in the directory? Also, please share your Python script that is
> > > > running
> > > > this calculation. If you are modifying the CONTCAR or ase-
> > sort.dat
> > > > files after your initial calculation but before your
> > restart=True
> > > > calculation, that could cause this issue.
> > > >
> > > > Eric
> > > > >
> > > > >
> > > > > > On Oct 16, 2017, at 11:33 AM, Eric Hermes via ase-users
> > <ase-
> > > > > > users@
> > > > >
> > > > > listserv.fysik.dtu.dk<http://listserv.fysik.dtu.dk>> wrote:
> > > > > >
> > > > > > On Mon, 2017-10-16 at 15:17 +0000, Dennis Trujillo wrote:
> > > > > > > I am using Vasp 5.4.1, attached is the CONTCAR,
> > > > > > >
> > > > > >
> > > > > >
> > > > > > I can't reproduce this error. It is not related to
> > constraints,
> > > > > > but
> > > > > > rather the atomic reordering the the VASP calculator does
> > > > >
> > > > > internally to
> > > > > > make all atoms of the same kind contiguous. The error
> > message
> > > > >
> > > > > indicates
> > > > > > that the geometry file being read has fewer than 41 atoms,
> > but
> > > > > > the
> > > > >
> > > > > file
> > > > > > you have attached indeed has 42 atoms. Are you sure you
> > have
> > > > > > sent
> > > > >
> > > > > the
> > > > > > correct CONTCAR file? Could you attach the ase-sort.dat
> > file
> > > > > > found
> > > > >
> > > > > in
> > > > > > the same directory? Those two files seem to be mismatched.
> > > > > >
> > > > > > Eric
> > > > > >
> > > > > > >
> > > > > > >
> > > > > > > > On Oct 16, 2017, at 11:07 AM, Eric Hermes via ase-users
> > > > > > > > <ase-
> > > > >
> > > > > users@
> > > > > > > listserv.fysik.dtu.dk<http://listserv.fysik.dtu.dk>> wrote:
> > > > > > > >
> > > > > > > > On Mon, 2017-10-16 at 10:59 -0400, Dennis Trujillo via
> > ase-
> > > > > > > > users
> > > > > > >
> > > > > > > wrote:
> > > > > > > > > Hello *,
> > > > > > > > >
> > > > > > > > > I am having trouble restarting a Vasp relaxation with
> > > > >
> > > > > constrained
> > > > > > > > > atoms; I am not sure if ase.io<http://ase.io> is designed to read in
> > a
> > > > > > >
> > > > > > > constrained
> > > > > > > > > POSCAR (i.e. with TTT, or etc. appended to the atomic
> > > > > > > > > position).
> > > > >
> > > > > I
> > > > > > > am
> > > > > > > > > using ASE version 3.15.0, on python 3.5.2. ASE gives
> > me
> > > > > > > > > the
> > > > > > >
> > > > > > > following
> > > > > > > > > error,
> > > > > > > > >
> > > > > > > > > > > > calc=Vasp(restart=True)
> > > > > > > > >
> > > > > > > > > Traceback (most recent call last):
> > > > > > > > >     File "<stdin>", line 1, in <module>
> > > > > > > > >     File "/users/dptru/.local/lib/python3.5/site-
> > > > > > > > > packages/ase/calculators/vasp/vasp.py", line 53, in
> > > > > > > > > __init__
> > > > > > > > >       self.restart_load()
> > > > > > > > >     File "/users/dptru/.local/lib/python3.5/site-
> > > > > > > > > packages/ase/calculators/vasp/vasp.py", line 190, in
> > > > >
> > > > > restart_load
> > > > > > > > >       atoms = ase.io.read('CONTCAR',
> > > > > > > > > format='vasp')[self.resort]
> > > > > > > > >     File "/users/dptru/.local/lib/python3.5/site-
> > > > > > > > > packages/ase/atoms.py", line 954, in __getitem__
> > > > > > > > >       atoms.arrays[name] = a[i].copy()
> > > > > > > > > IndexError: index 40 is out of bounds for axis 1 with
> > > > > > > > > size 40
> > > > > > > >
> > > > > > > >
> > > > > > > > We will need more information to help debug this issue.
> > ASE
> > > > > > > > does
> > > > > > > > support reading/writing constraints from/to VASP
> > geometry
> > > > > > > > files
> > > > > > > > (POSCAR, CONTCAR). Can you please attach the CONTCAR
> > file
> > > > > > > > that is
> > > > > > >
> > > > > > > being
> > > > > > > > read here? Also, what version of VASP are you using?
> > > > > > > >
> > > > > > > > Eric
> > > > > > > >
> > > > > > > > >
> > > > > > > > > Any help is appreciated,
> > > > > > > > >
> > > > > > > > > -Dennis
> > > > > > > > > _______________________________________________
> > > > > > > > > ase-users mailing list
> > > > > > > > > ase-users at listserv.fysik.dtu.dk<mailto:ase-users at listserv.fysik.dtu.dk>
> > > > > > > > > https://listserv.fysik.dtu.dk/mailman/listinfo/ase-us
> > ers
> > > > > > > >
> > > > > > > >
> > > > > > > > _______________________________________________
> > > > > > > > ase-users mailing list
> > > > > > > > ase-users at listserv.fysik.dtu.dk<mailto:ase-users at listserv.fysik.dtu.dk>
> > > > > > > > https://listserv.fysik.dtu.dk/mailman/listinfo/ase-user
> > s
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > > _______________________________________________
> > > > > > ase-users mailing list
> > > > > > ase-users at listserv.fysik.dtu.dk<mailto:ase-users at listserv.fysik.dtu.dk>
> > > > > > https://listserv.fysik.dtu.dk/mailman/listinfo/ase-users
> > > >
> > > > _______________________________________________
> > > > ase-users mailing list
> > > > ase-users at listserv.fysik.dtu.dk<mailto:ase-users at listserv.fysik.dtu.dk>
> > > > https://listserv.fysik.dtu.dk/mailman/listinfo/ase-users
> > >
> > >
> >
> > _______________________________________________
> > ase-users mailing list
> > ase-users at listserv.fysik.dtu.dk<mailto:ase-users at listserv.fysik.dtu.dk>
> > https://listserv.fysik.dtu.dk/mailman/listinfo/ase-users

_______________________________________________
ase-users mailing list
ase-users at listserv.fysik.dtu.dk<mailto:ase-users at listserv.fysik.dtu.dk>
https://listserv.fysik.dtu.dk/mailman/listinfo/ase-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listserv.fysik.dtu.dk/pipermail/ase-users/attachments/20180108/8561f93b/attachment-0001.html>


More information about the ase-users mailing list