static void cmp_rvec(FILE *fp,const char *s,int index,rvec i1,rvec i2,real ftol,real abstol) { if(!equal_real(i1[XX],i2[XX],ftol,abstol) || !equal_real(i1[YY],i2[YY],ftol,abstol) || !equal_real(i1[ZZ],i2[ZZ],ftol,abstol)) { if (index != -1) fprintf(fp,"%s[%5d] (%12.5e %12.5e %12.5e) - (%12.5e %12.5e %12.5e)\n", s,index,i1[XX],i1[YY],i1[ZZ],i2[XX],i2[YY],i2[ZZ]); else fprintf(fp,"%s (%12.5e %12.5e %12.5e) - (%12.5e %12.5e %12.5e)\n", s,i1[XX],i1[YY],i1[ZZ],i2[XX],i2[YY],i2[ZZ]); } }
static void cmp_iparm_AB(FILE *fp, const char *s, t_functype ft, const t_iparams &ip1, real ftol, real abstol) { int nrfpA, nrfpB, p0, i; gmx_bool bDiff; /* Normally the first parameter is perturbable */ p0 = 0; nrfpA = interaction_function[ft].nrfpA; nrfpB = interaction_function[ft].nrfpB; if (ft == F_PDIHS) { nrfpB = 2; } else if (interaction_function[ft].flags & IF_TABULATED) { /* For tabulated interactions only the second parameter is perturbable */ p0 = 1; nrfpB = 1; } bDiff = FALSE; for (i = 0; i < nrfpB && !bDiff; i++) { bDiff = !equal_real(ip1.generic.buf[p0+i], ip1.generic.buf[nrfpA+i], ftol, abstol); } if (bDiff) { fprintf(fp, "%s: ", s); pr_iparams(fp, ft, &ip1); } }
static void cmp_energies(FILE *fp,int step1,int step2, t_energy e1[],t_energy e2[], gmx_enxnm_t *enm1,gmx_enxnm_t *enm2, real ftol,real abstol, int nre,int *ind1,int *ind2,int maxener) { int i,ii; int *tensi,len,d1,d2; real ftol_i,abstol_i; snew(tensi,maxener); /* Check for tensor elements ending on "-XX", "-XY", ... , "-ZZ" */ for(i=0; (i<maxener); i++) { ii = ind1[i]; tensi[i] = -1; len = strlen(enm1[ii].name); if (len > 3 && enm1[ii].name[len-3] == '-') { d1 = enm1[ii].name[len-2] - 'X'; d2 = enm1[ii].name[len-1] - 'X'; if (d1 >= 0 && d1 < DIM && d2 >= 0 && d2 < DIM) { tensi[i] = d1*DIM + d2; } } } for(i=0; (i<maxener); i++) { /* Check if this is an off-diagonal tensor element */ if (tensi[i] >= 0 && tensi[i] != 0 && tensi[i] != 4 && tensi[i] != 8) { /* Turn on the relative tolerance check (4 is maximum relative diff.) */ ftol_i = 5; /* Do the relative tolerance through an absolute tolerance times * the size of diagonal components of the tensor. */ abstol_i = ftol*ener_tensor_diag(nre,ind1,ind2,enm1,tensi,i,e1,e2); if (debug) { fprintf(debug,"tensor '%s' val %f diag %f\n", enm1[i].name,e1[i].e,abstol_i/ftol); } if (abstol_i > 0) { /* We found a diagonal, we need to check with the minimum tolerance */ abstol_i = min(abstol_i,abstol); } else { /* We did not find a diagonal, ignore the relative tolerance check */ abstol_i = abstol; } } else { ftol_i = ftol; abstol_i = abstol; } if (!equal_real(e1[ind1[i]].e,e2[ind2[i]].e,ftol_i,abstol_i)) { fprintf(fp,"%-15s step %3d: %12g, step %3d: %12g\n", enm1[ind1[i]].name, step1,e1[ind1[i]].e, step2,e2[ind2[i]].e); } } sfree(tensi); }
static void cmp_real(FILE *fp,const char *s,int index,real i1,real i2,real ftol,real abstol) { if (!equal_real(i1,i2,ftol,abstol)) { if (index != -1) fprintf(fp,"%s[%2d] (%e - %e)\n",s,index,i1,i2); else fprintf(fp,"%s (%e - %e)\n",s,i1,i2); } }
void cmp_iparm(FILE *fp,const char *s,t_functype ft, t_iparams ip1,t_iparams ip2,real ftol,real abstol) { int i; gmx_bool bDiff; bDiff=FALSE; for(i=0; i<MAXFORCEPARAM && !bDiff; i++) bDiff = !equal_real(ip1.generic.buf[i],ip2.generic.buf[i],ftol,abstol); if (bDiff) { fprintf(fp,"%s1: ",s); pr_iparams(fp,ft,&ip1); fprintf(fp,"%s2: ",s); pr_iparams(fp,ft,&ip2); } }