Last active
August 29, 2015 14:08
-
-
Save aeantipov/5174552ff5a72e3a20b6 to your computer and use it in GitHub Desktop.
accumulators::SignedObservableType + hdf5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <alps/mc/mcbase.hpp> | |
#include <alps/mc/mpiadapter.hpp> | |
#include <alps/mc/api.hpp> | |
#include <alps/mc/stop_callback.hpp> | |
#include <alps/accumulators.hpp> | |
#include <alps/params.hpp> | |
class sim1 : public alps::mcbase { | |
public: | |
sim1(parameters_type const & p, std::size_t seed_offset = 0): | |
alps::mcbase(p, seed_offset), | |
nsweeps(p["nsweeps"]), | |
count(0) | |
{ | |
measurements << | |
alps::accumulator::RealObservable("e1") << | |
alps::accumulator::SignedRealObservable("e2") << // <- Here is the bug | |
alps::accumulator::RealObservable("Sign"); | |
// alps::accumulator::RealObservable("e2"); // This works | |
} | |
void update() { count++; } | |
void measure() { | |
measurements["e1"] << 1.0; | |
measurements["e2"] << 2*(count%2)-1; | |
measurements["Sign"] << 2*(count%2)-1; | |
} | |
double fraction_completed() const { return double (count/nsweeps); } | |
private: | |
int nsweeps; | |
int count; | |
}; | |
int main(int argc, char* argv[]) | |
{ | |
boost::mpi::environment env(argc, argv); | |
boost::mpi::communicator comm; | |
alps::params p; | |
p["nsweeps"] = 100000; | |
alps::mcmpiadapter<sim1> sim (p,comm, alps::check_schedule(0.0000001, 60)); | |
sim.run(alps::stop_callback(100)); | |
alps::results_type<sim1>::type res = alps::collect_results(sim); | |
std::cout << res << std::endl; | |
if (!comm.rank()) { | |
alps::hdf5::archive ar ("save_test.h5", "w"); | |
ar["/data"] << res; // segfault with SignedObservableType | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment