votca 2024.1-dev
Loading...
Searching...
No Matches
bead.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#ifndef VOTCA_CSG_BEAD_H
19#define VOTCA_CSG_BEAD_H
20#pragma once
21
22// Standard includes
23#include <cassert>
24#include <string>
25
26// VOTCA includes
28#include <votca/tools/types.h>
29
30// Local VOTCA includes
31#include "basebead.h"
32
33namespace votca {
34namespace csg {
35
36class Topology;
37class Molecule;
38
50class Bead : public BaseBead {
51 public:
55 ~Bead() override = default;
56
61 const Index &getResnr() const { return residue_number_; }
62
67 virtual const double &getQ() const { return charge_; }
68
73 virtual void setQ(const double &q) { charge_ = q; }
74
85 enum Symmetry { spherical = 1, ellipsoidal = 3 };
86 Symmetry getSymmetry() const { return symmetry_; }
87
92 void setVel(const Eigen::Vector3d &r);
93
98 const Eigen::Vector3d &getVel() const;
99
107 void setU(const Eigen::Vector3d &u);
108
124 const Eigen::Vector3d &getU() const;
125
133 void setV(const Eigen::Vector3d &v);
134
146 const Eigen::Vector3d &getV() const;
147
155 void setW(const Eigen::Vector3d &w);
156
167 const Eigen::Vector3d &getW() const;
168
173 Eigen::Vector3d &Vel() {
174 assert(bead_velocity_set_ &&
175 "Cannot access velocity, it has not been set.");
176 return velocity_;
177 }
178
183 Eigen::Vector3d &U() {
184 assert(bU_ && "Cannot access bead orientation u, has not been set.");
185 return u_;
186 }
187
192 Eigen::Vector3d &V() {
193 assert(bV_ && "Cannot access bead orientation v, has not been set.");
194 return v_;
195 }
196
201 Eigen::Vector3d &W() {
202 assert(bW_ && "Cannot access bead orientation w, has not been set.");
203 return w_;
204 }
205
210 Eigen::Vector3d &F() {
211 assert(bead_force_set_ && "Cannot access bead force, has not been set.");
212 return bead_force_;
213 }
214
219 void setF(const Eigen::Vector3d &bead_force);
220
229 const Eigen::Vector3d &getF() const;
230
232 bool HasVel() const noexcept { return bead_velocity_set_; }
233
235 bool HasF() const noexcept { return bead_force_set_; }
236
238 bool HasU() const noexcept { return bU_; }
239
241 bool HasV() const noexcept { return bV_; }
242
244 bool HasW() const noexcept { return bW_; }
245
247 void HasVel(bool b);
248
250 void HasF(bool b);
251
253 void HasU(bool b);
254
256 void HasV(bool b);
257
259 void HasW(bool b);
260
265 const std::vector<Index> &ParentBeads() { return parent_beads_; };
266
270 void ClearParentBeads() { parent_beads_.clear(); }
271
275 void AddParentBead(Index parent_bead_id) {
276 parent_beads_.push_back(parent_bead_id);
277 }
278
279 protected:
280 std::vector<Index> parent_beads_;
281
283 double charge_;
284
286
287 Eigen::Vector3d velocity_, bead_force_, u_, v_, w_;
288
290 bool bU_;
291 bool bV_;
292 bool bW_;
294
296 Bead(Index id, std::string type, Symmetry symmetry, std::string name,
297 Index resnr, double m, double q)
298 : symmetry_(symmetry), charge_(q), residue_number_(resnr) {
299 setId(id);
300 setType(type);
301 setName(name);
302 setMass(m);
303 bead_position_set_ = false;
304 bead_velocity_set_ = false;
305 bU_ = false;
306 bV_ = false;
307 bW_ = false;
308 bead_force_set_ = false;
309 }
310
311 friend class Topology;
312 friend class Molecule;
313};
314
315inline void Bead::setVel(const Eigen::Vector3d &r) {
316 bead_velocity_set_ = true;
317 velocity_ = r;
318}
319
320inline const Eigen::Vector3d &Bead::getVel() const {
321 assert(bead_velocity_set_ &&
322 "Cannot access bead velocity, has not been set.");
323 return velocity_;
324}
325
326inline void Bead::setU(const Eigen::Vector3d &u) {
327 bU_ = true;
328 u_ = u;
329}
330
331inline const Eigen::Vector3d &Bead::getU() const {
332 assert(bU_ && "Cannot access bead orientation u, has not been set.");
333 return u_;
334}
335
336inline void Bead::setV(const Eigen::Vector3d &v) {
337 bV_ = true;
338 v_ = v;
339}
340
341inline const Eigen::Vector3d &Bead::getV() const {
342 assert(bV_);
343 return v_;
344}
345
346inline void Bead::setW(const Eigen::Vector3d &w) {
347 bW_ = true;
348 w_ = w;
349}
350
351inline const Eigen::Vector3d &Bead::getW() const {
352 assert(bW_ && "Cannot access bead orientation w, has not been set.");
353 return w_;
354}
355
356inline void Bead::setF(const Eigen::Vector3d &bead_force) {
357 bead_force_set_ = true;
358 bead_force_ = bead_force;
359}
360
361inline const Eigen::Vector3d &Bead::getF() const {
362 assert(bead_force_set_ && "Cannot access bead force, has not been set.");
363 return bead_force_;
364}
365
366inline void Bead::HasVel(bool b) { bead_velocity_set_ = b; }
367
368inline void Bead::HasF(bool b) { bead_force_set_ = b; }
369
370inline void Bead::HasU(bool b) { bU_ = b; }
371
372inline void Bead::HasV(bool b) { bV_ = b; }
373
374inline void Bead::HasW(bool b) { bW_ = b; }
375} // namespace csg
376} // namespace votca
377
378#endif // VOTCA_CSG_BEAD_H
information about a base bead
Definition basebead.h:44
virtual void setMass(const double &m) noexcept
Definition basebead.h:110
void setName(std::string name)
Sets the name of the bead.
Definition basebead.h:61
void setId(const Index &id) noexcept
Sets the id of the bead.
Definition basebead.h:55
virtual void setType(const std::string &type) noexcept
Definition basebead.h:90
information about a bead
Definition bead.h:50
bool HasU() const noexcept
Definition bead.h:238
Eigen::Vector3d u_
Definition bead.h:287
const Eigen::Vector3d & getU() const
get first orientation (normal vector) vector of bead
Definition bead.h:331
const Eigen::Vector3d & getF() const
get the force acting on the bead
Definition bead.h:361
void ClearParentBeads()
Clears out all parent beads.
Definition bead.h:270
bool bead_velocity_set_
Definition bead.h:289
Eigen::Vector3d & V()
Definition bead.h:192
const Index & getResnr() const
Definition bead.h:61
Eigen::Vector3d w_
Definition bead.h:287
void setU(const Eigen::Vector3d &u)
set first orientation (normal vector) vector of bead
Definition bead.h:326
bool HasF() const noexcept
Definition bead.h:235
void setF(const Eigen::Vector3d &bead_force)
Definition bead.h:356
Eigen::Vector3d & F()
Definition bead.h:210
const Eigen::Vector3d & getW() const
get third orientation vector of bead
Definition bead.h:351
bool HasVel() const noexcept
Definition bead.h:232
bool HasV() const noexcept
Definition bead.h:241
Eigen::Vector3d & Vel()
Definition bead.h:173
void setW(const Eigen::Vector3d &w)
set third orientation vector of bead
Definition bead.h:346
void setVel(const Eigen::Vector3d &r)
Definition bead.h:315
const std::vector< Index > & ParentBeads()
Definition bead.h:265
void AddParentBead(Index parent_bead_id)
Adds the id of a parent bead.
Definition bead.h:275
const Eigen::Vector3d & getV() const
get second orientation vector of bead
Definition bead.h:341
virtual void setQ(const double &q)
Definition bead.h:73
Eigen::Vector3d velocity_
Definition bead.h:287
Eigen::Vector3d bead_force_
Definition bead.h:287
Eigen::Vector3d & W()
Definition bead.h:201
const Eigen::Vector3d & getVel() const
Definition bead.h:320
Index residue_number_
Definition bead.h:285
virtual const double & getQ() const
Definition bead.h:67
bool bead_force_set_
Definition bead.h:293
double charge_
Definition bead.h:283
void setV(const Eigen::Vector3d &v)
set second orientation vector of bead
Definition bead.h:336
Symmetry getSymmetry() const
Definition bead.h:86
Eigen::Vector3d v_
Definition bead.h:287
Symmetry symmetry_
Definition bead.h:282
Symmetry
get the symmetry of the bead
Definition bead.h:85
Eigen::Vector3d & U()
Definition bead.h:183
bool HasW() const noexcept
Definition bead.h:244
~Bead() override=default
Bead(Index id, std::string type, Symmetry symmetry, std::string name, Index resnr, double m, double q)
constructor
Definition bead.h:296
std::vector< Index > parent_beads_
Definition bead.h:280
information about molecules
Definition molecule.h:45
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