ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
grad_degen.h
Go to the documentation of this file.
1#ifndef ABACUS_SOURCE_LCAO_MODULE_LR_GRAD_DEGEN_H
2#define ABACUS_SOURCE_LCAO_MODULE_LR_GRAD_DEGEN_H
3#include <cstddef>
4#include <utility>
5#include <vector>
6
45
46namespace LR
47{
64 std::vector<std::vector<int>> group_degenerate_states(const std::vector<double>& omega,
65 const double thr);
66
71 std::vector<std::pair<int, int>> degenerate_pairs(const int d);
72
78 template <typename T>
79 void combine_normalized(const T* const Xk, const T* const Xl, const size_t nloc, T* const Xplus)
80 {
81 // 1/sqrt(2) as a literal: `std::sqrt` is not constexpr under the C++11 baseline.
82 const T inv_sqrt2 = static_cast<T>(0.70710678118654752440);
83 for (size_t i = 0; i < nloc; ++i)
84 {
85 Xplus[i] = inv_sqrt2 * (Xk[i] + Xl[i]);
86 }
87 }
88
99 template <typename TMat>
100 std::vector<std::vector<TMat>> assemble_grad_matrix(const std::vector<TMat>& diag,
101 const std::vector<TMat>& plus,
102 const std::vector<std::pair<int, int>>& pairs)
103 {
104 const int d = static_cast<int>(diag.size());
105 std::vector<std::vector<TMat>> g(d, std::vector<TMat>(d));
106 for (int k = 0; k < d; ++k)
107 {
108 g[k][k] = diag[k];
109 }
110 for (size_t ip = 0; ip < pairs.size(); ++ip)
111 {
112 const int k = pairs[ip].first;
113 const int l = pairs[ip].second;
114 // $G_{kl}=\mathcal F[X_+]-\tfrac12(G_{kk}+G_{ll})$
115 const TMat off = plus[ip] - (diag[k] + diag[l]) * 0.5;
116 g[k][l] = off;
117 g[l][k] = off;
118 }
119 return g;
120 }
121
125 {
126 std::vector<double> displacement;
127 std::vector<double> mixing;
128 double slope = 0.0;
130 int iterations = 0;
131 };
132
175 JTDirection find_jt_direction(const std::vector<double>& gflat, const int ncoord, const int d);
176
188 std::vector<double> split_symmetric_part(const std::vector<double>& gflat,
189 const int ncoord,
190 const int d,
191 const std::vector<double>& mixing,
192 std::vector<double>& jt_part);
193}
194
195#endif // ABACUS_SOURCE_LCAO_MODULE_LR_GRAD_DEGEN_H
#define T
Definition exp.cpp:237
Definition esolver_lr_lcao_tddft.h:28
JTDirection find_jt_direction(const std::vector< double > &gflat, const int ncoord, const int d)
Find the Jahn-Teller direction: the displacement that splits the multiplet and lowers one branch as f...
Definition grad_jt.cpp:173
std::vector< double > split_symmetric_part(const std::vector< double > &gflat, const int ncoord, const int d, const std::vector< double > &mixing, std::vector< double > &jt_part)
Split a branch gradient into the part shared by the whole multiplet and the part that actually breaks...
Definition grad_jt.cpp:244
std::vector< std::vector< int > > group_degenerate_states(const std::vector< double > &omega, const double thr)
Split states into multiplets of (near-)degenerate excitation energies.
Definition grad_degen.cpp:10
std::vector< std::vector< TMat > > assemble_grad_matrix(const std::vector< TMat > &diag, const std::vector< TMat > &plus, const std::vector< std::pair< int, int > > &pairs)
Assemble $G_{kl}$ of one multiplet from the diagonal gradients and the combinations,...
Definition grad_degen.h:100
std::vector< std::pair< int, int > > degenerate_pairs(const int d)
The $(k,l)$, $k<l$ pairs of a $d$-dimensional multiplet, lexicographically.
Definition grad_degen.cpp:60
void combine_normalized(const T *const Xk, const T *const Xl, const size_t nloc, T *const Xplus)
$X_+=(X_k+X_l)/\sqrt2$, normalized when $X_k$ and $X_l$ are orthonormal.
Definition grad_degen.h:79
The outcome of the Jahn-Teller search: the displacement direction that lowers one branch of the multi...
Definition grad_degen.h:125
std::vector< double > mixing
$v$, that branch's $d$ coefficients in the multiplet basis
Definition grad_degen.h:127
double slope
$|q(v)|$, the branch's steepest descent rate
Definition grad_degen.h:128
int iterations
iterations used by the winning start
Definition grad_degen.h:130
std::vector< double > displacement
the $3N$ direction, normalized, laid out (atom, xyz)
Definition grad_degen.h:126
int restarts_agreeing
how many starting points reached this same optimum
Definition grad_degen.h:129