11
$\begingroup$

My current procedure is to create a .xyz file out of my MD run for a crystal structure. I can read the energy and also each atomic position. But I want to add forces. If I add forces as the additional three columns for each atom, ASE seems to ignore this. ASE considers only the first three columns per atom which are the positions.

What's the best way to read positions and forces into ASE?

I'm working with FHI aims and I've just done an MD run. I don't think this is as important because the object to read FHI aims with ASE seems to be deprecated.

$\endgroup$
3
  • 4
    $\begingroup$ +1 Welcome to our new community and thank you for contributing your question here!! We hope to see much more of you in the future! How did you find us? $\endgroup$
    – Vasista
    Jul 26 at 7:47
  • 3
    $\begingroup$ @Vasista Googling! $\endgroup$
    – DLV
    Jul 26 at 7:55
  • 4
    $\begingroup$ I think the easiest way is to print the forces into a separate xyz-file. You can read this in as if it were positions into a second Atoms object, then loop over all images and copy the "forces/positions" from the second object into the first one. $\endgroup$
    – Fabian
    Jul 26 at 9:55
3
$\begingroup$

ASE should be able to read forces from the additional columns. Here is an example of an .xyz file which contains forces.

2
Lattice="6.0 0.0 0.0 0.0 6.0 0.0 0.0 0.0 6.0" Properties=species:S:1:pos:R:3:forces:R:3:magmoms:R:1 energy=-6.801137982077364 dipole="-1.3543798178593251e-15 -1.5609399349163789e-15 6.566746345129899e-16" magmom=0.0 pbc="F F F"
H        3.00000000       3.00000000       2.62674398      -0.00000000      -0.00000000      -0.00053835       0.00000000
H        3.00000000       3.00000000       3.37325602      -0.00000000      -0.00000000       0.00053835       0.00000000

For ASE to read it with forces, you can do

>>> import ase.io
>>> atoms = ase.io.read('h2.xyz')
>>> atoms.get_forces()
array([[-0.        , -0.        , -0.00053835],
       [-0.        , -0.        ,  0.00053835]])
>>> from ase import __version__
>>> __version__
'3.22.0b1'

I hope it helps. If not, then I suggest to post a sample of your xyz file to see if there is a way to make it compatible.

$\endgroup$
1
  • $\begingroup$ +1 and welcome to our new community! Thank you so much for the contribution, and we hope to see much more of you here in the future !!! $\endgroup$ Jul 29 at 19:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.