From: Alexander Schmidt Date: Thu, 14 Nov 2013 16:49:02 +0000 (+0100) Subject: Switched to 2d and added multiple sim-algorithm compilation. X-Git-Url: http://git.treefish.org/~alex/phys/heatbath.git/commitdiff_plain/d017fdeec8363b3e871692219bb7eacb614a41f1?ds=sidebyside Switched to 2d and added multiple sim-algorithm compilation. --- diff --git a/.gitignore b/.gitignore index 3bdf24f..abf17c1 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,6 @@ Makefile CMakeCache.txt CMakeFiles data +heatbath-heatless +heatbath-relaxedheat +heatbath-usualheat diff --git a/CMakeLists.txt b/CMakeLists.txt index bedfec9..c90e8c9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,14 @@ SET(CMAKE_BUILD_TYPE Release) add_subdirectory(latlib) -add_executable(heatbath heatbath.cpp) -#set_target_properties(phi4iso-local PROPERTIES COMPILE_DEFINITIONS "LOCAL_UPDATE_ALGORITHM") -target_link_libraries(heatbath o815 gsl gslcblas lat_neigh) +add_executable(heatbath-heatless heatbath.cpp) +set_target_properties(heatbath-heatless PROPERTIES COMPILE_DEFINITIONS "HEATLESS_ALGORITHM") +target_link_libraries(heatbath-heatless o815 gsl gslcblas lat_neigh) + +add_executable(heatbath-usualheat heatbath.cpp) +set_target_properties(heatbath-usualheat PROPERTIES COMPILE_DEFINITIONS "USUALHEAT_ALGORITHM") +target_link_libraries(heatbath-usualheat o815 gsl gslcblas lat_neigh) + +add_executable(heatbath-relaxedheat heatbath.cpp) +set_target_properties(heatbath-relaxedheat PROPERTIES COMPILE_DEFINITIONS "RELAXEDHEAT_ALGORITHM") +target_link_libraries(heatbath-relaxedheat o815 gsl gslcblas lat_neigh) diff --git a/heatbath.cpp b/heatbath.cpp index de99650..e6a7803 100644 --- a/heatbath.cpp +++ b/heatbath.cpp @@ -1,12 +1,27 @@ +#include + #include "latlib/o815/o815.h" -#include "sim.hpp" +#ifdef HEATLESS_ALGORITHM +#define ALGORITHM "heatless" +#include "sim-heatless.hpp" +#elif USUALHEAT_ALGORITHM +#define ALGORITHM "usualheat" +#include "sim-usualheat.hpp" +#elif RELAXEDHEAT_ALGORITHM +#define ALGORITHM "relaxedheat" +#include "sim-relaxedheat.hpp" +#else +#error NO UPDATE-ALGORITHM DEFINED! +#endif #include "obs_phi2.hpp" o815 *O815; sim *Sim; +const complex _i_ = complex(0.0,1.0); + o815::comoption specOps[] = { { "mass", required_argument, NULL, 'm', "set mass", "min:max:inc" }, { "", 0, NULL, 0, "", "" } @@ -23,8 +38,8 @@ void parseSpecOps() } void helpHeader() -{ - cout << "Usage: ./heatbath [OPTIONS] [obs1] ... [obsN]" << endl << endl; +{ + cout << "Usage: ./heatbath-"ALGORITHM" [OPTIONS] [obs1] ... [obsN]" << endl << endl; } void parseLonelyArgs() @@ -39,7 +54,7 @@ void parseLonelyArgs() int main (int argc, char *argv[]) { - O815 = new o815(argc, argv, "heatbath", specOps, &helpHeader); + O815 = new o815(argc, argv, "heatbath-"ALGORITHM, specOps, &helpHeader); O815->addPara("mass", 1); @@ -50,7 +65,7 @@ int main (int argc, char *argv[]) O815->Sim = new sim(O815); parseLonelyArgs(); - + O815->mainLoop(); delete O815; diff --git a/obs_phi2.hpp b/obs_phi2.hpp index 23a84e4..2274442 100644 --- a/obs_phi2.hpp +++ b/obs_phi2.hpp @@ -57,7 +57,7 @@ void obs_phi2::_finish() { int compid_phi2, compid_phi2sus; compid_phi2 = oPhi2.computeEasy(); - compid_phi2sus = oPhi2.computeJack(obs_phi2::phi2Sus, &(Sim->LSIZE4)); + compid_phi2sus = oPhi2.computeJack(obs_phi2::phi2Sus, &(Sim->LSIZE2)); *out << "\t" << oPhi2.getMean(compid_phi2) << "\t" << oPhi2.getErr(compid_phi2); *out << "\t" << oPhi2.getMean(compid_phi2sus) << "\t" << oPhi2.getErr(compid_phi2sus); @@ -71,10 +71,10 @@ void obs_phi2::phi2Compute() { OM->phi2 = 0; - for (int ix = 0; ix < Sim->LSIZE4; ix++) + for (int ix = 0; ix < Sim->LSIZE2; ix++) OM->phi2 += norm( Sim->conf[ix].phi ); - OM->phi2 /= Sim->LSIZE4; + OM->phi2 /= Sim->LSIZE2; } double obs_phi2::phi2Sus(vector< vector > *vals, void *para) { diff --git a/sim-heatless.hpp b/sim-heatless.hpp new file mode 100644 index 0000000..aa305ff --- /dev/null +++ b/sim-heatless.hpp @@ -0,0 +1,58 @@ +#ifndef SIM_HPP +#define SIM_HPP + +#include +#include +#include + +#include "latlib/neigh.h" + +class sim : public o815::sim { +public: + struct siteconf { + complex phi; + }; + sim(o815 *_O815); + siteconf* conf; + unsigned int LSIZE2; + +private: + void _makeSweep(); + void _newParas(); + + gsl_rng* rangsl; + + neigh *nb; + + void updatePhi (const int& x); +}; + + + +sim::sim(o815 *_O815) : o815::sim( _O815, + sizeof(siteconf)* + (_O815->comargs.lsize[0]*_O815->comargs.lsize[1]) ) { + conf = (siteconf*)confMem; + + rangsl = gsl_rng_alloc(gsl_rng_ranlxs0); + gsl_rng_set(rangsl, time(NULL)); + + LSIZE2 = _O815->comargs.lsize[0] * _O815->comargs.lsize[1]; + + nb = new neigh(2, _O815->comargs.lsize[0], _O815->comargs.lsize[1]); +} + +void sim::updatePhi (const int& x) +{ + const double r = gsl_rng_uniform(rangsl); + const double theta = gsl_rng_uniform(rangsl) * 2*M_PI; +} + +void sim::_makeSweep() { +} + +void sim::_newParas() { + /* reset variables */ +} + +#endif diff --git a/sim-relaxedheat.hpp b/sim-relaxedheat.hpp new file mode 100644 index 0000000..aa305ff --- /dev/null +++ b/sim-relaxedheat.hpp @@ -0,0 +1,58 @@ +#ifndef SIM_HPP +#define SIM_HPP + +#include +#include +#include + +#include "latlib/neigh.h" + +class sim : public o815::sim { +public: + struct siteconf { + complex phi; + }; + sim(o815 *_O815); + siteconf* conf; + unsigned int LSIZE2; + +private: + void _makeSweep(); + void _newParas(); + + gsl_rng* rangsl; + + neigh *nb; + + void updatePhi (const int& x); +}; + + + +sim::sim(o815 *_O815) : o815::sim( _O815, + sizeof(siteconf)* + (_O815->comargs.lsize[0]*_O815->comargs.lsize[1]) ) { + conf = (siteconf*)confMem; + + rangsl = gsl_rng_alloc(gsl_rng_ranlxs0); + gsl_rng_set(rangsl, time(NULL)); + + LSIZE2 = _O815->comargs.lsize[0] * _O815->comargs.lsize[1]; + + nb = new neigh(2, _O815->comargs.lsize[0], _O815->comargs.lsize[1]); +} + +void sim::updatePhi (const int& x) +{ + const double r = gsl_rng_uniform(rangsl); + const double theta = gsl_rng_uniform(rangsl) * 2*M_PI; +} + +void sim::_makeSweep() { +} + +void sim::_newParas() { + /* reset variables */ +} + +#endif diff --git a/sim-usualheat.hpp b/sim-usualheat.hpp new file mode 100644 index 0000000..aa305ff --- /dev/null +++ b/sim-usualheat.hpp @@ -0,0 +1,58 @@ +#ifndef SIM_HPP +#define SIM_HPP + +#include +#include +#include + +#include "latlib/neigh.h" + +class sim : public o815::sim { +public: + struct siteconf { + complex phi; + }; + sim(o815 *_O815); + siteconf* conf; + unsigned int LSIZE2; + +private: + void _makeSweep(); + void _newParas(); + + gsl_rng* rangsl; + + neigh *nb; + + void updatePhi (const int& x); +}; + + + +sim::sim(o815 *_O815) : o815::sim( _O815, + sizeof(siteconf)* + (_O815->comargs.lsize[0]*_O815->comargs.lsize[1]) ) { + conf = (siteconf*)confMem; + + rangsl = gsl_rng_alloc(gsl_rng_ranlxs0); + gsl_rng_set(rangsl, time(NULL)); + + LSIZE2 = _O815->comargs.lsize[0] * _O815->comargs.lsize[1]; + + nb = new neigh(2, _O815->comargs.lsize[0], _O815->comargs.lsize[1]); +} + +void sim::updatePhi (const int& x) +{ + const double r = gsl_rng_uniform(rangsl); + const double theta = gsl_rng_uniform(rangsl) * 2*M_PI; +} + +void sim::_makeSweep() { +} + +void sim::_newParas() { + /* reset variables */ +} + +#endif diff --git a/sim.hpp b/sim.hpp deleted file mode 100644 index 2e9a6b8..0000000 --- a/sim.hpp +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef SIM_HPP -#define SIM_HPP - -#include -#include - -#include "latlib/neigh.h" - -class sim : public o815::sim { -public: - struct siteconf { - complex phi; - }; - sim(o815 *_O815); - siteconf* conf; - int LSIZE4; - -private: - void _makeSweep(); - void _newParas(); - - gsl_rng* rangsl; - - neigh *nb; -}; - -sim::sim(o815 *_O815) : o815::sim( _O815, - sizeof(siteconf)* - (_O815->comargs.lsize[0]*_O815->comargs.lsize[0]*_O815->comargs.lsize[0]*_O815->comargs.lsize[1]) ) { - conf = (siteconf*)confMem; - LSIZE4 = _O815->comargs.lsize[0] * _O815->comargs.lsize[0] * _O815->comargs.lsize[0] * _O815->comargs.lsize[1]; - - rangsl = gsl_rng_alloc(gsl_rng_ranlxs0); - gsl_rng_set(rangsl, time(NULL)); - - nb = new neigh(4, _O815->comargs.lsize[0], _O815->comargs.lsize[0], _O815->comargs.lsize[0], _O815->comargs.lsize[1]); -} - -void sim::_makeSweep() { -} - -void sim::_newParas() { - /* reset variables */ -} - -#endif