]> git.treefish.org Git - phys/heatbath.git/blob - obs_phip2_hist.hpp
0f2ef3294052d99db9c08cc7cb7f29c85d9e934b
[phys/heatbath.git] / obs_phip2_hist.hpp
1 #ifndef OBS_PHIP2_HIST_HPP
2 #define OBS_PHIP2_HIST_HPP
3
4 #include "latlib/o815/o815.h"
5
6 #include "latlib/writeout.h"
7
8 #include "latlib/obstat.hpp"
9
10 #include <iostream>
11
12 using namespace std;
13
14 class obs_phip2_hist : public o815::obs {
15
16 public:
17   struct obsmem {
18     double phip2[4];
19   };
20   obs_phip2_hist(o815 *_O815);
21   
22 private:
23   void _start() {}
24   void _meas(bool loadedobs, const int& nthmeas);
25   void _finish() {}
26   obsmem *OM;
27   sim *Sim;
28 };
29
30 obs_phip2_hist::obs_phip2_hist(o815 *_O815) : o815::obs("phip2", 
31                                                         _O815->paraQ->getParaNames() + "nthstep:imode:kt:kx:phip2absdiffequi", _O815, 
32                                                         sizeof(obsmem), 
33                                                         "_hist") {
34   OM = (obsmem*)obsMem;
35   Sim = (sim*)O815->Sim;
36 }
37
38 void obs_phip2_hist::_meas(bool loadedobs, const int& nthmeas) {
39   for (int kpimode=0; kpimode<4; kpimode++) {
40     const double ppt = 2.*M_PI/O815->comargs.lsize[0] * ( 0 + int( kpimode/4. * O815->comargs.lsize[0] ) ) ;
41     const double ppx = 2.*M_PI/O815->comargs.lsize[1] * ( 0 + int( kpimode/4. * O815->comargs.lsize[1] ) );
42
43     if (!loadedobs) {
44       complex<double> phitildepp = 0;
45       
46       for (int ixpt = 0; ixpt < O815->comargs.lsize[0]; ixpt++)
47         for (int ixpx = 0; ixpx < O815->comargs.lsize[1]; ixpx++)
48           phitildepp += Sim->conf[ ixpt*O815->comargs.lsize[1] + ixpx ].phi 
49             * exp ( - _i_*(double)ppx*(double)ixpx - _i_*(double)ppt*(double)ixpt );
50       
51       OM->phip2[ kpimode ] = norm( phitildepp) / Sim->LSIZE2;
52     }
53     
54     *out << O815->paraQ->getParaVals();
55     *out << "\t" << ( Sim->nequi + (nthmeas+1)*Sim->nskip );
56     *out << "\t" << kpimode;
57     *out << "\t" << 0 + int( kpimode/4. * O815->comargs.lsize[0] );
58     *out << "\t" << 0 + int( kpimode/4. * O815->comargs.lsize[1] );
59     *out << "\t" << abs( OM->phip2[ kpimode ] - 1./(ppt*ppt + ppx*ppx + Sim->m*Sim->m) ) << endl;
60   }
61 };
62
63 #endif