-
Notifications
You must be signed in to change notification settings - Fork 3
/
operator_spec.h
168 lines (144 loc) · 5 KB
/
operator_spec.h
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#ifndef LIBRESPONSE_OPERATOR_SPEC_H_
#define LIBRESPONSE_OPERATOR_SPEC_H_
/*!
* @file
*
* Hold operators (integrals and metadata) and lists of operators.
*/
#include "configurable.h"
#include "indices.h"
#include "utils.h"
namespace libresponse {
/*!
* Internal representation of operator/integral, metadata only.
*
* The operator and origin labels are used for printing to the screen,
* not for actual computation.
*
* The slice ID is used to indicate if only a single slice out of the
* integrals is to be used. If this is -1, all slices (components)
* will be used.
*
* @todo Is slice_idx/slice_idx_ even used anywhere?
*/
class operator_metadata {
public:
//! name of the operator
std::string operator_label;
//! plain-text description of the operator origin
std::string origin_label;
//! index (zero-based) of cube slice to keep integrals from
int slice_idx;
//! Are the integrals imaginary (stored antisymmetric)?
bool is_imaginary;
//! Do the integrals have a spin factor in them (alpha/beta will
//! be opposite sign in MO basis)?
bool is_spin_dependent;
public:
/*!
* Default constructor.
*/
operator_metadata(
std::string &operator_label_,
std::string &origin_label_,
int slice_idx_,
bool is_imaginary_,
bool is_spin_dependent_)
: operator_label(operator_label_)
, origin_label(origin_label_)
, slice_idx(slice_idx_)
, is_imaginary(is_imaginary_)
, is_spin_dependent(is_spin_dependent_)
{ }
};
std::ostream& operator<<(std::ostream &stream, const operator_metadata &om);
/*!
* Information about an operator (integrals and associated metadata).
*
* The one-electron integrals are stored as [nbsf, nbsf] matrices
* in an Armadillo cube, where each slice is a part of the
* operator. If necessary, the ordering is slices per atom, then
* Cartesian components x, y, z, xx, xy, xz, yx, yy, ...
*
* The B prefactor is only needed for RPA (not TDA/CIS). If the
* operator is real, form \f$(\mathbf{A} + \mathbf{B})\f$. If the
* operator is imaginary, form \f$(\mathbf{A} - \mathbf{B})\f$.
*
* @todo A single operator might have more than one origin, in the
* case of nuclear centers. Is it important to store those, such
* as a std::vector<arma::vec>?
*/
class operator_spec {
public:
operator_metadata metadata; //!< operator metadata
arma::cube integrals_ao; //!< AO-basis integrals for operator
arma::vec origin; //!< operator (integral) origin
//! Should this operator be used as a property gradient on the RHS
//! of the response equations?
bool do_response;
// TODO sign is flipped?
int b_prefactor; //!< prefactor for RPA B-matrix; 1/-1 for real/imaginary
std::string prefix;
bool has_beta;
arma::mat integrals_mo_ai_alph;
arma::mat integrals_mo_ai_beta;
void form_rhs(
const arma::cube &C,
const arma::uvec &occupations,
const libresponse::configurable &cfg);
arma::mat rspvecs_alph;
arma::mat rspvecs_beta;
void form_guess_rspvec(const arma::vec &ediff, double frequency, bool beta);
type::indices indices_ao;
arma::uvec indices_mo_alph;
arma::uvec indices_mo_beta;
void form_guess_rspvec(const arma::mat &ediff, double frequency, bool beta, size_t nov, const libresponse::configurable &cfg);
void save_to_disk(int save_level, bool is_guess);
public:
/*!
* Default constructor.
*
* @param[in] &operator_metadata_ information about the operator
* @param[in] &integrals_ao_ AO-basis integrals for operator
* @param[in] &origin_ operator (integral) origin
*/
operator_spec(
const operator_metadata &metadata_,
arma::cube &integrals_ao_,
arma::vec &origin_,
bool do_response_)
: metadata(metadata_)
, integrals_ao(integrals_ao_)
, origin(origin_)
, do_response(do_response_)
{
b_prefactor = is_imaginary_to_b_prefactor(metadata.is_imaginary);
// Modify the metadata so the origin label also contains
// the numerical operator origin (in bohr).
std::ostringstream origin_label;
origin_label << metadata.origin_label << \
" (" << origin(0) << \
", " << origin(1) << \
", " << origin(2) << ")";
metadata.origin_label = origin_label.str();
}
void init_indices(
const arma::umat &fragment_occupations,
const libresponse::configurable &cfg);
};
/*!
* A shorter way to make a list of labels from a list of operators.
*
* @param[in] &operators operators to grab labels from
*
* @returns vector of labels taken from each operator
*/
std::vector<std::string> make_operator_label_vec(const std::vector<operator_spec> &operators);
/*!
*
*
* @todo document me!
*/
std::vector<std::string> make_operator_component_vec(const std::vector<operator_spec> &operators);
} // namespace libresponse
#endif // LIBRESPONSE_OPERATOR_SPEC_H_