Octopus
soc_uspp.F90
Go to the documentation of this file.
1!! Copyright (C) 2026 N. Tancogne-Dejean
2!!
3!! This program is free software; you can redistribute it and/or modify
4!! it under the terms of the GNU General Public License as published by
5!! the Free Software Foundation; either version 2, or (at your option)
6!! any later version.
7!!
8!! This program is distributed in the hope that it will be useful,
9!! but WITHOUT ANY WARRANTY; without even the implied warranty of
10!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11!! GNU General Public License for more details.
12!!
13!! You should have received a copy of the GNU General Public License
14!! along with this program; if not, write to the Free Software
15!! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16!! 02110-1301, USA.
17!!
18
19#include "global.h"
20
32module soc_uspp_oct_m
33 use debug_oct_m
34 use global_oct_m
35 use, intrinsic :: iso_fortran_env
38
39 implicit none
40
41 private
42
43 public :: &
47
48contains
49
50 ! ---------------------------------------------------------
58 subroutine soc_uspp_ylm_transform(l, uu)
59 integer, intent(in) :: l
60 complex(real64), intent(out) :: uu(:, :)
61
62 integer :: m
63 real(real64) :: sgn
64
66
67 uu(1:2*l+1, 1:2*l+1) = m_z0
68 uu(l+1, l+1) = m_z1
69 do m = 1, l
70 sgn = real((-1)**m, real64)
71 uu(l+1+m, l+1+m) = cmplx(m_one/sqrt(m_two), m_zero, real64)
72 uu(l+1+m, l+1-m) = cmplx(sgn/sqrt(m_two), m_zero, real64)
73 uu(l+1-m, l+1+m) = cmplx(m_zero, -m_one/sqrt(m_two), real64)
74 uu(l+1-m, l+1-m) = cmplx(m_zero, sgn/sqrt(m_two), real64)
75 end do
76
78 end subroutine soc_uspp_ylm_transform
79
80 ! ---------------------------------------------------------
86 pure real(real64) function soc_uspp_spinor_coeff(l, jplus, m, spin) result(coeff)
87 integer, intent(in) :: l
88 logical, intent(in) :: jplus
89 integer, intent(in) :: m
90 integer, intent(in) :: spin
91
92 real(real64) :: denom
93
94 coeff = m_zero
95 denom = m_one/(m_two*real(l, real64) + m_one)
96
97 if (jplus) then
98 ! |j = l+1/2, m_j = m+1/2>, m_j range: m in [-l-1, l]
99 if (m < -l - 1 .or. m > l) return
100 if (spin == 1) coeff = sqrt(real(l + m + 1, real64)*denom)
101 if (spin == 2) coeff = sqrt(real(l - m, real64)*denom)
102 else
103 ! |j = l-1/2, m_j = m+1/2>, m_j range: m in [-l, l-1]
104 if (m < -l .or. m > l - 1) return
105 if (spin == 1) coeff = sqrt(real(l - m, real64)*denom)
106 if (spin == 2) coeff = -sqrt(real(l + m + 1, real64)*denom)
107 end if
108 end function soc_uspp_spinor_coeff
109
110 ! ---------------------------------------------------------
120 subroutine soc_uspp_add_channel_coupling_cmplx(l, nc, jplus, mat, pidx, zmix)
121 integer, intent(in) :: l
122 integer, intent(in) :: nc
123 logical, intent(in) :: jplus(:)
124 real(real64), intent(in) :: mat(:, :)
125 integer, intent(in) :: pidx(:, :)
126 complex(real64), intent(inout) :: zmix(:, :, :)
127
128 integer :: ci, cj, m, s1, s2, ml1, ml2, blk, ip, jp
129 real(real64) :: acoef, bcoef
130 integer :: blkmap(2, 2)
131
133
134 blkmap(1, 1) = 1
135 blkmap(2, 2) = 2
136 blkmap(1, 2) = 3
137 blkmap(2, 1) = 4
138
139 do ci = 1, nc
140 do cj = 1, nc
141 if (jplus(ci) .neqv. jplus(cj)) cycle
142 if (abs(mat(ci, cj)) <= m_epsilon) cycle
143 do m = -l - 1, l
144 do s1 = 1, 2
145 ml1 = m + (s1 - 1)
146 if (ml1 < -l .or. ml1 > l) cycle
147 acoef = soc_uspp_spinor_coeff(l, jplus(ci), m, s1)
148 if (abs(acoef) <= m_epsilon) cycle
149 ip = pidx(ml1 + l + 1, ci)
150 if (ip == 0) cycle
151 do s2 = 1, 2
152 ml2 = m + (s2 - 1)
153 if (ml2 < -l .or. ml2 > l) cycle
154 bcoef = soc_uspp_spinor_coeff(l, jplus(cj), m, s2)
155 if (abs(bcoef) <= m_epsilon) cycle
156 jp = pidx(ml2 + l + 1, cj)
157 if (jp == 0) cycle
158 blk = blkmap(s1, s2)
159 zmix(ip, jp, blk) = zmix(ip, jp, blk) + cmplx(acoef*bcoef*mat(ci, cj), m_zero, real64)
160 end do
161 end do
162 end do
163 end do
164 end do
165
168
169end module soc_uspp_oct_m
170
171!! Local Variables:
172!! mode: f90
173!! coding: utf-8
174!! End:
double sqrt(double __x) __attribute__((__nothrow__
real(real64), parameter, public m_two
Definition: global.F90:175
real(real64), parameter, public m_zero
Definition: global.F90:173
complex(real64), parameter, public m_z0
Definition: global.F90:183
real(real64), parameter, public m_epsilon
Definition: global.F90:189
complex(real64), parameter, public m_z1
Definition: global.F90:184
real(real64), parameter, public m_one
Definition: global.F90:174
/* To use the profiling module, call profiling_in and profiling_out with the label of the region as a...
Definition: profiling.F90:122
Spin-orbit coupling for fully-relativistic ultrasoft pseudopotentials.
Definition: soc_uspp.F90:104
pure real(real64) function, public soc_uspp_spinor_coeff(l, jplus, m, spin)
Clebsch-Gordan spinor coefficient.
Definition: soc_uspp.F90:159
subroutine, public soc_uspp_ylm_transform(l, uu)
Complex-to-real spherical-harmonic transform U for a given l.
Definition: soc_uspp.F90:131
subroutine, public soc_uspp_add_channel_coupling_cmplx(l, nc, jplus, mat, pidx, zmix)
Add the (l,j)->spin coupling of one l-shell to the 2x2 spin zmix, complex-Y_lm basis.
Definition: soc_uspp.F90:193