From: toshinagata1964 Date: Tue, 27 Aug 2013 15:41:13 +0000 (+0000) Subject: Vdw and Vdw-pair parameters can now have atom indices instead of atom types. (This... X-Git-Tag: v1.0.2~249 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=d995ab6222d7bd6ca00f3385f8ee0adcc210a929;p=molby%2FMolby.git Vdw and Vdw-pair parameters can now have atom indices instead of atom types. (This have been implemented for a while, but not working well) git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/molby/trunk@389 a2be9bc6-48de-4e38-9406-05402d4bc13c --- diff --git a/MolLib/MD/MDCore.c b/MolLib/MD/MDCore.c index d06921b..daf2731 100644 --- a/MolLib/MD/MDCore.c +++ b/MolLib/MD/MDCore.c @@ -569,22 +569,19 @@ s_find_vdw_parameters(MDArena *arena) (3) variant->aware in global par, (4) global par ignoring variants */ for (i = 0, ap = mol->atoms; i < mol->natoms; i++, ap = ATOM_NEXT(ap)) { if (mol->par != NULL) { - vp = ParameterLookupVdwPar(mol->par, ap->type, 0); - /* vp = ParameterLookupVdwPar(mol->par, i, kParameterLookupLocal | kParameterLookupNoWildcard); - if (vp == NULL) - vp = ParameterLookupVdwPar(mol->par, ap->type, kParameterLookupLocal | kParameterLookupGlobal); */ + vp = ParameterLookupVdwPar(mol->par, ap->type, i, 0); if (vp != NULL) { arena->vdw_par_i[i] = (vp - mol->par->vdwPars) + ATOMS_MAX_NUMBER * 2; continue; } } - vp = ParameterLookupVdwPar(gBuiltinParameters, ap->type, 0); + vp = ParameterLookupVdwPar(gBuiltinParameters, ap->type, -1, 0); if (vp != NULL) { arena->vdw_par_i[i] = (vp - gBuiltinParameters->vdwPars) + ATOMS_MAX_NUMBER; continue; } /* Record as missing */ - vp = ParameterLookupVdwPar(par, ap->type, kParameterLookupMissing | kParameterLookupNoBaseAtomType); + vp = ParameterLookupVdwPar(par, ap->type, i, kParameterLookupMissing | kParameterLookupNoBaseAtomType); if (vp == NULL) { vp = AssignArray(&par->vdwPars, &par->nvdwPars, sizeof(VdwPar), par->nvdwPars, NULL); vp->src = -1; @@ -684,10 +681,10 @@ s_find_vdw_parameters(MDArena *arena) type2 = par->vdwPars[j].type1; /* Not type2 */ /* Look up the pair-specific van der Waals parameters */ if (mol->par != NULL) { - vpp = ParameterLookupVdwPairPar(mol->par, type1, type2, 0); + vpp = ParameterLookupVdwPairPar(mol->par, type1, type2, type1, type2, 0); } if (vpp == NULL) - vpp = ParameterLookupVdwPairPar(gBuiltinParameters, type1, type2, 0); + vpp = ParameterLookupVdwPairPar(gBuiltinParameters, type1, type2, type1, type2, 0); if (vpp != NULL) { newpar = *vpp; } else { diff --git a/MolLib/Parameter.c b/MolLib/Parameter.c index a480c0a..a0e5529 100755 --- a/MolLib/Parameter.c +++ b/MolLib/Parameter.c @@ -1651,7 +1651,7 @@ ParameterLookupImproperPar(Parameter *par, UInt t1, UInt t2, UInt t3, UInt t4, I } VdwPar * -ParameterLookupVdwPar(Parameter *par, UInt t1, Int options) +ParameterLookupVdwPar(Parameter *par, UInt t1, Int idx1, Int options) { int i; VdwPar *vp; @@ -1665,16 +1665,16 @@ ParameterLookupVdwPar(Parameter *par, UInt t1, Int options) || (vp->src == 0 && !(options & kParameterLookupLocal)) || (vp->src < 0 && !(options & kParameterLookupMissing))) continue; - if (s_ParMatch(vp->type1, t1, -1, nowildcard)) + if (s_ParMatch(vp->type1, t1, idx1, nowildcard)) return vp; } if (options & kParameterLookupNoBaseAtomType) return NULL; - return ParameterLookupVdwPar(par, t1 % kAtomTypeVariantBase, options | kParameterLookupNoBaseAtomType); + return ParameterLookupVdwPar(par, t1 % kAtomTypeVariantBase, idx1, options | kParameterLookupNoBaseAtomType); } VdwPairPar * -ParameterLookupVdwPairPar(Parameter *par, UInt t1, UInt t2, Int options) +ParameterLookupVdwPairPar(Parameter *par, UInt t1, UInt t2, Int idx1, Int idx2, Int options) { int i; VdwPairPar *vp; @@ -1688,13 +1688,13 @@ 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, -1, nowildcard) && s_ParMatch(vp->type2, t2, -1, nowildcard)) - || (s_ParMatch(vp->type1, t2, -1, nowildcard) && s_ParMatch(vp->type2, t1, -1, nowildcard))) + if ((s_ParMatch(vp->type1, t1, idx1, nowildcard) && s_ParMatch(vp->type2, t2, idx2, nowildcard)) + || (s_ParMatch(vp->type1, t2, idx2, nowildcard) && s_ParMatch(vp->type2, t1, idx1, nowildcard))) return vp; } if (options & kParameterLookupNoBaseAtomType) return NULL; - return ParameterLookupVdwPairPar(par, t1 % kAtomTypeVariantBase, t2 % kAtomTypeVariantBase, options | kParameterLookupNoBaseAtomType); + return ParameterLookupVdwPairPar(par, t1 % kAtomTypeVariantBase, t2 % kAtomTypeVariantBase, idx1, idx2, options | kParameterLookupNoBaseAtomType); } VdwCutoffPar * diff --git a/MolLib/Parameter.h b/MolLib/Parameter.h index 57242b0..9811a03 100755 --- a/MolLib/Parameter.h +++ b/MolLib/Parameter.h @@ -230,8 +230,8 @@ BondPar *ParameterLookupBondPar(Parameter *par, UInt t1, UInt t2, Int idx1, Int 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); +VdwPar *ParameterLookupVdwPar(Parameter *par, UInt t1, Int idx1, Int options); +VdwPairPar *ParameterLookupVdwPairPar(Parameter *par, UInt t1, UInt t2, Int idx1, Int idx2, Int options); VdwCutoffPar *ParameterLookupVdwCutoffPar(Parameter *par, UInt t1, UInt t2, Int options); int ElementParameterInitialize(const char *fname, char **outWarningMessage); diff --git a/MolLib/Ruby_bind/ruby_bind.c b/MolLib/Ruby_bind/ruby_bind.c index 88bfbeb..244bd3b 100644 --- a/MolLib/Ruby_bind/ruby_bind.c +++ b/MolLib/Ruby_bind/ruby_bind.c @@ -2870,13 +2870,13 @@ s_Parameter_Lookup_sub(int argc, VALUE *argv, int parType, Molecule *mol) case kVdwParType: { VdwPar *vp; if (mol != NULL) { - vp = ParameterLookupVdwPar(mol->par, t[0], flags); + vp = ParameterLookupVdwPar(mol->par, t[0], ii[0], flags); if (vp != NULL) { idx = vp - mol->par->vdwPars; break; } } - vp = ParameterLookupVdwPar(gBuiltinParameters, t[0], flags); + vp = ParameterLookupVdwPar(gBuiltinParameters, t[0], -1, flags); if (vp != NULL) { idx = vp - gBuiltinParameters->vdwPars; is_global = 1; @@ -2886,13 +2886,13 @@ s_Parameter_Lookup_sub(int argc, VALUE *argv, int parType, Molecule *mol) case kVdwPairParType: { VdwPairPar *vp; if (mol != NULL) { - vp = ParameterLookupVdwPairPar(mol->par, t[0], t[1], flags); + vp = ParameterLookupVdwPairPar(mol->par, t[0], t[1], ii[0], ii[1], flags); if (vp != NULL) { idx = vp - mol->par->vdwpPars; break; } } - vp = ParameterLookupVdwPairPar(gBuiltinParameters, t[0], t[1], flags); + vp = ParameterLookupVdwPairPar(gBuiltinParameters, t[0], t[1], -1, -1, flags); if (vp != NULL) { idx = vp - gBuiltinParameters->vdwpPars; is_global = 1; @@ -5496,34 +5496,6 @@ s_Molecule_ImproperPar(VALUE self, VALUE val) return ValueFromMoleculeWithParameterTypeAndIndex(mol, kImproperParType, tp - mol->par->improperPars); } */ -/* - * call-seq: - * vdw_par(idx) -> ParameterRef - * - * Returns the vdw parameter for the idx-th atom. - */ -/* -static VALUE -s_Molecule_VdwPar(VALUE self, VALUE val) -{ - Molecule *mol; - Int ival; - VdwPar *vp; - UInt t1; - Data_Get_Struct(self, Molecule, mol); - ival = NUM2INT(rb_Integer(val)); - if (ival < -mol->natoms || ival >= mol->natoms) - rb_raise(rb_eMolbyError, "atom index (%d) out of range", ival); - if (ival < 0) - ival += mol->natoms; - s_RebuildMDParameterIfNecessary(self, Qtrue); - t1 = ATOM_AT_INDEX(mol->atoms, ival)->type; - vp = ParameterLookupVdwPar(mol->par, t1, 0); - if (vp == NULL) - return Qnil; - return ValueFromMoleculeWithParameterTypeAndIndex(mol, kVdwParType, vp - mol->par->vdwPars); -} -*/ /* * call-seq: