From d2ea0f03a3a1adf115e793f2e3acd8c8d7dbe30a Mon Sep 17 00:00:00 2001 From: Lorenzo Rovigatti Date: Wed, 9 Dec 2020 23:17:10 +0100 Subject: [PATCH] Fix issue #3 The AVB move now prints an error and exits if used with patches that do not fulfill the single-bond-per-patch condition --- MC.c | 10 +++++++--- avb.c | 5 +++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/MC.c b/MC.c index 2cd3b86..62c3466 100644 --- a/MC.c +++ b/MC.c @@ -60,7 +60,7 @@ void do_SUS(System *syst, Output *output_files) { void do_NPT(System *syst, Output *output_files) { int i; for(i = 0; i < syst->N; i++) { - if(drand48() < 1./syst->N) { + if(drand48() < 1. / syst->N) { MC_change_volume(syst, output_files); } else if(syst->N > 0) syst->do_dynamics(syst, output_files); @@ -463,7 +463,9 @@ void MC_change_volume(System *syst, Output *IO) { double new_side = final_V; int i = 0; for(i = 0; i < 3; i++) { - if(i != dir) new_side /= syst->box[i]; + if(i != dir) { + new_side /= syst->box[i]; + } } syst->box[dir] = new_side; @@ -487,7 +489,9 @@ void MC_change_volume(System *syst, Output *IO) { for(i = 0; i < syst->N && !overlap_found; i++) { PatchyParticle *p = syst->particles + i; delta_E += MC_energy(syst, p) * 0.5; - if(syst->overlap) overlap_found = 1; + if(syst->overlap) { + overlap_found = 1; + } } double delta_V = final_V - initial_V; diff --git a/avb.c b/avb.c index 663cba8..6ad06dc 100644 --- a/avb.c +++ b/avb.c @@ -11,6 +11,11 @@ avbmc *avbdata; void AVBMC_init(input_file *input, System *syst, Output *IO) { + double sin_theta = sin(acos(syst->kf_cosmax)); + if(sin_theta >= 1. / (2. * (1. + syst->kf_delta))) { + output_exit(IO, "The AVB move cannot be used with patches that do not fulfill the single-bond-per-patch condition\n"); + } + avbdata = malloc(sizeof(avbmc)); int numpatches = syst->n_patches;