Ability to group molecules

I am currently working on some calculations with some larger numbers of molecules, and one of the tricks I use for that is ORCA’s fragment specification option. This is a pretty useful thing for larger optimizations, but I find myself needing to be very careful with how I create input files since Avogadro doesn’t seem to have any really specific method for ordering xyz coordinates. I recently realized that since Avogadro is able to identify individual molecules, it could most likely have some sort of method to sort the index of every atom such that the molecules were grouped together.

I also think that perhaps there could be a second level of organization, i.e. within a molecular fragment it could have the atoms listed by atomic number. That would be mostly a QOL thing though.

Edit

I do have a quick(ish) workaround that does reorganize things the right way, however it would be nice if it could be done automatically!

The basic idea is that you just make your molecular cluster normally, then copy and paste each individual molecule into a new file, and the molecules will be ordered properly. I’ve included an example of what this looks like, using a crystal structure to start, and then just copy and pasting each individual molecule into a new file.

Right now, the input generator scripts don’t take advantage of layers. Beyond being able to set slightly different visualization options for layers, this is one purpose. (Another would be moving solvent molecules to a different layer.)

In the atoms block of a cjson file, there’s this:

cjson['atoms']['layer'] = [      0,      0,      0,      0,      0,      0,      0,      0,      0,
      1,      1,      1,      1,      1,      1,      1,      1,      1    ],

So it would be fairly easy to set fragments based on atom layers in the script. I just haven’t gotten enough round-to-its…

There’s also probably a way to reorder atoms based on the groups using C++. The graph.cpp class has connectedComponents() which returns a list of each connected component with each containing a list of the atom / vertex index. Also, from a given atom you can call connectedComponent(index) to get all connected atoms (e.g., for the selection tool).

But renumbering atoms is a bit tricky to do right, since you also need to update bonds, residues, etc.

If you’re interested in hacking the ORCA script to add fragment IDs, I’d be happy to help provide some pointers.