CHROMA
t_conslinop.cc
Go to the documentation of this file.
1 
2 #include <iostream>
3 #include <cstdio>
4 
5 #define MAIN
6 
7 #include "chroma.h"
8 
9 using namespace Chroma;
10 
11 int main(int argc, char *argv[])
12 {
13  // Put the machine into a known state
14  Chroma::initialize(&argc, &argv);
15 
16  // Setup the layout
17  const int foo[] = {2,2,2,2};
18  multi1d<int> nrow(Nd);
19  nrow = foo; // Use only Nd elements
20  Layout::setLattSize(nrow);
21  Layout::create();
22 
23  XMLFileWriter xml("t_conslinop.xml");
24  push(xml,"t_conslinop");
25 
26  push(xml,"lattis");
27  write(xml,"Nd", Nd);
28  write(xml,"Nc", Nc);
29  write(xml,"nrow", nrow);
30  pop(xml);
31 
32  //! Example of calling a plaquette routine
33  /*! NOTE: the STL is *not* used to hold gauge fields */
34  multi1d<LatticeColorMatrix> u(Nd);
35 
36  QDPIO::cout << "Start gaussian\n";
37  for(int m=0; m < u.size(); ++m)
38  gaussian(u[m]);
39 
40  LatticeFermion psi, chi;
41  gaussian(psi);
42 
43  {
44  // Create a fermion BC. Note, the handle is on an ABSTRACT type
45  Handle< FermState<LatticeFermion,
46  multi1d<LatticeColorMatrix>,
47  multi1d<LatticeColorMatrix> > > state(new PeriodicFermState<LatticeFermion,
48  multi1d<LatticeColorMatrix>,
49  multi1d<LatticeColorMatrix> >(u));
50 
52 
53  QDPIO::cout << "before dslash call" << std::endl;
54  D.apply(chi, psi, PLUS, 0);
55  D.apply(chi, psi, PLUS, 1);
56  QDPIO::cout << "after dslash call" << std::endl;
57 
58  QDPIO::cout << "before wilson construct" << std::endl;
59  Real Mass = 0.1;
61  QDPIO::cout << "after wilson construct" << std::endl;
62  M(chi, psi, PLUS);
63  QDPIO::cout << "after wilson call" << std::endl;
64  }
65 
66  {
67  // Create your creator. Note, the handle is on an ABSTRACT type
68  Handle< CreateFermState<LatticeFermion,
69  multi1d<LatticeColorMatrix>,
70  multi1d<LatticeColorMatrix> > > cfs(new CreatePeriodicFermState<LatticeFermion,
71  multi1d<LatticeColorMatrix>,
72  multi1d<LatticeColorMatrix> >());
73 
74  Real Mass = 0.1;
76 
77  Handle< FermState<LatticeFermion,
78  multi1d<LatticeColorMatrix>,
79  multi1d<LatticeColorMatrix> > > state(S.createState(u));
80 
82 
83  LatticeFermion tmp;
84  (*A)(tmp, psi, PLUS);
85  DComplex np = innerProduct(psi,tmp);
86  (*A)(tmp, psi, MINUS);
87  DComplex nm = innerProduct(psi,tmp);
88 
89  push(xml,"norm_check");
90  write(xml,"np", np);
91  write(xml,"nm", nm);
92  pop(xml);
93  }
94 
95  pop(xml);
96 
97  // Time to bolt
99 
100  exit(0);
101 }
Primary include file for CHROMA in application codes.
Create a fermion connection state.
Definition: create_state.h:69
Create a simple ferm connection state.
Support class for fermion actions and linear operators.
Definition: state.h:94
virtual FermState< T, P, Q > * createState(const Q &q) const
Given links (coordinates Q) create the state needed for the linear operators.
Definition: fermact.h:59
Class for counted reference semantics.
Definition: handle.h:33
Periodic version of FermState.
General Wilson-Dirac dslash.
Definition: lwldslash_w.h:48
Unpreconditioned Wilson fermion action.
UnprecLinearOperator< T, P, Q > * linOp(Handle< FermState< T, P, Q > > state) const
Produce a linear operator for this action.
Unpreconditioned Wilson-Dirac operator.
void write(XMLWriter &xml, const std::string &path, const AsqtadFermActParams &param)
Writer parameters.
void apply(T &chi, const T &psi, enum PlusMinus isign, int cb) const
General Wilson-Dirac dslash.
Definition: lwldslash_w.h:228
static int m[4]
Definition: make_seeds.cc:16
Nd
Definition: meslate.cc:74
BinaryReturn< C1, C2, FnInnerProduct >::Type_t innerProduct(const QDPSubType< T1, C1 > &s1, const QDPType< T2, C2 > &s2)
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
gaussian(aux)
static multi1d< LatticeColorMatrix > u
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > const multi1d< Real > & Mass
Definition: pbg5p_w.cc:29
LatticeFermion tmp
Definition: mespbg5p_w.cc:36
push(xml_out,"Condensates")
void initialize(int *argc, char ***argv)
Chroma initialisation routine.
Definition: chroma_init.cc:114
@ MINUS
Definition: chromabase.h:45
@ PLUS
Definition: chromabase.h:45
void finalize(void)
Chroma finalization routine.
Definition: chroma_init.cc:308
multi1d< LatticeFermion > chi(Ncb)
LatticeFermion psi
Definition: mespbg5p_w.cc:35
pop(xml_out)
A(A, psi, r, Ncb, PLUS)
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > state
Definition: pbg5p_w.cc:28
int main(int argc, char *argv[])
Definition: t_conslinop.cc:11