Skip to content

Commit c0ce586

Browse files
DoctorDraDoctorDramohanchen
authored
Adding comments and modifying properties in the PW module (deepmodeling#4405)
* 对于'source/module_relax/relax_old' 的第85行附近进行了 修改 * A.s * class change * xiugai * add some comments --------- Co-authored-by: DoctorDra <DoctorDra@https://github.com> Co-authored-by: Mohan Chen <mohan.chen.chen.mohan@gmail.com>
1 parent 91b3d87 commit c0ce586

3 files changed

Lines changed: 12 additions & 9 deletions

File tree

‎source/module_basis/module_pw/fft.h‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,12 @@ class FFT
8484
#endif // defined(__ENABLE_FLOAT_FFTW)
8585
// void initplanf_mpi();
8686

87-
public:
87+
private:
8888
int fftnx=0, fftny=0;
8989
int fftnxy=0;
9090
int ny=0, nx=0, nz=0;
9191
int nxy=0;
92+
public :
9293
bool xprime = true; // true: when do recip2real, x-fft will be done last and when doing real2recip, x-fft will be done first; false: y-fft
9394
// For gamma_only, true: we use half x; false: we use half y
9495
int lixy=0,rixy=0;// lixy: the left edge of the pw ball in the y direction; rixy: the right edge of the pw ball in the x or y direction
@@ -110,8 +111,8 @@ class FFT
110111
private:
111112
bool gamma_only = false;
112113
bool mpifft = false; // if use mpi fft, only used when define __FFTW3_MPI
113-
114-
fftw_plan planzfor = NULL;
114+
//add by A.s 202406 considering that no all people are familiar with fftw3,some comments should be added.
115+
fftw_plan planzfor = NULL;//create a special pointer pointing to the fftw_plan class as a plan for performing FFT
115116
fftw_plan planzbac = NULL;
116117
fftw_plan planxfor1 = NULL;
117118
fftw_plan planxbac1 = NULL;

‎source/module_basis/module_pw/pw_basis.cpp‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,10 @@ void PW_Basis::collect_uniqgg()
146146
if(this->npw <= 0) return;
147147
this->ig_gge0 = -1;
148148
delete[] this->ig2igg; this->ig2igg = new int [this->npw];
149-
int *sortindex = new int [this->npw];
150-
double *tmpgg = new double [this->npw];
151-
double *tmpgg2 = new double [this->npw];
149+
//add by A.s 202406
150+
int *sortindex = new int [this->npw];//Reconstruct the mapping of the plane wave index ig according to the energy size of the plane waves
151+
double *tmpgg = new double [this->npw];//Ranking the plane waves by energy size while ensuring that the same energy is preserved for each wave to correspond
152+
double *tmpgg2 = new double [this->npw];//ranking the plane waves by energy size and removing the duplicates
152153
ModuleBase::Vector3<double> f;
153154
for(int ig = 0 ; ig < this-> npw ; ++ig)
154155
{
@@ -175,8 +176,8 @@ void PW_Basis::collect_uniqgg()
175176
int igg = 0;
176177
this->ig2igg[sortindex[0]] = 0;
177178
tmpgg2[0] = tmpgg[0];
178-
double avg_gg = tmpgg2[igg];
179-
int avg_n = 1;
179+
double avg_gg = tmpgg2[igg];//For waves with similar energy,take the average
180+
int avg_n = 1;//The number of waves required to take the average
180181
for (int ig = 1; ig < this->npw; ++ig)
181182
{
182183
if (std::abs(tmpgg[ig] - tmpgg2[igg]) > 1.0e-8)
@@ -233,4 +234,4 @@ void PW_Basis::set_precision(std::string precision_) {
233234
this->precision = std::move(precision_);
234235
}
235236

236-
}
237+
}

‎source/module_relax/relax_old/lattice_change_cg.cpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ void Lattice_Change_CG::start(UnitCell &ucell, const ModuleBase::matrix &stress_
8585
double *cg_gradn = new double[dim];
8686
double *move = new double[dim];
8787
double *cg_grad = new double[dim];
88+
8889
double best_x = 0.0;
8990
double fmin = 0.0;
9091

0 commit comments

Comments
 (0)