Probe-Particle / ppafm

Classical force field model for simulating atomic force microscopy images.
MIT License
49 stars 18 forks source link

Atoms with negative coordinates in non-periodic systems invisible (in the CPU version) #223

Closed mondracek closed 10 months ago

mondracek commented 10 months ago

The problem can be demonstrated on ppafm/examples/benzeneBrCl2. While the original example works because params.ini sets PBC True to ensure artificial periodicity, the problem pops up once we set PBC False. Compare the generated PNG files that show the frequency shift for one particular height above the molecule in the original setup, see here df_015 and after changing the PBC option to False in params.ini here: df_015

I stumbled over this issue when working on #216, see my discussion with @NikoOinonen over there. As far as I could tell from the source code, the issue is related to an inconsistent treatment of the grid's origin. At some point, the origin is made zero (so the coordinates of all grid points are always non-negative).

Not a problem for periodic systems, e.g. a coordinate -x rolls to ax - x, where ax is the x coordinate of a lattice vector. Also, the problem only appears for potentials generated from atomic positions like Lennard-Jones or point charges, not for DFT-calculated potentials and densities.

However, I should note that while the images calculated for periodic DFT systems are essentially correct even for an arbitrary grid origin in the CUBE or XSF file, the are shifted by the vector that starts at the original zero and ends at the non-zero origin (an artifact of the origin being effectively redefined to zero). Not a problem with VASP that does not define any origin of the grids outside zero anyway, but a big pain with FHI-AIMS.