Skip to content

Commit 5aa14e1

Browse files
committed
temporarily remove modified stratmann
1 parent 83795c3 commit 5aa14e1

File tree

3 files changed

+8
-102
lines changed

3 files changed

+8
-102
lines changed

source/module_base/grid/partition.cpp

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ namespace Grid {
1010
namespace Partition {
1111

1212
const double stratmann_a = 0.64;
13-
const double stratmann_mod_b = 0.8;
14-
1513

1614
double w_becke(
1715
int nR0,
@@ -135,76 +133,5 @@ double s_stratmann(double mu) {
135133
}
136134

137135

138-
double w_stratmann_mod(
139-
int nR0,
140-
const double* drR,
141-
const double* dRR,
142-
const double* drR_thr,
143-
const double* Rcut,
144-
int nR,
145-
int* iR,
146-
int c
147-
) {
148-
int I = iR[c], J = 0;
149-
150-
// If r falls within the exclusive zone of a center, return immediately.
151-
for (int j = 0; j < nR; ++j) {
152-
J = iR[j];
153-
if (drR[J] <= drR_thr[J]) {
154-
return static_cast<double>(I == J);
155-
}
156-
}
157-
158-
// Even if the grid point does not fall within the exclusive zone of any
159-
// center, the normalized weight could still be 0 or 1, and this can be
160-
// figured out by examining the unnormalized weight alone.
161-
162-
// Move the center to the first position for convenience. Swap back later.
163-
std::swap(iR[0], iR[c]);
164-
165-
double P[nR];
166-
for (int j = 1; j < nR; ++j) {
167-
J = iR[j];
168-
double mu = (drR[I] - drR[J]) / dRR[I*nR0 + J];
169-
P[j] = s_stratmann(mu);
170-
}
171-
P[0] = std::accumulate(P + 1, P + nR, 1.0, std::multiplies<double>());
172-
173-
if (P[0] == 0.0 || P[0] == 1.0) {
174-
std::swap(iR[0], iR[c]);
175-
return P[0];
176-
}
177-
178-
// If it passes all the screening, all unnormalized weights have to be
179-
// calculated in order to get the normalized weight.
180-
181-
std::for_each(P + 1, P + nR, [](double& s) { s = 1.0 - s; });
182-
for (int i = 1; i < nR; ++i) {
183-
I = iR[i];
184-
for (int j = i + 1; j < nR; ++j) {
185-
J = iR[j];
186-
double mu = (drR[I] - drR[J]) / dRR[I*nR0 + J];
187-
double s = s_stratmann(mu);
188-
P[i] *= s;
189-
P[j] *= (1.0 - s); // s(-mu) = 1 - s(mu)
190-
}
191-
}
192-
193-
std::swap(iR[0], iR[c]);
194-
return P[0] / std::accumulate(P, P + nR, 0.0);
195-
}
196-
197-
198-
double s_stratmann_mod(double mu, double y) {
199-
using ModuleBase::PI;
200-
bool core = y <= stratmann_mod_b;
201-
bool edge = !core && y < 1.0;
202-
double u = core + edge * 0.5 * (1.0 +
203-
std::cos(PI * (y - stratmann_mod_b) / (1.0 - stratmann_mod_b)));
204-
return 1.0 + u * (s_stratmann(mu) - 1.0);
205-
}
206-
207-
208-
209136
} // end of namespace Partition
210137
} // end of namespace Grid

source/module_base/grid/partition.h

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ namespace Partition {
77
enum class Type {
88
Becke,
99
Stratmann,
10-
StratmannMod
1110
};
1211

1312
extern const double stratmann_a;
14-
extern const double stratmann_mod_b;
1513

1614
/**
1715
* @brief Becke's partition weight.
@@ -80,32 +78,6 @@ double w_stratmann(
8078
// Stratmann's piecewise cell function
8179
double s_stratmann(double mu);
8280

83-
84-
/**
85-
* @brief Becke's partition weight with a modified Stratmann's scheme
86-
* by Knuth et al.
87-
*
88-
* Reference:
89-
* Knuth, F., Carbogno, C., Atalla, V., Blum, V., & Scheffler, M. (2015).
90-
* All-electron formalism for total energy strain derivatives and stress
91-
* tensor components for numeric atom-centered orbitals.
92-
* Computer Physics Communications, 190, 33-50.
93-
*
94-
*/
95-
double w_stratmann_mod(
96-
int nR0,
97-
const double* drR,
98-
const double* dRR,
99-
const double* drR_thr,
100-
const double* Rcut,
101-
int nR,
102-
int* iR,
103-
int c
104-
);
105-
106-
double s_stratmann_mod(double mu, double y); // y = || r - R[J] || / Rcut[J]
107-
108-
10981
} // end of namespace Partition
11082
} // end of namespace Grid
11183

source/module_base/grid/test/test_partition.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#include <array>
99
#include <numeric>
1010
#include <chrono>
11+
#include <random>
12+
#include <algorithm>
1113

1214
#ifdef __MPI
1315
#include <mpi.h>
@@ -154,7 +156,7 @@ PartitionTest::PartitionTest() {
154156
std::vector<double> r_rad, w_rad;
155157
int nrad = 60;
156158
int Rcut = 7.0;
157-
int mult = 4;
159+
int mult = 2;
158160
Grid::Radial::baker(nrad, Rcut, r_rad, w_rad, mult);
159161

160162
// complete grid & weight for one-center integration
@@ -189,6 +191,10 @@ TEST_F(PartitionTest, Becke) {
189191
std::vector<int> iR(nR);
190192
std::iota(iR.begin(), iR.end(), 0);
191193

194+
std::random_device rd;
195+
std::mt19937 g(rd());
196+
std::shuffle(iR.begin(), iR.end(), g);
197+
192198
for (size_t I = 0; I < nR; ++I) { // for each center
193199
for (size_t i = 0; i < w.size(); i++) {
194200
Vec3 ri = Vec3{r[3*i], r[3*i+1], r[3*i+2]} + param.R[I];
@@ -271,6 +277,7 @@ TEST_F(PartitionTest, Stratmann) {
271277
printf("time elapsed = %8.3e seconds\n", dur.count());
272278
}
273279

280+
274281
int main(int argc, char** argv)
275282
{
276283
#ifdef __MPI

0 commit comments

Comments
 (0)