From 72301b3d5c3a91ff2e7fc6eedcad7bce8e647efa Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Thu, 19 Jul 2018 18:22:15 -0400 Subject: efficient computation of the smallest fourier mode by doing a magnetization-style update anytime a bond with the external field changes --- lib/cluster.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lib/cluster.h') diff --git a/lib/cluster.h b/lib/cluster.h index 8061d34..2225e2f 100644 --- a/lib/cluster.h +++ b/lib/cluster.h @@ -94,12 +94,15 @@ void flip_cluster(state_t *state, v_t v0, R_t r, gsl_rng *rand) { if (is_ext) { X_t rs_old, rs_new; + v_t non_ghost; if (vn == state->nv) { rs_old = act_inverse (R_old, si_old); rs_new = act_inverse (R_old, si_new); + non_ghost = v; } else { rs_old = act_inverse (R_old, sj); rs_new = act_inverse (R_new, sj); + non_ghost = vn; } double dE = state->H(rs_old) - state->H(rs_new); prob = 1.0 - exp(-dE / state->T); @@ -108,6 +111,15 @@ void flip_cluster(state_t *state, v_t v0, R_t r, gsl_rng *rand) { add (&(state->M), rs_new); state->E += dE; + for (D_t i = 0; i < state->D; i++) { + double x = (double)((non_ghost / (v_t)pow(state->L, state->D - i - 1)) % state->L) / (double)state->L; + scalar_subtract(&(state->ReF[i]), cos(2 * M_PI * x), rs_old); + scalar_add(&(state->ReF[i]), cos(2 * M_PI * x), rs_new); + + scalar_subtract(&(state->ImF[i]), sin(2 * M_PI * x), rs_old); + scalar_add(&(state->ImF[i]), sin(2 * M_PI * x), rs_new); + } + free_spin (rs_old); free_spin (rs_new); } else { -- cgit v1.2.3-70-g09d2