akohlmey / topotools

VMD plugin for manipulating topology information
Other
28 stars 16 forks source link

mergemols() destroys simulation box angles #13

Closed EfremBraun closed 6 years ago

EfremBraun commented 6 years ago

If I have a triclinic simulation box, using the mergemols() command gets rid of this information. writelammpsdata() then prints the box incorrectly.

It's an easy fix to topoutils.tcl if both mols have the same unit cell parameters, but if they don't, the program should probably quit on error if mergemols() is attempted. I'm not sure how you want to do that error handling, so I figured I'd put this in as an issue rather than as a pull request.

AFX_unwrapped_OOnly.pdb.txt graphene-fake.pdb.txt lammps-toposcript.tcl.txt

akohlmey commented 6 years ago

This is not an issue but a deliberate choice. There is no meaningful way to infer from the source data how the cell should be sized and angled in the merged molecule. Even the heuristic you suggest can fail due to numerical instability of single precision floating point math in VMD. Thus the code just picks one simple way. Mind you, there is no checking for overlap either and so on. Thus it is the task of the script of the user to override and post process the merged system as desired. Since mergemols creates a new molecule, you can still access the old molecules and do the kind of box sizing you like, e.g. using pbc get and pbc set from the pbctools plugin to copy the box from one of the source systems.

EfremBraun commented 6 years ago

Maybe that should be mentioned in the documentation then? I was merging two molecules with identical (orthogonal) unit cell parameters and it was printing LAMMPS data files fine, and since the documentation says Topotools works for triclinic unit cells, there was no reason for me to think I needed to change my workflow. I didn't realize that it wasn't working until I viewed the LAMMPS trajectory post-simulation.

akohlmey commented 6 years ago

This is not a triclinic vs. orthogonal issue, there are many more ways how you can combine two different VMD "molecules" and whether the resulting cells are compatible or not. If people load .xyz files, for example, there is no box information available at all. Nevertheless, I've added a comment for the mergemols command documentation, but the basic issue really is that you are making assumptions about TopoTools and are not true. You got lucky, that it worked in the past. TopoTools is advertised as a "middleware", so it will simplify several complex tasks through abstraction (and do it in a rather efficient way, which requires some experience with VMD and Tcl), but it is not meant to be a complete end-to-end solution. It can function like that occasionally, and some of the high-level convenience functions are quite complete. BTW: there is an example showing a more complete processing with mergemols further down in the TopoTools section of my home page, that also shows a way to transfer the cell info: https://sites.google.com/site/akohlmey/software/topotools/topotools-tutorial---various-tips-tricks#TOC-Combine-multiple-data-files-with-overlap-detection-and-removal

EfremBraun commented 6 years ago

I admit not having seen that example in the documentation. Thanks Axel!