OpenMD 3.2
Molecular Dynamics in the Open
Loading...
Searching...
No Matches
AtomType.hpp
1/*
2 * Copyright (c) 2004-present, The University of Notre Dame. All rights
3 * reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 *
15 * 3. Neither the name of the copyright holder nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 * SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your
32 * research, please cite the following paper when you publish your work:
33 *
34 * [1] Drisko et al., J. Open Source Softw. 9, 7004 (2024).
35 *
36 * Good starting points for code and simulation methodology are:
37 *
38 * [2] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).
39 * [3] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).
40 * [4] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008).
41 * [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
42 * [6] Kuang & Gezelter, Mol. Phys., 110, 691-701 (2012).
43 * [7] Lamichhane, Gezelter & Newman, J. Chem. Phys. 141, 134109 (2014).
44 * [8] Bhattarai, Newman & Gezelter, Phys. Rev. B 99, 094106 (2019).
45 * [9] Drisko & Gezelter, J. Chem. Theory Comput. 20, 4986-4997 (2024).
46 */
47
48#ifndef TYPES_ATOMTYPE_HPP
49
50#define TYPES_ATOMTYPE_HPP
51
52#include <config.h>
53
54#include <set>
55#include <string>
56
57#include "utils/PropertyMap.hpp"
58
59using namespace std;
60
61namespace OpenMD {
62 /**
63 * @class AtomType
64 * AtomType is what OpenMD looks to for unchanging data about an atom.
65 * Things that belong to AtomType are universal properties (i.e. does
66 * this atom have a Charge? What is it's mass_?) Dynamic properties of
67 * an atom are not intended to be properties of an atom type
68 */
69 class AtomType {
70 public:
71 AtomType();
72
73 virtual ~AtomType() {};
74
75 virtual void useBase(AtomType* base);
76 virtual void copyAllData(AtomType* orig);
77 void setMass(RealType m);
78 RealType getMass();
79 void setIdent(int id);
80 int getIdent();
81 void setName(const string& name);
82 string getName();
83 std::vector<AtomType*> allYourBase();
84 std::vector<AtomType*> allYourZIG() { return everyZIG; }
85 void addZig(AtomType* at) { everyZIG.push_back(at); }
86
87 // below functions are just forward functions
88 /**
89 * Adds property into property map
90 * @param genData GenericData to be added into PropertyMap
91 */
92 void addProperty(std::shared_ptr<GenericData> genData);
93
94 /**
95 * Removes property from PropertyMap by name
96 * @param propName the name of property to be removed
97 */
98 void removeProperty(const string& propName);
99
100 /**
101 * Returns all names of properties
102 * @return all names of properties
103 */
104 std::vector<string> getPropertyNames();
105
106 /**
107 * Returns all of the properties in PropertyMap
108 * @return all of the properties in PropertyMap
109 */
110 std::vector<std::shared_ptr<GenericData>> getProperties();
111
112 /**
113 * Checks if property is in this PropertyMap
114 * @param propName name of property
115 * @return boolean
116 */
117 bool hasProperty(const string& propName);
118
119 /**
120 * Returns property
121 * @param propName name of property
122 * @return a pointer point to property with propName. If no
123 * property named propName exists, return NULL
124 */
125 std::shared_ptr<GenericData> getPropertyByName(const string& propName);
126
127 bool isLennardJones();
128 bool isElectrostatic();
129 bool isEAM();
130 bool isCharge();
131 bool isFixedCharge();
132 bool isDirectional();
133 bool isDipole();
134 bool isQuadrupole();
135 bool isMultipole();
136 bool isGayBerne();
137 bool isSticky();
138 bool isStickyPower();
139 bool isShape();
140 bool isSC();
141 bool isMetal();
142 bool isFluctuatingCharge();
143
144 protected:
145 int ident_;
146 RealType mass_;
147 string name_;
148 bool hasBase_; // All your base are belong to us
149 AtomType* base_;
150 vector<AtomType*> everyZIG; // list of atom types which use us as a base
151 map<string, bool> myResponsibilities_;
152 map<string, RealType> myValues_;
153
154 private:
155 // prevent copy construction and copy assignment, since property
156 // map contains pointers which can not be copied and managed
157 // safely, except make the generic data at PropertyMap as copy on
158 // write shared pointer
159 AtomType(const AtomType&);
160 AtomType& operator=(const AtomType& atomType);
161 PropertyMap properties_;
162 };
163
165 public:
166 bool operator()(AtomType* lhs, AtomType* rhs) const {
167 return lhs->getIdent() < rhs->getIdent();
168 }
169 };
170
171 using AtomTypeSet = std::set<AtomType*, AtomTypeCompare>;
172} // namespace OpenMD
173
174#endif
AtomType is what OpenMD looks to for unchanging data about an atom.
Definition AtomType.hpp:69
std::shared_ptr< GenericData > getPropertyByName(const string &propName)
Returns property.
Definition AtomType.cpp:137
std::vector< std::shared_ptr< GenericData > > getProperties()
Returns all of the properties in PropertyMap.
Definition AtomType.cpp:126
void removeProperty(const string &propName)
Removes property from PropertyMap by name.
Definition AtomType.cpp:117
bool hasProperty(const string &propName)
Checks if property is in this PropertyMap.
Definition AtomType.cpp:130
std::vector< string > getPropertyNames()
Returns all names of properties.
Definition AtomType.cpp:122
void addProperty(std::shared_ptr< GenericData > genData)
Adds property into property map.
Definition AtomType.cpp:112
PropertyMap class maintains a list of GenericData.
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.