votca 2024.1-dev
Loading...
Searching...
No Matches
xmltopologyreader.h
Go to the documentation of this file.
1/*
2 * Copyright 2009-2020 The VOTCA Development Team (http://www.votca.org)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17
18#ifndef VOTCA_CSG_XMLTOPOLOGYREADER_PRIVATE_H
19#define VOTCA_CSG_XMLTOPOLOGYREADER_PRIVATE_H
20
21// Standard includes
22#include <stack>
23#include <string>
24
25// Third party includes
26#include <boost/unordered_map.hpp>
27
28// Local VOTCA includes
30
31namespace votca {
32namespace csg {
33
34namespace TOOLS = votca::tools;
35
36class BondBead {
37 public:
38 BondBead(std::string &line) {
39 TOOLS::Tokenizer tok(line, ":");
40 std::vector<std::string> tmp_vec = tok.ToVector();
41 if (tmp_vec.size() != 2) {
42 throw std::runtime_error("Wrong number of elements in bead: " + line);
43 }
44 molname = tmp_vec[0];
45 atname = tmp_vec[1];
46 molname.erase(molname.find_last_not_of(" \n\r\t") + 1);
47 atname.erase(atname.find_last_not_of(" \n\r\t") + 1);
48 }
49
50 std::string molname;
51 std::string atname;
52};
53
54class XMLBead {
55 public:
56 XMLBead(std::string name_, std::string type_, double mass_ = 1.0,
57 double q_ = 0.0)
58 : name(name_), type(type_), mass(mass_), q(q_) {};
59 XMLBead() = default;
60
62 std::string name;
63 std::string type;
64 double mass;
65 double q;
66};
67
69 public:
70 XMLMolecule(std::string name_, Index nmols_) : name(name_), nmols(nmols_) {}
71 std::string name;
74 std::vector<XMLBead *> beads;
75 std::map<std::string, XMLBead *> name2beads;
77};
78
87 public:
89 bool ReadTopology(std::string filename, Topology &top) override;
90 ~XMLTopologyReader() override;
91
92 private:
93 typedef boost::unordered_multimap<std::string, XMLMolecule *> MoleculesMap;
94
95 void ReadTopolFile(std::string file);
96
97 void ParseRoot(tools::Property &property);
101 void ParseBox(tools::Property &p);
102 void ParseMolecule(tools::Property &p, std::string molname, Index nmols);
103 void ParseBond(tools::Property &p);
106
107 private:
112
114};
115
116} // namespace csg
117} // namespace votca
118
119#endif // VOTCA_CSG_XMLTOPOLOGYREADER_PRIVATE_H
BondBead(std::string &line)
information about molecules
Definition molecule.h:45
topology of the whole system
Definition topology.h:81
XMLBead(std::string name_, std::string type_, double mass_=1.0, double q_=0.0)
std::vector< XMLBead * > beads
std::map< std::string, XMLBead * > name2beads
XMLMolecule(std::string name_, Index nmols_)
void ParseBonded(tools::Property &el)
void ParseBeadTypes(tools::Property &el)
void ParseMolecule(tools::Property &p, std::string molname, Index nmols)
void ParseBond(tools::Property &p)
void ParseMolecules(tools::Property &p)
bool ReadTopology(std::string filename, Topology &top) override
read a topology file
void ParseAngle(tools::Property &p)
boost::unordered_multimap< std::string, XMLMolecule * > MoleculesMap
void ReadTopolFile(std::string file)
void ParseDihedral(tools::Property &p)
void ParseBox(tools::Property &p)
void ParseRoot(tools::Property &property)
class to manage program options with xml serialization functionality
Definition property.h:55
break string into words
Definition tokenizer.h:72
std::vector< T > ToVector()
store all words in a vector of type T, does type conversion.
Definition tokenizer.h:109
base class for all analysis tools
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26