CHROMA
t_hmc_pg.cc
Go to the documentation of this file.
1 #include "chroma.h"
2 
3 #include "io/pg_hmc_io.h"
4 #include "util/gauge/gaugebc_utils.h"
5 #include "util/gauge/gaugeact_utils.h"
6 
7 #include <iostream>
8 
9 using namespace Chroma;
10 
11 int main(int argc, char *argv[])
12 {
13  // Initialise QDP
14  Chroma::initialize(&argc, &argv);
15 
16  XMLReader xml_in(Chroma::getXMLInputFileName());
17 
18  struct PureGaugeHMCParams input;
19 
20  read(xml_in, "/PureGaugeHMC/params", input);
21 
22  XMLFileWriter& xml_out = Chroma::getXMLOutputInstance();
23  XMLFileWriter& xml_log = Chroma::getXMLLogInstance();
24 
25  push(xml_out, "PureGaugeHMC");
26  push(xml_log, "PureGaugeHMC");
27 
28  write(xml_out, "params", input);
29  write(xml_log, "params", input);
30 
31  // Set up the lattice
32  Layout::setLattSize(input.MC_iters.nrow);
33  Layout::create();
34 
35  // Now create the required classes
36 
37  // Gauge Boundary
38  Handle< GaugeBC > gbc( getGaugeBCFromParams( *(input.gauge_bc_handle) ) );
39 
40 
41  // Gauge Actions
42 
43  // MC Action
44  Handle< GaugeAction > S_g_MC_handle( getGaugeActFromParams(gbc,
45  *(input.gauge_act_MC_handle) ) );
46 
47  // MD Action
48  Handle< GaugeAction > S_g_MD_handle( getGaugeActFromParams(gbc,
49  *(input.gauge_act_MD_handle) ) );
50 
51 
52  // Create the Hamiltonians
53  ExactPureGaugeHamiltonian H_MC(*(S_g_MC_handle));
54  ExactPureGaugeHamiltonian H_MD(*(S_g_MD_handle));
55 
56  // Create the MD Integrator
57  // Nasty dynamic casting...
59 
60  Handle< AbsLatColMatHybInt<
61  AbsFieldState<multi1d<LatticeColorMatrix>, multi1d<LatticeColorMatrix> >,
62  AbsHamiltonian<multi1d<LatticeColorMatrix>, multi1d<LatticeColorMatrix> >
63  >
64  > integrator_handle;
65 
66  // Get the symplectic integrator
67  switch( input.MD_params_handle->getType() ) {
68  case MD_PQP_LEAPFROG:
69  {
70  leaps_handle = new PureGaugeSympUpdates(H_MD);
71 
72  const LeapfrogParams& lf_par =
73  dynamic_cast<LeapfrogParams&>(*(input.MD_params_handle));
74 
75  integrator_handle = new PureGaugePQPLeapFrog(*leaps_handle,
76  lf_par.getStepSize(),
77  lf_par.getTrajLength());
78 
79  }
80  break;
81  default:
82  QDPIO::cerr << "Integrator not yet implemented " << std::endl;
83  QDP_abort(1);
84  }
85 
86  PureGaugeHMCTraj HMC(H_MC, *integrator_handle);
87 
88  // Startup the gauge field and momenta
89  multi1d<LatticeColorMatrix> u(Nd);
90  multi1d<LatticeColorMatrix> p(Nd);
91 
92  if( input.MC_startup.restartP == false ) {
93  // Start up from cfg
94  XMLReader file_xml;
95  XMLReader config_xml;
96 
97  gaugeStartup(file_xml, config_xml, u, input.MC_startup.start_cfg);
98  // setrn(input.MC_startup.seed);
99  }
100  else {
101  QDPIO::cerr << "Restart from saved state not yet implemented" << std::endl;
102  QDP_abort(1);
103  }
104 
105  pop(xml_log);
106  pop(xml_out);
107 
109  exit(0);
110 }
111 
Primary include file for CHROMA in application codes.
Abstract field state.
Definition: field_state.h:27
New Abstract Hamiltonian.
Class for counted reference semantics.
Definition: handle.h:33
void read(XMLReader &xml, const std::string &path, AsqtadFermActParams &param)
Read parameters.
void write(XMLWriter &xml, const std::string &path, const AsqtadFermActParams &param)
Writer parameters.
void gaugeStartup(XMLReader &gauge_file_xml, XMLReader &gauge_xml, multi1d< LatticeColorMatrix > &u, Cfg_t &cfg)
Initialize the gauge fields.
Nd
Definition: meslate.cc:74
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
XMLFileWriter & getXMLLogInstance()
Get xml log instance.
Definition: chroma_init.cc:378
static multi1d< LatticeColorMatrix > u
push(xml_out,"Condensates")
void initialize(int *argc, char ***argv)
Chroma initialisation routine.
Definition: chroma_init.cc:114
void finalize(void)
Chroma finalization routine.
Definition: chroma_init.cc:308
std::string getXMLInputFileName()
Get input file name.
Definition: chroma_init.cc:88
pop(xml_out)
XMLFileWriter & getXMLOutputInstance()
Get xml output instance.
Definition: chroma_init.cc:359
#define HMC
Definition: primitives.h:63
int main(int argc, char *argv[])
Definition: t_hmc_pg.cc:11