Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refator:Use PARAM instead of nspin,cal_stress #5136

Merged
merged 36 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
802f830
change paramter two_fermi in cpp file
A-006 Sep 16, 2024
45a859e
change two_fermi in test file
A-006 Sep 16, 2024
ff99060
change cal_stress in the cpp file
A-006 Sep 16, 2024
9dab673
change cal_stress in cpp file
A-006 Sep 16, 2024
b4e0bf3
change cal_stress in test file
A-006 Sep 16, 2024
ba25a36
add dq,nqx,nqxq in system.cpp
A-006 Sep 16, 2024
61bb238
change dq
A-006 Sep 16, 2024
c604c18
change dqx
A-006 Sep 16, 2024
4d58209
change dqxq
A-006 Sep 16, 2024
b79ea07
fix bug in DQ
A-006 Sep 17, 2024
733e18e
Merge branch 'deepmodeling:develop' into para15
A-006 Sep 17, 2024
1914cdf
Merge branch 'deepmodeling:develop' into para15
A-006 Sep 17, 2024
6aded95
change parameter in gloabl variable
A-006 Sep 17, 2024
22d603d
change file in PW_DIAG_THR
A-006 Sep 17, 2024
2bb546c
change file in PW_DIAG_THAR
A-006 Sep 17, 2024
d28c2b0
delete parameter in gloablV
A-006 Sep 17, 2024
f57839f
change nspin in module_cell
A-006 Sep 17, 2024
9301eff
change nspin in module_elecstate
A-006 Sep 17, 2024
7e183ec
change nspin in module_esolver
A-006 Sep 17, 2024
bb6e20e
change nspin in module_hamilt_lcao
A-006 Sep 17, 2024
274d27c
change nspin in module_hamilt_pw
A-006 Sep 17, 2024
bcbe6e3
change nspin in module_hamilt_io
A-006 Sep 17, 2024
8535c0d
change nspin
A-006 Sep 17, 2024
cfd6586
change nspin in module_cell in test file
A-006 Sep 17, 2024
9fefd05
change nspin in module_elecstate in test file
A-006 Sep 17, 2024
024bbc8
change nspin in module_io in test file
A-006 Sep 17, 2024
48160bc
change nspin in module_xc in test file
A-006 Sep 17, 2024
4a5115b
change nspin in module_io in test file
A-006 Sep 17, 2024
c1ae027
change nspin in module_psi in test file
A-006 Sep 17, 2024
ce856d7
change nspin in test file
A-006 Sep 17, 2024
6433f88
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Sep 17, 2024
a2edcdc
fix bug in two_fermi
A-006 Sep 17, 2024
09be41c
Merge branch 'develop' into para15
A-006 Sep 18, 2024
df5fff3
fix bug in deepks merge
A-006 Sep 18, 2024
7c08553
Merge branch 'develop' into para19
A-006 Sep 19, 2024
e04e0a9
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Sep 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/module_base/global_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ void ModuleBase::Global_File::delete_tmp_files()
{
if (GlobalV::MY_RANK == 0)
{
for (int is = 0; is < GlobalV::NSPIN; ++is)
for (int is = 0; is < PARAM.inp.nspin; ++is)
{
std::string tmp_chg_1 = PARAM.globalv.global_out_dir + "NOW_SPIN" + std::to_string(is + 1) + "_CHG.cube";
std::string tmp_chg_2 = PARAM.globalv.global_out_dir + "OLD1_SPIN" + std::to_string(is + 1) + "_CHG.cube";
Expand Down
10 changes: 0 additions & 10 deletions source/module_base/global_variable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,15 @@ int NBANDS = 0;
int NLOCAL = 0; // total number of local basis.

int NSPIN = 1; // LDA
bool TWO_EFERMI = false; // two fermi energy, exist only magnetization is fixed.
double nupdown = 0.0;
bool CAL_STRESS = false;
std::string RELAX_METHOD = "bfgs";

bool use_uspp = false;
std::string KS_SOLVER = "cg"; // xiaohui add 2013-09-01
double SEARCH_RADIUS = -1.0;

int PW_DIAG_NDIM = 4;
double PW_DIAG_THR = 1.0e-2;
int NB2D = 1;


double DQ = 0.010; // space between Q points of the reciprocal radial tab
int NQX = 10000; // number of points describing reciprocal radial tab
int NQXQ = 10000; // number of points describing reciprocal radial tab for Q


//----------------------------------------------------------
// EXPLAIN : Parallel information
//----------------------------------------------------------
Expand Down
13 changes: 0 additions & 13 deletions source/module_base/global_variable.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,17 @@ extern int NLOCAL; // 1.1 // mohan add 2009-05-29


extern int NSPIN; // 7
extern bool TWO_EFERMI; // 7.5 two fermi energy, exist if nupdown isn't zero.
extern double nupdown;

extern bool CAL_STRESS; // 8.25 calcualte the stress

extern std::string RELAX_METHOD;


extern bool use_uspp;

extern std::string KS_SOLVER; // xiaohui add 2013-09-01
extern double SEARCH_RADIUS; // 11.1 // mohan add 2011-03-10


extern int PW_DIAG_NDIM; // 14
extern double PW_DIAG_THR; // 15 pw_diag_thr
extern int NB2D; // 16.5 dividsion of 2D_matrix.

// pw, 2: real drho for lcao

extern double DQ; // 19 mohan add 2009-09-10
extern int NQX; // 20 mohan add 2009-09-10
extern int NQXQ; // liuyu add 2023-10-03


//========================================================================
// EXPLAIN : Parallel information
Expand Down
3 changes: 2 additions & 1 deletion source/module_cell/atom_pseudo.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "atom_pseudo.h"
#include "module_parameter/parameter.h"

#include "module_parameter/parameter.h"
Atom_pseudo::Atom_pseudo()
Expand Down Expand Up @@ -106,7 +107,7 @@ void Atom_pseudo::set_d_so(ModuleBase::ComplexMatrix& d_so_in,
{
for (int is2 = 0; is2 < 2; is2++)
{
if (is >= GlobalV::NSPIN) {
if (is >= PARAM.inp.nspin) {
break;
}
for (int L1 = 0; L1 < nproj_soc; L1++)
Expand Down
25 changes: 13 additions & 12 deletions source/module_cell/module_paw/paw_atom.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "paw_atom.h"
#include "module_base/global_variable.h"
#include "module_parameter/parameter.h"

void Paw_Atom::init_paw_atom(const int nproj_in)
{
Expand All @@ -8,17 +9,17 @@ void Paw_Atom::init_paw_atom(const int nproj_in)

ca.resize(nproj);

rhoij.resize(GlobalV::NSPIN);
for(int is = 0; is < GlobalV::NSPIN; is ++)
rhoij.resize(PARAM.inp.nspin);
for(int is = 0; is < PARAM.inp.nspin; is ++)
{
rhoij[is].resize(nproj*(nproj + 1) / 2);
}

rhoijp.resize(GlobalV::NSPIN * nproj*(nproj + 1) / 2);
rhoijp.resize(PARAM.inp.nspin * nproj*(nproj + 1) / 2);
rhoijselect.resize(nproj*(nproj + 1) / 2);

dij.resize(GlobalV::NSPIN);
for(int is = 0; is < GlobalV::NSPIN; is ++)
dij.resize(PARAM.inp.nspin);
for(int is = 0; is < PARAM.inp.nspin; is ++)
{
dij[is].resize(nproj*nproj);
}
Expand All @@ -45,14 +46,14 @@ void Paw_Atom::reset_rhoij()

for(int i = 0; i < nproj*(nproj+1)/2; i ++)
{
for(int is = 0; is < GlobalV::NSPIN; is ++)
for(int is = 0; is < PARAM.inp.nspin; is ++)
{
rhoij[is][i] = 0.0;
}
rhoijselect[i] = -1;
}

for(int i = 0; i < GlobalV::NSPIN * nproj*(nproj + 1) / 2; i ++)
for(int i = 0; i < PARAM.inp.nspin * nproj*(nproj + 1) / 2; i ++)
{
rhoijp[i] = 0.0;
}
Expand All @@ -75,7 +76,7 @@ void Paw_Atom::set_rhoij(std::vector<double> & rhoij_in)
{
for(int i = 0; i < nproj*(nproj+1)/2; i ++)
{
for(int is = 0; is < GlobalV::NSPIN; is ++)
for(int is = 0; is < PARAM.inp.nspin; is ++)
{
rhoij[is][i] = rhoij_in[i];
}
Expand All @@ -88,7 +89,7 @@ void Paw_Atom::convert_rhoij()
for(int i = 0; i < rhoij[0].size(); i ++)
{
bool nonzero = false;
for(int is = 0; is < GlobalV::NSPIN; is ++)
for(int is = 0; is < PARAM.inp.nspin; is ++)
{
if(std::abs(rhoij[is][i]) > 1e-10)
{
Expand All @@ -100,7 +101,7 @@ void Paw_Atom::convert_rhoij()
if(nonzero)
{
rhoijselect[nrhoijsel] = i+1; //index in fortran
for(int is = 0; is < GlobalV::NSPIN; is ++)
for(int is = 0; is < PARAM.inp.nspin; is ++)
{
rhoijp[nrhoijsel + is * rhoij[0].size()] = rhoij[is][i];
}
Expand All @@ -111,7 +112,7 @@ void Paw_Atom::convert_rhoij()

void Paw_Atom::reset_dij()
{
for(int is = 0; is < GlobalV::NSPIN; is ++)
for(int is = 0; is < PARAM.inp.nspin; is ++)
{
for(int i = 0; i < nproj*nproj; i ++)
{
Expand All @@ -122,7 +123,7 @@ void Paw_Atom::reset_dij()

void Paw_Atom::set_dij(double** dij_in)
{
for(int is = 0; is < GlobalV::NSPIN; is ++)
for(int is = 0; is < PARAM.inp.nspin; is ++)
{
for(int i = 0; i < nproj*nproj; i ++)
{
Expand Down
4 changes: 2 additions & 2 deletions source/module_cell/module_paw/paw_cell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void Paw_Cell::init_rhoij()
for(int iproj = 0; iproj < nproj; iproj ++)
{
int i0 = iproj * (iproj + 1) / 2;
rhoij_in[i0 + iproj] = mstate_occ[iproj] / GlobalV::NSPIN;
rhoij_in[i0 + iproj] = mstate_occ[iproj] / PARAM.inp.nspin;
}

paw_atom_list[iat].set_rhoij(rhoij_in);
Expand Down Expand Up @@ -215,7 +215,7 @@ void Paw_Cell::set_paw_k(

std::complex<double> i_cplx(0.0,1.0);
// ig : i(G)
if(PARAM.inp.cal_force || GlobalV::CAL_STRESS)
if(PARAM.inp.cal_force || PARAM.inp.cal_stress)
{
ig.resize(npw);
for(int ipw = 0; ipw < npw; ipw ++)
Expand Down
5 changes: 4 additions & 1 deletion source/module_cell/module_paw/test/test_paw2.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#include "gtest/gtest.h"
#include <fstream>
#include <iostream>
#define private public
#include "module_parameter/parameter.h"
#undef private
#include "module_base/global_variable.h"

#include "../paw_atom.h"
Expand All @@ -24,7 +27,7 @@ class Test_Paw_Atom : public testing::Test

TEST_F(Test_Paw_Atom, test_paw)
{
GlobalV::NSPIN = 1;
PARAM.input.nspin = 1;
paw_atom.init_paw_atom(nproj);
paw_atom.reset_rhoij();

Expand Down
4 changes: 2 additions & 2 deletions source/module_cell/module_symmetry/symmetry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ void Symmetry::analy_sys(const Lattice& lat, const Statistics& st, Atom* atoms,
// which should be loop over all atoms, f.e only loop over spin-up atoms
// --------------------------------
// AFM analysis Start
if (GlobalV::NSPIN > 1) {
if (PARAM.inp.nspin > 1) {
pricell_loop = this->magmom_same_check(atoms);
}

if (!pricell_loop && GlobalV::NSPIN == 2)
if (!pricell_loop && PARAM.inp.nspin == 2)
{//analyze symmetry for spin-up atoms only
std::vector<double> pos_spinup;
for (int it = 0;it < ntype;++it)
Expand Down
8 changes: 4 additions & 4 deletions source/module_cell/read_atoms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ bool UnitCell::read_atom_positions(std::ifstream &ifpos, std::ofstream &ofs_runn
std::string mags;
//cout<<"mag"<<atoms[it].mag[ia]<<"angle1"<<atoms[it].angle1[ia]<<"angle2"<<atoms[it].angle2[ia]<<'\n';

if(GlobalV::NSPIN==4)
if(PARAM.inp.nspin==4)
{
if(PARAM.inp.noncolin)
{
Expand Down Expand Up @@ -684,7 +684,7 @@ bool UnitCell::read_atom_positions(std::ifstream &ifpos, std::ofstream &ofs_runn
}
ModuleBase::GlobalFunc::ZEROS(magnet.ux_ ,3);
}
else if(GlobalV::NSPIN==2)
else if(PARAM.inp.nspin==2)
{
atoms[it].m_loc_[ia].x = atoms[it].mag[ia];
//print only ia==0 && mag>0 to avoid too much output
Expand Down Expand Up @@ -813,7 +813,7 @@ bool UnitCell::read_atom_positions(std::ifstream &ifpos, std::ofstream &ofs_runn
}
if (autoset_mag)
{
if(GlobalV::NSPIN==4)
if(PARAM.inp.nspin==4)
{
for (int it = 0;it < ntype; it++)
{
Expand All @@ -827,7 +827,7 @@ bool UnitCell::read_atom_positions(std::ifstream &ifpos, std::ofstream &ofs_runn
}
}
}
else if(GlobalV::NSPIN==2)
else if(PARAM.inp.nspin==2)
{
for (int it = 0;it < ntype; it++)
{
Expand Down
2 changes: 1 addition & 1 deletion source/module_cell/test/atom_pseudo_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ TEST_F(AtomPseudoTest, SetDSo)
int nproj = 6;
int nproj_soc = 4;
bool has_so = true;
GlobalV::NSPIN = 4;
PARAM.input.nspin = 4;
atom_pseudo->set_d_so(d_so_in,nproj,nproj_soc,has_so);
EXPECT_NEAR(atom_pseudo->d_so(0,0,0).real(),1e-8,1e-7);
EXPECT_NEAR(atom_pseudo->d_so(0,0,0).imag(),1e-8,1e-7);
Expand Down
4 changes: 2 additions & 2 deletions source/module_cell/test/klist_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ TEST_F(KlistTest, SetAfterVC)
kv->kvec_c[0].x = 0;
kv->kvec_c[0].y = 0;
kv->kvec_c[0].z = 0;
kv->set_after_vc(GlobalV::NSPIN, GlobalC::ucell.G, GlobalC::ucell.latvec);
kv->set_after_vc(PARAM.input.nspin, GlobalC::ucell.G, GlobalC::ucell.latvec);
EXPECT_TRUE(kv->kd_done);
EXPECT_TRUE(kv->kc_done);
EXPECT_DOUBLE_EQ(kv->kvec_d[0].x, 0);
Expand All @@ -616,7 +616,7 @@ TEST_F(KlistTest, PrintKlists)
kv->kvec_c[0].x = 0;
kv->kvec_c[0].y = 0;
kv->kvec_c[0].z = 0;
kv->set_after_vc(GlobalV::NSPIN, GlobalC::ucell.G, GlobalC::ucell.latvec);
kv->set_after_vc(PARAM.input.nspin, GlobalC::ucell.G, GlobalC::ucell.latvec);
EXPECT_TRUE(kv->kd_done);
kv->print_klists(GlobalV::ofs_running);
GlobalV::ofs_running.close();
Expand Down
4 changes: 2 additions & 2 deletions source/module_cell/test/klist_test_para.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ TEST_F(KlistParaTest, Set)
std::string k_file = "./support/KPT1";
// set klist
kv->nspin = 1;
GlobalV::NSPIN = 1;
PARAM.input.nspin = 1;
if (GlobalV::NPROC == 4)
{
GlobalV::KPAR = 2;
Expand Down Expand Up @@ -281,7 +281,7 @@ TEST_F(KlistParaTest, SetAfterVC)
std::string k_file = "./support/KPT1";
// set klist
kv->nspin = 1;
GlobalV::NSPIN = 1;
PARAM.input.nspin = 1;
if (GlobalV::NPROC == 4)
{
GlobalV::KPAR = 1;
Expand Down
Loading
Loading