HILA
Loading...
Searching...
No Matches
Wilson.cpp
1/*********************************************
2 * Simulates Wilson fermions with a gauge *
3 * interaction *
4 *********************************************/
5
6#include "Wilson.h"
7
8int main(int argc, char **argv) {
9
10 hila::initialize(argc, argv);
11 lattice.setup(nd);
12
13 hila::input parameters("parameters");
14 double beta = parameters.get("beta");
15 double kappa = parameters.get("kappa");
16 double hasenbusch_mass = parameters.get("hasenbusch_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
24
25 // Define gauge field and momentum field
27 adjoint_gauge_field<N, double> adj_gauge(gauge);
28
29 // Initialize the gauge field
30 gauge.set_unity();
31
32 // Define gauge and momentum action terms
33 gauge_action ga(gauge, beta);
34 gauge_momentum_action ma(gauge);
35
36 // Define a Dirac operator
37 Dirac_Wilson_evenodd D(kappa, adj_gauge);
38 Hasenbusch_action_1 fa1(D, adj_gauge, hasenbusch_mass);
39 Hasenbusch_action_2 fa2(D, adj_gauge, hasenbusch_mass);
40
41 // Build two integrator levels. Gauge is on the lowest level and
42 // the fermions are on higher level
43 O2_integrator integrator_level_1(ga, ma);
44 O2_integrator integrator_level_2(fa1, integrator_level_1,
45 5); // 5 gauge updates each time
46 O2_integrator integrator_level_3(fa2, integrator_level_2);
47
48 int config_found = (bool)std::ifstream(configfile);
49 hila::broadcast(config_found);
50 if (config_found) {
51 hila::out0 << "Found configuration file, reading\n";
52 gauge.read_file(configfile);
53 double plaq = gauge.plaquette();
54 hila::out0 << "Initial plaquette: " << plaq << "\n";
55 } else {
56 hila::out0 << "No config file " << configfile << ", starting new run\n";
57 gauge.random();
58 }
59
60 // Run HMC using the integrator
61 for (int step = 0; step < n_trajectories; step++) {
62 update_hmc(integrator_level_3, hmc_steps, traj_length);
63 double plaq = gauge.plaquette();
64 hila::out0 << "Plaq: " << plaq << "\n";
65
66 gauge.write_file(configfile);
67 }
68
70
71 return 0;
72}
void set_unity()
Set the gauge field to unity.
void random()
Draw a random gauge field.
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
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:152
void finishrun()
Normal, controlled exit - all nodes must call this. Prints timing information and information about c...