From 3b53450b9236dc50abe652913cad17dedfca50df Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Wed, 10 Oct 2018 00:26:35 -0400 Subject: extended NOFIELD support when FINITE_STATES is also invoked --- CMakeLists.txt | 4 ++++ lib/finite_states.h | 14 ++++++++++---- lib/wolff.h | 4 ++++ src/wolff_ising.cpp | 4 ++++ 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 89c55a6..9eb1e48 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,7 @@ file(GLOB CSOURCES lib/*.c) file(GLOB CPPSOURCES lib/*.cpp) add_executable(wolff_ising src/wolff_ising.cpp ${CPPSOURCES} ${CSOURCES}) +add_executable(wolff_ising_2D_0 src/wolff_ising.cpp ${CPPSOURCES} ${CSOURCES}) add_executable(wolff_dgm src/wolff_dgm.cpp ${CPPSOURCES} ${CSOURCES}) add_executable(wolff_cgm src/wolff_cgm.cpp ${CPPSOURCES} ${CSOURCES}) add_executable(wolff_3potts src/wolff_potts.cpp ${CPPSOURCES} ${CSOURCES}) @@ -28,6 +29,7 @@ add_executable(wolff_planar_2D_0 src/wolff_On.cpp ${CPPSOURCES} ${CSOURCES}) add_executable(wolff_heisenberg src/wolff_On.cpp ${CPPSOURCES} ${CSOURCES}) add_executable(analyze_correlations src/analyze_correlations.cpp ${CPPSOURCES} ${CSOURCES}) +SET_TARGET_PROPERTIES(wolff_ising_2D_0 PROPERTIES COMPILE_FLAGS "-DDIMENSION=2 -DNOFIELD") SET_TARGET_PROPERTIES(wolff_3potts PROPERTIES COMPILE_FLAGS "-DPOTTSQ=3") SET_TARGET_PROPERTIES(wolff_4potts PROPERTIES COMPILE_FLAGS "-DPOTTSQ=4") SET_TARGET_PROPERTIES(wolff_7potts PROPERTIES COMPILE_FLAGS "-DPOTTSQ=7") @@ -49,6 +51,7 @@ target_link_libraries(analyze_correlations cblas gsl fftw3 m) if (${GLUT} MATCHES "GLUT-NOTFOUND") target_link_libraries(wolff_ising cblas gsl m) + target_link_libraries(wolff_ising_2D_0 cblas gsl m) target_link_libraries(wolff_dgm cblas gsl m) target_link_libraries(wolff_cgm cblas gsl m) target_link_libraries(wolff_3potts cblas gsl m) @@ -62,6 +65,7 @@ if (${GLUT} MATCHES "GLUT-NOTFOUND") target_link_libraries(wolff_planar_2D_0 cblas gsl m) else() target_link_libraries(wolff_ising cblas gsl m glut GL GLU) + target_link_libraries(wolff_ising_2D_0 cblas gsl m glut GL GLU) target_link_libraries(wolff_dgm cblas gsl m glut GL GLU) target_link_libraries(wolff_cgm cblas gsl m glut GL GLU) target_link_libraries(wolff_3potts cblas gsl m glut GL GLU) diff --git a/lib/finite_states.h b/lib/finite_states.h index 08eff30..426edad 100644 --- a/lib/finite_states.h +++ b/lib/finite_states.h @@ -11,20 +11,26 @@ // invoking header std::array, N_STATES>, N_STATES> J_probs; +#ifndef NOFIELD std::array, N_STATES> H_probs; +#endif template +#ifndef NOFIELD void initialize_probs(std::function J, std::function H, double T) { for (q_t i = 0; i < N_STATES; i++) { for (q_t j = 0; j < N_STATES; j++) { - for (q_t k = 0; k < N_STATES; k++) { - J_probs[i][j][k] = 1.0 - exp(-(J(states[i], states[k]) - J(states[j], states[k])) / T); - } + H_probs[i][j] = 1.0 - exp(-(H(states[i]) - H(states[j])) / T); } } +#else +void initialize_probs(std::function J, double T) { +#endif for (q_t i = 0; i < N_STATES; i++) { for (q_t j = 0; j < N_STATES; j++) { - H_probs[i][j] = 1.0 - exp(-(H(states[i]) - H(states[j])) / T); + for (q_t k = 0; k < N_STATES; k++) { + J_probs[i][j][k] = 1.0 - exp(-(J(states[i], states[k]) - J(states[j], states[k])) / T); + } } } } diff --git a/lib/wolff.h b/lib/wolff.h index 498f7f3..141a5b2 100644 --- a/lib/wolff.h +++ b/lib/wolff.h @@ -6,7 +6,11 @@ template void wolff(count_t N, state_t & s, std::function gen_R, std::function &)> measurements, gsl_rng *r, bool silent) { #ifdef FINITE_STATES +#ifdef NOFIELD + initialize_probs(s.J, s.T); +#else initialize_probs(s.J, s.H, s.T); +#endif #endif if (!silent) printf("\n"); diff --git a/src/wolff_ising.cpp b/src/wolff_ising.cpp index 24bf74c..a6f43b1 100644 --- a/src/wolff_ising.cpp +++ b/src/wolff_ising.cpp @@ -117,7 +117,11 @@ int main(int argc, char *argv[]) { }; // initialize state object +#ifndef NOFIELD state_t s(D, L, T, Z, B); +#else + state_t s(D, L, T, Z); +#endif // define function that generates self-inverse rotations std::function gen_R = [] (gsl_rng *, const ising_t& s) -> z2_t { -- cgit v1.2.3-54-g00ecf