/* * Project: MoleCuilder * Description: creates and alters molecular systems * Copyright (C) 2013 Frederik Heber. All rights reserved. * * * This file is part of MoleCuilder. * * MoleCuilder is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * MoleCuilder 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with MoleCuilder. If not, see . */ /* * FourBodyPotential_Improper.cpp * * Created on: Jul 10, 2013 * Author: heber */ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include "CodePatterns/MemDebug.hpp" #include "CodePatterns/Assert.hpp" #include "FourBodyPotential_Improper.hpp" #include // for 'map_list_of()' #include "Potentials/InternalCoordinates/FourBody_ImproperAngle.hpp" // static definitions const FourBodyPotential_Improper::ParameterNames_t FourBodyPotential_Improper::ParameterNames = boost::assign::list_of ("spring_constant") ("equilibrium_distance") ; const std::string FourBodyPotential_Improper::improper_token("improper"); Coordinator::ptr FourBodyPotential_Improper::coordinator(Memory::ignore(new FourBody_ImproperAngle())); static HomologyGraph generateBindingModel(const EmpiricalPotential::ParticleTypes_t &_ParticleTypes) { // fill nodes HomologyGraph::nodes_t nodes; { ASSERT( _ParticleTypes.size() == (size_t)4, "generateBindingModel() - FourBodyPotential_Improper needs four types."); std::pair inserter; inserter = nodes.insert( std::make_pair(FragmentNode(_ParticleTypes[0], 3), 1) ); if (!inserter.second) ++(inserter.first->second); inserter = nodes.insert( std::make_pair(FragmentNode(_ParticleTypes[1], 1), 1) ); if (!inserter.second) ++(inserter.first->second); inserter = nodes.insert( std::make_pair(FragmentNode(_ParticleTypes[2], 1), 1) ); if (!inserter.second) ++(inserter.first->second); inserter = nodes.insert( std::make_pair(FragmentNode(_ParticleTypes[3], 1), 1) ); if (!inserter.second) ++(inserter.first->second); } // there are no edges HomologyGraph::edges_t edges; { std::pair inserter; inserter = edges.insert( std::make_pair( FragmentEdge(_ParticleTypes[0], _ParticleTypes[1]), 1) ); if (!inserter.second) ++(inserter.first->second); inserter = edges.insert( std::make_pair( FragmentEdge(_ParticleTypes[0], _ParticleTypes[2]), 1) ); if (!inserter.second) ++(inserter.first->second); inserter = edges.insert( std::make_pair( FragmentEdge(_ParticleTypes[0], _ParticleTypes[3]), 1) ); if (!inserter.second) ++(inserter.first->second); } return HomologyGraph(nodes, edges); } FourBodyPotential_Improper::FourBodyPotential_Improper() : FourBodyPotential_Torsion(), bindingmodel(HomologyGraph()) {} FourBodyPotential_Improper::FourBodyPotential_Improper( const ParticleTypes_t &_ParticleTypes) : FourBodyPotential_Torsion(_ParticleTypes), bindingmodel(generateBindingModel(_ParticleTypes)) {} FourBodyPotential_Improper::FourBodyPotential_Improper( const ParticleTypes_t &_ParticleTypes, const double _spring_constant, const double _equilibrium_distance) : FourBodyPotential_Torsion( _ParticleTypes, _spring_constant, _equilibrium_distance), bindingmodel(generateBindingModel(_ParticleTypes)) {}