2#include "datatypes/representations.h"
6#include "hmc/gauge_field.h"
7#include "hmc/smearing.h"
8#include "dirac/wilson.h"
9#include "dirac/staggered.h"
10#include "hmc/fermion_field.h"
14template <
typename fermion_action,
typename dirac,
typename gauge_field_type>
15void check_forces(
fermion_action &fa, dirac &D, gauge_field_type &gauge) {
16 using sun =
typename gauge_field_type::fund_type;
21 for (
int ng = 0; ng < 1; ng++) {
24 gauge.zero_momentum();
29 sun g1 = gauge.get_gauge(0).get_element(coord);
43 psi[X].gaussian_random();
44 chi[X].gaussian_random();
49 onsites(D.par) { s1 += chi[X].rdot(tmp[X]); }
56 onsites(D.par) { s2 += chi[X].rdot(tmp[X]); }
61 D.force(chi, psi, force, 1);
63 gauge.add_momentum(force);
64 sun f = gauge.get_momentum(0).get_element(coord);
65 double f1 = (s2 - s1) / eps;
66 double f2 = (f *
Complex<double>(0, 1) * sun::generator(ng)).trace().re;
67 double diff = f2 - f1;
75 assert(diff * diff < eps &&
"Fermion deriv");
79 psi[X].gaussian_random();
80 chi[X].gaussian_random();
82 gauge.zero_momentum();
86 onsites(D.par) { s1 += chi[X].rdot(tmp[X]); }
93 onsites(D.par) { s2 += chi[X].rdot(tmp[X]); }
98 D.force(chi, psi, force, -1);
99 gauge.add_momentum(force);
100 f = gauge.get_momentum(0).get_element(coord);
101 f1 = (s2 - s1) / eps;
111 assert(diff * diff < eps &&
"Fermion dg deriv");
114 gauge.zero_momentum();
123 gauge.get_gauge(0).set_element(g1, coord);
130 dS += sf2[X] - sf1[X];
136 f = gauge.get_momentum(0).get_element(coord);
147 assert(diff * diff < eps &&
"Fermion force");
152int main(
int argc,
char **argv) {
177 for (
int ng = 0; ng < SU<N>::generator_count(); ng++) {
185 double s1 = ga.action();
191 double s2 = ga.action();
209 assert(diff * diff < eps * 10 &&
"Gauge force");
224 HEX_smeared_field<SUN> hex_gauge(gauge, 10);
231 check_forces(fa, D, gauge);
235 hila::out0 <<
"Checking evenodd preconditioned staggered forces:\n";
238 check_forces(fa, D, gauge);
242 hila::out0 <<
"Checking stout smeared forces:\n";
245 check_forces(fa, D, stout_gauge);
249 hila::out0 <<
"Checking HEX smeared forces:\n";
252 check_forces(fa, D, hex_gauge);
256 hila::out0 <<
"Checking adjoint staggered forces:\n";
259 check_forces(fa, D, adj_gauge);
263 hila::out0 <<
"Checking symmetric staggered forces:\n";
266 check_forces(fa, D, sym_gauge);
270 hila::out0 <<
"Checking antisymmetric staggered forces:\n";
273 check_forces(fa, D, asym_gauge);
281 check_forces(fa, D, gauge);
285 hila::out0 <<
"Checking evenodd Wilson forces:\n";
288 check_forces(fa, D, gauge);
292 check_forces(fa1, D, gauge);
296 check_forces(fa2, D, gauge);
300 hila::out0 <<
"Checking adjoint Wilson forces:\n";
303 check_forces(fa, D, adj_gauge);
307 hila::out0 <<
"Checking symmetric Wilson forces:\n";
310 check_forces(fa, D, sym_gauge);
314 hila::out0 <<
"Checking antisymmetric Wilson forces:\n";
317 check_forces(fa, D, asym_gauge);
321 for (
int ng = 0; ng < SU<N>::generator_count(); ng++) {
322 ga.draw_gaussian_fields();
324 double s1 = ga.action();
329 double s2 = ga.action();
337 assert(diff * diff < eps * 10 &&
"Momentum derivative");
The field class implements the standard methods for accessing Fields. Hilapp replaces the parity acce...
void set_boundary_condition(Direction dir, hila::bc bc)
Set the boundary condition in a given Direction (periodic or antiperiodic)
const T set_element(const CoordinateVector &coord, const A &value)
Get singular element which will be broadcast to all nodes.
auto get_value_at(const unsigned i) const
Get an individual element outside a loop. This is also used as a getter in the vanilla code.
void set_value_at(const A &value, unsigned i)
Set an individual element outside a loop. This is also used as a getter in the vanilla code.
void copy_boundary_condition(const Field< A > &rhs)
Copy the boundary condition from another field.
Matrix class which defines matrix operations.
void draw_gaussian_fields()
void force_step(double eps)
Field< sun > gauge[4]
A matrix field for each Direction.
void random()
Draw a random gauge field.
void setup(const CoordinateVector &siz)
General lattice setup.
#define foralldir(d)
Macro to loop over (all) Direction(s)
constexpr Parity ALL
bit pattern: 011
int myrank()
rank of this node
std::ostream out0
This writes output only from main process (node 0)
void initialize(int argc, char **argv)
Read in command line arguments. Initialise default stream and MPI communication.
void seed_random(uint64_t seed, bool device_rng=true)
Seed random generators with 64-bit unsigned value. On MPI shuffles the seed so that different MPI ran...
void finishrun()
Normal, controlled exit - all nodes must call this. Prints timing information and information about c...