libAtoms / extxyz

Extended XYZ specification and parsers
MIT License
12 stars 4 forks source link

How to sort ase xyz file according to ascending order of energies #11

Closed Amitcuhp closed 1 year ago

Amitcuhp commented 1 year ago

How to sort ase xyz file in ascending order of energies

Amitcuhp commented 1 year ago

Very thankful to you in advance

bernstei commented 1 year ago

This is a general python question, no specific to extxyz or libAtoms.

More or less:

python -c 'import ase.iohttp://ase.io; ase.iohttp://ase.io.write("outfile.xyzhttp://outfile.xyz", sorted(ase.iohttp://ase.io.read("infile.xyzhttp://infile.xyz", ":"), key=lambda at: at.infohttp://at.info["energy"]))'

(assuming the energy is in the info key "energy")

jameskermode commented 1 year ago

Thanks Noam. I tried to edit out the bogus links above, but it seems email replies don't support Markdown. Here's a copy-pastable version

python -c 'import ase.io; ase.io.write("outfile.xyz", sorted(ase.io.read("infile.xyz", ":"), key=lambda at: at.info["energy"]))'
Amitcuhp commented 1 year ago

Thanks for your help. I am very thankful to you.

Can you tell me one think more please:

How to add values to all the energies . in simple words , i want to add 200 to all energies values...can u help