From 895abef1c0e6c6c1f9b129f091d14fc889820cdc Mon Sep 17 00:00:00 2001 From: lindahl Date: Mon, 12 Mar 2001 12:46:34 +0000 Subject: [PATCH] Fixed a bug in grompp generating bad energy group exclusions. Included a check for consistency of charge vs. energy groups. Improved the neighborsearch to skip i charge groups with all energy groups excluded. --- src/gmxlib/fnbf.c | 5 ----- src/kernel/grompp.c | 29 ++++++++++++++++++++++++++++ src/kernel/readir.c | 2 +- src/mdlib/ns.c | 54 +++++++++++++++++++++++++++++++++++++---------------- 4 files changed, 68 insertions(+), 22 deletions(-) diff --git a/src/gmxlib/fnbf.c b/src/gmxlib/fnbf.c index d10286d3e8..5bf1fa3cf6 100644 --- a/src/gmxlib/fnbf.c +++ b/src/gmxlib/fnbf.c @@ -27,11 +27,6 @@ * GROningen MAchine for Chemical Simulation */ -/******************************************************** - * fnbf.c IS A GENERATED FILE DO NOT EDIT * - * edit fnbf.m4 instead * - ********************************************************/ - static char *SRCID_fnbf_c = "$Id$"; #ifdef USE_THREADS #include /* must come first! */ diff --git a/src/kernel/grompp.c b/src/kernel/grompp.c index 669a70c338..48adec49b2 100644 --- a/src/kernel/grompp.c +++ b/src/kernel/grompp.c @@ -245,6 +245,30 @@ static int check_atom_names(char *fn1, char *fn2, t_atoms *at1, t_atoms *at2, return nmismatch; } +static void check_eg_vs_cg(t_atoms *atoms,t_block *cgblock) +{ + int i,j,firstj; + unsigned char firsteg,eg; + + /* Go through all the charge groups and make sure all their + * atoms are in the same energy group. + */ + + for(i=0;inr;i++) { + /* Get the energy group of the first atom in this charge group */ + firstj=cgblock->index[i]; + firsteg=atoms->atom[firstj].grpnr[egcENER]; + for(j=cgblock->index[i]+1;jindex[i+1];j++) { + eg=atoms->atom[j].grpnr[egcENER]; + if(eg!=firsteg) { + fatal_error(0,"atoms %d and %d in charge group %d are in different energy groups", + firstj+1,j+1,i+1); + } + } + } +} + + static void check_pairs(int nrmols,t_molinfo mi[],int ntype,t_param *nb) { int i,j,jj,k,taiA,tajA,taiB,tajB,indA,indB,bLJ; @@ -899,6 +923,11 @@ int main (int argc, char *argv[]) do_index(ftp2fn_null(efNDX,NFILE,fnm), &sys->symtab,&(sys->atoms),bVerbose,ir,&sys->idef, forward); + + if (bVerbose) + fprintf(stderr,"Checking consistency between energy and charge groups...\n"); + check_eg_vs_cg(&(sys->atoms),&(sys->blocks[ebCGS])); + if (debug) pr_symtab(debug,0,"After index",&sys->symtab); triple_check(mdparin,ir,sys,&nerror); diff --git a/src/kernel/readir.c b/src/kernel/readir.c index cd7a7a4207..9f632185d5 100644 --- a/src/kernel/readir.c +++ b/src/kernel/readir.c @@ -991,7 +991,7 @@ void do_index(char *ndx, ptr1[2*i]); k=0; while ((k < nr) && - strcasecmp(ptr1[i+1],gnames[atoms->grps[egcENER].nm_ind[k]])) + strcasecmp(ptr1[2*i+1],gnames[atoms->grps[egcENER].nm_ind[k]])) k++; if (k==nr) fatal_error(0,"%s in energygrp_excl is not an energy group\n", diff --git a/src/mdlib/ns.c b/src/mdlib/ns.c index 99ea624403..7f43046130 100644 --- a/src/mdlib/ns.c +++ b/src/mdlib/ns.c @@ -1185,7 +1185,7 @@ static void do_longrange(FILE *log,t_commrec *cr,t_topology *top,t_forcerec *fr, static int ns5_core(FILE *log,t_commrec *cr,t_forcerec *fr,int cg_index[], matrix box,rvec box_size,int ngid, t_topology *top,t_groups *grps, - t_grid *grid,rvec x[],t_excl bexcl[], + t_grid *grid,rvec x[],t_excl bexcl[],bool *bExcludeAlleg, t_nrnb *nrnb,t_mdatoms *md, real lambda,real *dvdlambda, bool bHaveLJ[]) @@ -1300,11 +1300,16 @@ static int ns5_core(FILE *log,t_commrec *cr,t_forcerec *fr,int cg_index[], if (icg != iicg) fatal_error(0,"icg = %d, iicg = %d, file %s, line %d",icg,iicg,__FILE__, __LINE__); + + /* Skip this charge group if all energy groups are excluded! */ + if(bExcludeAlleg[icg]) + continue; + i0 = cgsindex[icg]; nri = cgsindex[icg+1]-i0; i_atoms = &(cgsatoms[i0]); i_eg_excl = fr->eg_excl + ngid*gid[*i_atoms]; - + /* Set the exclusions for the atoms in charge group icg using * a bitmask */ @@ -1387,16 +1392,14 @@ static int ns5_core(FILE *log,t_commrec *cr,t_forcerec *fr,int cg_index[], /* Loop over cgs */ for (j=0; (j= icg) && (jjcg < icg_naaj)) || - ((jjcg < min_icg))) { - r2=calc_dx2(XI,YI,ZI,cgcm[jjcg]); - if (r2 < rl2) { - /* jgid = gid[cgsatoms[cgsindex[jjcg]]]; */ - jgid = gid[cgsindex[jjcg]]; - /* check energy group exclusions */ - if (!i_eg_excl[jgid]) { + jgid = gid[cgsindex[jjcg]]; + /* check energy group exclusions */ + if (!i_eg_excl[jgid]) { + /* check whether this guy is in range! */ + if (((jjcg >= icg) && (jjcg < icg_naaj)) || + ((jjcg < min_icg))) { + r2=calc_dx2(XI,YI,ZI,cgcm[jjcg]); + if (r2 < rl2) { if (r2 < rs2) { if (nsr[jgid] >= MAX_CG) { put_in_list(bHaveLJ,ngid,md,icg,jgid, @@ -1432,9 +1435,9 @@ static int ns5_core(FILE *log,t_commrec *cr,t_forcerec *fr,int cg_index[], nl_lr_one[jgid][nlr_one[jgid]++]=jjcg; } } + nns++; } - nns++; - } + } } } } @@ -1534,15 +1537,17 @@ int search_neighbours(FILE *log,t_forcerec *fr, static bool *bHaveLJ; static t_ns_buf **ns_buf=NULL; static int *cg_index=NULL,*slab_index=NULL; + static bool *bExcludeAlleg; t_block *cgs=&(top->blocks[ebCGS]); rvec box_size; int i,j,m,ngid; real min_size; - + bool allexcl; int nsearch; bool bGrid; char *ptr; + bool *i_eg_excl; /* Set some local variables */ bGrid=fr->bGrid; @@ -1583,6 +1588,23 @@ int search_neighbours(FILE *log,t_forcerec *fr, nr_in_cg,maxcg); snew(bexcl,cgs->nra); + + /* Check for charge groups with all energy groups excluded */ + snew(bExcludeAlleg,cgs->nr); + for(i=0;inr;i++) { + allexcl=TRUE; + /* Make ptr to the excl list for the 1st atoms energy group */ + i_eg_excl = fr->eg_excl + ngid*md->cENER[cgs->a[cgs->index[i]]]; + + for(j=0; j