[ase-users] atoms.get_forces() and atoms.get_forces(md=True)

Ask Hjorth Larsen asklarsen at gmail.com
Sat Mar 6 19:42:16 CET 2021


Dear Michael,

Am Fr., 26. Feb. 2021 um 16:52 Uhr schrieb Michael Joseph Waters via
ase-users <ase-users at listserv.fysik.dtu.dk>:
>
> Hi all,
>
> I am implementing a dynamics module. I've been using VelocityVerlet as an example.
>
> I have so far left these lines alone since they don't interfere with what I am doing:
>
>         # We need to store the momenta on the atoms before calculating
>         # the forces, as in a parallel Asap calculation atoms may
>         # migrate during force calculations, and the momenta need to
>         # migrate along with the atoms.
>         atoms.set_momenta(p, apply_constraint=False)
>
>         forces = atoms.get_forces(md=True)
>
> And because 'forces' is returned by .step() .
>
> I realize now that I need the default constrained forces immediately afterwards.
>
>                   f_constrained = atoms.get_forces()
>
> Will requesting the forces a different way cause the calculator to rerun? I'd like to avoid that redundancy.

It is the calculator which controls the caching, for better or worse.

The calculator won't see constraints or the md boolean since those are
handled by the Atoms object without passing them to the calculator.

Requesting the forces in a different way will therefore reuse the
forces from the calculator, but it will re-apply constraints if any,
which could of course also cost something.

Best regards
Ask

>
> Best,
> -Mike
> _______________________________________________
> ase-users mailing list
> ase-users at listserv.fysik.dtu.dk
> https://listserv.fysik.dtu.dk/mailman/listinfo/ase-users


More information about the ase-users mailing list