@@ -120,13 +120,11 @@ void Exx<TA,Tcell,Ndim,Tdata>::set_dCs(
120120 const std::string &save_name_suffix)
121121{
122122 for (std::size_t ipos=0 ; ipos<Npos; ++ipos)
123- {
124123 this ->lri .set_tensors_map2 (
125124 dCs[ipos],
126125 {Label::ab::a, Label::ab::b},
127126 {{" threshold_filter" , threshold_dC}},
128127 " dCs_" +std::to_string (ipos)+" _" +save_name_suffix );
129- }
130128 this ->flag_finish .dC = true ;
131129}
132130
@@ -144,6 +142,37 @@ void Exx<TA,Tcell,Ndim,Tdata>::set_dVs(
144142 " dVs_" +std::to_string (ipos)+" _" +save_name_suffix );
145143 this ->flag_finish .dV = true ;
146144}
145+ template <typename TA, typename Tcell, std::size_t Ndim, typename Tdata>
146+ void Exx<TA,Tcell,Ndim,Tdata>::set_dCRs(
147+ const std::array<std::array<std::map<TA, std::map<TAC, Tensor<Tdata>>>,Npos>,Npos> &dCRs,
148+ const Tdata_real &threshold_dCR,
149+ const std::string &save_name_suffix)
150+ {
151+ for (std::size_t ipos0=0 ; ipos0<Npos; ++ipos0)
152+ for (std::size_t ipos1=0 ; ipos1<Npos; ++ipos1)
153+ this ->lri .set_tensors_map2 (
154+ dCRs[ipos0][ipos1],
155+ {Label::ab::a, Label::ab::b},
156+ {{" threshold_filter" , threshold_dCR}},
157+ " dCRs_" +std::to_string (ipos0)+" _" +std::to_string (ipos1)+" _" +save_name_suffix );
158+ this ->flag_finish .dCR = true ;
159+ }
160+
161+ template <typename TA, typename Tcell, std::size_t Ndim, typename Tdata>
162+ void Exx<TA,Tcell,Ndim,Tdata>::set_dVRs(
163+ const std::array<std::array<std::map<TA, std::map<TAC, Tensor<Tdata>>>,Npos>,Npos> &dVRs,
164+ const Tdata_real &threshold_dVR,
165+ const std::string &save_name_suffix)
166+ {
167+ for (std::size_t ipos0=0 ; ipos0<Npos; ++ipos0)
168+ for (std::size_t ipos1=0 ; ipos1<Npos; ++ipos1)
169+ this ->lri .set_tensors_map2 (
170+ dVRs[ipos0][ipos1],
171+ {Label::ab::a0b0},
172+ {{" threshold_filter" , threshold_dVR}},
173+ " dVRs_" +std::to_string (ipos0)+" _" +std::to_string (ipos1)+" _" +save_name_suffix );
174+ this ->flag_finish .dVR = true ;
175+ }
147176
148177
149178template <typename TA, typename Tcell, std::size_t Ndim, typename Tdata>
@@ -288,6 +317,7 @@ void Exx<TA,Tcell,Ndim,Tdata>::cal_force(
288317}
289318
290319
320+ /*
291321template<typename TA, typename Tcell, std::size_t Ndim, typename Tdata>
292322void Exx<TA,Tcell,Ndim,Tdata>::cal_stress(
293323 const std::array<std::string,5> &save_names_suffix) // "Cs","Vs","Ds","dCs","dVs"
@@ -371,5 +401,60 @@ void Exx<TA,Tcell,Ndim,Tdata>::cal_stress(
371401 this->post_2D.set_tensors_map2(dHs_vec[ipos1]));
372402 }
373403}
404+ */
405+
406+
407+ template <typename TA, typename Tcell, std::size_t Ndim, typename Tdata>
408+ void Exx<TA,Tcell,Ndim,Tdata>::cal_stress(
409+ const std::array<std::string,5 > &save_names_suffix) // "Cs","Vs","Ds","dCRs","dVRs"
410+ {
411+ assert (this ->flag_finish .stru );
412+ assert (this ->flag_finish .C );
413+ assert (this ->flag_finish .V );
414+ assert (this ->flag_finish .D );
415+ assert (this ->flag_finish .dCR );
416+ assert (this ->flag_finish .dVR );
417+
418+ this ->stress = Tensor<Tdata>({Npos, Npos});
419+
420+ this ->lri .data_ab_name [Label::ab::a1b1] = this ->lri .data_ab_name [Label::ab::a2b1] = " Ds_" +save_names_suffix[2 ];
421+ for (std::size_t ipos0=0 ; ipos0<Npos; ++ipos0)
422+ for (std::size_t ipos1=0 ; ipos1<Npos; ++ipos1)
423+ {
424+ std::vector<std::map<TA,std::map<TAC,Tensor<Tdata>>>> dHs_vec (1 );
425+
426+ this ->lri .data_ab_name [Label::ab::a ] = " dCRs_" +std::to_string (ipos0)+" _" +std::to_string (ipos1)+" _" +save_names_suffix[3 ];
427+ this ->lri .data_ab_name [Label::ab::a0b0] = " Vs_" +save_names_suffix[1 ];
428+ this ->lri .data_ab_name [Label::ab::b ] = " Cs_" +save_names_suffix[0 ];
429+
430+ this ->lri .cal_loop3 (
431+ {Label::ab_ab::a0b0_a1b1,
432+ Label::ab_ab::a0b0_a2b1},
433+ dHs_vec,
434+ 1.0 );
435+
436+ this ->lri .data_ab_name [Label::ab::a ] = " Cs_" +save_names_suffix[0 ];
437+ this ->lri .data_ab_name [Label::ab::a0b0] = " dVRs_" +std::to_string (ipos0)+" _" +std::to_string (ipos1)+" _" +save_names_suffix[4 ];
438+
439+ this ->lri .cal_loop3 (
440+ {Label::ab_ab::a0b0_a1b1,
441+ Label::ab_ab::a0b0_a2b1},
442+ dHs_vec,
443+ 1.0 );
444+
445+ this ->lri .data_ab_name [Label::ab::a0b0] = " Vs_" +save_names_suffix[1 ];
446+ this ->lri .data_ab_name [Label::ab::b ] = " dCRs_" +std::to_string (ipos0)+" _" +std::to_string (ipos1)+" _" +save_names_suffix[3 ];
447+
448+ this ->lri .cal_loop3 (
449+ {Label::ab_ab::a0b0_a1b1,
450+ Label::ab_ab::a0b0_a2b1},
451+ dHs_vec,
452+ 1.0 );
453+
454+ this ->stress (ipos0,ipos1) = post_2D.cal_energy (
455+ this ->post_2D .saves [" Ds_" +save_names_suffix[2 ]],
456+ this ->post_2D .set_tensors_map2 (dHs_vec[0 ]));
457+ }
458+ }
374459
375460}
0 commit comments