LatticeYangMills
wilsonflow.cpp
Go to the documentation of this file.
1 /******************************************************************************
2 *
3 * MIT License
4 *
5 * Copyright (c) 2018 Giovanni Pederiva
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * SOFTWARE.
24 ******************************************************************************/
25 
35 #include "Utils/clusterspecifier.h"
36 #ifndef LACONIA
37 #include <mpi/mpi.h>
38 #else
39 #include <mpi.h>
40 #endif
41 #include <vector>
42 #include <cstdio>
43 #include <string>
44 #include <ctime>
45 #include <cmath>
46 #include <random>
47 #include "lqcd.h"
48 
49 
55  initialize();
57 }
58 
64 WilsonFlow::WilsonFlow(double tauFinal, double epsilon){
65  m_epsilon = epsilon;
66  m_tauFinal = tauFinal;
67 }
68 
73  for(auto& obs : m_obs)
74  obs->initObservable(m_lat);
76  m_obsValues.resize(m_obs.size());
77 
78  LatticeIO::InputConf::getInputList(m_inputConfList);
81 }
82 
87 void WilsonFlow::createLattice(std::array<int,4> latticeSize){
88  m_size = latticeSize;
89  m_lat = new GluonField(m_size);
90  m_Z = new GluonField(m_size);
91 }
92 
97  // check that current processor should be active
98  int confNum = 0;
99  if(Parallel::isActive()){
100  for(auto& conf : m_inputConfList){
101  LatticeIO::InputConf::readConf(*m_lat, conf.c_str());
102  MPI_Barrier(Parallel::cartCoordComm());
105  applyWilsonFlow(confNum);
106  confNum++;
107  }
108  }
109 }
110 
115 void WilsonFlow::applyWilsonFlow(int confNum){
116  std::vector<std::vector<double>> flowObsMatrix;
117  flowObsMatrix.resize(int(m_tauFinal/m_epsilon));
118  for(auto& slice : flowObsMatrix)
119  slice.resize(4);
120  flowObsMatrix[0][0] = 0.0;
121  flowObsMatrix[0][1] = m_obs[0]->plaq;
122  flowObsMatrix[0][2] = m_obs[0]->topc;
123  flowObsMatrix[0][3] = m_obs[0]->energy;
124  for(int t = 1; t < flowObsMatrix.size(); t++){
125  flowStep();
126  flowObsMatrix[t][0] = flowObsMatrix[t-1][0] + m_epsilon;
128  //for(int i = 0; i < m_obs.size(); i++)
129  // flowObsMatrix[t][i+1] = m_obs[i]->value();
130  flowObsMatrix[t][1] = m_obs[0]->plaq;
131  flowObsMatrix[t][2] = m_obs[0]->topc;
132  flowObsMatrix[t][3] = m_obs[0]->energy;
133  LatticeIO::OutputTerm::writeFlowObs(flowObsMatrix[t][0], m_obs);
134  }
135  LatticeIO::OutputObs::writeFlowObs(confNum, m_obs, flowObsMatrix);
136 }
137 
142  // compute Z0
143  for(int mu = 0; mu < 4; mu++)
144  (*m_Z)[mu] = m_act->computeDerivative(mu);
145 
146  // compute W1
147  for(int mu = 0; mu < 4; mu++){
148  (*m_lat)[mu] = exp((*m_Z)[mu] * m_epsilon * (1.0/4.0))* (*m_lat)[mu];
149  }
150 
151  // compute Z1
152  for(int mu = 0; mu < 4; mu++)
153  (*m_Z)[mu] = m_act->computeDerivative(mu)*(8.0/9.0)
154  - (*m_Z)[mu]*(17.0/36.0);
155 
156 
157  // compute W2
158  for(int mu = 0; mu < 4; mu++){
159  (*m_lat)[mu] = exp((*m_Z)[mu]*m_epsilon)* (*m_lat)[mu];
160  }
161 
162  // compute Z2
163  for(int mu = 0; mu < 4; mu++)
164  (*m_Z)[mu] = m_act->computeDerivative(mu)*(3.0/4.0)
165  - (*m_Z)[mu];
166 
167 
168  // compute V_t+eps
169  for(int mu = 0; mu < 4; mu++){
170  (*m_lat)[mu] = exp((*m_Z)[mu] *m_epsilon)* (*m_lat)[mu];
171  }
172 }
173 
174 
179  for(auto& obs : m_obs)
180  obs->compute();
181 }
void flowConfigurations()
applies the gradient flow to all the configurations given as input
Definition: wilsonflow.cpp:96
void computeObservables()
computes all observables in the Observable vector
Definition: wilsonflow.cpp:178
std::vector< Observable * > m_obs
Vector of pointers to Observable instances.
Definition: app.h:75
WilsonFlow(double tauFinal, double epsilon)
constructor of the class
Definition: wilsonflow.cpp:64
static void printInitialConditions()
Prints basic info about the system.
Definition: outputterm.cpp:45
void applyWilsonFlow(int confNum)
applies the gradient flow to one configuration
Definition: wilsonflow.cpp:115
void initialize()
runs the initializers of the subclasses.
Definition: wilsonflow.cpp:72
void createLattice(std::array< int, 4 > latticeSize)
creates the GluonField object and the temporary lattice for the action derivative.
Definition: wilsonflow.cpp:87
static void writeFlowObs(double flowTime, std::vector< Observable * > &obsList)
Prints information about a flow time evolution step.
Definition: outputterm.cpp:108
void execute()
Executes the App. First initializes the system then applies the gradient flow to the configurations...
Definition: wilsonflow.cpp:54
static void writeFlowObs(int confNum, std::vector< Observable * > &obsList, std::vector< std::vector< double >> &obsMatrix)
Writes the observables for given flow step.
Definition: outputobs.cpp:97
Main include file for all headers.
GluonField * m_lat
Pointer to the GluonField instance.
Definition: app.h:71
std::array< int, 4 > m_size
Size of the sublattice.
Definition: app.h:73
static void readConf(GluonField &lattice, int confNum)
Reads a binary file from a int marker for the name.
Definition: inputconf.cpp:136
void initAction(GluonField *field)
Links the action to a given field and initializes.
Definition: action.cpp:41
void flowStep()
applies one step of the integration scheme, described in paper
Definition: wilsonflow.cpp:141
Action * m_act
Pointer to the Action instance.
Definition: app.h:69
static void getInputList(std::vector< std::string > &inputConfList)
Returns a list of all valid input files in a the input directory.
Definition: inputconf.cpp:109
SU3 exp(const SU3 &Q)
exponential of a SU3 algebra matrix
Definition: su3.cpp:136
Field< SU3, 4 > GluonField
Definition: field.h:76
virtual Lattice< SU3 > computeDerivative(int mu)=0
Computes the derivative in a given direction around all links.
static void writeObs(int confNum, std::vector< Observable * > &obsList)
Prints the status of the current object list for a given conf.
Definition: outputterm.cpp:91
static void initialize(std::vector< Observable * > &obsList)
Opens the files and writes needed headers.
Definition: outputobs.cpp:63