-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Correct sign of densities and potentials in KPFM #251
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #251 +/- ##
==========================================
- Coverage 46.40% 46.34% -0.06%
==========================================
Files 35 35
Lines 5185 5170 -15
==========================================
- Hits 2406 2396 -10
+ Misses 2779 2774 -5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
This PR now also closes #252. On the one hand, I understand this is a somewhat non-standard work flow as the two issues, #250 and #252, have nothing in common except they both need to be solved in order to generate the LCPD image for the paper. On the other hand, we need the figure for the paper urgently and the commit that solves #252 changes literary just one line of code. As long as the change is uncontroversial, doing all the motions with a separate pull request would be a waste of time and effort. Tl;dr: Please also check the second commit in this PR. |
Fixes #250. What I have done to address the sign issue itself can be best understood from the code changes I think. Besides that
main
ofppafm/cli/generateElFF.py
was creating two copies of the electrostatic potential before calculating LCPD:v_v0_aux = electrostatic_potential.copy()
andv_v0_aux2 = electrostatic_potential.copy()
. Having the same field written in three places made the code look rather messy to me and I found it difficult to keep track of the required sign changes in such a mess so I did away with those copies. As I understood it, they were needed because thepotential2forces_mem
function inppafm/fieldFFT.py
would remove the array with the potential after the potential had been used, unless the function had been called with thedeleteV=False
argument. In order to address this, I have therefore introduced thedeleteV
argument to the functioncomputeElFF
fromppafm/HighLevel.py
so that thedeleteV=False
option could be passed fromgenerateElFF.py
topotential2forces_mem
throughcomputeElFF
.FFkpfm_tVs0
term was scaled by the tip chargeabs(PPU.params.["charge"])
hereppafm/ppafm/HighLevel.py
Line 160 in 18a5d8a
ppafm/ppafm/HighLevel.py
Line 160 in aaeedbc
ppafm/ppafm/cli/generateElFF.py
Lines 126 to 137 in aaeedbc
FFkpfm_tVs0
contribution was always negligible with respect to theFFkpfm_t0sV
contribution for default tip polarizability and typical tip charge, which did not seem right. Now this relative contributions ofFFkpfm_tVs0
andFFkpfm_tVs0
somewhat improved as to become more equalized.