From 15efa42d09d2363bad128e57d45c8827569bba78 Mon Sep 17 00:00:00 2001 From: Liu-RX Date: Sun, 18 Jul 2021 08:44:00 +0800 Subject: [PATCH 1/5] update symm_other.h --- source/module_symmetry/symm_other.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/module_symmetry/symm_other.h b/source/module_symmetry/symm_other.h index aabdb1db3c..dad95978cd 100644 --- a/source/module_symmetry/symm_other.h +++ b/source/module_symmetry/symm_other.h @@ -1,8 +1,11 @@ #ifndef SYMM_OTHER_H #define SYMM_OTHER_H -#include "../src_pw/tools.h" - +//#include "../src_pw/tools.h" +#include "../module_base/vector3.h" +#include "../module_base/tool_title.h" +#include "../module_base/global_function.h" +#include "../module_base/tool_quit.h" namespace Symm_Other { void print1(const int &ibrav, const double *cel_const); From b6a2db49a958a445288f028c1b2ad393c6d22fcb Mon Sep 17 00:00:00 2001 From: Liu-RX Date: Sun, 18 Jul 2021 13:31:39 +0800 Subject: [PATCH 2/5] remove direct dependence of module_symmetry on global file --- source/module_md/run_md.cpp | 2 +- source/module_symmetry/symm_other.h | 2 -- source/module_symmetry/symmetry.cpp | 25 ++++++++++++----------- source/module_symmetry/symmetry.h | 14 ++++++------- source/module_symmetry/symmetry_basic.cpp | 4 ++-- source/module_symmetry/symmetry_basic.h | 9 +++++--- source/module_symmetry/symmetry_rho.cpp | 8 ++++---- source/module_symmetry/symmetry_rho.h | 7 +++++-- source/run_lcao.cpp | 2 +- source/run_pw.cpp | 2 +- source/src_io/output.h | 6 ++++-- source/src_ions/variable_cell.cpp | 4 ++-- source/src_lcao/ELEC_scf.cpp | 4 ++-- source/src_lcao/FORCE_STRESS.cpp | 4 ++-- source/src_pw/Makefile | 1 + source/src_pw/Makefile.Objects | 2 ++ source/src_pw/Makefile.parallel | 1 + source/src_pw/Makefile.serial | 1 + source/src_pw/charge_broyden.cpp | 1 + source/src_pw/charge_broyden.h | 1 + source/src_pw/electrons.cpp | 4 ++-- source/src_pw/forces.cpp | 2 +- source/src_pw/sto_elec.cpp | 4 ++-- source/src_pw/stress_func_kin.cpp | 2 +- source/src_pw/stress_func_nl.cpp | 2 +- source/src_pw/stress_pw.cpp | 2 +- 26 files changed, 65 insertions(+), 51 deletions(-) diff --git a/source/module_md/run_md.cpp b/source/module_md/run_md.cpp index 39e93ea975..e6047f877e 100644 --- a/source/module_md/run_md.cpp +++ b/source/module_md/run_md.cpp @@ -60,7 +60,7 @@ void Run_md::ai_md_line(void) // symmetry analysis should be performed every time the cell is changed if (Symmetry::symm_flag) { - symm.analy_sys(); + symm.analy_sys(ucell, out); DONE(ofs_running, "SYMMETRY"); } diff --git a/source/module_symmetry/symm_other.h b/source/module_symmetry/symm_other.h index dad95978cd..8a1701b8bd 100644 --- a/source/module_symmetry/symm_other.h +++ b/source/module_symmetry/symm_other.h @@ -3,9 +3,7 @@ //#include "../src_pw/tools.h" #include "../module_base/vector3.h" -#include "../module_base/tool_title.h" #include "../module_base/global_function.h" -#include "../module_base/tool_quit.h" namespace Symm_Other { void print1(const int &ibrav, const double *cel_const); diff --git a/source/module_symmetry/symmetry.cpp b/source/module_symmetry/symmetry.cpp index fb81743fcc..df8fd75d47 100644 --- a/source/module_symmetry/symmetry.cpp +++ b/source/module_symmetry/symmetry.cpp @@ -1,7 +1,7 @@ #include #include "symmetry.h" -#include "../src_pw/global.h" -#include "symm_other.h" +//#include "../src_pw/global.h" +//#include "symm_other.h" Symmetry::Symmetry() { @@ -18,7 +18,7 @@ Symmetry::~Symmetry() bool Symmetry::symm_flag=false; -void Symmetry::analy_sys(void) +void Symmetry::analy_sys(const UnitCell_pseudo &ucell, output &out) { if (available == false) return; TITLE("Symmetry","init"); @@ -109,7 +109,7 @@ void Symmetry::analy_sys(void) s3 = a3; // find the lattice type accordiing to lattice vectors. - this->lattice_type(a1,a2,a3,ibrav,cel_const,ilattname); + this->lattice_type(a1,a2,a3,ibrav,cel_const,ilattname, ucell); // cout << "a1 = " << a1.x << " " << a1.y << " " << a1.z < &v3, int &brav, double *cel_const, - string &bravname + string &bravname, + const UnitCell_pseudo &ucell ) { TITLE("Symmetry","lattice_type"); @@ -837,8 +838,8 @@ void Symmetry::change_lattice(void) } return; } - -void Symmetry::pricell(void) +/* +void Symmetry::pricell(const UnitCell_pseudo &ucell) { //detect the generating cell (primitive cell) of a supercell if (test_symmetry) TITLE("Symmetry","pricell"); @@ -1074,12 +1075,12 @@ void Symmetry::pricell(void) double celvolume = 0; double pcelvolume = 0.0; - this->lattice_type(p1, p2, p3, pbrav, pcel_const, plattname); + this->lattice_type(p1, p2, p3, pbrav, pcel_const, plattname, ucell); pcelvolume = std::fabs( Symm_Other::celvol(p1,p2,p3) ); OUT(ofs_running,"pcelvolume",pcelvolume); - this->lattice_type(a1, a2, a3, ibrav, cel_const, ilattname); + this->lattice_type(a1, a2, a3, ibrav, cel_const, ilattname, ucell); celvolume = std::fabs( Symm_Other::celvol(a1, a2, a3) ); OUT(ofs_running,"celvolume",celvolume); @@ -1117,7 +1118,7 @@ void Symmetry::pricell(void) } //cout<<"pricell ends!"< s1, s2, s3; @@ -68,7 +68,7 @@ class Symmetry : public Symmetry_Basic int standard_lat(Vector3 &a,Vector3 &b,Vector3 &c,double *celconst ); void lattice_type(Vector3 &v1,Vector3 &v2,Vector3 &v3, - int &ibrav,double *cel_const,string &bravname); + int &ibrav,double *cel_const,string &bravname, const UnitCell_pseudo &ucell); void recip( const double a, @@ -83,12 +83,12 @@ class Symmetry : public Symmetry_Basic void change_lattice(void); // check if the input cell is a primitive cell. - void pricell(void); + //void pricell(const UnitCell_pseudo &ucell); void getgroup(int &nrot, int &nrotk); void checksym(Matrix3 &s, Vector3 >rans, double *pos); void rho_symmetry(double *rho, const int &nr1, const int &nr2, const int &nr3); - void force_symmetry(matrix &force, double* pos); - void stress_symmetry(matrix &sigma); + void force_symmetry(matrix &force, double* pos, const UnitCell_pseudo &ucell); + void stress_symmetry(matrix &sigma, const UnitCell_pseudo &ucell); void write(); void print_pos(const double* pos, const int &nat); diff --git a/source/module_symmetry/symmetry_basic.cpp b/source/module_symmetry/symmetry_basic.cpp index f6927a7456..6f769099b9 100644 --- a/source/module_symmetry/symmetry_basic.cpp +++ b/source/module_symmetry/symmetry_basic.cpp @@ -3,9 +3,9 @@ // DATE : 2007-9 //========================================================== #include "symmetry.h" -#include "../src_pw/global.h" +//#include "../src_pw/global.h" #include "../module_base/mymath.h" -#include "symm_other.h" +//#include "symm_other.h" Symmetry_Basic::Symmetry_Basic() { diff --git a/source/module_symmetry/symmetry_basic.h b/source/module_symmetry/symmetry_basic.h index 27e304debb..2f4d3a1982 100644 --- a/source/module_symmetry/symmetry_basic.h +++ b/source/module_symmetry/symmetry_basic.h @@ -4,9 +4,12 @@ //========================================================== #ifndef SYMMETRY_BASIC_H #define SYMMETRY_BASIC_H -#include "../src_pw/tools.h" -#include "symmetry_basic.h" - +//#include "../src_pw/tools.h" +//#include "symmetry_basic.h" +#include "symm_other.h" +#include "../module_base/mymath.h" +#include "../module_base/ylm.h" +#include "../module_base/matrix3.h" class Symmetry_Basic { public: diff --git a/source/module_symmetry/symmetry_rho.cpp b/source/module_symmetry/symmetry_rho.cpp index de91a491f4..52e2ad1b2f 100644 --- a/source/module_symmetry/symmetry_rho.cpp +++ b/source/module_symmetry/symmetry_rho.cpp @@ -1,5 +1,5 @@ #include "symmetry_rho.h" -#include "../src_pw/global.h" +//#include "../src_pw/global.h" Symmetry_rho::Symmetry_rho() { @@ -11,14 +11,14 @@ Symmetry_rho::~Symmetry_rho() } -void Symmetry_rho::begin(const int &spin_now) const +void Symmetry_rho::begin(const int &spin_now, const Charge_Broyden &CHR, PW_Basis &pw, Parallel_Grid &Pgrid, Symmetry &symm) const { assert(spin_now < 4);//added by zhengdy-soc if(!Symmetry::symm_flag) return; #ifdef __MPI // parallel version - psymm(CHR.rho[spin_now]); + psymm(CHR.rho[spin_now], pw, Pgrid, symm); #else // series version. symm.rho_symmetry(CHR.rho[spin_now], pw.ncx, pw.ncy, pw.ncz); @@ -26,7 +26,7 @@ void Symmetry_rho::begin(const int &spin_now) const return; } -void Symmetry_rho::psymm(double* rho_part) const +void Symmetry_rho::psymm(double* rho_part, PW_Basis &pw, Parallel_Grid &Pgrid, Symmetry &symm) const { #ifdef __MPI // (1) reduce all rho from the first pool. diff --git a/source/module_symmetry/symmetry_rho.h b/source/module_symmetry/symmetry_rho.h index 015d5f7401..4b184d47a7 100644 --- a/source/module_symmetry/symmetry_rho.h +++ b/source/module_symmetry/symmetry_rho.h @@ -1,5 +1,8 @@ #ifndef SYMMETRY_RHO_H #define SYMMETRY_RHO_H +#include "../src_pw/charge_broyden.h" +#include "../src_pw/pw_basis.h" +#include "../src_parallel/parallel_grid.h" #include "symmetry.h" @@ -9,11 +12,11 @@ class Symmetry_rho Symmetry_rho(); ~Symmetry_rho(); - void begin(const int &spin_now) const; + void begin(const int &spin_now, const Charge_Broyden &CHR, PW_Basis &pw, Parallel_Grid &Pgrid, Symmetry &symm) const; private: - void psymm(double *rho_part) const; + void psymm(double *rho_part, PW_Basis &pw, Parallel_Grid &Pgrid, Symmetry &symm) const; }; diff --git a/source/run_lcao.cpp b/source/run_lcao.cpp index 392e61467a..79492fe140 100644 --- a/source/run_lcao.cpp +++ b/source/run_lcao.cpp @@ -61,7 +61,7 @@ void Run_lcao::lcao_line(void) // symmetry analysis should be performed every time the cell is changed if (Symmetry::symm_flag) { - symm.analy_sys(); + symm.analy_sys(ucell, out); DONE(ofs_running, "SYMMETRY"); } diff --git a/source/run_pw.cpp b/source/run_pw.cpp index 5c23bb46a6..b239e9671a 100644 --- a/source/run_pw.cpp +++ b/source/run_pw.cpp @@ -44,7 +44,7 @@ void Run_pw::plane_wave_line(void) // symmetry analysis should be performed every time the cell is changed if (Symmetry::symm_flag) { - symm.analy_sys(); + symm.analy_sys(ucell, out); DONE(ofs_running, "SYMMETRY"); } diff --git a/source/src_io/output.h b/source/src_io/output.h index a60a0a7035..fa630aab2c 100644 --- a/source/src_io/output.h +++ b/source/src_io/output.h @@ -5,8 +5,10 @@ #ifndef OUTPUT_H #define OUTPUT_H -#include "../src_pw/tools.h" - +//#include "../src_pw/tools.h" +#include "../module_base/realarray.h" +#include "../module_base/matrix3.h" +#include "../module_base/complexmatrix.h" class output { public: diff --git a/source/src_ions/variable_cell.cpp b/source/src_ions/variable_cell.cpp index 63ad28ad84..9cabd17ec3 100644 --- a/source/src_ions/variable_cell.cpp +++ b/source/src_ions/variable_cell.cpp @@ -14,7 +14,7 @@ void Variable_Cell::init_after_vc(void) if(Symmetry::symm_flag) { - symm.analy_sys(); + symm.analy_sys(ucell, out); DONE(ofs_running, "SYMMETRY"); } @@ -78,7 +78,7 @@ void Variable_Cell::final_calculation_after_vc(void) // (6) symmetry analysize. if(Symmetry::symm_flag) { - symm.analy_sys(); + symm.analy_sys(ucell, out); DONE(ofs_running, "SYMMETRY"); } diff --git a/source/src_lcao/ELEC_scf.cpp b/source/src_lcao/ELEC_scf.cpp index 461c25dbf4..cb02999945 100644 --- a/source/src_lcao/ELEC_scf.cpp +++ b/source/src_lcao/ELEC_scf.cpp @@ -37,7 +37,7 @@ void ELEC_scf::scf(const int &istep) Symmetry_rho srho; for(int is=0; isprint(ofs_running, "nonlocal stress", stresnl); diff --git a/source/src_pw/stress_pw.cpp b/source/src_pw/stress_pw.cpp index db9589a351..a9a657ff5b 100644 --- a/source/src_pw/stress_pw.cpp +++ b/source/src_pw/stress_pw.cpp @@ -96,7 +96,7 @@ void Stress_PW::cal_stress(matrix& sigmatot) if(Symmetry::symm_flag) { - symm.stress_symmetry(sigmatot); + symm.stress_symmetry(sigmatot, ucell); } bool ry = false; From 3c75ce892c8e4ebf0db9f35f39d7decea86a3f13 Mon Sep 17 00:00:00 2001 From: Liu-RX Date: Sun, 18 Jul 2021 17:31:11 +0800 Subject: [PATCH 3/5] add const to all class varibable inputs, fix CMakelist.txt in module_symmetry --- source/module_symmetry/CMakeLists.txt | 2 +- source/module_symmetry/symmetry.cpp | 2 +- source/module_symmetry/symmetry.h | 2 +- source/module_symmetry/symmetry_rho.cpp | 4 ++-- source/module_symmetry/symmetry_rho.h | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/source/module_symmetry/CMakeLists.txt b/source/module_symmetry/CMakeLists.txt index 95fa96db2f..d4024385f6 100644 --- a/source/module_symmetry/CMakeLists.txt +++ b/source/module_symmetry/CMakeLists.txt @@ -1,5 +1,5 @@ add_library( - base + symmetry OBJECT symm_other.cpp symmetry_basic.cpp diff --git a/source/module_symmetry/symmetry.cpp b/source/module_symmetry/symmetry.cpp index df8fd75d47..b4275248e3 100644 --- a/source/module_symmetry/symmetry.cpp +++ b/source/module_symmetry/symmetry.cpp @@ -18,7 +18,7 @@ Symmetry::~Symmetry() bool Symmetry::symm_flag=false; -void Symmetry::analy_sys(const UnitCell_pseudo &ucell, output &out) +void Symmetry::analy_sys(const UnitCell_pseudo &ucell, const output &out) { if (available == false) return; TITLE("Symmetry","init"); diff --git a/source/module_symmetry/symmetry.h b/source/module_symmetry/symmetry.h index 9a3570f366..37fa8bf590 100644 --- a/source/module_symmetry/symmetry.h +++ b/source/module_symmetry/symmetry.h @@ -15,7 +15,7 @@ class Symmetry : public Symmetry_Basic // mohan add 2021-02-21 static bool symm_flag; - void analy_sys(const UnitCell_pseudo &ucell, output &out); + void analy_sys(const UnitCell_pseudo &ucell, const output &out); bool available; Vector3 s1, s2, s3; diff --git a/source/module_symmetry/symmetry_rho.cpp b/source/module_symmetry/symmetry_rho.cpp index 52e2ad1b2f..dffd605b13 100644 --- a/source/module_symmetry/symmetry_rho.cpp +++ b/source/module_symmetry/symmetry_rho.cpp @@ -11,7 +11,7 @@ Symmetry_rho::~Symmetry_rho() } -void Symmetry_rho::begin(const int &spin_now, const Charge_Broyden &CHR, PW_Basis &pw, Parallel_Grid &Pgrid, Symmetry &symm) const +void Symmetry_rho::begin(const int &spin_now, const Charge_Broyden &CHR, const PW_Basis &pw, const Parallel_Grid &Pgrid, const Symmetry &symm) const { assert(spin_now < 4);//added by zhengdy-soc @@ -26,7 +26,7 @@ void Symmetry_rho::begin(const int &spin_now, const Charge_Broyden &CHR, PW_Basi return; } -void Symmetry_rho::psymm(double* rho_part, PW_Basis &pw, Parallel_Grid &Pgrid, Symmetry &symm) const +void Symmetry_rho::psymm(double* rho_part, const PW_Basis &pw, const Parallel_Grid &Pgrid, const Symmetry &symm) const { #ifdef __MPI // (1) reduce all rho from the first pool. diff --git a/source/module_symmetry/symmetry_rho.h b/source/module_symmetry/symmetry_rho.h index 4b184d47a7..9a3eb73b31 100644 --- a/source/module_symmetry/symmetry_rho.h +++ b/source/module_symmetry/symmetry_rho.h @@ -12,11 +12,11 @@ class Symmetry_rho Symmetry_rho(); ~Symmetry_rho(); - void begin(const int &spin_now, const Charge_Broyden &CHR, PW_Basis &pw, Parallel_Grid &Pgrid, Symmetry &symm) const; + void begin(const int &spin_now, const Charge_Broyden &CHR, const PW_Basis &pw, const Parallel_Grid &Pgrid, const Symmetry &symm) const; private: - void psymm(double *rho_part, PW_Basis &pw, Parallel_Grid &Pgrid, Symmetry &symm) const; + void psymm(double *rho_part, const PW_Basis &pw, const Parallel_Grid &Pgrid, const Symmetry &symm) const; }; From 93d94eb4651d9883940af68b1169badfde2e0751 Mon Sep 17 00:00:00 2001 From: Liu-RX Date: Sun, 18 Jul 2021 18:01:50 +0800 Subject: [PATCH 4/5] fix CMakeList.txt in root dir --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index b6bd57ee92..c92fb8c45d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -112,6 +112,7 @@ add_executable(${ABACUS_BIN_NAME} target_link_libraries(${ABACUS_BIN_NAME} base cell + symmetry md neighbor orb From 5b58803d0ade702eee3649a8299e1a83e7607a01 Mon Sep 17 00:00:00 2001 From: Liu-RX Date: Sun, 18 Jul 2021 21:56:22 +0800 Subject: [PATCH 5/5] fix CMakeList.txt in src_pw --- source/src_pw/CMakeLists.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/source/src_pw/CMakeLists.txt b/source/src_pw/CMakeLists.txt index 8ca34b6f2f..b7d50ba386 100644 --- a/source/src_pw/CMakeLists.txt +++ b/source/src_pw/CMakeLists.txt @@ -42,10 +42,6 @@ add_library( stress_func_nl.cpp stress_func_print.cpp stress_pw.cpp - symm_other.cpp - symmetry.cpp - symmetry_basic.cpp - symmetry_rho.cpp threshold_elec.cpp use_fft.cpp vdwd2.cpp