]> git.treefish.org Git - phys/heatbath.git/commitdiff
Added phi2_hist.
authorAlexander Schmidt <alex@treefish.org>
Mon, 18 Nov 2013 15:12:47 +0000 (16:12 +0100)
committerAlexander Schmidt <alex@treefish.org>
Mon, 18 Nov 2013 15:12:47 +0000 (16:12 +0100)
heatbath.cpp
latlib
obs_phi2.hpp
obs_phi2_hist.hpp [new file with mode: 0644]

index dbfe63ae7aa2bd0f52455d22a951fe212e87418b..13b6f5114ae42dcc6a2bd2d63a14b5e168a83b3b 100644 (file)
@@ -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 a2b065a04a23009d81caab4ce169497b042b352b..d09f5f0aeff338a0262c3faf5272b82945a3bf8f 160000 (submodule)
--- a/latlib
+++ b/latlib
@@ -1 +1 @@
-Subproject commit a2b065a04a23009d81caab4ce169497b042b352b
+Subproject commit d09f5f0aeff338a0262c3faf5272b82945a3bf8f
index 227444211307bf9007feb4594862c3cbba052d9c..b2140e1f955904624ff8f9c161d766cecc7bea91 100644 (file)
@@ -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 (file)
index 0000000..b97d38c
--- /dev/null
@@ -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 <iostream>
+
+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