From e5cff91a5d41824397f96316a56ac5d60c20abe8 Mon Sep 17 00:00:00 2001
From: Paolo Giannozzi
Date: Mon, 3 Aug 2020 19:20:31 +0200
Subject: [PATCH] Incorrect detection of inversion symmetry in phonons fixed
(Phil Wang, JHU). I think a better fix would be to move the detection of the
inversion symmetry into function "copy_sym" (not making assumptions on which
operation is the inversion, and transforming the function into a subroutine)
but this must be done with care and far from a release. The current fix seem
to be 100% safe.
---
LR_Modules/set_small_group_of_q.f90 | 15 ++++++++++-----
TDDFPT/src/lr_smallgq.f90 | 13 +++++++++----
2 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/LR_Modules/set_small_group_of_q.f90 b/LR_Modules/set_small_group_of_q.f90
index 5f5bc2068..0d9196924 100644
--- a/LR_Modules/set_small_group_of_q.f90
+++ b/LR_Modules/set_small_group_of_q.f90
@@ -30,7 +30,7 @@ SUBROUTINE set_small_group_of_q(nsymq, invsymq, minus_q)
LOGICAL, INTENT(INOUT) :: minus_q, invsymq
!
REAL(DP), ALLOCATABLE :: rtau(:,:,:)
-
+ INTEGER :: isym
LOGICAL :: sym(48)
!
sym(1:nsym)=.true.
@@ -55,11 +55,16 @@ SUBROUTINE set_small_group_of_q(nsymq, invsymq, minus_q)
!
CALL inverse_s ( )
!
- ! check if inversion (I) is a symmetry. If so, there should be nsymq/2
- ! symmetries without inversion, followed by nsymq/2 with inversion
- ! Since identity is always s(:,:,1), inversion should be s(:,:,1+nsymq/2)
+ ! Check if inversion (I) is a symmetry
+ ! Note that the first symmetry operation is always the identity (E)
!
- invsymq = ALL ( s(:,:,nsymq/2+1) == -s(:,:,1) )
+ invsymq =.FALSE.
+ DO isym = 1, nsymq
+ IF ( ALL ( s(:,:,isym) == -s(:,:,1) ) ) THEN
+ invsymq = .TRUE.
+ EXIT
+ END IF
+ END DO
!
! Since the order of the s matrices is changed we need to recalculate:
!
diff --git a/TDDFPT/src/lr_smallgq.f90 b/TDDFPT/src/lr_smallgq.f90
index 70c0c220a..30b38740d 100644
--- a/TDDFPT/src/lr_smallgq.f90
+++ b/TDDFPT/src/lr_smallgq.f90
@@ -139,12 +139,17 @@ SUBROUTINE lr_smallgq (xq)
!
ENDDO
!
- ! Check if inversion (I) is a symmetry. If so, there should be nsymq/2
- ! symmetries without inversion, followed by nsymq/2 with inversion
- ! Since identity is always s(:,:,1), inversion should be s(:,:,1+nsymq/2)
+ ! Check if inversion (I) is a symmetry
+ ! Note that the first symmetry operation is always the identity (E)
! IT: it seems that invsymq is useless (used nowhere)...
!
- invsymq = ALL ( s(:,:,nsymq/2+1) == -s(:,:,1) )
+ invsymq =.FALSE.
+ DO isym = 1, nsymq
+ IF ( ALL ( s(:,:,isym) == -s(:,:,1) ) ) THEN
+ invsymq = .TRUE.
+ EXIT
+ END IF
+ END DO
!
! The order of the s matrices has changed.
! Transform symmetry matrices s from crystal to cartesian axes.