00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00032 class fermi_propagator: public mdp_complex_field {
00033 public:
00034 int nspin, nc;
00035 fermi_propagator() {
00036 reset_field();
00037 };
00038 fermi_propagator(mdp_lattice &mylattice, int nc_, int nspin_=4) {
00039 reset_field();
00040 nspin=nspin_;
00041 nc=nc_;
00042 allocate_field(mylattice, nspin*nspin*nc*nc);
00043 };
00044 void allocate_fermi_propagator(mdp_lattice &mylattice,
00045 int nc_, int nspin_=4) {
00046 deallocate_field();
00047 nspin=nspin_;
00048 nc=nc_;
00049 allocate_field(mylattice, nspin*nspin*nc*nc);
00050 };
00051 inline mdp_matrix operator() (site x, int a, int b) {
00052 mdp_matrix tmp(address(x,(a*nspin+b)*nc*nc), nc, nc);
00053 return tmp;
00054 };
00055 inline mdp_complex &operator() (site x, int a, int b, int i, int j) {
00056 return *(address(x,((a*nspin+b)*nc+i)*nc+j));
00057 };
00068 friend void generate(fermi_propagator &S, gauge_field &U,
00069 coefficients &coeff,
00070 mdp_real absolute_precision=fermi_inversion_precision,
00071 mdp_real relative_precision=0,
00072 int max_steps=2000,
00073 void (*smf)(fermi_field&,
00074 gauge_field&,
00075 coefficients&)=0,
00076 coefficients smear_coeff=coefficients(),
00077 int comp=0) {
00078 fermi_field psi(S.lattice(),S.nc,S.nspin);
00079 fermi_field chi(S.lattice(),S.nc,S.nspin);
00080 site x(S.lattice());
00081 int i,j,a,b;
00082 double time=mpi.time();
00083 inversion_stats stats;
00084 begin_function("generate");
00085 mdp << "BEGIN Generating ordinary propagator\n";
00086
00087 for(b=0; b<psi.nspin; b++)
00088 for(j=0; j<psi.nc; j++) {
00089
00090 mdp << "Source: spin=" << b << ", color=" << j << '\n';
00091
00092 forallsitesandcopies(x)
00093 for(a=0; a<psi.nspin; a++)
00094 for(i=0; i<psi.nc; i++) {
00095 if((x.is_equal(0)) && (a==b) && (i==j)) psi(x,a,i)=1;
00096 else psi(x,a,i)=0;
00097 }
00098
00099
00100
00101
00102
00103 if(smf!=0) (*smf)(psi,U,smear_coeff);
00104 stats=mul_invQ(chi,psi,U,coeff,
00105 absolute_precision,relative_precision,max_steps);
00106
00107 forallsites(x)
00108 for(a=0; a<psi.nspin; a++)
00109 for(i=0; i<psi.nc; i++) {
00110 S(x,a,b,i,j)=chi(x,a,i);
00111 }
00112 cout << "Statistics: residue=" << stats.residue
00113 << ", steps=" << stats.steps
00114 << ", time=" << stats.time << '\n';
00115 }
00116 mdp << "END Generating ordinary propagator. ";
00117 mdp << "time=" << mpi.time()-time << '\n';
00118 end_function("generate");
00119 }
00120 };
00121
00122
00123
00124
00126
00127 void print_propagator(fermi_propagator &S) {
00128 begin_function("print_propagator");
00129 int x0,x1,x2,x3;
00130 site x(S.lattice());
00131 int spin_source, spin_sink;
00132 int color_source, color_sink;
00133 mdp_complex tmp;
00134 int do_exit=false;
00135 int nc=S.nc;
00136 do {
00137 mdp << "\nCheck point!\n";
00138 mdp << "Here you called the function to print the propagator\n";
00139 mdp << "Enter the coordinates (x0,x1,x2,x3 or 'quit' to end): ";
00140 if(ME==0) {
00141 string stringa;
00142 cin >> stringa;
00143 if(stringa=="quit") do_exit=true;
00144 else sscanf(stringa.c_str(),"%i,%i,%i,%i", &x0,&x1,&x2,&x3);
00145 }
00146 mpi.broadcast(do_exit,0);
00147 if(do_exit==true) {
00148 mdp << '\n';
00149 break;
00150 };
00151 mpi.broadcast(x0,0);
00152 mpi.broadcast(x1,0);
00153 mpi.broadcast(x2,0);
00154 mpi.broadcast(x3,0);
00155 if(on_which_process(S.lattice(),x0,x1,x2,x3)==ME) {
00156 x.set(x0,x1,x2,x3);
00157 for(color_source=0; color_source<nc; color_source++)
00158 for(spin_source=0; spin_source<4; spin_source++) {
00159 mdp << "Source: spin=" << spin_source
00160 << ", color=" << color_source << '\n';
00161 for(spin_sink=0; spin_sink<4; spin_sink++) {
00162 mdp << "[ ";
00163 for(color_sink=0; color_sink<nc; color_sink++) {
00164 tmp=S(x,spin_sink, spin_source, color_sink, color_source);
00165 mdp << tmp;
00166 if(color_sink<nc-1) mdp << ",\t";
00167 };
00168 mdp << " ]\n";
00169 };
00170 };
00171 fflush(stdout);
00172 };
00173 } while(1);
00174 begin_function("print_propagator");
00175 };