• R/O
  • HTTP
  • SSH
  • HTTPS

Molby: コミット

Molecular Modeling Software


コミットメタ情報

リビジョン5bcbf4af0a62b9e0d8c7dac104c2e32c774b8794 (tree)
日時2014-04-24 00:32:04
作者toshinagata1964 <toshinagata1964@a2be...>
コミッターtoshinagata1964

ログメッセージ

In reading MM/MD parameters, check criteria for duplicate parameters are somewhat relaxed (i.e. comparison of floating numbers is allowed for rounding errors)

git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/molby/trunk@529 a2be9bc6-48de-4e38-9406-05402d4bc13c

変更サマリ

差分

--- a/MolLib/Parameter.c
+++ b/MolLib/Parameter.c
@@ -20,6 +20,7 @@
2020 #include <ctype.h>
2121 #include <stdarg.h>
2222 #include <math.h>
23+#include <float.h>
2324
2425 /* Global parameter: it is initialized by the first call to ParameterReadFromFile() */
2526 Parameter *gBuiltinParameters = NULL;
@@ -837,6 +838,8 @@ s_CommentToString(char *buf, int bufsize, void *bp)
837838 snprintf(buf, bufsize, " ! %s", com);
838839 }
839840
841+#define DBL_EQUAL(a, b) (fabs((a) - (b)) < DBL_EPSILON * 2)
842+
840843 int
841844 ParameterReadFromString(Parameter *par, char *buf, char **wbufp, const char *fname, int lineNumber, int src_idx)
842845 {
@@ -924,7 +927,7 @@ ParameterReadFromString(Parameter *par, char *buf, char **wbufp, const char *fna
924927 val[0] *= KCAL2INTERNAL;
925928 bp = ParameterLookupBondPar(par, itype[0], itype[1], -1, -1, options);
926929 if (bp != NULL) {
927- if (bp->k != val[0] || bp->r0 != val[1]) {
930+ if (!DBL_EQUAL(bp->k, val[0]) || !DBL_EQUAL(bp->r0, val[1])) {
928931 s_AppendWarning(wbufp, "%s:%d: The BOND %s-%s parameter appeared twice; the values (%f, %f) are used\n", fname, lineNumber, AtomTypeDecodeToString(itype[0], type[0]), AtomTypeDecodeToString(itype[1], type[1]), val[0], val[1]);
929932 retval = 1;
930933 }
@@ -953,7 +956,7 @@ ParameterReadFromString(Parameter *par, char *buf, char **wbufp, const char *fna
953956 val[1] *= (3.14159265358979 / 180.0);
954957 ap = ParameterLookupAnglePar(par, itype[0], itype[1], itype[2], -1, -1, -1, options);
955958 if (ap != NULL) {
956- if (ap->k != val[0] || ap->a0 != val[1]) {
959+ if (!DBL_EQUAL(ap->k, val[0]) || !DBL_EQUAL(ap->a0, val[1])) {
957960 s_AppendWarning(wbufp, "%s:%d: The ANGLE %s-%s-%s parameter appeared twice; the values (%f, %f) are used\n", fname, lineNumber, AtomTypeDecodeToString(itype[0], type[0]), AtomTypeDecodeToString(itype[1], type[1]), AtomTypeDecodeToString(itype[2], type[2]), val[0], val[1]);
958961 retval = 1;
959962 }
@@ -987,7 +990,8 @@ ParameterReadFromString(Parameter *par, char *buf, char **wbufp, const char *fna
987990 val[0] *= KCAL2INTERNAL;
988991 val[1] *= 3.14159265358979 / 180.0;
989992 if (dp != NULL) {
990- if (dp->mult != 1 || dp->k[0] != val[0] || dp->period[0] != ival[0] || dp->phi0[0] != val[1]) {
993+ if (dp->mult != 1 || !DBL_EQUAL(dp->k[0], val[0]) || dp->period[0] != ival[0] ||
994+ !DBL_EQUAL(dp->phi0[0], val[1])) {
991995 s_AppendWarning(wbufp, "%s:%d: The DIHEDRAL %s-%s-%s-%s parameter appeared twice; the values (%f, %d, %f) are used\n", fname, lineNumber, AtomTypeDecodeToString(itype[0], type[0]), AtomTypeDecodeToString(itype[1], type[1]), AtomTypeDecodeToString(itype[2], type[2]), AtomTypeDecodeToString(itype[3], type[3]), val[0], ival[0], val[1]);
992996 retval = 1;
993997 }
@@ -1031,7 +1035,8 @@ ParameterReadFromString(Parameter *par, char *buf, char **wbufp, const char *fna
10311035 val[0] *= KCAL2INTERNAL;
10321036 val[1] *= 3.14159265358979 / 180.0;
10331037 if (ip != NULL) {
1034- if (ip->mult != 1 || ip->k[0] != val[0] || ip->period[0] != ival[0] || ip->phi0[0] != val[1]) {
1038+ if (ip->mult != 1 || !DBL_EQUAL(ip->k[0], val[0]) ||
1039+ ip->period[0] != ival[0] || !DBL_EQUAL(ip->phi0[0], val[1])) {
10351040 s_AppendWarning(wbufp, "%s:%d: The IMPROPER %s-%s-%s-%s parameter appeared twice; the values (%f, %d, %f) are used\n", fname, lineNumber, AtomTypeDecodeToString(itype[0], type[0]), AtomTypeDecodeToString(itype[1], type[1]), AtomTypeDecodeToString(itype[2], type[2]), AtomTypeDecodeToString(itype[3], type[3]), val[0], ival[0], val[1]);
10361041 retval = 1;
10371042 }
@@ -1097,7 +1102,7 @@ ParameterReadFromString(Parameter *par, char *buf, char **wbufp, const char *fna
10971102 for (i = 0; i < par->nvdwPars; i++) {
10981103 if (itype[0] == par->vdwPars[i].type1) {
10991104 vp = par->vdwPars + i;
1100- if (vp->A != vtemp.A || vp->B != vtemp.B || vp->A14 != vtemp.A14 || vp->B14 != vtemp.B14) {
1105+ if (!DBL_EQUAL(vp->A, vtemp.A) || !DBL_EQUAL(vp->B, vtemp.B) || !DBL_EQUAL(vp->A14, vtemp.A14) || !DBL_EQUAL(vp->B14, vtemp.B14)) {
11011106 s_AppendWarning(wbufp, "%s:%d: The %s %s parameter appeared twice; the values (%f, %f, %f, %f, %d, %f, %f) are used\n", fname, lineNumber, (flag ? "VDW" : "NONBONDED"), AtomTypeDecodeToString(itype[0], type[0]), val[0], val[1], val[2], val[3], ival[0], val[4], val[5]);
11021107 retval = 1;
11031108 }
@@ -1147,7 +1152,7 @@ ParameterReadFromString(Parameter *par, char *buf, char **wbufp, const char *fna
11471152 for (i = 0; i < par->nvdwpPars; i++) {
11481153 if (itype[0] == par->vdwpPars[i].type1 && itype[1] == par->vdwpPars[i].type2) {
11491154 vp = par->vdwpPars + i;
1150- if (vp->A != vtemp.A || vp->B != vtemp.B || vp->A14 != vtemp.A14 || vp->B14 != vtemp.B14) {
1155+ if (!DBL_EQUAL(vp->A, vtemp.A) || !DBL_EQUAL(vp->B, vtemp.B) || !DBL_EQUAL(vp->A14, vtemp.A14) || !DBL_EQUAL(vp->B14, vtemp.B14)) {
11511156 s_AppendWarning(wbufp, "%s:%d: The %s %s-%s parameter appeared twice; the values (%f, %f, %f, %f) are used\n", fname, lineNumber, (flag ? "VDWP" : "NBFI"), AtomTypeDecodeToString(itype[0], type[0]), AtomTypeDecodeToString(itype[1], type[1]), val[0], val[1], val[2], val[3]);
11521157 retval = 1;
11531158 }
旧リポジトリブラウザで表示