From 81f5fc7a2249ee2952cb9d1416aa51dde838526d Mon Sep 17 00:00:00 2001 From: dyzheng Date: Tue, 6 Jun 2023 12:35:44 +0800 Subject: [PATCH 1/2] Fix: optimized printing of start magnetization --- source/module_base/global_function.h | 8 +--- .../module_base/test/global_function_test.cpp | 4 +- source/module_cell/read_atoms.cpp | 37 +++++++++++++++---- 3 files changed, 33 insertions(+), 16 deletions(-) diff --git a/source/module_base/global_function.h b/source/module_base/global_function.h index fa77c76b26..358454cc1d 100644 --- a/source/module_base/global_function.h +++ b/source/module_base/global_function.h @@ -49,9 +49,7 @@ void OUT(std::ofstream &ofs,const std::string &name,const T &a) template void OUT(std::ofstream &ofs,const std::string &name,const T &x, const T&y) { - std::stringstream name2; - name2 << "[" << name << "]"; - ofs<< " " << std::setw(40) < void OUT(std::ofstream &ofs,const std::string &name,const T &x, const T &y, const T &z) { - std::stringstream name2; - name2 << "[" << name << "]"; - ofs<< " " << std::setw(40) <0 to avoid too much output + //print when ia!=0 && mag[ia] != mag[0] to avoid too much output + if(ia==0 || (ia!=0 + && (atoms[it].m_loc_[ia].x != atoms[it].m_loc_[0].x + || atoms[it].m_loc_[ia].y != atoms[it].m_loc_[0].y + || atoms[it].m_loc_[ia].z != atoms[it].m_loc_[0].z))) + { + //use a stringstream to generate string: "concollinear magnetization of element it is:" + std::stringstream ss; + ss << "magnetization of element " << it+1; + if(ia!=0) + { + ss<<" (atom"<0 to avoid too much output + //print when ia!=0 && mag[ia] != mag[0] to avoid too much output + if(ia==0 || (ia!=0 && atoms[it].mag[ia] != atoms[it].mag[0])) + { + //use a stringstream to generate string: "cocollinear magnetization of element it is:" + std::stringstream ss; + ss << "magnetization of element " << it+1; + if(ia!=0) + { + ss<<" (atom"< Date: Tue, 6 Jun 2023 12:39:26 +0800 Subject: [PATCH 2/2] Fix: update refs in examples --- .../Pt-slab/running_scf.ref | 27 ------------------- .../Pt-slab/running_scf.ref1 | 27 ------------------- .../Pt-slab/running_scf.ref2 | 27 ------------------- .../electric_field/Pt-slab/running_scf.ref | 27 ------------------- examples/hse/lcao_Si2/running_scf.log_ref | 2 -- 5 files changed, 110 deletions(-) diff --git a/examples/compensating_charge/Pt-slab/running_scf.ref b/examples/compensating_charge/Pt-slab/running_scf.ref index c3a70e0684..7534bfc886 100644 --- a/examples/compensating_charge/Pt-slab/running_scf.ref +++ b/examples/compensating_charge/Pt-slab/running_scf.ref @@ -55,33 +55,6 @@ L=1, number of zeta = 1 L=2, number of zeta = 1 number of atom for this type = 27 - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE TOTAL ATOM NUMBER = 27 diff --git a/examples/dipole_correction/Pt-slab/running_scf.ref1 b/examples/dipole_correction/Pt-slab/running_scf.ref1 index 6e739912b5..f53ed349bb 100644 --- a/examples/dipole_correction/Pt-slab/running_scf.ref1 +++ b/examples/dipole_correction/Pt-slab/running_scf.ref1 @@ -56,33 +56,6 @@ L=1, number of zeta = 1 L=2, number of zeta = 1 number of atom for this type = 27 - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE TOTAL ATOM NUMBER = 27 diff --git a/examples/dipole_correction/Pt-slab/running_scf.ref2 b/examples/dipole_correction/Pt-slab/running_scf.ref2 index f06d639ec1..63692a7f6b 100644 --- a/examples/dipole_correction/Pt-slab/running_scf.ref2 +++ b/examples/dipole_correction/Pt-slab/running_scf.ref2 @@ -56,33 +56,6 @@ L=1, number of zeta = 1 L=2, number of zeta = 1 number of atom for this type = 27 - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE TOTAL ATOM NUMBER = 27 diff --git a/examples/electric_field/Pt-slab/running_scf.ref b/examples/electric_field/Pt-slab/running_scf.ref index 9106c25e76..a06f820c69 100644 --- a/examples/electric_field/Pt-slab/running_scf.ref +++ b/examples/electric_field/Pt-slab/running_scf.ref @@ -56,33 +56,6 @@ L=1, number of zeta = 1 L=2, number of zeta = 1 number of atom for this type = 27 - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE - start magnetization = FALSE TOTAL ATOM NUMBER = 27 diff --git a/examples/hse/lcao_Si2/running_scf.log_ref b/examples/hse/lcao_Si2/running_scf.log_ref index 6fe86a4053..507b7bb9a7 100644 --- a/examples/hse/lcao_Si2/running_scf.log_ref +++ b/examples/hse/lcao_Si2/running_scf.log_ref @@ -56,8 +56,6 @@ L=1, number of zeta = 2 L=2, number of zeta = 1 number of atom for this type = 2 - start magnetization = FALSE - start magnetization = FALSE TOTAL ATOM NUMBER = 2