40 std::string config_file;
64template <
typename group>
66 bool relax,
const plaqw_t<ftype> &plaqw) {
76 staples_timer.start();
78 staplesum(U, staples, d, plaqw, par);
83 acc.allreduce(
false).delayed(
true);
85 att.allreduce(
false).delayed(
true);
92 if(plaqw[d][d][X] != 0) {
93#ifdef SUN_OVERRELAX_dFJ
94 acc += suN_overrelax_dFJ(U[d][X], staples[X], p.beta);
110 if (plaqw[d][d][X] != 0) {
120 accr = acc.value() / accr;
135template <
typename group>
137 for (
int i = 0; i < 2 * NDIM; ++i) {
140 int tpar = 1 + (tdp % 2);
158template <
typename group>
160 for (
int n = 0; n < p.n_update; n++) {
161 for (
int i = 0; i <= p.n_overrelax; i++) {
173template <
typename group>
175 const plaqw_t<ftype> &plaqw) {
177 int obdlsize = lattice.
size(obd);
180 plaql.allreduce(
false).delayed(
true);
181 double normf = 2.0 / (NDIM * (NDIM - 1) * lattice.
volume() / obdlsize);
184 U[dir2].start_gather(dir1,
ALL);
185 U[dir1].start_gather(dir2,
ALL);
187 double tplq = (1.0 -
real(trace(U[dir1][X] * U[dir2][X + dir1] *
188 (U[dir2][X] * U[dir1][X + dir2]).
dagger())) /
190 plaqw[dir1][dir2][X] * normf;
191 int obdind = X.coordinate(obd);
192 if (dir1 != obd && dir2 != obd) {
193 plaql[obdind] += tplq;
195 if (obdind > 0 && obdind < obdlsize - 1) {
197 plaql[obdind] += tplq;
198 plaql[obdind + 1] += 0.5 * tplq;
199 }
else if (obdind == obdlsize - 2) {
200 plaql[obdind] += 0.5 * tplq;
201 plaql[obdind + 1] += tplq;
203 plaql[obdind] += 0.5 * tplq;
204 plaql[obdind + 1] += 0.5 * tplq;
211 return plaql.vector();
229 for (
int plane = lattice.
size(dir) - 2; plane >= 0; plane--) {
236#pragma hila safe_access(polyakov)
238 if (X.coordinate(dir) == plane) {
239 polyakov[X] = U[dir][X] * polyakov[X + dir];
246 ploopl.allreduce(
false).delayed(
true);
248 int obdlsize = lattice.
size(obd);
249 double normf = 1.0 / (lattice.
volume() / (lattice.
size(dir) * obdlsize));
251 onsites(
ALL)
if (X.coordinate(dir) == 0) {
252 ploopl[X.coordinate(obd)] += trace(polyakov[X]) * normf;
256 return ploopl.vector();
259template <
typename group>
263 static bool first =
true;
264#if BCOPEN >= 0 && BCOPEN < NDIM
267 hila::out0 <<
"LMPLAQPS: plaq[1] plaq[2] plaq[3] plaq[4] ...\n";
268 hila::out0 <<
"LMPOLPS: P[1].re P[1].im P[2].re P[2].im ...\n";
272 auto plaql = measure_s_wplaq_ps(U, obd, plaqw);
273 auto polyl = measure_polyakov_ps(U, obd, e_t);
275 for (
int i = 1; i < lattice.
size(obd); ++i) {
276 hila::out0 << string_format(
" % 0.6e", plaql[i]);
280 for (
int i = 1; i < lattice.
size(obd); ++i) {
290 auto plaq = measure_s_wplaq(U) / (lattice.
volume() * NDIM * (NDIM - 1) / 2);
292 hila::out0 << string_format(
"MEAS % 0.6e % 0.6e % 0.6e", plaq, poly.real(), poly.imag())
295 hila::out0 << string_format(
"MEASEFF HB: % 0.6e , OR: % 0.6e ", acc[0] / att[0],
309template <
typename group>
310void checkpoint(
const GaugeField<group> &U,
int trajectory,
const parameters &p) {
313 std::string config_file =
314 p.config_file +
"_" + std::to_string(
abs((trajectory + 1) / p.n_save) % 2);
320 outf.open(
"run_status", std::ios::out | std::ios::trunc);
321 outf <<
"trajectory " << trajectory + 1 <<
'\n';
322 outf <<
"seed " <<
static_cast<uint64_t
>(
hila::random() * (1UL << 61)) <<
'\n';
325 outf <<
"config name " << config_file <<
'\n';
328 std::stringstream msg;
330 hila::timestamp(msg.str().c_str());
333template <
typename group>
339 if (status.
open(
"run_status",
false,
false)) {
341 trajectory = status.
get(
"trajectory");
342 seed = status.
get(
"seed");
343 p.time_offset = status.
get(
"time");
345 std::string config_file = status.
get(
"config name");
348 U.config_read(config_file);
352 in.open(p.config_file, std::ios::in | std::ios::binary);
356 U.config_read(p.config_file);
369int main(
int argc,
char **argv) {
387 hila::out0 <<
"Using floating point epsilon: " << fp<ftype>::epsilon <<
"\n";
395 lsize = par.get(
"lattice size");
397 p.beta = par.get(
"beta");
399 p.n_traj = par.get(
"number of trajectories");
401 p.n_update = par.get(
"updates in trajectory");
403 p.n_overrelax = par.get(
"overrelax steps");
405 p.n_therm = par.get(
"thermalization trajs");
407 p.gflow_freq = par.get(
"gflow freq");
409 p.gflow_max_l = par.get(
"gflow max lambda");
411 p.gflow_l_step = par.get(
"gflow lambda step");
413 p.gflow_a_accu = par.get(
"gflow abs. accuracy");
415 p.gflow_r_accu = par.get(
"gflow rel. accuracy");
417 long seed = par.get(
"random seed");
419 p.n_save = par.get(
"trajs/saved");
421 p.config_file = par.get(
"config name");
426 lattice.
setup(lsize);
435 plaqw_t<ftype> plaqw;
439 plaqw[d1][d2][X] = 1.0;
444#if BCOPEN>=0 && BCOPEN<NDIM
446 hila::out0 <<
"Using open boundary conditions in " << obd <<
"-direction\n";
450 if (X.coordinate(obd) == 0) {
451 plaqw[d1][d2][X] = 0;
453 if (X.coordinate(obd) == 1) {
454 if (d1 != obd && d2 != obd) {
455 plaqw[d1][d2][X] = 0.5;
458 if (X.coordinate(obd) == lattice.
size(obd) - 1) {
459 if (d1 != obd && d2 != obd) {
460 plaqw[d1][d2][X] = 0.5;
462 plaqw[d1][d2][X] = 0;
471 int start_traj = -p.n_therm;
473 if (!restore_checkpoint(U, start_traj, p)) {
483 for (
int trajectory = start_traj; trajectory < p.n_traj; ++trajectory) {
487 update_timer.start();
492 hila::synchronize_threads();
495 measure_timer.start();
497 hila::out0 <<
"Measure_start " << trajectory <<
'\n';
501 hila::out0 <<
"Measure_end " << trajectory <<
'\n';
503 measure_timer.stop();
505 if (trajectory >= 0) {
507 if (p.gflow_freq > 0 && trajectory % p.gflow_freq == 0) {
510 int gtrajectory = trajectory / p.gflow_freq;
511 if (p.gflow_l_step > 0) {
515 int nflow_steps = (int)(p.gflow_max_l / p.gflow_l_step);
517 hila::out0 <<
"Gflow_start " << gtrajectory <<
'\n';
521 ftype t_step = t_step0;
522 measure_gradient_flow_stuff(V, (ftype)0.0, t_step);
523 t_step = do_gradient_flow_adapt(V, (ftype)0.0, p.gflow_l_step, p.gflow_a_accu,
524 p.gflow_r_accu, t_step);
525 measure_gradient_flow_stuff(V, p.gflow_l_step, t_step);
528 for (
int i = 1; i < nflow_steps; ++i) {
531 do_gradient_flow_adapt(V, i * p.gflow_l_step, (i + 1) * p.gflow_l_step,
532 p.gflow_a_accu, p.gflow_r_accu, t_step);
534 measure_gradient_flow_stuff(V, (i + 1) * p.gflow_l_step, t_step);
537 hila::out0 <<
"Gflow_end " << gtrajectory <<
" time " << std::setprecision(3)
545 if (p.n_save > 0 && (trajectory + 1) % p.n_save == 0) {
546 checkpoint(U, trajectory, p);
Array< n, m, hila::arithmetic_type< T > > imag(const Array< n, m, T > &arg)
Return imaginary part of Array.
Array< n, m, hila::arithmetic_type< T > > real(const Array< n, m, T > &arg)
Return real part of Array.
The field class implements the standard methods for accessing Fields. Hilapp replaces the parity acce...
void reunitarize_gauge()
Reunitarize Gauge Field consisting of matrices.
void config_write(const std::string &filename) const
config_write writes the gauge field to file, with additional "verifying" header
void setup(const CoordinateVector &siz)
lattice.setup(CoordinateVector size) - set up the base lattice. Called at the beginning of the progra...
int size(Direction d) const
lattice.size() -> CoordinateVector or lattice.size(d) -> int returns the dimensions of the lattice,...
int64_t volume() const
lattice.volume() returns lattice volume Can be used inside onsites()-loops
static constexpr int size()
Returns size of Vector or square Matrix.
Special reduction class: enables delayed and non-blocking reductions, which are not possible with the...
Complex< T > dagger(const Complex< T > &val)
Return dagger of Complex number.
T abs(const Complex< T > &a)
Return absolute value of Complex number.
Parity
Parity enum with values EVEN, ODD, ALL; refers to parity of the site. Parity of site (x,...
#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
double random()
Real valued uniform random number generator.
int myrank()
rank of this node
std::ostream out0
This writes output only from main process (node 0)
void initialize(int argc, char **argv)
Initial setup routines.
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...
T broadcast(T &var, int rank=0)
Broadcast the value of var to all MPI ranks from rank (default=0).
void finishrun()
Normal, controlled exit - all nodes must call this. Prints timing information and information about c...
Complex< double > measure_polyakov(const GaugeField< T > &U, Direction dir=Direction(NDIM - 1))
Measure Polyakov lines to direction dir.
void update(GaugeField< group > &U, const parameters &p, bool relax)
Wrapper update function.
void update_parity_dir(GaugeField< group > &U, const parameters &p, Parity par, Direction d, bool relax)
Wrapper function to updated GaugeField per direction.
void do_trajectory(GaugeField< group > &U, const parameters &p)
Evolve gauge field.
void measure_stuff(const GaugeField< group > &U, const parameters &p)
Measures Polyakov lines and Wilson action.
double suN_heatbath(SU< N, T > &U, const SU< N, T > &staple, double beta)
heatbath
int suN_overrelax(SU< N, T > &U, const SU< N, T > &staple, Btype beta)
overrelaxation using matrix obtained from max_staple_sum_rot() routine