OSDN Git Service

Parameters now can be specified by using both explicit indices and atom types, like...
authortoshinagata1964 <toshinagata1964@a2be9bc6-48de-4e38-9406-05402d4bc13c>
Tue, 8 May 2012 04:30:35 +0000 (04:30 +0000)
committertoshinagata1964 <toshinagata1964@a2be9bc6-48de-4e38-9406-05402d4bc13c>
Tue, 8 May 2012 04:30:35 +0000 (04:30 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/molby/trunk@199 a2be9bc6-48de-4e38-9406-05402d4bc13c

MolLib/MD/MDCore.c
MolLib/Molecule.c
MolLib/Parameter.c
MolLib/Parameter.h
MolLib/Ruby_bind/ruby_bind.c

index 9691ea6..213e417 100644 (file)
@@ -787,20 +787,18 @@ s_find_bond_parameters(MDArena *arena)
                        type2 = ap2->type;
                        bp = NULL;
                        if (mol->par != NULL) {
-                               bp = ParameterLookupBondPar(mol->par, i1, i2, kParameterLookupLocal | kParameterLookupNoWildcard);
-                               if (bp == NULL)
-                                       bp = ParameterLookupBondPar(mol->par, type1, type2, kParameterLookupLocal | kParameterLookupGlobal);
+                               bp = ParameterLookupBondPar(mol->par, type1, type2, i1, i2, 0);
                                if (bp != NULL) {
                                        arena->bond_par_i[i] = (bp - mol->par->bondPars) + ATOMS_MAX_NUMBER * 2;
                                        continue;
                                }
                        }
-                       bp = ParameterLookupBondPar(gBuiltinParameters, type1, type2, 0);
+                       bp = ParameterLookupBondPar(gBuiltinParameters, type1, type2, -1, -1, 0);
                        if (bp != NULL) {
                                arena->bond_par_i[i] = (bp - gBuiltinParameters->bondPars) + ATOMS_MAX_NUMBER;
                                continue;
                        }
-                       bp = ParameterLookupBondPar(par, type1, type2, kParameterLookupMissing | kParameterLookupNoBaseAtomType);
+                       bp = ParameterLookupBondPar(par, type1, type2, -1, -1, kParameterLookupMissing | kParameterLookupNoBaseAtomType);
                        if (bp == NULL) {
                                /*  Record as missing  */
                                bp = AssignArray(&par->bondPars, &par->nbondPars, sizeof(BondPar), par->nbondPars, NULL);
@@ -874,21 +872,19 @@ s_find_angle_parameters(MDArena *arena)
                        type2 = ATOM_AT_INDEX(mol->atoms, i2)->type;
                        type3 = ATOM_AT_INDEX(mol->atoms, i3)->type;
                        if (mol->par != NULL) {
-                               ap = ParameterLookupAnglePar(mol->par, i1, i2, i3, kParameterLookupLocal | kParameterLookupNoWildcard);
-                               if (ap == NULL)
-                                       ap = ParameterLookupAnglePar(mol->par, type1, type2, type3, kParameterLookupLocal | kParameterLookupGlobal);
+                               ap = ParameterLookupAnglePar(mol->par, type1, type2, type3, i1, i2, i3, 0);
                                if (ap != NULL) {
                                        arena->angle_par_i[i] = (ap - mol->par->anglePars) + ATOMS_MAX_NUMBER * 2;
                                        continue;
                                }
                        }
-                       ap = ParameterLookupAnglePar(gBuiltinParameters, type1, type2, type3, 0);
+                       ap = ParameterLookupAnglePar(gBuiltinParameters, type1, type2, type3, -1, -1, -1, 0);
                        if (ap != NULL) {
                                arena->angle_par_i[i] = (ap - gBuiltinParameters->anglePars) + ATOMS_MAX_NUMBER;
                                continue;
                        }
                        /*  Record as missing  */
-                       ap = ParameterLookupAnglePar(par, type1, type2, type3, kParameterLookupMissing | kParameterLookupNoBaseAtomType);
+                       ap = ParameterLookupAnglePar(par, type1, type2, type3, -1, -1, -1, kParameterLookupMissing | kParameterLookupNoBaseAtomType);
                        if (ap == NULL) {
                                ap = AssignArray(&par->anglePars, &par->nanglePars, sizeof(AnglePar), par->nanglePars, NULL);
                                ap->src = -1;
@@ -965,21 +961,19 @@ s_find_dihedral_parameters(MDArena *arena)
                        type3 = ATOM_AT_INDEX(mol->atoms, i3)->type;
                        type4 = ATOM_AT_INDEX(mol->atoms, i4)->type;
                        if (mol->par != NULL) {
-                               tp = ParameterLookupDihedralPar(mol->par, i1, i2, i3, i4, kParameterLookupLocal | kParameterLookupNoWildcard);
-                               if (tp == NULL)
-                                       tp = ParameterLookupDihedralPar(mol->par, type1, type2, type3, type4, kParameterLookupLocal | kParameterLookupGlobal);
+                               tp = ParameterLookupDihedralPar(mol->par, type1, type2, type3, type4, i1, i2, i3, i4, 0);
                                if (tp != NULL) {
                                        arena->dihedral_par_i[i] = (tp - mol->par->dihedralPars) + ATOMS_MAX_NUMBER * 2;
                                        continue;
                                }
                        }
-                       tp = ParameterLookupDihedralPar(gBuiltinParameters, type1, type2, type3, type4, 0);
+                       tp = ParameterLookupDihedralPar(gBuiltinParameters, type1, type2, type3, type4, -1, -1, -1, -1, 0);
                        if (tp != NULL) {
                                arena->dihedral_par_i[i] = (tp - gBuiltinParameters->dihedralPars) + ATOMS_MAX_NUMBER;
                                continue;
                        }
                        /*  Record as missing  */
-                       tp = ParameterLookupDihedralPar(par, type1, type2, type3, type4, kParameterLookupMissing | kParameterLookupNoBaseAtomType);
+                       tp = ParameterLookupDihedralPar(par, type1, type2, type3, type4, -1, -1, -1, -1, kParameterLookupMissing | kParameterLookupNoBaseAtomType);
                        if (tp == NULL) {
                                tp = AssignArray(&par->dihedralPars, &par->ndihedralPars, sizeof(TorsionPar), par->ndihedralPars, NULL);
                                tp->src = -1;
@@ -1062,21 +1056,19 @@ s_find_improper_parameters(MDArena *arena)
                        type3 = ATOM_AT_INDEX(mol->atoms, i3)->type;
                        type4 = ATOM_AT_INDEX(mol->atoms, i4)->type;
                        if (mol->par != NULL) {
-                               tp = ParameterLookupImproperPar(mol->par, i1, i2, i3, i4, kParameterLookupLocal | kParameterLookupNoWildcard);
-                               if (tp == NULL)
-                                       tp = ParameterLookupImproperPar(mol->par, type1, type2, type3, type4, kParameterLookupLocal | kParameterLookupGlobal);
+                               tp = ParameterLookupImproperPar(mol->par, type1, type2, type3, type4, i1, i2, i3, i4, 0);
                                if (tp != NULL) {
                                        arena->improper_par_i[i] = (tp - mol->par->improperPars) + ATOMS_MAX_NUMBER * 2;
                                        continue;
                                }
                        }
-                       tp = ParameterLookupImproperPar(gBuiltinParameters, type1, type2, type3, type4, 0);
+                       tp = ParameterLookupImproperPar(gBuiltinParameters, type1, type2, type3, type4, -1, -1, -1, -1, 0);
                        if (tp != NULL) {
                                arena->improper_par_i[i] = (tp - gBuiltinParameters->improperPars) + ATOMS_MAX_NUMBER;
                                continue;
                        }
                        /*  Record as missing  */
-                       tp = ParameterLookupImproperPar(par, type1, type2, type3, type4, kParameterLookupMissing | kParameterLookupNoBaseAtomType);
+                       tp = ParameterLookupImproperPar(par, type1, type2, type3, type4, -1, -1, -1, -1, kParameterLookupMissing | kParameterLookupNoBaseAtomType);
                        if (tp == NULL) {
                                tp = AssignArray(&par->improperPars, &par->nimproperPars, sizeof(TorsionPar), par->nimproperPars, NULL);
                                tp->src = -1;
index 8087ce2..586bb4f 100755 (executable)
@@ -7600,11 +7600,9 @@ MoleculeFindMissingImpropers(Molecule *mol, Int **outImpropers)
                                        n4 = ap3->connects[i4];
                                        t4 = ATOM_AT_INDEX(ap, n4)->type;
                                        found = 0;
-                                       if (ParameterLookupImproperPar(par, n1, n2, n3, n4, 1) != NULL)
+                                       if (ParameterLookupImproperPar(par, t1, t2, t3, t4, n1, n2, n3, n4, 0) != NULL)
                                                found = 1;
-                                       else if (ParameterLookupImproperPar(par, t1, t2, t3, t4, 0) != NULL)
-                                               found = 1;
-                                       else if (ParameterLookupImproperPar(gBuiltinParameters, t1, t2, t3, t4, 0) != NULL)
+                                       else if (ParameterLookupImproperPar(gBuiltinParameters, t1, t2, t3, t4, -1, -1, -1, -1, 0) != NULL)
                                                found = 1;
                                        if (found && MoleculeLookupImproper(mol, n1, n2, n3, n4) < 0) {
                                                ip = (Int *)AssignArray(&impropers, &nimpropers, sizeof(Int) * 4, nimpropers, NULL);
index f2eb302..464ff08 100755 (executable)
@@ -733,7 +733,7 @@ ParameterReadFromString(Parameter *par, char *buf, char **wbufp, const char *fna
                        itype[1] = i;
                }
                val[0] *= KCAL2INTERNAL;
-               bp = ParameterLookupBondPar(par, itype[0], itype[1], options);
+               bp = ParameterLookupBondPar(par, itype[0], itype[1], -1, -1, options);
                if (bp != NULL) {
                        if (bp->k != val[0] || bp->r0 != val[1]) {
                                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]);
@@ -762,7 +762,7 @@ ParameterReadFromString(Parameter *par, char *buf, char **wbufp, const char *fna
                }
                val[0] *= KCAL2INTERNAL;
                val[1] *= (3.14159265358979 / 180.0);
-               ap = ParameterLookupAnglePar(par, itype[0], itype[1], itype[2], options);
+               ap = ParameterLookupAnglePar(par, itype[0], itype[1], itype[2], -1, -1, -1, options);
                if (ap != NULL) {
                        if (ap->k != val[0] || ap->a0 != val[1]) {
                                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]);
@@ -794,7 +794,7 @@ ParameterReadFromString(Parameter *par, char *buf, char **wbufp, const char *fna
                        itype[1] = itype[2];
                        itype[2] = i;
                }
-               dp = ParameterLookupDihedralPar(par, itype[0], itype[1], itype[2], itype[3], options);
+               dp = ParameterLookupDihedralPar(par, itype[0], itype[1], itype[2], itype[3], -1, -1, -1, -1, options);
                val[0] *= KCAL2INTERNAL;
                val[1] *= 3.14159265358979 / 180.0;
                if (dp != NULL) {
@@ -838,7 +838,7 @@ ParameterReadFromString(Parameter *par, char *buf, char **wbufp, const char *fna
                        itype[1] = itype[3];
                        itype[3] = i;
                }
-               ip = ParameterLookupImproperPar(par, itype[0], itype[1], itype[2], itype[3], options);
+               ip = ParameterLookupImproperPar(par, itype[0], itype[1], itype[2], itype[3], -1, -1, -1, -1, options);
                val[0] *= KCAL2INTERNAL;
                val[1] *= 3.14159265358979 / 180.0;
                if (ip != NULL) {
@@ -1250,14 +1250,14 @@ ParameterGetComment(int idx)
 
 #pragma mark ====== Parameter Lookup ======
 
-#define s_ParMatch(_t1, _t2, _nowildcard) (_t1 == _t2 || (!_nowildcard && _t1 == kAtomTypeWildcard))
+#define s_ParMatch(_t1, _t2, _idx, _nowildcard) (_t1 == _t2 || _t1 == _idx || (!_nowildcard && _t2 >= kAtomTypeMinimum && _t1 == kAtomTypeWildcard))
 
 /*  Returns non-zero if the parameter record contains designated atom_type.
  The atom_type can also be an atom index.  */
 int
 ParameterDoesContainAtom(Int type, const UnionPar *up, UInt atom_type, Int options)
 {
-#define CHECK_FIELD(_tp, _field) s_ParMatch((((const _tp *)up)->_field), atom_type, nowildcard)
+#define CHECK_FIELD(_tp, _field) s_ParMatch((((const _tp *)up)->_field), atom_type, -1, nowildcard)
        Int nowildcard = (options & kParameterLookupNoWildcard);
        switch (type) {
                case kBondParType:
@@ -1360,7 +1360,7 @@ ParameterIsRelevantToAtomGroup(Int type, const UnionPar *up, const struct Atom *
 }
 
 BondPar *
-ParameterLookupBondPar(Parameter *par, UInt t1, UInt t2, Int options)
+ParameterLookupBondPar(Parameter *par, UInt t1, UInt t2, Int idx1, Int idx2, Int options)
 {
        int i;
        BondPar *bp;
@@ -1374,18 +1374,18 @@ ParameterLookupBondPar(Parameter *par, UInt t1, UInt t2, Int options)
                        || (bp->src == 0 && !(options & kParameterLookupLocal))
                        || (bp->src < 0 && !(options & kParameterLookupMissing)))
                        continue;
-               if (s_ParMatch(bp->type1, t1, nowildcard) && s_ParMatch(bp->type2, t2, nowildcard))
+               if (s_ParMatch(bp->type1, t1, idx1, nowildcard) && s_ParMatch(bp->type2, t2, idx2, nowildcard))
                        return bp;
-               if (s_ParMatch(bp->type1, t2, nowildcard) && s_ParMatch(bp->type2, t1, nowildcard))
+               if (s_ParMatch(bp->type1, t2, idx2, nowildcard) && s_ParMatch(bp->type2, t1, idx1, nowildcard))
                        return bp;              
        }
        if (options & kParameterLookupNoBaseAtomType)
                return NULL;
-       return ParameterLookupBondPar(par, t1 % kAtomTypeVariantBase, t2 % kAtomTypeVariantBase, options | kParameterLookupNoBaseAtomType);
+       return ParameterLookupBondPar(par, t1 % kAtomTypeVariantBase, t2 % kAtomTypeVariantBase, idx1, idx2, options | kParameterLookupNoBaseAtomType);
 }
 
 AnglePar *
-ParameterLookupAnglePar(Parameter *par, UInt t1, UInt t2, UInt t3, Int options)
+ParameterLookupAnglePar(Parameter *par, UInt t1, UInt t2, UInt t3, Int idx1, Int idx2, Int idx3, Int options)
 {
        int i;
        AnglePar *ap;
@@ -1399,18 +1399,18 @@ ParameterLookupAnglePar(Parameter *par, UInt t1, UInt t2, UInt t3, Int options)
                        || (ap->src == 0 && !(options & kParameterLookupLocal))
                        || (ap->src < 0 && !(options & kParameterLookupMissing)))
                        continue;
-               if (s_ParMatch(ap->type1, t1, nowildcard) && s_ParMatch(ap->type2, t2, nowildcard) && s_ParMatch(ap->type3, t3, nowildcard))
+               if (s_ParMatch(ap->type1, t1, idx1, nowildcard) && s_ParMatch(ap->type2, t2, idx2, nowildcard) && s_ParMatch(ap->type3, t3, idx3, nowildcard))
                        return ap;
-               if (s_ParMatch(ap->type1, t3, nowildcard) && s_ParMatch(ap->type2, t2, nowildcard) && s_ParMatch(ap->type3, t1, nowildcard))
+               if (s_ParMatch(ap->type1, t3, idx3, nowildcard) && s_ParMatch(ap->type2, t2, idx2, nowildcard) && s_ParMatch(ap->type3, t1, idx1, nowildcard))
                        return ap;
        }
        if (options & kParameterLookupNoBaseAtomType)
                return NULL;
-       return ParameterLookupAnglePar(par, t1 % kAtomTypeVariantBase, t2 % kAtomTypeVariantBase, t3 % kAtomTypeVariantBase, options | kParameterLookupNoBaseAtomType);
+       return ParameterLookupAnglePar(par, t1 % kAtomTypeVariantBase, t2 % kAtomTypeVariantBase, t3 % kAtomTypeVariantBase, idx1, idx2, idx3, options | kParameterLookupNoBaseAtomType);
 }
 
 TorsionPar *
-ParameterLookupDihedralPar(Parameter *par, UInt t1, UInt t2, UInt t3, UInt t4, Int options)
+ParameterLookupDihedralPar(Parameter *par, UInt t1, UInt t2, UInt t3, UInt t4, Int idx1, Int idx2, Int idx3, Int idx4, Int options)
 {
        int i;
        TorsionPar *tp;
@@ -1424,18 +1424,18 @@ ParameterLookupDihedralPar(Parameter *par, UInt t1, UInt t2, UInt t3, UInt t4, I
                        || (tp->src == 0 && !(options & kParameterLookupLocal))
                        || (tp->src < 0 && !(options & kParameterLookupMissing)))
                        continue;
-               if (s_ParMatch(tp->type1, t1, nowildcard) && s_ParMatch(tp->type2, t2, nowildcard) && s_ParMatch(tp->type3, t3, nowildcard) && s_ParMatch(tp->type4, t4, nowildcard))
+               if (s_ParMatch(tp->type1, t1, idx1, nowildcard) && s_ParMatch(tp->type2, t2, idx2, nowildcard) && s_ParMatch(tp->type3, t3, idx3, nowildcard) && s_ParMatch(tp->type4, t4, idx4, nowildcard))
                        return tp;
-               if (s_ParMatch(tp->type1, t4, nowildcard) && s_ParMatch(tp->type2, t3, nowildcard) && s_ParMatch(tp->type3, t2, nowildcard) && s_ParMatch(tp->type4, t1, nowildcard))
+               if (s_ParMatch(tp->type1, t4, idx4, nowildcard) && s_ParMatch(tp->type2, t3, idx3, nowildcard) && s_ParMatch(tp->type3, t2, idx2, nowildcard) && s_ParMatch(tp->type4, t1, idx1, nowildcard))
                        return tp;
        }
        if (options & kParameterLookupNoBaseAtomType)
                return NULL;
-       return ParameterLookupDihedralPar(par, t1 % kAtomTypeVariantBase, t2 % kAtomTypeVariantBase, t3 % kAtomTypeVariantBase, t4 % kAtomTypeVariantBase, options | kParameterLookupNoBaseAtomType);
+       return ParameterLookupDihedralPar(par, t1 % kAtomTypeVariantBase, t2 % kAtomTypeVariantBase, t3 % kAtomTypeVariantBase, t4 % kAtomTypeVariantBase, idx1, idx2, idx3, idx4, options | kParameterLookupNoBaseAtomType);
 }
 
 TorsionPar *
-ParameterLookupImproperPar(Parameter *par, UInt t1, UInt t2, UInt t3, UInt t4, Int options)
+ParameterLookupImproperPar(Parameter *par, UInt t1, UInt t2, UInt t3, UInt t4, Int idx1, Int idx2, Int idx3, Int idx4, Int options)
 {
        int i;
        TorsionPar *tp;
@@ -1449,19 +1449,19 @@ ParameterLookupImproperPar(Parameter *par, UInt t1, UInt t2, UInt t3, UInt t4, I
                        || (tp->src == 0 && !(options & kParameterLookupLocal))
                        || (tp->src < 0 && !(options & kParameterLookupMissing)))
                        continue;
-               if (!s_ParMatch(tp->type3, t3, nowildcard))
+               if (!s_ParMatch(tp->type3, t3, idx3, nowildcard))
                        continue;
-               if ((s_ParMatch(tp->type1, t1, nowildcard) && s_ParMatch(tp->type2, t2, nowildcard) && s_ParMatch(tp->type4, t4, nowildcard))
-                       || (s_ParMatch(tp->type1, t1, nowildcard) && s_ParMatch(tp->type2, t4, nowildcard) && s_ParMatch(tp->type4, t2, nowildcard))
-                       || (s_ParMatch(tp->type1, t2, nowildcard) && s_ParMatch(tp->type2, t1, nowildcard) && s_ParMatch(tp->type4, t4, nowildcard))
-                       || (s_ParMatch(tp->type1, t2, nowildcard) && s_ParMatch(tp->type2, t4, nowildcard) && s_ParMatch(tp->type4, t1, nowildcard))
-                       || (s_ParMatch(tp->type1, t4, nowildcard) && s_ParMatch(tp->type2, t1, nowildcard) && s_ParMatch(tp->type4, t2, nowildcard))
-                       || (s_ParMatch(tp->type1, t4, nowildcard) && s_ParMatch(tp->type2, t2, nowildcard) && s_ParMatch(tp->type4, t1, nowildcard)))
+               if ((s_ParMatch(tp->type1, t1, idx1, nowildcard) && s_ParMatch(tp->type2, t2, idx2, nowildcard) && s_ParMatch(tp->type4, t4, idx4, nowildcard))
+                       || (s_ParMatch(tp->type1, t1, idx1, nowildcard) && s_ParMatch(tp->type2, t4, idx4, nowildcard) && s_ParMatch(tp->type4, t2, idx2, nowildcard))
+                       || (s_ParMatch(tp->type1, t2, idx2, nowildcard) && s_ParMatch(tp->type2, t1, idx1, nowildcard) && s_ParMatch(tp->type4, t4, idx4, nowildcard))
+                       || (s_ParMatch(tp->type1, t2, idx2, nowildcard) && s_ParMatch(tp->type2, t4, idx4, nowildcard) && s_ParMatch(tp->type4, t1, idx1, nowildcard))
+                       || (s_ParMatch(tp->type1, t4, idx4, nowildcard) && s_ParMatch(tp->type2, t1, idx1, nowildcard) && s_ParMatch(tp->type4, t2, idx2, nowildcard))
+                       || (s_ParMatch(tp->type1, t4, idx4, nowildcard) && s_ParMatch(tp->type2, t2, idx2, nowildcard) && s_ParMatch(tp->type4, t1, idx1, nowildcard)))
                        return tp;
        }
        if (options & kParameterLookupNoBaseAtomType)
                return NULL;
-       return ParameterLookupImproperPar(par, t1 % kAtomTypeVariantBase, t2 % kAtomTypeVariantBase, t3 % kAtomTypeVariantBase, t4 % kAtomTypeVariantBase, options | kParameterLookupNoBaseAtomType);
+       return ParameterLookupImproperPar(par, t1 % kAtomTypeVariantBase, t2 % kAtomTypeVariantBase, t3 % kAtomTypeVariantBase, t4 % kAtomTypeVariantBase, idx1, idx2, idx3, idx4, options | kParameterLookupNoBaseAtomType);
 }
 
 VdwPar *
@@ -1479,7 +1479,7 @@ ParameterLookupVdwPar(Parameter *par, UInt t1, Int options)
                        || (vp->src == 0 && !(options & kParameterLookupLocal))
                        || (vp->src < 0 && !(options & kParameterLookupMissing)))
                        continue;
-               if (s_ParMatch(vp->type1, t1, nowildcard))
+               if (s_ParMatch(vp->type1, t1, -1, nowildcard))
                        return vp;
        }
        if (options & kParameterLookupNoBaseAtomType)
@@ -1502,8 +1502,8 @@ ParameterLookupVdwPairPar(Parameter *par, UInt t1, UInt t2, Int options)
                        || (vp->src == 0 && !(options & kParameterLookupLocal))
                        || (vp->src < 0 && !(options & kParameterLookupMissing)))
                        continue;
-               if ((s_ParMatch(vp->type1, t1, nowildcard) && s_ParMatch(vp->type2, t2, nowildcard))
-                       || (s_ParMatch(vp->type1, t2, nowildcard) && s_ParMatch(vp->type2, t1, nowildcard)))
+               if ((s_ParMatch(vp->type1, t1, -1, nowildcard) && s_ParMatch(vp->type2, t2, -1, nowildcard))
+                       || (s_ParMatch(vp->type1, t2, -1, nowildcard) && s_ParMatch(vp->type2, t1, -1, nowildcard)))
                        return vp;
        }
        if (options & kParameterLookupNoBaseAtomType)
@@ -1526,9 +1526,9 @@ ParameterLookupVdwCutoffPar(Parameter *par, UInt t1, UInt t2, Int options)
                        || (vp->src == 0 && !(options & kParameterLookupLocal))
                        || (vp->src < 0 && !(options & kParameterLookupMissing)))
                        continue;
-               if (s_ParMatch(vp->type1, t1, nowildcard) && s_ParMatch(vp->type2, t2, nowildcard))
+               if (s_ParMatch(vp->type1, t1, -1, nowildcard) && s_ParMatch(vp->type2, t2, -1, nowildcard))
                        return vp;
-               if (s_ParMatch(vp->type1, t2, nowildcard) && s_ParMatch(vp->type2, t1, nowildcard))
+               if (s_ParMatch(vp->type1, t2, -1, nowildcard) && s_ParMatch(vp->type2, t1, -1, nowildcard))
                        return vp;
        }
        if (options & kParameterLookupNoBaseAtomType)
index 0a7df01..8a288f0 100755 (executable)
@@ -224,10 +224,10 @@ int ParameterRenumberAtoms(Int type, UnionPar *up, Int oldnatoms, const Int *old
 int ParameterDoesContainAtom(Int type, const UnionPar *up, UInt atom_type, Int options);
 int ParameterIsRelevantToAtomGroup(Int type, const UnionPar *up, const struct Atom *ap, struct IntGroup *ig);
 
-BondPar *ParameterLookupBondPar(Parameter *par, UInt t1, UInt t2, Int options);
-AnglePar *ParameterLookupAnglePar(Parameter *par, UInt t1, UInt t2, UInt t3, Int options);
-TorsionPar *ParameterLookupDihedralPar(Parameter *par, UInt t1, UInt t2, UInt t3, UInt t4, Int options);
-TorsionPar *ParameterLookupImproperPar(Parameter *par, UInt t1, UInt t2, UInt t3, UInt t4, Int options);
+BondPar *ParameterLookupBondPar(Parameter *par, UInt t1, UInt t2, Int idx1, Int idx2, Int options);
+AnglePar *ParameterLookupAnglePar(Parameter *par, UInt t1, UInt t2, UInt t3, Int idx1, Int idx2, Int idx3, Int options);
+TorsionPar *ParameterLookupDihedralPar(Parameter *par, UInt t1, UInt t2, UInt t3, UInt t4, Int idx1, Int idx2, Int idx3, Int idx4, Int options);
+TorsionPar *ParameterLookupImproperPar(Parameter *par, UInt t1, UInt t2, UInt t3, UInt t4, Int idx1, Int idx2, Int idx3, Int idx4, Int options);
 VdwPar *ParameterLookupVdwPar(Parameter *par, UInt t1, Int options);
 VdwPairPar *ParameterLookupVdwPairPar(Parameter *par, UInt t1, UInt t2, Int options);
 VdwCutoffPar *ParameterLookupVdwCutoffPar(Parameter *par, UInt t1, UInt t2, Int options);
index 553481e..7943e96 100644 (file)
@@ -2693,13 +2693,13 @@ s_Parameter_Lookup_sub(int argc, VALUE *argv, int parType, Molecule *mol)
                case kBondParType: {
                        BondPar *bp;
                        if (mol != NULL) {
-                               bp = ParameterLookupBondPar(mol->par, t[0], t[1], flags);
+                               bp = ParameterLookupBondPar(mol->par, t[0], t[1], -1, -1, flags);
                                if (bp != NULL) {
                                        idx = bp - mol->par->bondPars;
                                        break;
                                }
                        }
-                       bp = ParameterLookupBondPar(gBuiltinParameters, t[0], t[1], flags);
+                       bp = ParameterLookupBondPar(gBuiltinParameters, t[0], t[1], -1, -1, flags);
                        if (bp != NULL) {
                                idx = bp - gBuiltinParameters->bondPars;
                                is_global = 1;
@@ -2709,13 +2709,13 @@ s_Parameter_Lookup_sub(int argc, VALUE *argv, int parType, Molecule *mol)
                case kAngleParType: {
                        AnglePar *ap;
                        if (mol != NULL) {
-                               ap = ParameterLookupAnglePar(mol->par, t[0], t[1], t[2], flags);
+                               ap = ParameterLookupAnglePar(mol->par, t[0], t[1], t[2], -1, -1, -1, flags);
                                if (ap != NULL) {
                                        idx = ap - mol->par->anglePars;
                                        break;
                                }
                        }
-                       ap = ParameterLookupAnglePar(gBuiltinParameters, t[0], t[1], t[2], flags);
+                       ap = ParameterLookupAnglePar(gBuiltinParameters, t[0], t[1], t[2], -1, -1, -1, flags);
                        if (ap != NULL) {
                                idx = ap - gBuiltinParameters->anglePars;
                                is_global = 1;
@@ -2725,13 +2725,13 @@ s_Parameter_Lookup_sub(int argc, VALUE *argv, int parType, Molecule *mol)
                case kDihedralParType: {
                        TorsionPar *tp;
                        if (mol != NULL) {
-                               tp = ParameterLookupDihedralPar(mol->par, t[0], t[1], t[2], t[3], flags);
+                               tp = ParameterLookupDihedralPar(mol->par, t[0], t[1], t[2], t[3], -1, -1, -1, -1, flags);
                                if (tp != NULL) {
                                        idx = tp - mol->par->dihedralPars;
                                        break;
                                }
                        }
-                       tp = ParameterLookupDihedralPar(gBuiltinParameters, t[0], t[1], t[2], t[3], flags);
+                       tp = ParameterLookupDihedralPar(gBuiltinParameters, t[0], t[1], t[2], t[3], -1, -1, -1, -1, flags);
                        if (tp != NULL) {
                                idx = tp - gBuiltinParameters->dihedralPars;
                                is_global = 1;
@@ -2741,13 +2741,13 @@ s_Parameter_Lookup_sub(int argc, VALUE *argv, int parType, Molecule *mol)
                case kImproperParType: {
                        TorsionPar *tp;
                        if (mol != NULL) {
-                               tp = ParameterLookupImproperPar(mol->par, t[0], t[1], t[2], t[3], flags);
+                               tp = ParameterLookupImproperPar(mol->par, t[0], t[1], t[2], t[3], -1, -1, -1, -1, flags);
                                if (tp != NULL) {
                                        idx = tp - mol->par->improperPars;
                                        break;
                                }
                        }
-                       tp = ParameterLookupImproperPar(gBuiltinParameters, t[0], t[1], t[2], t[3], flags);
+                       tp = ParameterLookupImproperPar(gBuiltinParameters, t[0], t[1], t[2], t[3], -1, -1, -1, -1, flags);
                        if (tp != NULL) {
                                idx = tp - gBuiltinParameters->improperPars;
                                is_global = 1;
@@ -5000,6 +5000,7 @@ s_Molecule_BondPar(VALUE self, VALUE val)
     Molecule *mol;
        BondPar *bp;
        UInt t1, t2;
+       Int i1, i2;
        Int ival;
     Data_Get_Struct(self, Molecule, mol);
        ival = NUM2INT(rb_Integer(val));
@@ -5008,9 +5009,11 @@ s_Molecule_BondPar(VALUE self, VALUE val)
        if (ival < 0)
                ival += mol->nbonds;
        s_RebuildMDParameterIfNecessary(self, Qtrue);
-       t1 = ATOM_AT_INDEX(mol->atoms, mol->bonds[ival * 2])->type;
-       t2 = ATOM_AT_INDEX(mol->atoms, mol->bonds[ival * 2 + 1])->type;
-       bp = ParameterLookupBondPar(mol->par, t1, t2, 0);
+       i1 = mol->bonds[ival * 2];
+       i2 = mol->bonds[ival * 2 + 1];
+       t1 = ATOM_AT_INDEX(mol->atoms, i1)->type;
+       t2 = ATOM_AT_INDEX(mol->atoms, i2)->type;
+       bp = ParameterLookupBondPar(mol->par, t1, t2, i1, i2, 0);
        if (bp == NULL)
                return Qnil;
        return ValueFromMoleculeWithParameterTypeAndIndex(mol, kBondParType, bp - mol->par->bondPars);
@@ -5028,6 +5031,7 @@ s_Molecule_AnglePar(VALUE self, VALUE val)
     Molecule *mol;
        AnglePar *ap;
        UInt t1, t2, t3;
+       Int i1, i2, i3;
        Int ival;
     Data_Get_Struct(self, Molecule, mol);
        ival = NUM2INT(rb_Integer(val));
@@ -5036,10 +5040,13 @@ s_Molecule_AnglePar(VALUE self, VALUE val)
        if (ival < 0)
                ival += mol->nangles;
        s_RebuildMDParameterIfNecessary(self, Qtrue);
-       t1 = ATOM_AT_INDEX(mol->atoms, mol->angles[ival * 3])->type;
-       t2 = ATOM_AT_INDEX(mol->atoms, mol->angles[ival * 3 + 1])->type;
-       t3 = ATOM_AT_INDEX(mol->atoms, mol->angles[ival * 3 + 2])->type;
-       ap = ParameterLookupAnglePar(mol->par, t1, t2, t3, 0);
+       i1 = mol->angles[ival * 3];
+       i2 = mol->angles[ival * 3 + 1];
+       i3 = mol->angles[ival * 3 + 2];
+       t1 = ATOM_AT_INDEX(mol->atoms, i1)->type;
+       t2 = ATOM_AT_INDEX(mol->atoms, i2)->type;
+       t3 = ATOM_AT_INDEX(mol->atoms, i3)->type;
+       ap = ParameterLookupAnglePar(mol->par, t1, t2, t3, i1, i2, i3, 0);
        if (ap == NULL)
                return Qnil;
        return ValueFromMoleculeWithParameterTypeAndIndex(mol, kAngleParType, ap - mol->par->anglePars);
@@ -5058,6 +5065,7 @@ s_Molecule_DihedralPar(VALUE self, VALUE val)
        Int ival;
        TorsionPar *tp;
        UInt t1, t2, t3, t4;
+       Int i1, i2, i3, i4;
     Data_Get_Struct(self, Molecule, mol);
        ival = NUM2INT(rb_Integer(val));
        if (ival < -mol->ndihedrals || ival >= mol->ndihedrals)
@@ -5065,11 +5073,15 @@ s_Molecule_DihedralPar(VALUE self, VALUE val)
        if (ival < 0)
                ival += mol->ndihedrals;
        s_RebuildMDParameterIfNecessary(self, Qtrue);
-       t1 = ATOM_AT_INDEX(mol->atoms, mol->dihedrals[ival * 4])->type;
-       t2 = ATOM_AT_INDEX(mol->atoms, mol->dihedrals[ival * 4 + 1])->type;
-       t3 = ATOM_AT_INDEX(mol->atoms, mol->dihedrals[ival * 4 + 2])->type;
-       t4 = ATOM_AT_INDEX(mol->atoms, mol->dihedrals[ival * 4 + 3])->type;
-       tp = ParameterLookupDihedralPar(mol->par, t1, t2, t3, t4, 0);
+       i1 = mol->dihedrals[ival * 4];
+       i2 = mol->dihedrals[ival * 4 + 1];
+       i3 = mol->dihedrals[ival * 4 + 2];
+       i4 = mol->dihedrals[ival * 4 + 3];
+       t1 = ATOM_AT_INDEX(mol->atoms, i1)->type;
+       t2 = ATOM_AT_INDEX(mol->atoms, i2)->type;
+       t3 = ATOM_AT_INDEX(mol->atoms, i3)->type;
+       t4 = ATOM_AT_INDEX(mol->atoms, i4)->type;
+       tp = ParameterLookupDihedralPar(mol->par, t1, t2, t3, t4, i1, i2, i3, i4, 0);
        if (tp == NULL)
                return Qnil;
        return ValueFromMoleculeWithParameterTypeAndIndex(mol, kDihedralParType, tp - mol->par->dihedralPars);
@@ -5088,6 +5100,7 @@ s_Molecule_ImproperPar(VALUE self, VALUE val)
        Int ival;
        TorsionPar *tp;
        UInt t1, t2, t3, t4;
+       Int i1, i2, i3, i4;
     Data_Get_Struct(self, Molecule, mol);
        ival = NUM2INT(rb_Integer(val));
        if (ival < -mol->nimpropers || ival >= mol->nimpropers)
@@ -5095,11 +5108,15 @@ s_Molecule_ImproperPar(VALUE self, VALUE val)
        if (ival < 0)
                ival += mol->nimpropers;
        s_RebuildMDParameterIfNecessary(self, Qtrue);
-       t1 = ATOM_AT_INDEX(mol->atoms, mol->impropers[ival * 4])->type;
-       t2 = ATOM_AT_INDEX(mol->atoms, mol->impropers[ival * 4 + 1])->type;
-       t3 = ATOM_AT_INDEX(mol->atoms, mol->impropers[ival * 4 + 2])->type;
-       t4 = ATOM_AT_INDEX(mol->atoms, mol->impropers[ival * 4 + 3])->type;
-       tp = ParameterLookupImproperPar(mol->par, t1, t2, t3, t4, 0);
+       i1 = mol->impropers[ival * 4];
+       i2 = mol->impropers[ival * 4 + 1];
+       i3 = mol->impropers[ival * 4 + 2];
+       i4 = mol->impropers[ival * 4 + 3];
+       t1 = ATOM_AT_INDEX(mol->atoms, i1)->type;
+       t2 = ATOM_AT_INDEX(mol->atoms, i2)->type;
+       t3 = ATOM_AT_INDEX(mol->atoms, i3)->type;
+       t4 = ATOM_AT_INDEX(mol->atoms, i4)->type;
+       tp = ParameterLookupImproperPar(mol->par, t1, t2, t3, t4, i1, i2, i3, i4, 0);
        if (tp == NULL)
                return Qnil;
        return ValueFromMoleculeWithParameterTypeAndIndex(mol, kImproperParType, tp - mol->par->improperPars);