CHROMA
twisted_fermbc_w.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 /*! \file
3  * \brief Twisted fermionic BC
4  */
5 
6 #ifndef __twisted_fermbc_w_h__
7 #define __twisted_fermbc_w_h__
8 
9 #include "fermbc.h"
10 #include "handle.h"
12 
13 namespace Chroma
14 {
15  //! Params struct for twisted params
16  /*! \ingroup fermbcs */
19  TwistedFermBCParams(XMLReader& in, const std::string& path);
20  multi1d<int> boundary;
21  multi1d<Real> phases_by_pi;
22  multi1d<int> phases_dir;
23  };
24 
25  // Readers writers
26  void read(XMLReader& xml, const std::string& path, TwistedFermBCParams& param);
27  void write(XMLWriter& xml, const std::string& path, const TwistedFermBCParams& param);
28 
29 
30  //! Name and registration
31  /*! \ingroup fermbcs */
32  namespace WilsonTypeTwistedFermBCEnv
33  {
34  extern const std::string name;
35  bool registerAll();
36  }
37 
38 
39  //! Concrete class for all fermionic actions with twisted boundary conditions
40  /*!
41  * \ingroup fermbcs
42  *
43  * Twisted BC
44  */
45  template<class T>
46  class TwistedFermBC : public FermBC<T,
47  multi1d<LatticeColorMatrix>,
48  multi1d<LatticeColorMatrix> >
49  {
50  public:
51 
52  //! Only full constructor
53  /*!
54  * \param boundary_phases multiply links on edge of lattice by boundary
55  *
56  * NOTE: there is no real reason this is of type int, could be more general
57  * like Complex
58  */
59 
60  TwistedFermBC(const multi1d<int>& boundary_,
61  const multi1d<Real>& phases_by_pi_,
62  const multi1d<int>& phases_dir_) :
63  phases_by_pi(phases_by_pi_),
64  phases_dir(phases_dir_),
66  multi1d<LatticeColorMatrix>,
67  multi1d<LatticeColorMatrix> >(boundary_))
68  {
69  check_arrays(phases_by_pi_, phases_dir_);
70  }
71 
72  //! Copy constructor
77  {
78  check_arrays(a.phases_by_pi, a.phases_dir);
79  }
80 
81  //! Destructor is automatic
83 
84  //! Assignment
86  {
87  phases_by_pi = a.phases_by_pi;
88  phases_dir = a.phases_dir;
89  simple_bc_handle = a.simple_bc_handle;
90  check_arrays(a.phases_by_pi, a.phases_dir);
91  return *this;
92  }
93 
94 
95  //! Modify U fields in place
96  void modify(multi1d<LatticeColorMatrix>& u) const
97  {
98  START_CODE();
99 
100  // Apply the simple BC's first
101  (*simple_bc_handle).modify(u);
102  const Real twopi = Real(6.283185307179586476925286);
103  const Real onepi = twopi/Real(2);
104 
105  const multi1d<int>& nrow = Layout::lattSize();
106 
107  // Loop over the three twist angles
108  for(int i=0; i < Nd-1; i++)
109  {
110  int direction = phases_dir[i];
111  Real arg = phases_by_pi[i]*onepi / Real( nrow[ direction ] );
112  Real re = cos(arg);
113  Real im = sin(arg);
114  Complex phase = cmplx( re, im );
115  u[ direction ] *= phase;
116  }
117 
118  END_CODE();
119  }
120 
121  //! Modify fermion fields in place
122  /*! NOP */
123  void modifyF(T& psi) const {}
124 
125  //! Modify fermion fields in place under a subset
126  /*! NOP */
127  void modifyF(T& psi, const Subset& s) const {}
128 
129  //! Modify fermion fields in place
130  /*! NOP */
131  void modifyF(multi1d<T>& psi) const {}
132 
133  //! Modify fermion fields in place under a subset
134  /*! NOP */
135  void modifyF(multi1d<T>& psi, const Subset& s) const {}
136 
137  //! Zero some gauge-like field in place on the masked links
138  /*! NOP */
139  void zero(multi1d<LatticeColorMatrix>& ds_u) const {}
140 
141  //! Says if there are non-trivial BC links
142  bool nontrivialP() const {return true;}
143 
144 
145  private:
146  // No empty constructor
148 
149  void check_arrays( const multi1d<Real> phases_by_pi,
150  const multi1d<int> phases_dir )
151  {
152  START_CODE();
153 
154  if( phases_by_pi.size() != (Nd-1) ) {
155  QDPIO::cerr << "TwistedFermBCParams: Invalid size for phases_by_pi. Should be " << Nd-1 << " but is " << phases_by_pi.size() << std::endl;
156  QDP_abort(1);
157  }
158 
159  if( phases_dir.size() != (Nd-1) ) {
160  QDPIO::cerr << "TwistedFermBCParams: Invalid size for phases_dir. Should be " << Nd-1 << " but is " << phases_dir.size() << std::endl;
161  QDP_abort(1);
162  }
163 
164  for(int i=0; i < Nd-1; i++) {
165  if( toBool( phases_dir[i] < 0 || phases_dir[i] > Nd-1 ) ) {
166  QDPIO::cerr << "Invalid value in phases_dir, direction " << i << " should be between 0 and " << Nd-1 << " but is " << phases_dir[i] << std::endl;
167  }
168  }
169 
170  END_CODE();
171  }
172 
173  private:
174  multi1d<Real> phases_by_pi;
175  multi1d<int> phases_dir;
176  multi1d<int> boundary;
177 
179  multi1d<LatticeColorMatrix>,
180  multi1d<LatticeColorMatrix> > > simple_bc_handle;
181  };
182 
183 
184 } // Namespace Chroma
185 
186 
187 // End of include guard
188 #endif
Base class for all fermion action boundary conditions.
Definition: fermbc.h:20
Class for counted reference semantics.
Definition: handle.h:33
Concrete class for all gauge actions with simple boundary conditions.
Definition: simple_fermbc.h:42
Concrete class for all fermionic actions with twisted boundary conditions.
void zero(multi1d< LatticeColorMatrix > &ds_u) const
Zero some gauge-like field in place on the masked links.
bool nontrivialP() const
Says if there are non-trivial BC links.
TwistedFermBC & operator=(const TwistedFermBC &a)
Assignment.
void modifyF(T &psi, const Subset &s) const
Modify fermion fields in place under a subset.
void modifyF(multi1d< T > &psi, const Subset &s) const
Modify fermion fields in place under a subset.
multi1d< Real > phases_by_pi
void modify(multi1d< LatticeColorMatrix > &u) const
Modify U fields in place.
~TwistedFermBC()
Destructor is automatic.
void modifyF(multi1d< T > &psi) const
Modify fermion fields in place.
void modifyF(T &psi) const
Modify fermion fields in place.
multi1d< int > phases_dir
TwistedFermBC(const multi1d< int > &boundary_, const multi1d< Real > &phases_by_pi_, const multi1d< int > &phases_dir_)
Only full constructor.
void check_arrays(const multi1d< Real > phases_by_pi, const multi1d< int > phases_dir)
Handle< SimpleFermBC< T, multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > > simple_bc_handle
TwistedFermBC(const TwistedFermBC &a)
Copy constructor.
Fermion action boundary conditions.
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.
Class for counted reference semantics.
Nd
Definition: meslate.cc:74
bool registerAll()
Register all the factories.
const std::string name
Name to be used.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
static multi1d< LatticeColorMatrix > u
LinOpSysSolverMGProtoClover::T T
int i
Definition: pbg5p_w.cc:55
const Real twopi
Definition: chromabase.h:55
Complex a
Definition: invbicg.cc:95
LatticeFermion psi
Definition: mespbg5p_w.cc:35
START_CODE()
static QDP_ColorVector * in
multi1d< LatticeFermion > s(Ncb)
::std::string string
Definition: gtest.h:1979
Simple fermionic BC.
Params struct for twisted params.