votca 2024.2-dev
Loading...
Searching...
No Matches
molecule.h
Go to the documentation of this file.
1/*
2 * Copyright 2009-2021 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#pragma once
19#ifndef VOTCA_CSG_MOLECULE_H
20#define VOTCA_CSG_MOLECULE_H
21
22// Standard includes
23#include <cassert>
24#include <map>
25#include <string>
26#include <vector>
27
28// Local VOTCA includes
29#include "bead.h"
30
31namespace votca {
32namespace csg {
33
34class Interaction;
35
45class Molecule {
46 public:
48 Index getId() const { return id_; }
49
51 const std::string &getName() const { return name_; }
52
54 void setName(const std::string &name) { name_ = name; }
55
57 void AddBead(Bead *bead, const std::string &name);
59 Bead *getBead(Index bead) { return beads_[bead]; }
60 const Bead *getBead(Index bead) const { return beads_[bead]; }
61 Index getBeadId(Index bead) const { return beads_[bead]->getId(); }
62 Index getBeadIdByName(const std::string &name) const;
63
65 Index BeadCount() const { return beads_.size(); }
66
67 const std::vector<Bead *> &Beads() const { return beads_; }
68 std::vector<Bead *> &Beads() { return beads_; }
70 Index getBeadByName(const std::string &name) const;
71 std::string getBeadName(const Index bead) { return bead_names_[bead]; }
72 const std::string &getBeadName(const Index bead) const {
73 return bead_names_[bead];
74 }
75
77 void AddInteraction(Interaction *ic) { interactions_.push_back(ic); }
78
79 std::vector<Interaction *> Interactions() { return interactions_; }
80 const std::vector<Interaction *> &Interactions() const {
81 return interactions_;
82 }
83
84 private:
85 // maps a name to a bead id
86 std::map<std::string, Index> beadmap_;
87 std::vector<Interaction *> interactions_;
88
89 // id of the molecules
91
92 // name of the molecule
93 std::string name_;
94 // the beads in the molecule
95 std::vector<Bead *> beads_;
96 std::vector<std::string> bead_names_;
97
99 Molecule(Index id, std::string name) : id_(id), name_(name) {}
100
101 friend class Topology;
102};
103
104inline Index Molecule::getBeadIdByName(const std::string &name) const {
105 Index i = getBeadByName(name);
106 if (i < 0) {
107 return i;
108 }
109 return beads_[i]->getId();
110}
111
112} // namespace csg
113} // namespace votca
114
115#endif // VOTCA_CSG_MOLECULE_H
information about a bead
Definition bead.h:50
base class for all interactions
Definition interaction.h:40
information about molecules
Definition molecule.h:45
Index getBeadIdByName(const std::string &name) const
Definition molecule.h:104
void AddBead(Bead *bead, const std::string &name)
Add a bead to the molecule.
Definition molecule.cc:29
std::string getBeadName(const Index bead)
Definition molecule.h:71
std::map< std::string, Index > beadmap_
Definition molecule.h:86
Bead * getBead(Index bead)
get the id of a bead in the molecule
Definition molecule.h:59
Index getBeadByName(const std::string &name) const
find a bead by it's name
Definition molecule.cc:37
const Bead * getBead(Index bead) const
Definition molecule.h:60
Molecule(Index id, std::string name)
constructor
Definition molecule.h:99
std::vector< Bead * > & Beads()
Definition molecule.h:68
void AddInteraction(Interaction *ic)
Add an interaction to the molecule.
Definition molecule.h:77
std::vector< Bead * > beads_
Definition molecule.h:95
std::vector< Interaction * > Interactions()
Definition molecule.h:79
std::string name_
Definition molecule.h:93
const std::string & getName() const
get the name of the molecule
Definition molecule.h:51
std::vector< std::string > bead_names_
Definition molecule.h:96
Index BeadCount() const
get the number of beads in the molecule
Definition molecule.h:65
const std::vector< Interaction * > & Interactions() const
Definition molecule.h:80
std::vector< Interaction * > interactions_
Definition molecule.h:87
void setName(const std::string &name)
set the name of the molecule
Definition molecule.h:54
const std::string & getBeadName(const Index bead) const
Definition molecule.h:72
Index getId() const
get the molecule ID
Definition molecule.h:48
const std::vector< Bead * > & Beads() const
Definition molecule.h:67
Index getBeadId(Index bead) const
Definition molecule.h:61
topology of the whole system
Definition topology.h:81
base class for all analysis tools
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26