[ase-users] sorting by number of atoms
Jens Jørgen Mortensen
jjmo at dtu.dk
Mon Feb 19 09:09:50 CET 2018
On 02/18/2018 12:03 PM, Kim Nicoli via ase-users wrote:
> Hello,
>
> I am new to this ASE and I am trying to become confident with both the
> environment and database. Therefore, I have a simple question:
> Is there a simple and straightforward way to sort (and save/update
> after the sorting) a database of atoms over the *number of atoms* in
> a decreasing order? This is to say that I would like the longest
> molecules to be on the first row and so on.
> I went through the documentation and I guess this should be feasible
> and not that complicated but I am not getting the right syntax to do it.
You can loop over rows in a sorted order like this:
"db.select(sort='-natoms')". Or on the command line:
$ ase db x.db -s natoms-
If you want to write a new sorted database:
from ase.db import connect
db1 = connect('x.db')
with connect('x-sorted.db') as db2:
for row in db1.select(sort='natoms'):
db2.write(row)
Jens Jørgen
> Thanks for any help!
> With my best regards,
>
> --
> */Kim Nicoli/*
> */--------------------------------------------------------------/*
> */Contact No: +39 3489875018/**/
> /*
> /*Guest Master Student Researcher, Non-Equlibrium Statistical
> Mechanics*/*/
> /*
> /Nordic Institute for Theoretical Physics (NORDITA),
> //Roslagstullbacken 23, Stockholm, Sweden/
> /Department of Physics, University of Turin, Via Pietro Giuria 1,
> Torino, Italy/
> */--------------------------------------------------------------/*/
> /
>
>
>
> _______________________________________________
> 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