[ase-users] reading externally-calculated energies

Efrem Braun efrem.braun at berkeley.edu
Tue Feb 20 22:47:17 CET 2018


That indeed does the job. Thanks Jens!

Retrospectively, it looks like that trick was used in https://gitlab.com/
ase/ase/blob/master/ase/io/vasp.py. Next time I'll be able to figure out
such a thing on my own.

For future readers, the working code now looks something like:
$ cat ase_script.py
from ase.calculators.singlepoint import SinglePointCalculator
a = read('mof-pos-1.xyz', index=':', format='xyz')
traj = Trajectory('example.traj', mode='w')
for atoms in a:
    atoms.set_cell([[10, 0, 0], [0, 10, 0], [0, 0, 10]])
    atoms.set_pbc((True,True,True))
    atoms.set_calculator(SinglePointCalculator(atoms, energy=5.0))
    traj.write(atoms)


Efrem Braun

On Mon, Feb 19, 2018 at 11:41 PM, Jens Jørgen Mortensen <jjmo at dtu.dk> wrote:

> Den 19-02-2018 kl. 22:15 skrev Efrem Braun via ase-users:
>
> Hello,
>
> I used CP2K outside of ASE to run an ab-initio MD simulation, and I had it
> print the system's configurations and energies as an xyz file. The first
> two timesteps of this xyz file are:
> $ cat example.xyz
>      3
>  i =        0, time =        0.000, E =     -5465.5196498106
> <(519)%20649-8106>
>   C         4.7753151998 <(775)%20315-1998>        1.4886642032        5.
> 9515672483 <(951)%20567-2483>
>   C         0.8642611428 <(864)%20261-1428>        4.2998370820
>  5.3928988465
>   C         3.0466930517        4.1336654269        6.7372427573
> <(737)%20242-7573>
>      3
>  i =        10, time =        5.000, E =     -5464.9735639414
> <(973)%20563-9414>
>   C         4.8155298134 <(815)%20529-8134>        1.4733826364
>  5.9468561636
>   C         0.8488805807 <(848)%20880-5807>        4.2922470670
>  5.3836244585
>   C         3.0342523925        4.1219859976        6.7176807277
> <(717)%20680-7277>
>
> I'd like to read this into ASE and have it be a trajectory file so I can
> use ASE for some post-processing work. I can easily read in the file with:
> $ cat ase_script.py
> a = read('example.xyz', index=':', format='xyz')
> traj = Trajectory('example.traj', mode='w')
> for atoms in a:
>     atoms.set_cell([[10, 0, 0], [0, 10, 0], [0, 0, 10]])
>     atoms.set_pbc((True,True,True))
>     traj.write(atoms)
>
>
> Try adding this after the set_pbc line:
>
>     E = atoms.info['E']
>     atoms.calc = SinglePointCalculator(atoms, energy=E)
>
> And add an import like this: "from ase.calculators.singlepoint import
> SinglePointCalculator".
>
> Jens Jørgen
>
> However, I also want ASE to know the energy of each configuration, since I
> already calculated it and I don't want to have to call the CP2K
> calculator's get_potential_energy() method since this would be a waste of
> computational resources. In a dream world, ASE would read the comment lines
> of the example.xyz file into the Atoms object, but I figure that I will
> probably have to do some post-processing on my own to set the energy for
> each Atoms object.
>
> My problem:
> I can't find any method like a set_potential_energy() for the Atoms
> object. Is there any way to do what I'm trying to do?
> Efrem Braun
>
>
> _______________________________________________
> ase-users mailing listase-users at listserv.fysik.dtu.dkhttps://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/20180220/ddae7faf/attachment.html>


More information about the ase-users mailing list