[QE-developers] subroutine "xc"
Lorenzo Paulatto
paulatz at gmail.com
Sat Jun 8 16:53:39 CEST 2019
Hello,
this is the email I was talking before at the developer meeting, please
take no offense if it seems a bit rude. It was meant like an incitement
to be bold and change others people code if it looks better.
--
Compiling the d3q code I discovered today that the xc subroutine from
the module "funct" does not exist anymore, so I went and checked the
changes trying to make it work again.
I'm quite surprised because the new code adds quite a lot of
complication for not an obvious reason. I.e. this code
(LR_Modules/setup_dmuxc.f90):
dmuxc(:) = 0.d0
DO i = 1,dfftp%nnr
rhotot = rho%of_r(i,1) + rho_core(i)
IF ( rhotot> 1.d-30 ) dmuxc(i)= dmxc( rhotot)
IF ( rhotot<-1.d-30 ) dmuxc(i)=-dmxc(-rhotot)
ENDDO
becomes
CALL init_lda_xc()
!
rhotot(:) = rho%of_r(:,1) + rho_core(:)
!
sign_r = 1.0_DP
DO i = 1, dfftp%nnr
IF ( rhotot(i) < -1.d-30 ) THEN
sign_r(i) = -1.0_DP
rhotot(i) = -rhotot(i)
ELSEIF ( rhotot(i)<1.d-30 .AND. rhotot(i)>-1.d-30 ) THEN
sign_r(i) = 0.0_DP
rhotot(i) = 0.5_DP
ENDIF
ENDDO
!
CALL dmxc_lda( dfftp%nnr, rhotot, dmuxc )
!
dmuxc = dmuxc * sign_r
The new code requires:
1. to create, allocate and deallocate two new arrays
2. to call an initialization routine
I can take some more complexity, but only if it provides a real
performance improvement (I don't recall doing local density functional
being expensive in a long while) or it can solve a conceptual problem.
Here there is quite an obvious conceptual problem: how to treat the
negative charge, and the fact that it could be done differently in
different parts of the code. But the new implementation does not solve
it, on the contrary it makes it more complicated !
And, if we have to call an initialization subroutine EVERY time we call
dmxc, why is it not called INSIDE dmxc?
cheers
--
Lorenzo Paulatto - Paris
More information about the developers
mailing list