Probe-Particle / ppafm

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

Fixing FHI-aims electron densities for FDBM #276

Open NikoOinonen opened 7 months ago

NikoOinonen commented 7 months ago

I have been having some problems using electron densities from FHI-aims with the full-density-based model. The problem shows up in the simulated images as severe noise and artifacts in the mid to far range images.

Here is a random test molecule from our database which exhibits the issue: image Far: 10 Close: 26

The close range image is fine, but in the far-range image there is a lot of noise and a weird round artifact at the position of the Cl atom.

Since the problem only shows up at the far range, I first thought the issue might be something to do with the integration grid in aims, which gets more sparse further away from the atoms. However, after a quite a bit of testing, it looks like the issue actually stems from the core electrons. FHI-aims is an all-electron code so the density has sharp spikes at the positions of the atoms.

By simply applying a cutoff to the electron density, the issue seems to go away: 10

After trying a bunch of different cutoff values, it looks like somewhere around 100 the image becomes completely smooth for this particular case. Interestingly, going down even far as 1 with the cutoff still does not affect the close range image in any appreciable way. For reference, the original value at the position of the Cl atom is ~18000.

A line scan through the center of the Cl atoms: density_line

It seems worth implementing this cutoff into ppafm in some way in order to make electron densities from aims also usable with the FDBM.

@ProkopHapala Do you foresee any problem with applying a cutoff in this way? It does get rid of some electrons, but then again, previously we have used the pseudo-potential densities that don't have the core electrons either.

ondrejkrejci commented 7 months ago

My personal opinion is that it makes sense to apply this cutoff with a proper keyword and documentation later.

I would suggest the value for a cutoff to be as low as possible, but still bigger than density from VASP - as this is the "ground truth" testing code for the ppafm (not telling that the VASP or its density - e.g. soft PPs ... - just that we tune everything on it.

With this saying I would suggest, to update the code, once #275 is implemented. I think that this is also interesting for @mondracek

ProkopHapala commented 7 months ago

Hi, I was never using (or liking) FHI-aims to much. But I remember we had this problem with PPAFM from the start.

ad possible problems

NikoOinonen commented 7 months ago

@ProkopHapala

We should distinguish if we speak about Electrostacis (Hartree) or Pauli poentials.

Sorry I did not specify. I was only using the cutoff for the Pauli part. The electrostatics with aims does not pose any problem.

NikoOinonen commented 6 months ago

We agreed in the meeting that this should be implemented. I will try to get around to it some time soon.

NikoOinonen commented 1 month ago

I did some more testing with this and implemented two different types of cutoff, a hard cutoff and a soft cutoff: clamps

After trying different cutoff values with both types, it does not seem to make any significant difference which one you use. Both get rid of the artifacts just fine, so I would probably opt for the hard cutoff because it's simpler and faster.

I would suggest the value for a cutoff to be as low as possible, but still bigger than density from VASP - as this is the "ground truth" testing code for the ppafm (not telling that the VASP or its density - e.g. soft PPs ... - just that we tune everything on it.

Using the 6 molecules in the review paper as a reference, the maximum value for the VASP densities there is ~13. A cutoff of 100 seems to get rid of all artifacts and is well above the VASP values, so I would probably use that as a default value.

With the cutoff, the simulations between aims and VASP look pretty much identical in the relevant range: C60_26

The aims densities also have the advantage that they don't have these ring oscillations arising from the plane waves in the VASP densities, so with the cutoff aims electron densities could actually work quite nicely with the FDBM: C60_19

ProkopHapala commented 1 month ago

Perfect. ad VASP rings due to PW cutoff - this is probably something we can smooth out by doing few iteration of real-space laplace as I was mentioning.

Code is here in FireCore: OpenCL python C++

but I'm still testing it

EDIT: Oh, I'm stupid. This is relevatn just for electrostatics. But you speak about Pauli.

NikoOinonen commented 1 month ago

Also adding this option to the GUI: Pasted image 20241017155034

NikoOinonen commented 1 month ago

After testing on a larger set of molecules with a wider range of the Pauli integral parameters, it looks like a cutoff of 100 is in some rare cases still too large, requiring going down as low as 20, mostly when the exponent and prefactor are both large. I'll add this information to the documentation.