source: src/Potentials/PotentialFactory.cpp@ ff90e3

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since ff90e3 was ff90e3, checked in by Frederik Heber <heber@…>, 11 years ago

Renamed potential token harmonic to harmonic_bond.

  • Property mode set to 100644
File size: 5.1 KB
Line 
1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2012 University of Bonn. All rights reserved.
5 * Copyright (C) 2013 Frederik Heber. All rights reserved.
6 * Please see the COPYING file or "Copyright notice" in builder.cpp for details.
7 *
8 *
9 * This file is part of MoleCuilder.
10 *
11 * MoleCuilder is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation, either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * MoleCuilder is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with MoleCuilder. If not, see <http://www.gnu.org/licenses/>.
23 */
24
25/*
26 * PotentialFactory.cpp
27 *
28 * Created on: 30.11.2012
29 * Author: heber
30 */
31
32// include config.h
33#ifdef HAVE_CONFIG_H
34#include <config.h>
35#endif
36
37#include "CodePatterns/MemDebug.hpp"
38
39#include "PotentialFactory.hpp"
40
41#include <boost/assign/list_of.hpp>
42#include <boost/lambda/lambda.hpp>
43#include <boost/preprocessor/seq/elem.hpp>
44#include <boost/preprocessor/seq/seq.hpp>
45#include <boost/preprocessor/seq/size.hpp>
46#include <boost/preprocessor/stringize.hpp>
47#include <boost/preprocessor/iteration/local.hpp>
48
49#include "CodePatterns/Singleton_impl.hpp"
50
51#include "Potentials/SerializablePotential.hpp"
52
53#include "AllPotentialHeaders.hpp"
54
55#include "Potentials/Specifics/PotentialTypes.def"
56
57//!> function to print each member of the sequence in the enumeration
58#define sequence_print(z,n,seq) \
59 ( \
60 BOOST_PP_STRINGIZE( BOOST_PP_SEQ_ELEM(n, seq) ), \
61 BOOST_PP_SEQ_ELEM(n, seq) \
62 )
63
64//!> function to print each member of the sequence in the enumeration
65#define reverse_sequence_print(z,n,seq) \
66 ( \
67 BOOST_PP_SEQ_ELEM(n, seq), \
68 BOOST_PP_STRINGIZE( BOOST_PP_SEQ_ELEM(n, seq) ) \
69 )
70
71// static defines
72PotentialFactory::NameToType_t PotentialFactory::NameToType =
73 boost::assign::map_list_of
74#if defined PotentialTypes_END // do we have parameters at all?
75#define BOOST_PP_LOCAL_MACRO(n) sequence_print(~, n, POTENTIALSEQUENCE)
76#define BOOST_PP_LOCAL_LIMITS (0, PotentialTypes_END-1)
77#include BOOST_PP_LOCAL_ITERATE()
78#undef BOOST_PP_LOCAL_MACRO
79#undef BOOST_PP_LOCAL_LIMITS
80#endif
81 ;
82PotentialFactory::TypeToName_t PotentialFactory::TypeToName =
83 boost::assign::map_list_of
84#if defined PotentialTypes_END // do we have parameters at all?
85#define BOOST_PP_LOCAL_MACRO(n) reverse_sequence_print(~, n, POTENTIALSEQUENCE)
86#define BOOST_PP_LOCAL_LIMITS (0, PotentialTypes_END-1)
87#include BOOST_PP_LOCAL_ITERATE()
88#undef BOOST_PP_LOCAL_MACRO
89#undef BOOST_PP_LOCAL_LIMITS
90#endif
91 ;
92
93#undef sequence_print
94#undef reverse_sequence_print
95
96#include "Potentials/Specifics/PotentialTypes.undef"
97
98EmpiricalPotential *PotentialFactory::createInstance(
99 const std::string &potentialtype,
100 const SerializablePotential::ParticleTypes_t &types) const
101{
102 ASSERT (NameToType.count(potentialtype),
103 "PotentialFactory::createInstance() - cannot find potential of name "+potentialtype);
104 switch (NameToType[potentialtype]) {
105 case constant:
106 return new ConstantPotential(types);
107 case tersoff:
108 return new ManyBodyPotential_Tersoff(types);
109 case morse:
110 return new PairPotential_Morse(types);
111 case harmonic_bond:
112 return new PairPotential_Harmonic(types);
113 case harmonic_angle:
114 return new ThreeBodyPotential_Angle(types);
115 case lennardjones:
116 return new PairPotential_LennardJones(types);
117 case torsion:
118 return new FourBodyPotential_Torsion(types);
119 case improper:
120 return new FourBodyPotential_Improper(types);
121 default:
122 ASSERT(0, "PotentialFactory::createInstance() - unknown potential desired to create.");
123 }
124 return NULL;
125}
126
127EmpiricalPotential *PotentialFactory::createInstance(
128 const std::string &potentialtype,
129 std::istream &serialized) const
130{
131 EmpiricalPotential *potential = NULL;
132 ASSERT (NameToType.count(potentialtype),
133 "PotentialFactory::createInstance() - cannot find potential of name "+potentialtype);
134 switch (NameToType[potentialtype]) {
135 case constant:
136 potential = new ConstantPotential();
137 break;
138 case tersoff:
139 potential = new ManyBodyPotential_Tersoff();
140 break;
141 case morse:
142 potential = new PairPotential_Morse();
143 break;
144 case harmonic_bond:
145 potential = new PairPotential_Harmonic();
146 break;
147 case harmonic_angle:
148 potential = new ThreeBodyPotential_Angle();
149 break;
150 case lennardjones:
151 potential = new PairPotential_LennardJones();
152 break;
153 case torsion:
154 potential = new FourBodyPotential_Torsion();
155 break;
156 case improper:
157 potential = new FourBodyPotential_Improper();
158 break;
159 default:
160 ASSERT(0, "PotentialFactory::createInstance() - unknown potential desired to create.");
161 break;
162 }
163 // now stream in types and parameters
164 potential->stream_from(serialized);
165
166 return potential;
167}
168
169CONSTRUCT_SINGLETON(PotentialFactory)
Note: See TracBrowser for help on using the repository browser.