HILA
Loading...
Searching...
No Matches
log_topo_supp_action.h
Go to the documentation of this file.
1/** @file log_topo_supp_action.h */
2
3#ifndef LOG_TOPO_SUPP_ACTION_H_
4#define LOG_TOPO_SUPP_ACTION_H_
5
6#include "hila.h"
7// #include "gauge/log_clover_action.h"
8
9// functions for topo.-sup. gauge action
10
11template <typename group, typename atype = hila::arithmetic_type<group>>
12void get_log_p_and_c_mat(const GaugeField<group> &U, Direction dir1, Direction dir2,
13 out_only Field<group> &C, out_only Field<group> &Csum) {
14 // sets Csum=(C[0]+C[1]+C[2]+C[3])/4 where C[0],C[1],C[2],C[3] are the logs of the clover-leaf
15 // matrices in counter-clockwise order
16
17 U[dir2].start_gather(dir1, ALL);
18 U[dir1].start_gather(dir2, ALL);
19
20 Field<group> tF;
21
22 onsites(ALL) {
23 // log of dir1-dir2-plaquette that starts and ends at X; corresponds to F[dir1][dir2]
24 // at center location X+dir1/2+dir2/2 of plaquette:
25 C[X] = log((U[dir1][X] * U[dir2][X + dir1] * (U[dir2][X] * U[dir1][X + dir2]).dagger()))
26 .expand();
27 // parallel transport to X+dir1
28 tF[X] = U[dir1][X].dagger() * C[X] * U[dir1][X];
29 }
30 tF.start_gather(-dir1, ALL);
31 // set Csum to leaf-matrix at X
32 onsites(ALL) {
33 Csum[X] = C[X];
34 }
35 // add parallel transported leaf-matrix from X-dir1 to the leaf-matrix at X
36 onsites(ALL) {
37 Csum[X] += tF[X - dir1];
38 }
39
40 onsites(ALL) {
41 // parallel transport two-leaves sum from X to X+dir2
42 tF[X] = U[dir2][X].dagger() * Csum[X] * U[dir2][X];
43 }
44 tF.start_gather(-dir2, ALL);
45 // add parallel transported two-leaves sum from X-dir2 to two-leaves sum at X and divide by 4
46 onsites(ALL) {
47 Csum[X] += tF[X - dir2];
48 Csum[X] *= 0.25;
49 }
50}
51
52template <typename group, typename atype = hila::arithmetic_type<group>>
53void get_log_plaq_mat(const GaugeField<group> &U, Direction dir1, Direction dir2,
54 out_only Field<group> &C) {
55 // sets C=log(U) where U is the plaquette variable panned by dir1 and dir2
56 U[dir2].start_gather(dir1, ALL);
57 U[dir1].start_gather(dir2, ALL);
58
59 onsites(ALL) {
60 // log of dir1-dir2-plaquette that starts and ends at X; corresponds to F[dir1][dir2]
61 // at center location X+dir1/2+dir2/2 of plaquette:
62 C[X] = log((U[dir1][X] * U[dir2][X + dir1] * (U[dir2][X] * U[dir1][X + dir2]).dagger()))
63 .expand();
64 }
65}
66
67
68template <typename group>
69double measure_s_topo_supp(const GaugeField<group> &U) {
70 // double teps = 1.0 / (4.0 * M_PI * M_PI);
71
72 Field<group> F[6];
73 //Field<group> Fsum[6];
74
75 int k = 0;
76 foralldir(dir1) foralldir(dir2) if (dir1 < dir2) {
77 // get the 4 clover leave matrices C[][X] (ordered counter-clockwise in (dir1,dir2)-plane)
78 // and their anti-hermitian traceless sum Csum[X]
79 get_log_plaq_mat(U, dir1, dir2, F[k]);
80
81 ++k;
82 }
83
84 int kmap[6] = {5, 4, 3, 2, 1, 0};
85
86 //int kmap[6] = {0, 1, 2, 3, 4, 5};
87
88 //int psign[6] = {1, -1, 1, 1, -1, 1};
89
90 Reduction<double> stot = 0;
91 stot.allreduce(false).delayed(true);
92 for (k = 0; k < 3; ++k) {
93 onsites(ALL) {
94 double ttstot = -real(mul_trace(F[k][X], F[kmap[k]][X]));
95 stot += ttstot * ttstot;
96 }
97 }
98
99 return stot.value() / group::size();
100}
101
102template <typename group, typename atype = hila::arithmetic_type<group>>
103void get_force_topo_supp_add(const GaugeField<group> &U, VectorField<Algebra<group>> &K,
104 atype eps = 1.0) {
105 // compute gauge force for clover action and add result to K
106 // atype qtoponf = 1.0 / (4.0 * M_PI * M_PI);
107 atype teps = 2.0 * eps;
108
109 Field<group> F[6];
110 //Field<group> Fsum[6];
111
112 int kmap[6] = {5, 4, 3, 2, 1, 0};
113
114 //int kmap[6] = {0, 1, 2, 3, 4, 5};
115
116 //int psign[6] = {1, -1, 1, 1, -1, 1};
117 Field<atype> Qdens[3];
118
119
120 int k = 0;
121 foralldir(dir1) foralldir(dir2) if (dir1 < dir2) {
122 // get the 4 clover leave matrices C[][X] (ordered counter-clockwise in (dir1,dir2)-plane)
123 // and their anti-hermitian traceless sum Csum[X]
124 get_log_plaq_mat(U, dir1, dir2, F[k]);
125
126 ++k;
127 }
128
129
130 for (k = 0; k < 3; ++k) {
131 onsites(ALL) {
132 Qdens[k][X] = -real(mul_trace(F[k][X], F[kmap[k]][X]));
133 }
134 }
135
136 for (k = 0; k < 3; ++k) {
137 onsites(ALL) F[k][X] *= Qdens[k][X];
138 onsites(ALL) F[kmap[k]][X] *= Qdens[k][X];
139 }
140
141
142
143 k = 0;
144 foralldir(dir1) foralldir(dir2) if (dir1 < dir2) {
145
146 std::vector<Direction> path = {dir1, dir2, -dir1, -dir2};
147
148 get_wloop_force_from_wl_add(U, path, F[kmap[k]], teps, K);
149
150 /*
151 // define for each clover leave matrix the correspondin path of gauge links
152 std::vector<Direction>
153 paths[4] = {{dir1, dir2, -dir1, -dir2},
154 {dir2, -dir1, -dir2, dir1},
155 {-dir1, -dir2, dir1, dir2},
156 {-dir2, dir1, dir2, -dir1}};
157
158 for (int m = 0; m < 4; ++m) {
159 get_wloop_force_from_wl_add(U, paths[m], F[kmap[k]], 0.25 * teps, K);
160 }
161 */
162 ++k;
163 }
164}
165
166template <typename group, typename atype = hila::arithmetic_type<group>>
167void get_force_topo_supp(const GaugeField<group> &U, out_only VectorField<Algebra<group>> &K,
168 atype eps = 1.0) {
169 // determine gauge force for clover action and store result in K
170 foralldir(d1) {
171 K[d1][ALL] = 0;
172 }
173 get_force_topo_supp_add(U, K, eps);
174}
175
176
177#endif
Array< n, m, hila::arithmetic_type< T > > real(const Array< n, m, T > &arg)
Return real part of Array.
Definition array.h:688
Array< n, m, T > log(Array< n, m, T > a)
Logarithm.
Definition array.h:1069
Definition su2.h:7
The field class implements the standard methods for accessing Fields. Hilapp replaces the parity acce...
Definition field.h:61
dir_mask_t start_gather(Direction d, Parity p=ALL) const
Definition field_comm.h:262
Gauge field class.
Definition gaugefield.h:22
Special reduction class: enables delayed and non-blocking reductions, which are not possible with the...
Definition reduction.h:14
const T value()
Return value of the reduction variable. Wait for the comms if needed.
Definition reduction.h:157
Reduction & allreduce(bool b=true)
allreduce(bool) turns allreduce on or off. By default on.
Definition reduction.h:130
Reduction & delayed(bool b=true)
deferred(bool) turns deferred on or off. By default turns on.
Definition reduction.h:148
Complex< T > dagger(const Complex< T > &val)
Return dagger of Complex number.
Definition cmplx.h:1223
#define foralldir(d)
Macro to loop over (all) Direction(s)
Definition coordinates.h:78
Direction
Enumerator for direction that assigns integer to direction to be interpreted as unit vector.
Definition coordinates.h:34
constexpr Parity ALL
bit pattern: 011
auto mul_trace(const Mtype1 &a, const Mtype2 &b)
Returns trace of product of two matrices.
Definition matrix.h:2309