CHROMA
su2_hb_update.cc
Go to the documentation of this file.
1 // su2_hb_update.cc, 2004/11/16 velytsky
2 #include "chromabase.h"
4 #include "util/gauge/sunfill.h"
5 
6 namespace Chroma
7 {
8 
9  void print_field(const LatticeReal& a0);
10  void su2_a_0(const LatticeReal&, LatticeReal& ,
11  const Subset& sub, const int NmaxHB,
12  LatticeBoolean& lAccept);
13  void su2_a_0_kp(const LatticeReal&, LatticeReal& ,
14  const Subset& sub, const int NmaxHB,
15  LatticeBoolean& lAccept);
16 
17  void su2_hb_update(LatticeColorMatrix& u_mu, const LatticeColorMatrix&
18  u_mu_staple, Double BetaMC, const int su2_index,
19  const Subset& sub, const int NmaxHB)
20  {
21  // ******************************************
22  // Parameters
23  Double fuzz=1e-16; //the smallest number for devision (det)
24  // ******************************************
25  // Temp Storages
26  LatticeBoolean lbtmp; // storage for lattice booleans
27  //LatticeReal lftmp; // storage for lattice float tmps
28  // ******************************************
29  //V=U*U_staple
30  LatticeColorMatrix v;
31  v[sub]=u_mu*u_mu_staple;
32  // convert to Pauli matrices parametrization
33  LatticeReal a_0;
34  multi1d<LatticeReal> r(4);
35  su2Extract(r,v,su2_index,sub);
36  //compensate for extra 2 !!! su(2)
37  Real half(0.5);
38  r[0][sub] *= half;
39  r[1][sub] *= half;
40  r[2][sub] *= half;
41  r[3][sub] *= half;
42  LatticeReal SqDet;
43  //SqDet=-1;
44  SqDet[sub]=sqrt(r[0]*r[0]+r[1]*r[1]+r[2]*r[2]+r[3]*r[3]);
45  //print_field(SqDet);
46  // Normalize
47  //lftmp[sub]=1.0/where(lbtmp,SqDet,LatticeReal(1)); //not needed???
48  // Inverse matrix u^-1
49  r[0][sub]=r[0]/SqDet;
50  r[1][sub]=-r[1]/SqDet;
51  r[2][sub]=-r[2]/SqDet;
52  r[3][sub]=-r[3]/SqDet;
53 
54  LatticeBoolean lAccept;
55  su2_a_0(BetaMC*SqDet, a_0, sub, NmaxHB,lAccept);
56  //su2_a_0_kp(BetaMC*SqDet, a_0, sub, NmaxHB,lAccept);
57  //print_field(a_0);
58  multi1d<LatticeReal> a(4);
59  a[0][sub]=a_0;
60  //other a components
61  LatticeReal CosTheta, Phi;
62  LatticeReal a_abs;
63  LatticeInt lWarning;
64  int iWarning;
65  a_abs[sub] = 1.0-a[0]*a[0];
66  lbtmp = (1>0);
67  lbtmp[sub] = (a_abs >= 0);
68  lWarning=where(lbtmp,0,1);
69  iWarning=toInt(sum(lWarning));
70  if(iWarning>0) QDPIO::cerr <<"wrong a_0!!!"<<std::endl;
71  lbtmp = (1>0);
72  lbtmp[sub] = (a_abs > fuzz);
73  lWarning=where(lbtmp,0,1);
74  iWarning=toInt(sum(lWarning));
75  if(iWarning>0) QDPIO::cerr <<"large a_0!!!"<<std::endl;
76  LatticeReal a_r;
77  a_r[sub]=sqrt(a_abs);
78  random(CosTheta,sub);
79  Real RDummy;
80  random(RDummy);
81  CosTheta[sub]=1.0-2.0*CosTheta;
82  a[3][sub]=a_r*CosTheta;
83  //LatticeReal pr_a;
84  //pr_a[sub]=a[3];
85  //print_field(pr_a);
86  CosTheta[sub]=(1-CosTheta*CosTheta);
87  CosTheta[sub]=sqrt(CosTheta);//SinTheta
88  random(Phi,sub);
89  random(RDummy);
90  Phi[sub]*=8.0*atan(1.0);
91  a_r[sub]*=CosTheta; //a_r*SinTheta
92  a[1][sub]=a_r*cos(Phi);
93  a[2][sub]=a_r*sin(Phi);
94  //u'=uu^-1 -> b = a*r
95  multi1d<LatticeReal> b(4);
96  b[0][sub]=a[0]*r[0]-a[1]*r[1]-a[2]*r[2]-a[3]*r[3];
97  b[1][sub]=a[0]*r[1]+a[1]*r[0]-a[2]*r[3]+a[3]*r[2];
98  b[2][sub]=a[0]*r[2]+a[2]*r[0]-a[3]*r[1]+a[1]*r[3];
99  b[3][sub]=a[0]*r[3]+a[3]*r[0]-a[1]*r[2]+a[2]*r[1];
100  sunFill(v,b,su2_index,sub);
101  u_mu[sub]=where(lAccept,v*u_mu,u_mu);
102 
103  }
104 
105  void su2_a_0(const LatticeReal& weight, LatticeReal& a_0,
106  const Subset& sub,const int NmaxHB,
107  LatticeBoolean& lAccept)
108  {
109  // received weight=SqDet*BetaMC
110  int vol_cb = Layout::vol() >> 1; //volume of cb sublattice
111  int vol_accept;
112  LatticeInt ilbtmp=0;
113  lAccept = (1 < 0);
114  LatticeReal w_exp;
115  w_exp[sub]=exp(-2.0*weight); //too small, need to avoid
116  LatticeReal x; //container for random numbers
117  int n_runs=0;
118  Real RDummy;
119  do {
120  n_runs++;
121  //random(x[sub]);
122  random(x,sub);
123  random(RDummy);
124  //a_0[sub]=where(lAccept,a_0,1.0+log(x*(1.0-w_exp)+w_exp)/weight);
125  a_0[sub]=where(lAccept,a_0,1.0+log(w_exp*(1-x)+x)/weight);
126  //print_field(a_0);exit(1);
127  //random(x[sub]);
128  random(x,sub);
129  random(RDummy);
130  //lAccept[sub] = where(lAccept,(1 > 0),((x*x) < (1.0-a_0*a_0)));
131  //x=1.0l-x;
132  x=x*x;
133  LatticeReal a_0trial;
134  a_0trial=a_0*a_0;
135  a_0trial=1-a_0trial;
136  lAccept[sub] = where(lAccept,(1 > 0),(x < a_0trial));
137  //lAccept[sub] = where(lAccept,(1 > 0),(x > (1.0-sqrt(1.0-a_0*a_0))));
138  ilbtmp[sub]=where(lAccept,1,0); //convert to 1/0
139  vol_accept = toInt(sum(ilbtmp));
140  } while ((vol_accept < vol_cb) && ((NmaxHB <= 0) || (n_runs<NmaxHB)));
141  }
142 
143  void su2_a_0_kp(const LatticeReal& weight, LatticeReal& a_0,
144  const Subset& sub, const int NmaxHB,
145  LatticeBoolean& lAccept)
146  {
147  // received weight=SqDet*BetaMC
148  int vol_cb = Layout::vol() >> 1; //volume of cb sublattice
149  lAccept = (1 < 0);
150  LatticeInt ilbtmp=0;
151  int vol_accept;
152  LatticeReal xr1,xr2,xr3,xr4;
153  int n_runs=0;
154  do {
155  n_runs++;
156  random(xr1);
157  random(xr2);
158  random(xr3);
159  random(xr4);
160  xr1=-(log(xr1)/weight);
161  xr3 = cos(2.0l*M_PI*xr3);
162  xr3=xr3*xr3;
163  xr2=-(log(xr2)/weight);
164  //a_0=xr2+xr1*xr3;
165  a_0[sub]=where(lAccept,a_0,xr2+xr1*xr3);
166  lAccept[sub] = where(lAccept,(1 > 0),(xr4*xr4) < (1.0l-a_0/2.0l));
167  ilbtmp[sub]=where(lAccept,1,0); //convert to 1/0
168  vol_accept = toInt(sum(ilbtmp));
169  //QDPIO::cout<<vol_accept<<std::endl;
170 
171  } while ((vol_accept < vol_cb) && ((NmaxHB <= 0) || (n_runs<NmaxHB)));
172  a_0=1.0l-a_0;
173  }
174 
175  void print_field(const LatticeReal& a0)
176  {
177  // single node only !!!
178  double temp,fuzz=1e-44;
179  const int nodeSites = Layout::sitesOnNode();
180  const int nodeNumber = Layout::nodeNumber();
181  for(int i=0;i<nodeSites;i++) {
182  temp=toDouble(peekSite(a0,Layout::siteCoords(nodeNumber,i)));
183  if(temp > fuzz || temp<-fuzz) std::cout<<temp<<" ";
184  //if(temp > -0.1 && temp <0.01) std::cout<<temp<<" ";
185  //cout<<temp<<" ";
186  }
187  std::cout<<std::endl;
188 
189  }
190 
191 } // end namespace Chroma
Primary include file for CHROMA library code.
EXTERN Real BetaMC
int su2_index
Definition: cool.cc:27
void sunFill(LatticeColorMatrix &dest, const multi1d< LatticeReal > &r, int su2_index, const Subset &s)
Fill a dest(su2_index) <- r_0,r_1,r_2,r_3 under a subset.
Definition: sunfill.cc:33
void su2Extract(multi1d< LatticeReal > &r, const LatticeColorMatrix &source, int su2_index, const Subset &s)
Su2_extract: r_0,r_1,r_2,r_3 <- source(su2_index) [SU(N) field] under a subset.
Definition: su2extract.cc:86
int x
Definition: meslate.cc:34
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
void su2_a_0(const LatticeReal &, LatticeReal &, const Subset &sub, const int NmaxHB, LatticeBoolean &lAccept)
void su2_a_0_kp(const LatticeReal &, LatticeReal &, const Subset &sub, const int NmaxHB, LatticeBoolean &lAccept)
int i
Definition: pbg5p_w.cc:55
void print_field(const LatticeReal &a0)
Complex a
Definition: invbicg.cc:95
Complex b
Definition: invbicg.cc:96
void su2_hb_update(LatticeColorMatrix &u_mu, const LatticeColorMatrix &u_mu_staple, Double BetaMC, const int su2_index, const Subset &sub, const int NmaxHB)
FloatingPoint< double > Double
Definition: gtest.h:7351
Double sum
Definition: qtopcor.cc:37
Extract an unnormalized SU(2) matrix from a GL(3,C) matrix.
Fill an SU(Nc) matrix with an SU(2) submatrix.
#define M_PI