diff options
author | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2017-06-21 17:29:10 -0400 |
---|---|---|
committer | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2017-06-21 17:29:10 -0400 |
commit | f2639be5d5006079868f69b0c7105a066166bec6 (patch) | |
tree | 5dcbc9802f6f34f6f0f6488c47d4f5486bca3b40 /lib | |
parent | f036a7fc75752b362eb17fe55b2a05376a0bb09f (diff) | |
download | c++-f2639be5d5006079868f69b0c7105a066166bec6.tar.gz c++-f2639be5d5006079868f69b0c7105a066166bec6.tar.bz2 c++-f2639be5d5006079868f69b0c7105a066166bec6.zip |
fixed bug related to counting number of full cluster flips, and added support for choosing other lattices
Diffstat (limited to 'lib')
-rw-r--r-- | lib/wolff.h | 4 | ||||
-rw-r--r-- | lib/wolff_tools.c | 7 |
2 files changed, 6 insertions, 5 deletions
diff --git a/lib/wolff.h b/lib/wolff.h index 4839083..cec9ee3 100644 --- a/lib/wolff.h +++ b/lib/wolff.h @@ -27,7 +27,7 @@ typedef struct ll_tag { } ll_t; typedef struct { - int32_t nv; + uint32_t nv; double dH; int32_t dM; } cluster_t; @@ -48,5 +48,5 @@ double hh(double th); double *get_bond_probs(double T, double H, ising_state_t *s); -int32_t wolff_step(double T, double H, ising_state_t *s, gsl_rng *r, double *ps); +uint32_t wolff_step(double T, double H, ising_state_t *s, gsl_rng *r, double *ps); diff --git a/lib/wolff_tools.c b/lib/wolff_tools.c index d361344..016e19b 100644 --- a/lib/wolff_tools.c +++ b/lib/wolff_tools.c @@ -79,7 +79,6 @@ cluster_t *flip_cluster(const graph_t *g, const double *ps, double H, bool *x, g // initiate the data structure for returning flip information c = (cluster_t *)calloc(1, sizeof(cluster_t)); c->nv = 0; - c->dH = 0; n_h_bonds = 0; n_bonds = 0; @@ -152,7 +151,7 @@ double *get_bond_probs(double T, double H, ising_state_t *s) { return ps; } -int32_t wolff_step(double T, double H, ising_state_t *s, gsl_rng *r, double *ps) { +uint32_t wolff_step(double T, double H, ising_state_t *s, gsl_rng *r, double *ps) { if (r == NULL) { r = gsl_rng_alloc(gsl_rng_mt19937); gsl_rng_set(r, jst_rand_seed()); @@ -167,8 +166,10 @@ int32_t wolff_step(double T, double H, ising_state_t *s, gsl_rng *r, double *ps) s->M += -2 * c->dM; s->H += 2 * c->dH; + uint32_t n_flips = c->nv; + free(c); - return c->nv; + return n_flips; } |