Skip to content

Commit 4bf4cb5

Browse files
committed
update pulay_fs files
1 parent 80f9d3d commit 4bf4cb5

File tree

9 files changed

+153
-141
lines changed

9 files changed

+153
-141
lines changed

source/Makefile.Objects

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ OBJS_LCAO=evolve_elec.o\
655655
FORCE_k.o\
656656
stress_tools.o\
657657
edm.o\
658-
pulay_force_stress_center2.o\
658+
pulay_fs_center2.o\
659659
grid_init.o\
660660
spar_dh.o\
661661
spar_exx.o\

source/source_lcao/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ if(ENABLE_LCAO)
2222
module_operator_lcao/td_pot_hybrid.cpp
2323
module_operator_lcao/dspin_lcao.cpp
2424
module_operator_lcao/dftu_lcao.cpp
25-
pulay_force_stress_center2.cpp
25+
pulay_fs_center2.cpp
2626
FORCE_STRESS.cpp
2727
FORCE_gamma.cpp
2828
FORCE_k.cpp

source/source_lcao/FORCE_gamma.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include "source_cell/module_neighbor/sltk_grid_driver.h" //GridD
1313
#include "source_estate/elecstate_lcao.h"
1414
#include "source_lcao/LCAO_domain.h"
15-
#include "source_lcao/pulay_force_stress.h"
15+
#include "source_lcao/pulay_fs.h"
1616
#include "source_io/write_HS.h"
1717

1818
template <>

source/source_lcao/FORCE_k.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include "source_estate/elecstate_lcao.h"
1010
#include "source_estate/module_dm/cal_dm_psi.h"
1111
#include "source_lcao/LCAO_domain.h"
12-
#include "source_lcao/pulay_force_stress.h"
12+
#include "source_lcao/pulay_fs.h"
1313
#include "source_pw/module_pwdft/global.h"
1414
#include "source_io/write_HS.h"
1515
#include "source_io/module_parameter/parameter.h"

source/source_lcao/pulay_force_stress_center2.cpp

Lines changed: 0 additions & 132 deletions
This file was deleted.

source/source_lcao/pulay_force_stress.h renamed to source/source_lcao/pulay_fs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,5 @@ namespace PulayForceStress
6565
const bool& isstress,
6666
const bool& set_dmr_gint = true);
6767
}
68-
#include "pulay_force_stress_center2_template.hpp"
69-
#include "pulay_force_stress_gint.hpp"
68+
#include "pulay_fs_temp.hpp"
69+
#include "pulay_fs_gint.hpp"
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
#include "pulay_fs.h"
2+
3+
template<> // gamma-only, provided xy
4+
void PulayForceStress::cal_pulay_fs(
5+
ModuleBase::matrix& force,
6+
ModuleBase::matrix& stress,
7+
const elecstate::DensityMatrix<double, double>& dm,
8+
const UnitCell& ucell,
9+
const Parallel_Orbitals& pv,
10+
const double* (&dHSx)[3],
11+
const double* (&dHSxy)[6],
12+
const bool& isforce,
13+
const bool& isstress,
14+
Record_adj* ra,
15+
const double& factor_force,
16+
const double& factor_stress)
17+
{
18+
ModuleBase::TITLE("Forces", "cal_pulay_fs");
19+
ModuleBase::timer::tick("Forces", "cal_pulay_fs");
20+
21+
const int nspin = PARAM.inp.nspin;
22+
const int nlocal = PARAM.globalv.nlocal;
23+
24+
for (int i = 0; i < nlocal; ++i)
25+
{
26+
const int iat = ucell.iwt2iat[i];
27+
for (int j = 0; j < nlocal; ++j)
28+
{
29+
const int mu = pv.global2local_row(j);
30+
const int nu = pv.global2local_col(i);
31+
32+
if (mu >= 0 && nu >= 0)
33+
{
34+
const int index = mu * pv.ncol + nu;
35+
double sum = 0.0;
36+
for (int is = 0; is < nspin; ++is)
37+
{
38+
sum += dm.get_DMK(is + 1, 0, nu, mu);
39+
}
40+
if (isforce)
41+
{
42+
const double sumf = sum * factor_force;
43+
for (int i = 0; i < 3; ++i)
44+
{
45+
force(iat, i) += sumf * 2.0 * dHSx[i][index];
46+
}
47+
}
48+
if (isstress)
49+
{
50+
const double sums = sum * factor_stress;
51+
int ij = 0;
52+
for (int i = 0; i < 3;++i)
53+
{
54+
for (int j = i; j < 3; ++j)
55+
{
56+
stress(i, j) += sums * dHSxy[ij++][index];
57+
}
58+
}
59+
}
60+
}
61+
}
62+
}
63+
64+
if (isstress)
65+
{
66+
StressTools::stress_fill(ucell.lat0, ucell.omega, stress);
67+
}
68+
69+
ModuleBase::timer::tick("Forces", "cal_pulay_fs");
70+
}
71+
72+
73+
template<> //multi-k, provided xy
74+
void PulayForceStress::cal_pulay_fs(
75+
ModuleBase::matrix& force,
76+
ModuleBase::matrix& stress,
77+
const elecstate::DensityMatrix<std::complex<double>, double>& dm,
78+
const UnitCell& ucell,
79+
const Parallel_Orbitals& pv,
80+
const double* (&dHSx)[3],
81+
const double* (&dHSxy)[6],
82+
const bool& isforce,
83+
const bool& isstress,
84+
Record_adj* ra,
85+
const double& factor_force,
86+
const double& factor_stress)
87+
{
88+
auto stress_func = [](ModuleBase::matrix& local_s,
89+
const double& dm2d1_s,
90+
const double** dHSx,
91+
const double** dHSxy,
92+
const double* dtau,
93+
const int& irr)
94+
{
95+
int ij = 0;
96+
for (int i = 0; i < 3; ++i)
97+
{
98+
for (int j = i; j < 3; ++j)
99+
{
100+
local_s(i, j) += dm2d1_s * dHSxy[ij++][irr];
101+
}
102+
}
103+
};
104+
cal_pulay_fs(force, stress, dm, ucell, pv, dHSx, dHSxy,
105+
nullptr, isforce, isstress, ra,
106+
factor_force, factor_stress, stress_func);
107+
}
108+
109+
110+
template<> // multi-k, provided x
111+
void PulayForceStress::cal_pulay_fs(
112+
ModuleBase::matrix& force,
113+
ModuleBase::matrix& stress,
114+
const elecstate::DensityMatrix<std::complex<double>, double>& dm,
115+
const UnitCell& ucell,
116+
const Parallel_Orbitals& pv,
117+
const double* (&dHSx)[3],
118+
const double* dtau,
119+
const bool& isforce,
120+
const bool& isstress,
121+
Record_adj* ra,
122+
const double& factor_force,
123+
const double& factor_stress)
124+
{
125+
auto stress_func = [](ModuleBase::matrix& local_s,
126+
const double& dm2d1_s,
127+
const double** dHSx,
128+
const double** dHSxy,
129+
const double* dtau,
130+
const int& irr)
131+
{
132+
for (int i = 0; i < 3; ++i)
133+
{
134+
for (int j = i; j < 3; ++j)
135+
{
136+
local_s(i, j) += dm2d1_s * dHSx[i][irr] * dtau[irr * 3 + j];
137+
}
138+
}
139+
};
140+
cal_pulay_fs(force, stress, dm, ucell, pv, dHSx,
141+
nullptr, dtau, isforce, isstress, ra,
142+
factor_force, factor_stress, stress_func);
143+
}
144+

source/source_lcao/pulay_force_stress_gint.hpp renamed to source/source_lcao/pulay_fs_gint.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#pragma once
2-
#include "pulay_force_stress.h"
2+
#include "pulay_fs.h"
33
#include "source_lcao/stress_tools.h"
44
#include "source_hamilt/module_xc/xc_functional.h"
55
#include "source_io/module_parameter/parameter.h"
@@ -62,4 +62,4 @@ namespace PulayForceStress
6262

6363
if (isstress) { StressTools::stress_fill(-1.0, ucell.omega, s); }
6464
}
65-
}
65+
}

source/source_lcao/pulay_force_stress_center2_template.hpp renamed to source/source_lcao/pulay_fs_temp.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#pragma once
2-
#include "pulay_force_stress.h"
2+
#include "pulay_fs.h"
33
#include "source_base/timer.h"
44
#include "source_io/module_parameter/parameter.h"
55
namespace PulayForceStress

0 commit comments

Comments
 (0)