4#include "datatypes/sun.h"
5#include "hmc/gauge_field.h"
9void exp_and_derivative(sun &Q, sun &m0, sun &lambda, sun &eQ,
int exp_steps) {
22 for (
int k = 2; k <= exp_steps; k++) {
23 n = n * 1.0 / ((double)k);
24 m1 = m0 * qn + Q * m1;
29 lambda = lambda + m1 * n;
35template <
typename matrix,
typename forcetype>
42 matrix
U1, U2, U3, U4, L, L2;
44 U2 = basegauge2[X + dir1];
45 U3 = basegauge1[X + dir2];
48 L2 = Lambda[X + dir2];
51 result2[X] += (L * U2 * U3.dagger()).
dagger();
52 stapleder2[X] = U3.
dagger() * U4.dagger() * L;
53 stapleder3[X] = (U4.dagger() * L * U2).
dagger();
56 stapleder2[X] = stapleder2[X] + L2.
dagger() * U4.dagger() *
U1;
57 result1[X] += U2 * L2.
dagger() * U4.dagger();
58 result2[X] += L2 * U2.
dagger() *
U1.dagger();
63 result2[X] += stapleder2[X - dir1];
64 result1[X] += stapleder3[X - dir2];
78 using gauge_type = sun;
79 using fund_type = sun;
80 using basetype = hila::arithmetic_type<sun>;
81 static constexpr int Nf = sun::size;
82 static constexpr int N = sun::size;
93 : base_field(f), c(coeff) {
98 : base_field(f), c(coeff), smear_steps(nsteps) {
103 : base_field(f), c(coeff), smear_steps(nsteps), exp_steps(expsteps) {
108 : base_field(r.base_field), c(r.c), smear_steps(r.smear_steps),
109 exp_steps(r.exp_steps) {
117 for (
int step = 0; step < smear_steps - 1; step++) {
121 staples[smear_steps - 1] =
new Field<sun>[NDIM];
122 smeared_fields[smear_steps - 1] = &(this->
gauge[0]);
126 for (
int step = 0; step < smear_steps - 1; step++) {
127 delete staples[step];
128 delete smeared_fields[step];
131 free(smeared_fields);
137 previous = &base_field.
gauge[0];
139 for (
int step = 0; step < smear_steps; step++) {
142 staples[step][dir] = calc_staples(previous, dir);
145 Q = -c * previous[dir][X] * staples[step][dir][X];
146 project_antihermitean(Q);
147 Q = Q.exp(exp_steps);
148 smeared_fields[step][dir][X] = previous[dir][X] * Q;
151 previous = smeared_fields[step];
169 foralldir(dir) { storage1[dir] = force[dir]; }
176 for (
int step = smear_steps - 1; step >= 0; step--) {
180 basegauge = &base_field.
gauge[0];
182 basegauge = smeared_fields[step - 1];
187 result[dir][
ALL] = 0;
189 element<sun> m0, m1, qn, eQ, Q;
190 Q = -c * basegauge[dir][X] * staples[step][dir][X];
191 project_antihermitean(Q);
193 m0 = previous[dir][X] * basegauge[dir][X];
194 exp_and_derivative(Q, m0, Lambda[dir][X], eQ, exp_steps);
196 project_antihermitean(Lambda[dir][X]);
199 result[dir][X] = eQ * previous[dir][X];
202 result[dir][X] -= c * staples[step][dir][X] * Lambda[dir][X];
205 Lambda[dir][X] = -c * Lambda[dir][X] * basegauge[dir][X];
211 staple_dir_derivative(basegauge[dir1], basegauge[dir2], Lambda[dir1],
212 result[dir1], result[dir2], dir1, dir2);
219 basegauge = &smeared_fields[step][0];
240template <
typename sun>
struct HEX_smeared_field :
public gauge_field_base<sun> {
241 using gauge_type = sun;
242 using fund_type = sun;
243 using basetype = hila::arithmetic_type<sun>;
244 static constexpr int Nf = sun::size;
245 static constexpr int N = sun::size;
264 : base_field(f), exp_steps(nsteps) {
268 : base_field(f), c1(_c1), c2(_c2), c3(_c3) {
273 : base_field(f), c1(_c1), c2(_c2), c3(_c3), exp_steps(nsteps) {
280 previous = &base_field.
gauge[0];
287 staples3[nu][mu] = calc_staples(base_field.
gauge, base_field.
gauge, mu, nu);
290 Q = -c3 * base_field.
gauge[mu][X] * staples3[nu][mu][X];
291 project_antihermitean(Q);
292 Q = Q.exp(exp_steps);
293 level3[nu][mu][X] = base_field.
gauge[mu][X] * Q;
300 staples2[nu][mu][
ALL] = 0;
301 foralldir(rho)
if (rho != mu)
if (rho != nu) {
303 foralldir(e)
if (e != mu && e != nu && e != rho) eta = e;
304 Field<sun> stp = calc_staples(level3[eta], level3[eta], mu, rho);
305 staples2[nu][mu][
ALL] = staples2[nu][mu][X] + stp[X];
309 Q = -c2 * base_field.
gauge[mu][X] * staples2[nu][mu][X];
310 project_antihermitean(Q);
311 Q = Q.exp(exp_steps);
312 level2[nu][mu][X] = base_field.
gauge[mu][X] * Q;
319 staples1[mu][
ALL] = 0;
321 Field<sun> stp = calc_staples(level2[nu], level2[mu], mu, nu);
322 staples1[mu][
ALL] = staples1[mu][X] + stp[X];
326 Q = -c1 * base_field.
gauge[mu][X] * staples1[mu][X];
327 project_antihermitean(Q);
328 Q = Q.exp(exp_steps);
329 this->
gauge[mu][X] = base_field.
gauge[mu][X] * Q;
363 element<sun> m0, m1, qn, eQ, Q;
364 Q = -c1 * base_field.
gauge[mu][X] * staples1[mu][X];
365 project_antihermitean(Q);
367 m0 = force[mu][X] * base_field.
gauge[mu][X];
368 exp_and_derivative(Q, m0, lambda1[mu][X], eQ, exp_steps);
369 project_antihermitean(lambda1[mu][X]);
372 result[mu][X] = eQ * force[mu][X];
375 result[mu][X] -= c1 * staples1[mu][X] * lambda1[mu][X];
378 lambda1[mu][X] = -c1 * lambda1[mu][X] * base_field.
gauge[mu][X];
384 staple_dir_derivative(level2[nu][mu], level2[mu][nu], lambda1[mu],
385 result1[nu][mu], result1[mu][nu], mu, nu);
391 element<sun> m0, m1, qn, eQ, Q;
392 Q = -c2 * base_field.
gauge[mu][X] * staples2[nu][mu][X];
393 project_antihermitean(Q);
395 m0 = result1[nu][mu][X] * base_field.
gauge[mu][X];
396 exp_and_derivative(Q, m0, lambda2[nu][mu][X], eQ, exp_steps);
397 project_antihermitean(lambda2[nu][mu][X]);
400 result[mu][X] += eQ * result1[nu][mu][X];
403 result[mu][X] -= c2 * staples2[nu][mu][X] * lambda2[nu][mu][X];
406 lambda2[nu][mu][X] = -c2 * lambda2[nu][mu][X] * base_field.
gauge[mu][X];
412 foralldir(rho)
if (rho != mu)
if (rho != nu) {
414 foralldir(e)
if (e != mu && e != nu && e != rho) eta = e;
415 staple_dir_derivative(level3[eta][mu], level3[eta][rho], lambda2[nu][mu],
416 result2[eta][mu], result2[eta][rho], mu, rho);
423 element<sun> m0, m1, qn, eQ, Q;
424 Q = -c3 * base_field.
gauge[mu][X] * staples3[nu][mu][X];
425 project_antihermitean(Q);
427 m0 = result2[nu][mu][X] * base_field.
gauge[mu][X];
428 exp_and_derivative(Q, m0, lambda3[nu][mu][X], eQ, exp_steps);
429 project_antihermitean(lambda3[nu][mu][X]);
432 result[mu][X] += eQ * result2[nu][mu][X];
435 result[mu][X] -= c3 * staples3[nu][mu][X] * lambda3[nu][mu][X];
438 lambda3[nu][mu][X] = -c3 * lambda3[nu][mu][X] * base_field.
gauge[mu][X];
444 staple_dir_derivative(base_field.
gauge[mu], base_field.
gauge[nu],
445 lambda3[nu][mu], result[mu], result[nu], mu, nu);
The field class implements the standard methods for accessing Fields. Hilapp replaces the parity acce...
Field< A > dagger() const
Returns dagger or Hermitian conjugate of Field depending on how it is defined for Field type T.
void check_alloc()
Allocate Field if it is not already allocated.
Matrix class which defines matrix operations.
virtual void restore_backup()
virtual void refresh()
Recalculate represented or smeared field.
virtual void draw_momentum()
Draw gaussian random momentum.
virtual void random()
Draw a random gauge field.
Field< sun > gauge[4]
A matrix field for each Direction.
virtual void set_unity()
Set the field to unity.
virtual void backup()
Make a copy of the gauge field for HMC.
virtual void add_momentum(Field< SquareMatrix< N, Complex< basetype > > > *force)
Update the momentum by given force.
virtual void zero_momentum()
Set the momentum to zero.
void restore_backup()
Restore the previous backup.
void zero_momentum()
Set the momentum to zero.
void set_unity()
Set the gauge field to unity.
void random()
Draw a random gauge field.
void backup()
Make a copy of fields updated in a trajectory.
Field< gauge_type > & get_gauge(int dir)
Return a reference to the gauge field.
void draw_momentum()
Gaussian random momentum for each element.
void add_momentum(Field< SquareMatrix< N, Complex< basetype > > > *force)
Field< gauge_type > & get_momentum(int dir)
Return a reference to the momentum field.
void random()
Draw a random gauge field.
void draw_momentum()
Draw gaussian random momentum.
void set_unity()
Set the field to unity.
void zero_momentum()
Set the momentum to zero.
void add_momentum(Field< SquareMatrix< N, Complex< basetype > > > *force)
Update the momentum by given force.
void backup()
Make a copy of the gauge field for HMC.
void refresh()
Recalculate represented or smeared field.
Complex< T > dagger(const Complex< T > &val)
Return dagger of Complex number.
#define foralldir(d)
Macro to loop over (all) Direction(s)
Direction
Enumerator for direction that assigns integer to direction to be interpreted as unit vector.
constexpr Parity ALL
bit pattern: 011