Probe-Particle / ppafm

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

Mismatch between GPU and CPU simulations "pyridineDensOverlap" example #284

Open prometeus3 opened 3 months ago

prometeus3 commented 3 months ago

I ran the "pyridineDensOverlap" example with the GPU and CPU versions (https://github.com/Probe-Particle/ppafm/tree/main/examples/pyridineDensOverlap). Using the same input files and comparing the results, I noticed differences in the simulated images generated. For most simulations, there is a match; but some appear quite different (e.g., df_024.png or df_029.png). What are these differences due to? I expected much more similar results. Am I missing something? Thank you df_024 df_024 df_029 df_029

NikoOinonen commented 3 months ago

The GPU version is using some faster approximations in various parts of the computation, which means that it's potentially less stable in some respects.

In this case it's a interpolation error that comes from resampling the charge density and Hartree potential to a coarser grid. If you set the grid density higher by putting pixPerAngstrome=14 (the original grid density) in the run_gpu.py script, then the rings should disappear, but this also makes the computation slower and requires significantly more memory.

I actually spotted this one before but forgot about it. We probably should fix this but I'm not sure how, because for example my laptop GPU runs out of memory if I set the grid density to that value.

yakutovicha commented 3 weeks ago

We agreed that @NikoOinonen will take on the task of adding documentation explaining the areas of applicability of different methods/approximations. After that, the issue can be closed.