18
18
#include < stdexcept>
19
19
#include < string>
20
20
21
+ /*
21
22
template<typename T, typename Tdata>
22
23
void Exx_LRI_Interface<T, Tdata>::write_Hexxs_cereal(const std::string& file_name) const
23
24
{
@@ -34,11 +35,15 @@ void Exx_LRI_Interface<T, Tdata>::read_Hexxs_cereal(const std::string& file_name
34
35
{
35
36
ModuleBase::TITLE("Exx_LRI_Interface", "read_Hexxs_cereal");
36
37
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."); }
38
42
cereal::BinaryInputArchive iar(ifs);
39
43
iar(this->exx_ptr->Hexxs);
40
44
ModuleBase::timer::tick("Exx_LRI_Interface", "read_Hexxs_cereal");
41
45
}
46
+ */
42
47
43
48
template <typename T, typename Tdata>
44
49
void 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
70
75
const ModuleSymmetry::Symmetry_rotation* p_symrot)
71
76
{
72
77
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 "
76
81
+std::string (__FILE__)+" line " +std::to_string (__LINE__));
77
- }
82
+ }
78
83
79
84
this ->exx_ptr ->cal_exx_elec (Ds, ucell, pv, p_symrot);
80
85
@@ -85,15 +90,15 @@ template<typename T, typename Tdata>
85
90
void Exx_LRI_Interface<T, Tdata>::cal_exx_force(const int & nat)
86
91
{
87
92
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__)
95
100
+" line " +std::to_string (__LINE__));
96
- }
101
+ }
97
102
98
103
this ->exx_ptr ->cal_exx_force (nat);
99
104
@@ -104,33 +109,36 @@ template<typename T, typename Tdata>
104
109
void Exx_LRI_Interface<T, Tdata>::cal_exx_stress(const double & omega, const double & lat0)
105
110
{
106
111
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
+ }
117
122
118
123
this ->exx_ptr ->cal_exx_stress (omega, lat0);
119
124
120
125
this ->flag_finish .stress = true ;
121
126
}
122
127
123
128
template <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)
126
133
{
127
134
ModuleBase::TITLE (" Exx_LRI_Interface" ," exx_before_all_runners" );
128
135
// initialize the rotation matrix in AO representation
129
136
this ->exx_spacegroup_symmetry = (PARAM.inp .nspin < 4 && ModuleSymmetry::Symmetry::symm_flag == 1 );
130
137
if (this ->exx_spacegroup_symmetry )
131
138
{
132
139
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 ,
134
142
RI_Util::get_Born_von_Karmen_cells (period), period, ucell.lat );
135
143
// this->symrot_.set_Cs_rotation(this->exx_ptr->get_abfs_nchis());
136
144
this ->symrot_ .cal_Ms (kv, ucell, pv);
@@ -233,18 +241,18 @@ void Exx_LRI_Interface<T, Tdata>::exx_eachiterinit(const int istep,
233
241
const std::vector<std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>>
234
242
Ds = PARAM.globalv .gamma_only_local
235
243
? 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 )
241
249
: 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 );
248
256
249
257
if (this ->exx_spacegroup_symmetry && GlobalC::exx_info.info_global .exx_symmetry_realspace )
250
258
{ 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
274
282
{
275
283
if (GlobalV::MY_RANK == 0 )
276
284
{
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 ); }
278
287
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; }
282
289
}
283
290
Parallel_Common::bcast_double (this ->exx_ptr ->Eexx );
284
291
this ->exx_ptr ->Eexx /= GlobalC::exx_info.info_global .hybrid_alpha ;
0 commit comments