ATB-UQ / PyThinFilm

GNU General Public License v3.0
7 stars 1 forks source link

Centralise rotation origin of inserted molecules #1

Closed ssande7 closed 2 years ago

ssande7 commented 2 years ago

When molecules are inserted, they are rotated to a random orientation around their origin, but that origin could be anywhere relative to the molecule, leading to the possibility that it overlaps the z boundary and clips into the electrode, and also making it more difficult to place multiple molecules in such a way that they don't overlap.

This can be fixed by shifting the origin of inserted molecules to be their geometric centre before they are inserted and rotated. Doing this calculation would also give the spatial extents of the molecule with little extra effort, meaning the z dimension of the simulation box could be set automatically based on a "minimum gap between the highest possible inserted atom and the top of the box" parameter, which can probably be given a sane default. A manual override for the z dimension would also be useful in some cases though (eg. simulations where some deposited molecules could bounce back up, or solvent evaporation simulations).

martinstroet commented 2 years ago

I have addressed the issue of rotation about the centre of geometry by translating the molecule to the origin when the model is initialised: https://github.com/ATB-UQ/PyThinFilm/blob/9c7c16262e6415114f9c2bf0f612a7995ebec9b1/src/PyThinFilm/deposition.py#L470

As for adjusting the z box dimension, my preference at this stage would be to issue a warning that the specified over-head void space is insufficient based on: overhead void < insertion hight + (molecule's longest dimension) / 2. I'll raise this as a separate issue.