From: Alexander Schmidt Date: Mon, 18 Nov 2013 15:12:47 +0000 (+0100) Subject: Added phi2_hist. X-Git-Url: http://git.treefish.org/~alex/phys/heatbath.git/commitdiff_plain/628f4432052ed72944d5cf663c0cde4da9ac6d56?ds=sidebyside Added phi2_hist. --- diff --git a/heatbath.cpp b/heatbath.cpp index dbfe63a..13b6f51 100644 --- a/heatbath.cpp +++ b/heatbath.cpp @@ -16,6 +16,7 @@ #endif #include "obs_phi2.hpp" +#include "obs_phi2_hist.hpp" o815 *O815; sim *Sim; @@ -48,7 +49,11 @@ void parseLonelyArgs() if ( strcmp(*lonit, "phi2") == 0 ) { *O815->out->log << "MASTER: registered observable: phi2" << endl << flush; O815->observables.push_back(new obs_phi2(O815)); - } + } + else if ( strcmp(*lonit, "phi2_hist") == 0 ) { + *O815->out->log << "MASTER: registered observable: phi2_hist" << endl << flush; + O815->observables.push_back(new obs_phi2_hist(O815)); + } } } diff --git a/latlib b/latlib index a2b065a..d09f5f0 160000 --- a/latlib +++ b/latlib @@ -1 +1 @@ -Subproject commit a2b065a04a23009d81caab4ce169497b042b352b +Subproject commit d09f5f0aeff338a0262c3faf5272b82945a3bf8f diff --git a/obs_phi2.hpp b/obs_phi2.hpp index 2274442..b2140e1 100644 --- a/obs_phi2.hpp +++ b/obs_phi2.hpp @@ -21,7 +21,7 @@ public: private: void _start(); - void _meas(bool loadedobs); + void _meas(bool loadedobs, const int& nthmeas); void _finish(); obsmem* OM; @@ -44,7 +44,7 @@ void obs_phi2::_start() { //*out << "OBS_test: start" << endl; }; -void obs_phi2::_meas(bool loadedobs) { +void obs_phi2::_meas(bool loadedobs, const int& nthmeas) { if (!loadedobs) phi2Compute(); diff --git a/obs_phi2_hist.hpp b/obs_phi2_hist.hpp new file mode 100644 index 0000000..b97d38c --- /dev/null +++ b/obs_phi2_hist.hpp @@ -0,0 +1,57 @@ +#ifndef OBS_PHI2_HIST_HPP +#define OBS_PHI2_HIST_HPP + +#include "latlib/o815/o815.h" + +#include "latlib/writeout.h" + +#include "latlib/obstat.hpp" + +#include + +using namespace std; + +class obs_phi2_hist : public o815::obs { + +public: + struct obsmem { + double phi2; + }; + obs_phi2_hist(o815 *_O815); + +private: + void _start() {} + void _meas(bool loadedobs, const int& nthmeas); + void _finish() {} + obsmem* OM; + void phi2Compute(); + sim *Sim; +}; + +obs_phi2_hist::obs_phi2_hist(o815 *_O815) : o815::obs("phi2", + _O815->paraQ->getParaNames() + "nthstep:phi2:phi2_err", + _O815, sizeof(obsmem), "_hist") { + OM = (obsmem*)obsMem; + Sim = (sim*)O815->Sim; +} + +void obs_phi2_hist::_meas(bool loadedobs, const int& nthmeas) { + if (!loadedobs) + phi2Compute(); + + *out << O815->paraQ->getParaVals(); + *out << "\t" << ( Sim->nequi + (nthmeas+1)*Sim->nskip ); + *out << "\t" << OM->phi2 << endl; +}; + +void obs_phi2_hist::phi2Compute() +{ + OM->phi2 = 0; + + for (int ix = 0; ix < Sim->LSIZE2; ix++) + OM->phi2 += norm( Sim->conf[ix].phi ); + + OM->phi2 /= Sim->LSIZE2; +} + +#endif