--- trunk/src/brains/MoleculeCreator.cpp 2015/03/07 16:59:57 2070 +++ trunk/src/brains/MoleculeCreator.cpp 2015/03/07 21:41:51 2071 @@ -184,7 +184,7 @@ namespace OpenMD { createConstraintPair(mol); //create non-bonded constraintPairs - for (int i = 0; i < molStamp->getNConstraints(); ++i) { + for (std::size_t i = 0; i < molStamp->getNConstraints(); ++i) { ConstraintStamp* cStamp = molStamp->getConstraintStamp(i); Atom* atomA; Atom* atomB; @@ -193,9 +193,12 @@ namespace OpenMD { atomB = mol->getAtomAt(cStamp->getB()); assert( atomA && atomB ); - RealType distance; bool printConstraintForce = false; + if (cStamp->havePrintConstraintForce()) { + printConstraintForce = cStamp->getPrintConstraintForce(); + } + if (!cStamp->haveConstrainedDistance()) { sprintf(painCave.errMsg, "Constraint Error: A non-bond constraint was specified\n" @@ -203,18 +206,14 @@ namespace OpenMD { painCave.isFatal = 1; simError(); } else { - distance = cStamp->getConstrainedDistance(); - } - - if (cStamp->havePrintConstraintForce()) { - printConstraintForce = cStamp->getPrintConstraintForce(); - } - - ConstraintElem* consElemA = new ConstraintElem(atomA); - ConstraintElem* consElemB = new ConstraintElem(atomB); - ConstraintPair* cPair = new ConstraintPair(consElemA, consElemB, distance, - printConstraintForce); - mol->addConstraintPair(cPair); + RealType distance = cStamp->getConstrainedDistance(); + ConstraintElem* consElemA = new ConstraintElem(atomA); + ConstraintElem* consElemB = new ConstraintElem(atomB); + ConstraintPair* cPair = new ConstraintPair(consElemA, consElemB, + distance, + printConstraintForce); + mol->addConstraintPair(cPair); + } } // now create the constraint elements: @@ -228,7 +227,7 @@ namespace OpenMD { mol->setConstrainTotalCharge( molStamp->getConstrainTotalCharge() ); } - //the construction of this molecule is finished + // The construction of this molecule is finished: mol->complete(); return mol;