Skip to content

Commit d6be570

Browse files
committed
change ucell in module_io/cal_test.cpp
1 parent 410a051 commit d6be570

File tree

4 files changed

+39
-20
lines changed

4 files changed

+39
-20
lines changed

source/module_esolver/lcao_others.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ void ESolver_KS_LCAO<TK, TR>::others(UnitCell& ucell, const int istep)
4848
if (cal_type == "test_memory")
4949
{
5050
std::cout << FmtCore::format("\n * * * * * *\n << Start %s.\n", "testing memory");
51-
Cal_Test::test_memory(this->pw_rho,
51+
Cal_Test::test_memory(ucell.nat,
52+
ucell.ntype,
53+
ucell.GGT,
54+
this->pw_rho,
5255
this->pw_wfc,
5356
this->p_chgmix->get_mixing_mode(),
5457
this->p_chgmix->get_mixing_ndim());

source/module_esolver/pw_others.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ void ESolver_KS_PW<T, Device>::others(UnitCell& ucell, const int istep)
5656
const std::string cal_type = PARAM.inp.calculation;
5757

5858
if (cal_type == "test_memory") {
59-
Cal_Test::test_memory(this->pw_rho,
59+
Cal_Test::test_memory(ucell.nat,
60+
ucell.ntype,
61+
ucell.GGT,
62+
this->pw_rho,
6063
this->pw_wfc,
6164
this->p_chgmix->get_mixing_mode(),
6265
this->p_chgmix->get_mixing_ndim());

source/module_io/cal_test.cpp

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,24 +48,26 @@ double Cal_Test::meigts123=0.0;
4848

4949
double Cal_Test::mtot=0.0;
5050

51-
void Cal_Test::test_memory(
52-
const ModulePW::PW_Basis* rhopw,
53-
const ModulePW::PW_Basis_K* wfcpw,
54-
const std::string chr_mixing_mode,
55-
const int chr_mixing_ndim)
51+
void Cal_Test::test_memory(const int nat,
52+
const int ntype,
53+
const ModuleBase::Matrix3& GGT,
54+
const ModulePW::PW_Basis* rhopw,
55+
const ModulePW::PW_Basis_K* wfcpw,
56+
const std::string chr_mixing_mode,
57+
const int chr_mixing_ndim)
5658
{
5759
ModuleBase::TITLE("Cal_Test","test_memory");
5860

59-
const int ngmw = Cal_Test::cal_np(wfcpw->ggecut, rhopw->nx, rhopw->ny, rhopw->nz);
60-
const int ngmc = Cal_Test::cal_np(rhopw->ggecut, rhopw->nx, rhopw->ny, rhopw->nz);
61+
const int ngmw = Cal_Test::cal_np(GGT,wfcpw->ggecut, rhopw->nx, rhopw->ny, rhopw->nz);
62+
const int ngmc = Cal_Test::cal_np(GGT,rhopw->ggecut, rhopw->nx, rhopw->ny, rhopw->nz);
6163

6264
// const int ecut_wfc = INPUT.ecutwfc;
6365
// const int ecut_chg = INPUT.ecutrho;
6466

6567
// const int ngmw = Cal_Test::cal_np(ecut_wfc, rhopw->nx, rhopw->ny, rhopw->nz);
6668
// const int ngmc = Cal_Test::cal_np(ecut_chg, rhopw->nx, rhopw->ny, rhopw->nz);
6769

68-
std::cout << " number of atoms = " << GlobalC::ucell.nat << std::endl;
70+
std::cout << " number of atoms = " << nat << std::endl;
6971
std::cout << " plane wave number for wave functions = " << ngmw << std::endl;
7072
std::cout << " plane wave number for chage density = " << ngmc << std::endl;
7173

@@ -108,8 +110,8 @@ void Cal_Test::test_memory(
108110
mig2fftc = ModuleBase::Memory::calculate_mem( ngmc , "int");
109111
mgg = ModuleBase::Memory::calculate_mem( ngmc, "double");
110112
mig123 = ModuleBase::Memory::calculate_mem( ngmc*3, "int");
111-
mstrucFac = ModuleBase::Memory::calculate_mem( GlobalC::ucell.ntype*ngmc, "cdouble");
112-
meigts123 = ModuleBase::Memory::calculate_mem( GlobalC::ucell.nat * (2*rhopw->nx+1+2*rhopw->ny+1+2*rhopw->nz+1), "cdouble");
113+
mstrucFac = ModuleBase::Memory::calculate_mem( ntype*ngmc, "cdouble");
114+
meigts123 = ModuleBase::Memory::calculate_mem( nat * (2*rhopw->nx+1+2*rhopw->ny+1+2*rhopw->nz+1), "cdouble");
113115

114116
//(3) Memory for H,S matrix.
115117
std::cout << " NLOCAL = " << PARAM.globalv.nlocal << std::endl;
@@ -130,7 +132,7 @@ void Cal_Test::test_memory(
130132
// print_mem(8);
131133
// print_mem(16);
132134

133-
// if(GlobalC::ucell.nat > 200)
135+
// if(nat > 200)
134136
// {
135137
// print_mem(32);
136138
// print_mem(64);
@@ -140,7 +142,11 @@ void Cal_Test::test_memory(
140142
}
141143

142144
//! compute the number of plane waves
143-
int Cal_Test::cal_np(const double &ggcut, const int &n1, const int &n2, const int &n3)
145+
int Cal_Test::cal_np(const ModuleBase::Matrix3& GGT,
146+
const double &ggcut,
147+
const int &n1,
148+
const int &n2,
149+
const int &n3)
144150
{
145151

146152
/*
@@ -170,7 +176,7 @@ int Cal_Test::cal_np(const double &ggcut, const int &n1, const int &n2, const in
170176
{
171177
ModuleBase::Vector3<double> f(i,j,k);
172178
// g2= |f|^2 in the unit of (2Pi/lat0)^2
173-
double g2 = f * (GlobalC::ucell.GGT * f);
179+
double g2 = f * (GGT * f);
174180

175181
// gcut is from input.
176182
if (g2 <= ggcut)

source/module_io/cal_test.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,19 @@
55

66
namespace Cal_Test
77
{
8-
void test_memory(const ModulePW::PW_Basis* rhopw,
9-
const ModulePW::PW_Basis_K* wfcpw,
10-
const std::string chr_mixing_mode,
11-
const int chr_mixing_ndim);
8+
void test_memory(const int nat,
9+
const int ntype,
10+
const ModuleBase::Matrix3& GGT,
11+
const ModulePW::PW_Basis* rhopw,
12+
const ModulePW::PW_Basis_K* wfcpw,
13+
const std::string chr_mixing_mode,
14+
const int chr_mixing_ndim);
1215

13-
int cal_np(const double &ggcut, const int &n1, const int &n2, const int &n3);
16+
int cal_np(const ModuleBase::Matrix3& GGT,
17+
const double &ggcut,
18+
const int &n1,
19+
const int &n2,
20+
const int &n3);
1421

1522
void print_mem(const int &nproc);
1623

0 commit comments

Comments
 (0)