Skip to content

Commit

Permalink
Fix issue #3
Browse files Browse the repository at this point in the history
The AVB move now prints an error and exits if used with patches that do
not fulfill the single-bond-per-patch condition
  • Loading branch information
lorenzo-rovigatti committed Dec 9, 2020
1 parent 3154326 commit d2ea0f0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
10 changes: 7 additions & 3 deletions MC.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions avb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d2ea0f0

Please sign in to comment.