--- branches/new_design/OOPSE-4/src/UseTheForce/ForceField.cpp 2004/11/05 21:04:13 1716 +++ branches/new_design/OOPSE-4/src/UseTheForce/ForceField.cpp 2004/11/06 05:21:55 1720 @@ -1,96 +1,120 @@ +/* + * Copyright (C) 2000-2004 Object Oriented Parallel Simulation Engine (OOPSE) project + * + * Contact: oopse@oopse.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 + * of the License, or (at your option) any later version. + * All we ask is that proper credit is given for our work, which includes + * - but is not limited to - adding the above copyright notice to the beginning + * of your source code files, and to any copyright notice that you may distribute + * with programs based on this work. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + + /** + * @file ForceField.cpp + * @author tlin + * @date 11/04/2004 + * @time 22:51am + * @version 1.0 + */ + #include "UseTheForce/ForceField.hpp" +namespace oopse { -AtomType* ForceField::getMatchingAtomType(const string &at) { +ForceField::ForceField() : hasVariant_(false){ + char* tempPath; + tempPath = getenv("FORCE_PARAM_PATH"); - map::iterator iter; - - iter = atomTypeMap.find(at); - if (iter != atomTypeMap.end()) { - return iter->second; - } else { - return NULL; - } + if (tempPath == NULL) { + //convert a macro from compiler to a string in c++ + STR_DEFINE(ffPath_, FRC_PATH ); + } else { + ffPath_ = tempPath; + } } -BondType* ForceField::getMatchingBondType(const string &at1, - const string &at2) { +AtomType* ForceField::getAtomType(const std::string &at) { + std::vector keys; + keys.push_back(at); + return atomTypeCont_.find(keys); +} - map, BondType*>::iterator iter; - vector foundTypes; +BondType* ForceField::getBondType(const std::string &at1, const std::string &at2) { + std::vector keys; + keys.push_back(at1); + keys.push_back(at2); + return bondTypeCont_.find(keys, wildCardAtomTypeName_); - iter = bondTypeMap.find(pair); - if (iter != bondTypeMap.end()) { - // exact match, so just return it - return iter->second; - } +} - iter = bondTypeMap.find(pair); - if (iter != bondTypeMap.end()) { - // exact match in reverse order, so just return it - return iter->second; - } +BendType* ForceField::getBendType(const std::string &at1, const std::string &at2, + const std::string &at3) { + std::vector keys; + keys.push_back(at1); + keys.push_back(at2); + keys.push_back(at3); + return bendTypeCont_.find(keys, wildCardAtomTypeName_); +} - iter = bondTypeMap.find(pair); - if (iter != bondTypeMap.end()) { - foundTypes.push_back(iter->second); - } +TorsionType* ForceField::getTorsionType(const std::string &at1, const std::string &at2, + const std::string &at3, const std::string &at4) { + std::vector keys; + keys.push_back(at1); + keys.push_back(at2); + keys.push_back(at3); + keys.push_back(at4); + return torsionTypeCont_.find(keys, wildCardAtomTypeName_); - iter = bondTypeMap.find(pair); - if (iter != bondTypeMap.end()) { - foundTypes.push_back(iter->second); - } +} - iter = bondTypeMap.find(pair); - if (iter != bondTypeMap.end()) { - foundTypes.push_back(iter->second); - } +void ForceField::addAtomType(const std::string &at, AtomType* atomType) { + std::vector keys; + keys.push_back(at); + return atomTypeCont_.add(keys); +} - iter = bondTypeMap.find(pair); - if (iter != bondTypeMap.end()) { - foundTypes.push_back(iter->second); - } - - if (foundTypes.empty()) { - return NULL; - } else { - +void ForceField::addBondType(const std::string &at1, const std::string &at2, BondType* bondType) { + std::vector keys; + keys.push_back(at1); + keys.push_back(at2); + return bondTypeCont_.add(keys); - +} +void ForceField::addBendType(const std::string &at1, const std::string &at2, + const std::string &at3, BendType* bendType) { + std::vector keys; + keys.push_back(at1); + keys.push_back(at2); + keys.push_back(at3); + return bendTypeCont_.add(keys); +} +void ForceField::addTorsionType(const std::string &at1, const std::string &at2, + const std::string &at3, const std::string &at4, TorsionType* torsionType) { + std::vector keys; + keys.push_back(at1); + keys.push_back(at2); + keys.push_back(at3); + keys.push_back(at4); + return torsionTypeCont_.add(keys); +} - +double ForceField::getRcutForAtomType(AtomType* at) { +} -BendType* ForceField::getMatchingBendType(const string &at1, const string &at2, - const string &at3); -TorsionType* ForceField::getMatchingTorsionType(const string &at1, const string &at2, - const string &at3, const string &at4); - -double ForceField::getRcutForAtomType(AtomType* at); - - - vector > generateWildcardSequence(const vector atomTypes) { - - vector > results; - - - - - vector > getAllWildcardPermutations(const vector myAts) { - - int nStrings; - vector oneResult; - vector > allResults; - - nStrings = myAts.size(); - - if (nStrings == 1) { - oneResult.push_back(wildcardCharacter); - allResults.push_back(oneResult); - return allResults; - } else { - - for (i=0; i < nStrings; i++) { - oneResult = myAts; - replace(oneResult.begin(), oneResult.end(), +} //end namespace oopse