Skip to content

Commit e6a51f2

Browse files
author
abacus_fixer
committed
update soc_base
1 parent 9e0a9b6 commit e6a51f2

2 files changed

Lines changed: 23 additions & 3 deletions

File tree

source/source_psi/soc_base.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,21 @@ void Fcoef::create(const int i1, const int i2, const int i3)
1515
ind1 = i1;
1616
ind4 = i2;
1717
ind5 = i3;
18+
1819
if (this->p != nullptr)
1920
{
2021
delete[] this->p;
2122
this->p = nullptr;
2223
}
24+
2325
int tot = ind1 * ind2 * ind3 * ind4 * ind5;
26+
2427
this->p = new std::complex<double>[tot];
28+
2529
for (int i = 0; i < tot; i++)
30+
{
2631
this->p[i] = std::complex<double>(0.0, 0.0);
32+
}
2733
}
2834
else
2935
{
@@ -57,9 +63,13 @@ SocBase::~SocBase()
5763
double SocBase::spinor(const int l, const double j, const int m, const int spin) const
5864
{
5965
if (spin != 0 && spin != 1)
66+
{
6067
ModuleBase::WARNING_QUIT("spinor", "spin direction unknown");
68+
}
6169
if (m < -l - 1 || m > l)
70+
{
6271
ModuleBase::WARNING_QUIT("spinor", "m not allowed");
72+
}
6373

6474
double den = 1.0 / (2.0 * l + 1.0); // denominator
6575

@@ -86,9 +96,13 @@ double SocBase::spinor(const int l, const double j, const int m, const int spin)
8696
else
8797
{
8898
if (spin == 0)
99+
{
89100
spinor0 = sqrt((l - m + 1.0) * den);
101+
}
90102
if (spin == 1)
103+
{
91104
spinor0 = -sqrt((l + m) * den);
105+
}
92106
}
93107
}
94108
else
@@ -147,9 +161,13 @@ int SocBase::sph_ind(const int l, const double j, const int m, const int spin) c
147161
if (fabs(j - l - 0.5) < 1e-8)
148162
{
149163
if (spin == 0)
164+
{
150165
sph_ind0 = m;
166+
}
151167
if (spin == 1)
168+
{
152169
sph_ind0 = m + 1;
170+
}
153171
}
154172
else if (fabs(j - l + 0.5) < 1e-8)
155173
{
@@ -201,4 +219,4 @@ void SocBase::set_fcoef(const int &l1,
201219
coeff += rotylm(m1, mi) * spinor(l1, j1, m, is1) * conj(rotylm(m2, mj)) * spinor(l2, j2, m, is2);
202220
}
203221
this->fcoef(it, is1, is2, ip1, ip2) = coeff;
204-
}
222+
}

source/source_psi/soc_base.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ class SocBase
5454
int sph_ind(const int l, const double j, const int m, const int spin) const;
5555

5656
void rot_ylm(const int lmax);
57-
// std::complex<double> **rotylm;
5857

5958
const std::complex<double> &rotylm(const int &i1, const int &i2) const
6059
{
6160
return p_rot[l2plus1_ * i1 + i2];
6261
}
6362

6463
Fcoef fcoef;
64+
6565
void set_fcoef(const int &l1,
6666
const int &l2,
6767
const int &is1,
@@ -74,10 +74,12 @@ class SocBase
7474
const int &ip1,
7575
const int &ip2);
7676

77-
// int npol;
7877
private:
78+
7979
int l_max_ = -1; // maximum orbital index, must initialized before set_fcoef
80+
8081
int l2plus1_ = -1;
82+
8183
std::complex<double> *p_rot = nullptr;
8284
};
8385
#endif

0 commit comments

Comments
 (0)