Skip to content

Commit 1346e96

Browse files
committed
1. change Exx::cal_stress() to loop3
1 parent c267b74 commit 1346e96

File tree

2 files changed

+98
-3
lines changed

2 files changed

+98
-3
lines changed

include/RI/physics/Exx.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ class Exx
5858
const std::array<std::map<TA, std::map<TAC, Tensor<Tdata>>>,Npos> &dVs,
5959
const Tdata_real &threshold_dV,
6060
const std::string &save_name_suffix="");
61+
void set_dCRs(
62+
const std::array<std::array<std::map<TA, std::map<TAC, Tensor<Tdata>>>,Npos>,Npos> &dCRs,
63+
const Tdata_real &threshold_dCR,
64+
const std::string &save_name_suffix="");
65+
void set_dVRs(
66+
const std::array<std::array<std::map<TA, std::map<TAC, Tensor<Tdata>>>,Npos>,Npos> &dVRs,
67+
const Tdata_real &threshold_dVR,
68+
const std::string &save_name_suffix="");
6169
void set_csm_threshold(
6270
const Tdata_real &threshold) { this->lri.csm.set_threshold(threshold); }
6371

@@ -66,7 +74,7 @@ class Exx
6674
void cal_force(
6775
const std::array<std::string,5> &save_names_suffix={"","","","",""}); // "Cs","Vs","Ds","dCs","dVs"
6876
void cal_stress(
69-
const std::array<std::string,5> &save_names_suffix={"","","","",""}); // "Cs","Vs","Ds","dCs","dVs"
77+
const std::array<std::string,5> &save_names_suffix={"","","","",""}); // "Cs","Vs","Ds","dCRs","dVRs"
7078

7179
std::map<TA, std::map<TAC, Tensor<Tdata>>> Hs;
7280
Tdata energy = 0;
@@ -87,6 +95,8 @@ class Exx
8795
bool D_delta=false;
8896
bool dC=false;
8997
bool dV=false;
98+
bool dCR=false;
99+
bool dVR=false;
90100
};
91101
Flag_Finish flag_finish;
92102

include/RI/physics/Exx.hpp

Lines changed: 87 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

149178
template<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+
/*
291321
template<typename TA, typename Tcell, std::size_t Ndim, typename Tdata>
292322
void 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

Comments
 (0)