HILA
Loading...
Searching...
No Matches
staggered.cpp
1/*********************************************
2 * Simulates staggered fermions with a gauge *
3 * interaction *
4 *********************************************/
5
6//#define DEBUG_CG
7#include "staggered.h"
8
9int main(int argc, char **argv) {
10
11 hila::initialize(argc, argv);
12 lattice.setup(nd);
13
14 hila::input parameters("parameters");
15 double beta = parameters.get("beta");
16 double mass = parameters.get("mass");
17 int seed = parameters.get("seed");
18 int n_trajectories = parameters.get("n_trajectories");
19 double hmc_steps = parameters.get("hmc_steps");
20 double traj_length = parameters.get("traj_length");
21 std::string configfile = parameters.get("configuration_file");
22 int log_level = parameters.get("log_level");
23
24 hila::log.set_verbosity(log_level);
25
26 hila::log << "Example simulation with SU(" << N << ") gauge and \n";
27 hila::log << "and a staggered fermion. \n";
28 hila::log << "Running " << n_trajectories << " HMC trajectories.\n";
29 hila::log << "beta: " << beta << "\n";
30 hila::log << "mass: " << mass << "\n";
31 hila::log << "seed: " << seed << "\n";
32 hila::log << "Steps per HMC trajectory: " << hmc_steps << "\n";
33 hila::log << "writing output to " << configfile << "\n";
34
36
37 // Define gauge field and momentum field
39 symmetric_gauge_field<N, double> sym_gauge(gauge);
40 antisymmetric_gauge_field<N, double> antisym_gauge(gauge);
41 adjoint_gauge_field<N, double> adj_gauge(gauge);
42
43 // Initialize the gauge field
44 gauge.set_unity();
45
46 // Define gauge and momentum action terms
47 gauge_action ga(gauge, beta);
48 gauge_momentum_action ma(gauge);
49
50 // Define a Dirac operator
51 dirac_staggered_evenodd D(mass, gauge);
52 fermion_action fa(D, gauge);
53
54 // A second fermion, for checking that addition works
55 dirac_staggered_evenodd D2(mass, antisym_gauge);
56 fermion_action fa2(D2, antisym_gauge);
57
58 dirac_staggered_evenodd D3(mass, sym_gauge);
59 fermion_action fa3(D3, sym_gauge);
60
61 dirac_staggered_evenodd D4(mass, adj_gauge);
62 fermion_action fa4(D4, adj_gauge);
63
64 action_sum fsum = fa + fa2 + fa3 + fa4;
65
66 // Build two integrator levels. Gauge is on the lowest level and
67 // the fermions are on higher level
68 O2_integrator integrator_level_1(ga, ma);
69 O2_integrator integrator_level_2(fsum, integrator_level_1);
70
71 int config_found = (bool)std::ifstream(configfile);
72 hila::broadcast(config_found);
73 if (config_found) {
74 hila::out0 << "Found configuration file, reading\n";
75 gauge.read_file(configfile);
76 } else {
77 hila::out0 << "No config file " << configfile << ", starting new run\n";
78 }
79
80 // Run HMC using the integrator
81 for (int step = 0; step < n_trajectories; step++) {
82 update_hmc(integrator_level_2, hmc_steps, traj_length);
83 double plaq = gauge.plaquette();
84 hila::out0 << "Plaq: " << plaq << "\n";
85
86 gauge.write_file(configfile);
87 }
88
90
91 return 0;
92}
void set_unity()
Set the gauge field to unity.
void read_file(std::string filename)
Read the gauge field from a file.
double plaquette()
Calculate the plaquette.
void write_file(std::string filename)
Write the gauge field to a file.
hila::input - Class for parsing runtime parameter files.
Definition input.h:52
void setup(const CoordinateVector &siz)
General lattice setup.
Definition lattice.cpp:33
void set_verbosity(int level)
Set logging level.
Definition logger.h:36
logger_class log
Now declare the logger.
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...
Definition random.cpp:86
T broadcast(T &var, int rank=0)
Broadcast the value of var to all MPI ranks from rank (default=0).
Definition com_mpi.h:153
void finishrun()
Normal, controlled exit - all nodes must call this. Prints timing information and information about c...