Skip to content

Commit 0ba139b

Browse files
committed
update structure_factor
1 parent 4dc6f15 commit 0ba139b

File tree

7 files changed

+47
-27
lines changed

7 files changed

+47
-27
lines changed

source/source_esolver/esolver_fp.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ void ESolver_FP::before_all_runners(UnitCell& ucell, const Input_para& inp)
5454

5555
// write geometry file
5656
ModuleIO::CifParser::write(PARAM.globalv.global_out_dir + "STRU.cif",
57-
ucell,
58-
"# Generated by ABACUS ModuleIO::CifParser",
59-
"data_?");
57+
ucell, "# Generated by ABACUS ModuleIO::CifParser", "data_?");
6058

6159
// init charge extrapolation
6260
this->CE.Init_CE(inp.nspin, ucell.nat, this->pw_rhod->nrxx, inp.chg_extrap);

source/source_esolver/esolver_ks.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ void ESolver_KS<T, Device>::before_all_runners(UnitCell& ucell, const Input_para
9999
this->pw_rhod->nplane, this->pw_rhod->nrxx, pw_big->nbz, pw_big->bz);
100100

101101
//! 11) calculate the structure factor
102-
this->sf.setup_structure_factor(&ucell, Pgrid, this->pw_rhod);
102+
this->sf.setup(&ucell, Pgrid, this->pw_rhod);
103103
}
104104

105105
template <typename T, typename Device>

source/source_esolver/esolver_of.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ void ESolver_OF::before_all_runners(UnitCell& ucell, const Input_para& inp)
105105
pw_big->nbz,
106106
pw_big->bz); // mohan add 2010-07-22, update 2011-05-04
107107
// Calculate Structure factor
108-
sf.setup_structure_factor(&ucell, Pgrid, pw_rho);
108+
sf.setup(&ucell, Pgrid, pw_rho);
109109
ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "INIT BASIS");
110110

111111
// initialize local pseudopotential

source/source_estate/module_charge/charge_extra.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ void Charge_Extra::extrapolate_charge(
107107
rho_extr = std::min(istep, pot_order);
108108
if(rho_extr == 0)
109109
{
110-
sf->setup_structure_factor(&ucell, *Pgrid, chr->rhopw);
110+
sf->setup(&ucell, *Pgrid, chr->rhopw);
111111
ofs_running << " charge density from previous step !" << std::endl;
112112
return;
113113
}
@@ -169,7 +169,7 @@ void Charge_Extra::extrapolate_charge(
169169
}
170170
}
171171

172-
sf->setup_structure_factor(&ucell, *Pgrid, chr->rhopw);
172+
sf->setup(&ucell, *Pgrid, chr->rhopw);
173173
double** rho_atom = new double*[this->nspin];
174174
for (int is = 0; is < this->nspin; is++)
175175
{
@@ -314,4 +314,4 @@ void Charge_Extra::update_delta_rho(const UnitCell& ucell, const Charge* chr, co
314314
}
315315
delete[] rho_atom;
316316
return;
317-
}
317+
}

source/source_hamilt/module_surchem/cal_pseudo.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ void surchem::gauss_charge(const UnitCell& cell,
99
std::complex<double>* N,
1010
Structure_Factor* sf)
1111
{
12-
sf->setup_structure_factor(&cell, pgrid, rho_basis); // call strucFac(ntype,ngmc)
12+
sf->setup(&cell, pgrid, rho_basis); // this is strange, should be removed to other places, mohan add 2025-11-04
13+
1314
const int ig0 = rho_basis->ig_gge0; // G=0 index
1415
for (int it = 0; it < cell.ntype; it++)
1516
{

source/source_pw/module_pwdft/structure_factor.cpp

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,19 @@ Structure_Factor::~Structure_Factor()
4646
// called in input.cpp
4747
void Structure_Factor::set(const ModulePW::PW_Basis* rho_basis_in, const int& nbspline_in)
4848
{
49-
ModuleBase::TITLE("PW_Basis","set");
49+
ModuleBase::TITLE("Structure_Factor","set");
5050
this->rho_basis = rho_basis_in;
5151
this->nbspline = nbspline_in;
5252
return;
5353
}
5454

5555
// Peize Lin optimize and add OpenMP 2021.04.01
5656
// Calculate structure factor
57-
void Structure_Factor::setup_structure_factor(const UnitCell* Ucell, const Parallel_Grid& pgrid, const ModulePW::PW_Basis* rho_basis)
57+
void Structure_Factor::setup(const UnitCell* Ucell, const Parallel_Grid& pgrid, const ModulePW::PW_Basis* rho_basis)
5858
{
59-
ModuleBase::TITLE("PW_Basis","setup_structure_factor");
60-
ModuleBase::timer::tick("PW_Basis","setup_struc_factor");
59+
ModuleBase::TITLE("Structure_Factor","setup");
60+
ModuleBase::timer::tick("Structure_Factor","setup");
61+
6162
const std::complex<double> ci_tpi = ModuleBase::NEG_IMAG_UNIT * ModuleBase::TWO_PI;
6263
this->ucell = Ucell;
6364
this->strucFac.create(Ucell->ntype, rho_basis->npw);
@@ -66,9 +67,15 @@ void Structure_Factor::setup_structure_factor(const UnitCell* Ucell, const Paral
6667
// std::string outstr;
6768
// outstr = PARAM.globalv.global_out_dir + "strucFac.dat";
6869
// std::ofstream ofs( outstr.c_str() ) ;
69-
bool usebspline;
70-
if(nbspline > 0) { usebspline = true;
71-
} else { usebspline = false;}
70+
bool usebspline;
71+
if(nbspline > 0)
72+
{
73+
usebspline = true;
74+
}
75+
else
76+
{
77+
usebspline = false;
78+
}
7279

7380
if(usebspline)
7481
{
@@ -100,12 +107,15 @@ void Structure_Factor::setup_structure_factor(const UnitCell* Ucell, const Paral
100107

101108
// ofs.close();
102109

103-
int i,j; //ng;
110+
int i=0;
111+
int j=0;
112+
104113
this->eigts1.create(Ucell->nat, 2*rho_basis->nx + 1);
105114
this->eigts2.create(Ucell->nat, 2*rho_basis->ny + 1);
106115
this->eigts3.create(Ucell->nat, 2*rho_basis->nz + 1);
107116

108-
ModuleBase::Memory::record("SF::eigts123",sizeof(std::complex<double>) * (Ucell->nat*2 * (rho_basis->nx + rho_basis->ny + rho_basis->nz) + 3));
117+
ModuleBase::Memory::record("SF::eigts123",sizeof(std::complex<double>)
118+
* (Ucell->nat*2 * (rho_basis->nx + rho_basis->ny + rho_basis->nz) + 3));
109119

110120
ModuleBase::Vector3<double> gtau;
111121
int inat = 0;
@@ -177,7 +187,7 @@ void Structure_Factor::setup_structure_factor(const UnitCell* Ucell, const Paral
177187
this->z_eigts3 = this->eigts3.c;
178188
// There's no need to delete double precision pointers while in a CPU environment.
179189
}
180-
ModuleBase::timer::tick("PW_Basis","setup_struc_factor");
190+
ModuleBase::timer::tick("Structure_Factor","setup");
181191
return;
182192
}
183193

@@ -379,4 +389,4 @@ template <>
379389
std::complex<double> * Structure_Factor::get_eigts3_data() const
380390
{
381391
return this->z_eigts3;
382-
}
392+
}

source/source_pw/module_pwdft/structure_factor.h

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef PLANEWAVE_H
2-
#define PLANEWAVE_H
1+
#ifndef STRUCTURE_FACTOR_H
2+
#define STRUCTURE_FACTOR_H
33

44
#include "source_base/complexmatrix.h"
55
#include "source_basis/module_pw/pw_basis_k.h"
@@ -23,16 +23,18 @@ class Structure_Factor
2323

2424
// structure factor (ntype, ngmc)
2525
ModuleBase::ComplexMatrix strucFac;
26-
void setup_structure_factor(const UnitCell* Ucell,
27-
const Parallel_Grid& pgrid,
28-
const ModulePW::PW_Basis* rho_basis); // Calculate structure factors
26+
27+
void setup(const UnitCell* Ucell,
28+
const Parallel_Grid& pgrid,
29+
const ModulePW::PW_Basis* rho_basis); // Calculate structure factors
2930

3031
/// calculate structure factors through Cardinal B-spline interpolation
3132
void bspline_sf(
3233
const int,
3334
const UnitCell* Ucell,
3435
const Parallel_Grid& pgrid,
3536
const ModulePW::PW_Basis* rho_basis);
37+
3638
void bsplinecoef(std::complex<double> *b1, std::complex<double> *b2, std::complex<double> *b3,
3739
const int nx, const int ny, const int nz, const int norder);
3840

@@ -51,17 +53,26 @@ class Structure_Factor
5153
// sf with k points
5254
std::complex<double>* get_sk(const int ik, const int it, const int ia, const ModulePW::PW_Basis_K* wfc_basis) const;
5355
template <typename FPTYPE, typename Device>
56+
5457
void get_sk(Device* ctx, const int ik, const ModulePW::PW_Basis_K* wfc_basis, std::complex<FPTYPE>* sk) const;
58+
5559
std::complex<double>* get_skq(int ik,
5660
int it,
5761
int ia,
5862
const ModulePW::PW_Basis_K* wfc_basis,
5963
ModuleBase::Vector3<double> q);
6064

6165
private:
66+
6267
const UnitCell* ucell=nullptr;
63-
std::complex<float> * c_eigts1 = nullptr, * c_eigts2 = nullptr, * c_eigts3 = nullptr;
64-
std::complex<double> * z_eigts1 = nullptr, * z_eigts2 = nullptr, * z_eigts3 = nullptr;
68+
std::complex<float> * c_eigts1 = nullptr;
69+
std::complex<float> * c_eigts2 = nullptr;
70+
std::complex<float> * c_eigts3 = nullptr;
71+
72+
std::complex<double> * z_eigts1 = nullptr;
73+
std::complex<double> * z_eigts2 = nullptr;
74+
std::complex<double> * z_eigts3 = nullptr;
75+
6576
const ModulePW::PW_Basis* rho_basis = nullptr;
6677
std::string device = "cpu";
6778
};

0 commit comments

Comments
 (0)