Skip to content
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

Implementation of RPA dielectric screening #170

Open
wants to merge 15 commits into
base: prot
Choose a base branch
from
Open

Implementation of RPA dielectric screening #170

wants to merge 15 commits into from

Conversation

dpaulzc
Copy link
Collaborator

@dpaulzc dpaulzc commented Jan 8, 2025

Added a new function to compute RPA screened Coulomb interaction, used to compute the electron electron scattering rates. Also there is a new function added in misc.f90, which is a 1d interpolator (along with its test).
A small note: In some places I have added "?" in the comments which should be looked at in the future.

Comment on lines +313 to +318
! NOTE: Now the wannier deallocation is happening after solve_BTE
if(num%need_Wannier) then
!Deallocate Wannier quantities
call wann%deallocate_wannier(num)
end if

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just leaving a note here to mention that this is a temporary solution. The code basically ends after the BTE solution, so there is no need to deallocate anything manually at that stage. Earlier deallocation of those quantities was needed to free up memory. But I'll handle this later.

Copy link
Owner

@nakib nakib left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Dwaipayan,

Thanks a lot for the PR. I left my first round of reviews below for your consideration.

Best,
Nakib


prefac = 1.0e9_r64*qe/(perm0*crys%epsilon0) ! ev.nm

!Transfer wave vector in Cartesian coordinates
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean "transform"?

qcart = matmul(crys%reclattvecs, qcrys)

!Use a safe range for the G vector sums
!Assuming G = G' (neglecting local-field effects)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are not assuming G = G', we are ignoring G /= G' terms.

do ik1 = -3, 3
do ik2 = -3, 3
do ik3 = -3, 3
G_plusq = ( ik1*crys%reclattvecs(:, 1) &
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the meaning of the underscore? We are calculating G + q, so Gplusq is a perfectly good name.

Comment on lines +188 to +189
diel_qw = 1 - prefac*X0_qw/twonorm(G_plusq)**2
W_qw = W_qw + 1.0_r64/diel_qw/twonorm(G_plusq)**2
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you are calculating the same 2-norm twice. Better define a variable and evaluate the 2-norm once.

Comment on lines +188 to +189
diel_qw = 1 - prefac*X0_qw/twonorm(G_plusq)**2
W_qw = W_qw + 1.0_r64/diel_qw/twonorm(G_plusq)**2
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be comments above each of these lines explaining what exactly is being done here physically. Also, please check the style guide regarding using spaces to separate conceptually distinct statements.

Comment on lines +1699 to +1700
!! linear interpolation from 1d array evaluated on a fine, continuous mesh.
!! to a sample mesh
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here document what the arguments and the output are.

@@ -1694,4 +1694,35 @@ subroutine Hilbert_transform(fx, Hfx)
Hfx(k + 1) = -(fx(k + 2) - fx(k) + term2 + term3)/pi
end do
end subroutine Hilbert_transform

pure function interpolator_1d(samp, cont, res_cont) result(res_samp)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does res_cont mean? By looking at res_samp from its context, it seems like the prefix res is supposed to mean result. But why would an argument of a function contain a result?

@@ -1694,4 +1694,35 @@ subroutine Hilbert_transform(fx, Hfx)
Hfx(k + 1) = -(fx(k + 2) - fx(k) + term2 + term3)/pi
end do
end subroutine Hilbert_transform

pure function interpolator_1d(samp, cont, res_cont) result(res_samp)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These names are all quite cryptic to me.

Comment on lines +1716 to +1726
do isamp = 1, nsamp
w = samp(isamp)
ileft = minloc(abs(cont - w), dim = 1)
if(ileft == ncont) then
res_samp(isamp) = res_cont(ileft)
else
iright = ileft + 1
res_samp(isamp) = ((cont(iright) - w)*res_cont(ileft) + &
(w - cont(ileft))*res_cont(iright))/dcont
end if
end do
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this 1-d interpolator work generally? Can you add some documentation to briefly explain how this works?

Comment on lines +387 to +388
call test_array(itest)%assert([9, 19, 29]*1.0_r64, interpolator_1d([2, 4, 6]*1.0_r64, &
[1, 3, 5, 7]*1.0_r64, [4, 14, 24, 34]*1.0_r64))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would help to explain a bit what this test it about. For example, what linear function are you testing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants