-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathExx.h
More file actions
136 lines (116 loc) · 4.44 KB
/
Copy pathExx.h
File metadata and controls
136 lines (116 loc) · 4.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// ===================
// Author: Peize Lin
// date: 2022.06.02
// ===================
#pragma once
#include "Exx_Post_2D.h"
#include "../global/Global_Func-2.h"
#include "../global/Tensor.h"
#include "../ri/LRI.h"
#include <mpi.h>
#include <array>
#include <map>
#include <set>
namespace RI
{
template<typename TA, typename Tcell, std::size_t Ndim, typename Tdata>
class Exx
{
public:
using TC = std::array<Tcell,Ndim>;
using TAC = std::pair<TA,TC>;
using Tdata_real = Global_Func::To_Real_t<Tdata>;
using Tpos = double; // tmp
constexpr static std::size_t Npos = Ndim; // tmp
using Tatom_pos = std::array<Tpos,Npos>; // tmp
void set_parallel(
const MPI_Comm &mpi_comm,
const std::map<TA,Tatom_pos> &atoms_pos,
const std::array<Tatom_pos,Ndim> &latvec,
const std::array<Tcell,Ndim> &period);
void set_symmetry(
const bool flag_symmetry,
const std::map<std::pair<TA,TA>, std::set<TC>> &irreducible_sector);
void set_Cs(
const std::map<TA, std::map<TAC, Tensor<Tdata>>> &Cs,
const Tdata_real &threshold,
const std::string &save_name_suffix="");
void set_Vs(
const std::map<TA, std::map<TAC, Tensor<Tdata>>> &Vs,
const Tdata_real &threshold,
const std::string &save_name_suffix="");
void set_Ds(
const std::map<TA, std::map<TAC, Tensor<Tdata>>> &Ds,
const Tdata_real &threshold,
const std::string &save_name_suffix="");
void set_Ds_delta(
const std::map<TA, std::map<TAC, Tensor<Tdata>>> &Ds,
const Tdata_real &threshold,
const std::string &save_name_suffix="");
void set_dCs(
const std::array<std::map<TA, std::map<TAC, Tensor<Tdata>>>,Npos> &dCs,
const Tdata_real &threshold,
const std::string &save_name_suffix="");
void set_dVs(
const std::array<std::map<TA, std::map<TAC, Tensor<Tdata>>>,Npos> &dVs,
const Tdata_real &threshold,
const std::string &save_name_suffix="");
void set_dCRs(
const std::array<std::array<std::map<TA, std::map<TAC, Tensor<Tdata>>>,Npos>,Npos> &dCRs,
const Tdata_real &threshold,
const std::string &save_name_suffix="");
void set_dVRs(
const std::array<std::array<std::map<TA, std::map<TAC, Tensor<Tdata>>>,Npos>,Npos> &dVRs,
const Tdata_real &threshold,
const std::string &save_name_suffix="");
void set_flag_save_dHs(const bool flag) { this->flag_save_result.dHs = flag; }
void set_flag_save_dHRs(const bool flag) { this->flag_save_result.dHRs = flag; }
void cal_Hs(
const std::array<std::string,3> &save_names_suffix={"","",""}); // "Cs","Vs","Ds"
void cal_force(
const std::array<std::string,5> &save_names_suffix={"","","","",""}); // "Cs","Vs","Ds","dCs","dVs"
void cal_dHs(
const std::array<std::string, 5>& save_names_suffix = { "","","","","" }); // "Cs","Vs","Ds","dCs","dVs"
void cal_stress(
const std::array<std::string,5> &save_names_suffix={"","","","",""}); // "Cs","Vs","Ds","dCRs","dVRs"
std::map<TA, std::map<TAC, Tensor<Tdata>>> Hs;
std::array<std::array<std::map<TA, std::map<TAC, Tensor<Tdata>>>, 2>, Npos> dHs; // Pulay term only. [direction][diffed atom 0/1][I][JR]
std::array<std::map<TA, std::map<TA, std::map<TAC, Tensor<Tdata>>>>, Npos> dHs_HF; // Hellmann-Feynman term only. [direction][diffed atom on {K,L}, 0-Natom][I][JR]. Filled by cal_dHs; like dHs it is left rank-PARTIAL -- the consumer must sum-reduce it on (diffed atom, I, JR).
std::array<std::array< std::map<TA, std::map<TAC, Tensor<Tdata>>> ,Npos>,Npos> dHRs;
Tdata energy = 0;
std::array<std::map<TA,Tdata>,Ndim> force;
Tensor<Tdata> stress = Tensor<Tdata>({Npos, Npos});
Exx_Post_2D<TA,TC,Tdata> post_2D;
void free_Cs(const std::string &save_name_suffix="");
void free_Vs(const std::string &save_name_suffix="");
void free_Ds(const std::string &save_name_suffix="");
void free_Ds_delta(const std::string &save_name_suffix="");
void free_dCs(const std::string &save_name_suffix="");
void free_dVs(const std::string &save_name_suffix="");
void free_dCRs(const std::string &save_name_suffix="");
void free_dVRs(const std::string &save_name_suffix="");
public:
LRI<TA,Tcell,Ndim,Tdata> lri;
struct Flag_Finish
{
bool stru=false;
bool Cs=false;
bool Vs=false;
bool Ds=false;
bool Ds_delta=false;
bool dCs=false;
bool dVs=false;
bool dCRs=false;
bool dVRs=false;
};
Flag_Finish flag_finish;
struct Flag_Save_Result
{
bool Hs=true;
bool dHs=false;
bool dHRs=false;
};
Flag_Save_Result flag_save_result;
};
}
#include "Exx.hpp"