1818#include < stdexcept>
1919#include < string>
2020
21+ /*
2122template<typename T, typename Tdata>
2223void Exx_LRI_Interface<T, Tdata>::write_Hexxs_cereal(const std::string& file_name) const
2324{
@@ -34,11 +35,15 @@ void Exx_LRI_Interface<T, Tdata>::read_Hexxs_cereal(const std::string& file_name
3435{
3536 ModuleBase::TITLE("Exx_LRI_Interface", "read_Hexxs_cereal");
3637 ModuleBase::timer::tick("Exx_LRI_Interface", "read_Hexxs_cereal");
37- std::ifstream ifs (file_name + " _" + std::to_string (GlobalV::MY_RANK), std::ofstream::binary);
38+ const std::string file_name_rank = file_name + "_" + std::to_string(GlobalV::MY_RANK);
39+ std::ifstream ifs(file_name_rank, std::ofstream::binary);
40+ if(!ifs.is_open())
41+ { ModuleBase::WARNING_QUIT("Exx_LRI_Interface", file_name_rank+" not found."); }
3842 cereal::BinaryInputArchive iar(ifs);
3943 iar(this->exx_ptr->Hexxs);
4044 ModuleBase::timer::tick("Exx_LRI_Interface", "read_Hexxs_cereal");
4145}
46+ */
4247
4348template <typename T, typename Tdata>
4449void Exx_LRI_Interface<T, Tdata>::init(const MPI_Comm &mpi_comm,
@@ -70,11 +75,11 @@ void Exx_LRI_Interface<T, Tdata>::cal_exx_elec(const std::vector<std::map<TA, st
7075 const ModuleSymmetry::Symmetry_rotation* p_symrot)
7176{
7277 ModuleBase::TITLE (" Exx_LRI_Interface" ," cal_exx_elec" );
73- if (!this ->flag_finish .init || !this ->flag_finish .ions )
74- {
75- throw std::runtime_error (" Exx init unfinished when "
78+ if (!this ->flag_finish .init || !this ->flag_finish .ions )
79+ {
80+ throw std::runtime_error (" Exx init unfinished when "
7681 +std::string (__FILE__)+" line " +std::to_string (__LINE__));
77- }
82+ }
7883
7984 this ->exx_ptr ->cal_exx_elec (Ds, ucell, pv, p_symrot);
8085
@@ -85,15 +90,15 @@ template<typename T, typename Tdata>
8590void Exx_LRI_Interface<T, Tdata>::cal_exx_force(const int & nat)
8691{
8792 ModuleBase::TITLE (" Exx_LRI_Interface" ," cal_exx_force" );
88- if (!this ->flag_finish .init || !this ->flag_finish .ions )
89- {
90- throw std::runtime_error (" Exx init unfinished when " +std::string (__FILE__)+" line " +std::to_string (__LINE__));
91- }
92- if (!this ->flag_finish .elec )
93- {
94- throw std::runtime_error (" Exx Hamiltonian unfinished when " +std::string (__FILE__)
93+ if (!this ->flag_finish .init || !this ->flag_finish .ions )
94+ {
95+ throw std::runtime_error (" Exx init unfinished when " +std::string (__FILE__)+" line " +std::to_string (__LINE__));
96+ }
97+ if (!this ->flag_finish .elec )
98+ {
99+ throw std::runtime_error (" Exx Hamiltonian unfinished when " +std::string (__FILE__)
95100 +" line " +std::to_string (__LINE__));
96- }
101+ }
97102
98103 this ->exx_ptr ->cal_exx_force (nat);
99104
@@ -104,33 +109,36 @@ template<typename T, typename Tdata>
104109void Exx_LRI_Interface<T, Tdata>::cal_exx_stress(const double & omega, const double & lat0)
105110{
106111 ModuleBase::TITLE (" Exx_LRI_Interface" ," cal_exx_stress" );
107- if (!this ->flag_finish .init || !this ->flag_finish .ions )
108- {
109- throw std::runtime_error (" Exx init unfinished when "
110- +std::string (__FILE__)+" line " +std::to_string (__LINE__));
111- }
112- if (!this ->flag_finish .elec )
113- {
114- throw std::runtime_error (" Exx Hamiltonian unfinished when "
115- +std::string (__FILE__)+" line " +std::to_string (__LINE__));
116- }
112+ if (!this ->flag_finish .init || !this ->flag_finish .ions )
113+ {
114+ throw std::runtime_error (" Exx init unfinished when "
115+ +std::string (__FILE__)+" line " +std::to_string (__LINE__));
116+ }
117+ if (!this ->flag_finish .elec )
118+ {
119+ throw std::runtime_error (" Exx Hamiltonian unfinished when "
120+ +std::string (__FILE__)+" line " +std::to_string (__LINE__));
121+ }
117122
118123 this ->exx_ptr ->cal_exx_stress (omega, lat0);
119124
120125 this ->flag_finish .stress = true ;
121126}
122127
123128template <typename T, typename Tdata>
124- void Exx_LRI_Interface<T, Tdata>::exx_before_all_runners(const K_Vectors& kv,
125- const UnitCell& ucell, const Parallel_2D& pv)
129+ void Exx_LRI_Interface<T, Tdata>::exx_before_all_runners(
130+ const K_Vectors& kv,
131+ const UnitCell& ucell,
132+ const Parallel_2D& pv)
126133{
127134 ModuleBase::TITLE (" Exx_LRI_Interface" ," exx_before_all_runners" );
128135 // initialize the rotation matrix in AO representation
129136 this ->exx_spacegroup_symmetry = (PARAM.inp .nspin < 4 && ModuleSymmetry::Symmetry::symm_flag == 1 );
130137 if (this ->exx_spacegroup_symmetry )
131138 {
132139 const std::array<int , 3 >& period = RI_Util::get_Born_vonKarmen_period (kv);
133- this ->symrot_ .find_irreducible_sector (ucell.symm , ucell.atoms , ucell.st ,
140+ this ->symrot_ .find_irreducible_sector (
141+ ucell.symm , ucell.atoms , ucell.st ,
134142 RI_Util::get_Born_von_Karmen_cells (period), period, ucell.lat );
135143 // this->symrot_.set_Cs_rotation(this->exx_ptr->get_abfs_nchis());
136144 this ->symrot_ .cal_Ms (kv, ucell, pv);
@@ -233,18 +241,18 @@ void Exx_LRI_Interface<T, Tdata>::exx_eachiterinit(const int istep,
233241 const std::vector<std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>>
234242 Ds = PARAM.globalv .gamma_only_local
235243 ? RI_2D_Comm::split_m2D_ktoR<Tdata>(
236- ucell,
237- *this ->exx_ptr ->p_kv ,
238- this ->mix_DMk_2D .get_DMk_gamma_out (),
239- *dm_in.get_paraV_pointer (),
240- PARAM.inp .nspin )
244+ ucell,
245+ *this ->exx_ptr ->p_kv ,
246+ this ->mix_DMk_2D .get_DMk_gamma_out (),
247+ *dm_in.get_paraV_pointer (),
248+ PARAM.inp .nspin )
241249 : RI_2D_Comm::split_m2D_ktoR<Tdata>(
242- ucell,
243- *this ->exx_ptr ->p_kv ,
244- this ->mix_DMk_2D .get_DMk_k_out (),
245- *dm_in.get_paraV_pointer (),
246- PARAM.inp .nspin ,
247- this ->exx_spacegroup_symmetry );
250+ ucell,
251+ *this ->exx_ptr ->p_kv ,
252+ this ->mix_DMk_2D .get_DMk_k_out (),
253+ *dm_in.get_paraV_pointer (),
254+ PARAM.inp .nspin ,
255+ this ->exx_spacegroup_symmetry );
248256
249257 if (this ->exx_spacegroup_symmetry && GlobalC::exx_info.info_global .exx_symmetry_realspace )
250258 { this ->cal_exx_elec (Ds, ucell,*dm_in.get_paraV_pointer (), &this ->symrot_ ); }
@@ -274,11 +282,10 @@ void Exx_LRI_Interface<T, Tdata>::exx_hamilt2rho(elecstate::ElecState& elec, con
274282 {
275283 if (GlobalV::MY_RANK == 0 )
276284 {
277- try { GlobalC::restart.load_disk (" Eexx" , 0 , 1 , &this ->exx_ptr ->Eexx ); }
285+ try
286+ { GlobalC::restart.load_disk (" Eexx" , 0 , 1 , &this ->exx_ptr ->Eexx ); }
278287 catch (const std::exception& e)
279- {
280- std::cout << " WARNING: Cannot read Eexx from disk, the energy of the 1st loop will be wrong, sbut it does not influence the subsequent loops." << std::endl;
281- }
288+ { std::cout << " WARNING: Cannot read Eexx from disk, the energy of the 1st loop will be wrong, sbut it does not influence the subsequent loops." << std::endl; }
282289 }
283290 Parallel_Common::bcast_double (this ->exx_ptr ->Eexx );
284291 this ->exx_ptr ->Eexx /= GlobalC::exx_info.info_global .hybrid_alpha ;
0 commit comments