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
@@ -20,6 +20,7 @@ | ||
20 | 20 | #include <ctype.h> |
21 | 21 | #include <stdarg.h> |
22 | 22 | #include <math.h> |
23 | +#include <float.h> | |
23 | 24 | |
24 | 25 | /* Global parameter: it is initialized by the first call to ParameterReadFromFile() */ |
25 | 26 | Parameter *gBuiltinParameters = NULL; |
@@ -837,6 +838,8 @@ s_CommentToString(char *buf, int bufsize, void *bp) | ||
837 | 838 | snprintf(buf, bufsize, " ! %s", com); |
838 | 839 | } |
839 | 840 | |
841 | +#define DBL_EQUAL(a, b) (fabs((a) - (b)) < DBL_EPSILON * 2) | |
842 | + | |
840 | 843 | int |
841 | 844 | ParameterReadFromString(Parameter *par, char *buf, char **wbufp, const char *fname, int lineNumber, int src_idx) |
842 | 845 | { |
@@ -924,7 +927,7 @@ ParameterReadFromString(Parameter *par, char *buf, char **wbufp, const char *fna | ||
924 | 927 | val[0] *= KCAL2INTERNAL; |
925 | 928 | bp = ParameterLookupBondPar(par, itype[0], itype[1], -1, -1, options); |
926 | 929 | 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])) { | |
928 | 931 | 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]); |
929 | 932 | retval = 1; |
930 | 933 | } |
@@ -953,7 +956,7 @@ ParameterReadFromString(Parameter *par, char *buf, char **wbufp, const char *fna | ||
953 | 956 | val[1] *= (3.14159265358979 / 180.0); |
954 | 957 | ap = ParameterLookupAnglePar(par, itype[0], itype[1], itype[2], -1, -1, -1, options); |
955 | 958 | 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])) { | |
957 | 960 | 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]); |
958 | 961 | retval = 1; |
959 | 962 | } |
@@ -987,7 +990,8 @@ ParameterReadFromString(Parameter *par, char *buf, char **wbufp, const char *fna | ||
987 | 990 | val[0] *= KCAL2INTERNAL; |
988 | 991 | val[1] *= 3.14159265358979 / 180.0; |
989 | 992 | 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])) { | |
991 | 995 | 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]); |
992 | 996 | retval = 1; |
993 | 997 | } |
@@ -1031,7 +1035,8 @@ ParameterReadFromString(Parameter *par, char *buf, char **wbufp, const char *fna | ||
1031 | 1035 | val[0] *= KCAL2INTERNAL; |
1032 | 1036 | val[1] *= 3.14159265358979 / 180.0; |
1033 | 1037 | 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])) { | |
1035 | 1040 | 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]); |
1036 | 1041 | retval = 1; |
1037 | 1042 | } |
@@ -1097,7 +1102,7 @@ ParameterReadFromString(Parameter *par, char *buf, char **wbufp, const char *fna | ||
1097 | 1102 | for (i = 0; i < par->nvdwPars; i++) { |
1098 | 1103 | if (itype[0] == par->vdwPars[i].type1) { |
1099 | 1104 | 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)) { | |
1101 | 1106 | 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]); |
1102 | 1107 | retval = 1; |
1103 | 1108 | } |
@@ -1147,7 +1152,7 @@ ParameterReadFromString(Parameter *par, char *buf, char **wbufp, const char *fna | ||
1147 | 1152 | for (i = 0; i < par->nvdwpPars; i++) { |
1148 | 1153 | if (itype[0] == par->vdwpPars[i].type1 && itype[1] == par->vdwpPars[i].type2) { |
1149 | 1154 | 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)) { | |
1151 | 1156 | 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]); |
1152 | 1157 | retval = 1; |
1153 | 1158 | } |