Tissue Forge C++ 0.2.1
Interactive, particle-based physics, chemistry and biology modeling and simulation environment
Loading...
Searching...
No Matches
tfDihedral.h
Go to the documentation of this file.
1/*******************************************************************************
2 * This file is part of mdcore.
3 * Coypright (c) 2010 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
4 * Coypright (c) 2017 Andy Somogyi (somogyie at indiana dot edu)
5 * Copyright (c) 2022-2024 T.J. Sego
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published
9 * by the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 ******************************************************************************/
21
26
27#ifndef _MDCORE_INCLUDE_TFDIHEDRAL_H_
28#define _MDCORE_INCLUDE_TFDIHEDRAL_H_
29
30#include <mdcore_config.h>
31#include <tfParticleList.h>
32
33
34namespace TissueForge {
35
36
37 namespace rendering {
38 struct Style;
39 }
40
41
42 typedef enum DihedralFlags {
43
44 // none type dihedral are initial state, and can be
45 // re-assigned if ref count is 1 (only owned by engine).
46 DIHEDRAL_NONE = 0,
47 DIHEDRAL_ACTIVE = 1 << 0
48 } DihedralFlags;
49
50 struct DihedralHandle;
51 struct ParticleHandle;
52
54 typedef struct CAPI_EXPORT Dihedral {
55
56 uint32_t flags;
57
58 /* id of particles involved */
59 int i, j, k, l;
60
61 uint32_t id;
62
63 uint64_t creation_time;
64
68 FPTYPE half_life;
69
70 /* potential energy required to break this bond */
71 FPTYPE dissociation_energy;
72
73 /* potential energy of this bond */
74 FPTYPE potential_energy;
75
76 /* dihedral potential. */
77 struct Potential *potential;
78
79 struct rendering::Style *style;
80
85
86 void init(Potential *potential,
87 ParticleHandle *p1,
88 ParticleHandle *p2,
89 ParticleHandle *p3,
90 ParticleHandle *p4);
91
102 static DihedralHandle *create(Potential *potential,
103 ParticleHandle *p1,
104 ParticleHandle *p2,
105 ParticleHandle *p3,
106 ParticleHandle *p4);
107
111 std::string toString();
112
120 static Dihedral *fromString(const std::string &str);
121
123
129 struct CAPI_EXPORT DihedralHandle {
130 int id;
131
138
142 std::string str() const;
143
150 bool check();
151
156
160 static std::vector<DihedralHandle> items();
161
167 bool decays();
168
169 ParticleHandle *operator[](unsigned int index);
170
172 bool has(const int32_t &pid);
173
175 bool has(ParticleHandle *part);
176
178 FloatP_t getAngle();
179
181 FPTYPE getEnergy();
182
184 std::vector<int32_t> getParts();
185
188
191
193 uint32_t getId();
194
197
199 void setDissociationEnergy(const FPTYPE &dissociation_energy);
200
202 FPTYPE getHalfLife();
203
205 void setHalfLife(const FPTYPE &half_life);
206
209
212
214 FPTYPE getAge();
215
216 DihedralHandle() : id(-1) {}
217
223 DihedralHandle(const int &_id);
224 };
225
232
237
238 /* associated functions */
239
248 HRESULT dihedral_eval(struct Dihedral *d, int N, struct engine *e, FPTYPE *epot_out);
249
261 HRESULT dihedral_evalf(struct Dihedral *d, int N, struct engine *e, FPTYPE *f, FPTYPE *epot_out);
262
266 std::vector<int32_t> Dihedral_IdsForParticle(int32_t pid);
267
268 inline bool operator< (const TissueForge::DihedralHandle& lhs, const TissueForge::DihedralHandle& rhs) { return lhs.id < rhs.id; }
269 inline bool operator> (const TissueForge::DihedralHandle& lhs, const TissueForge::DihedralHandle& rhs) { return rhs < lhs; }
270 inline bool operator<=(const TissueForge::DihedralHandle& lhs, const TissueForge::DihedralHandle& rhs) { return !(lhs > rhs); }
271 inline bool operator>=(const TissueForge::DihedralHandle& lhs, const TissueForge::DihedralHandle& rhs) { return !(lhs < rhs); }
272 inline bool operator==(const TissueForge::DihedralHandle& lhs, const TissueForge::DihedralHandle& rhs) { return lhs.id == rhs.id; }
273 inline bool operator!=(const TissueForge::DihedralHandle& lhs, const TissueForge::DihedralHandle& rhs) { return !(lhs == rhs); }
274
275
276};
277
278
279inline std::ostream &operator<<(std::ostream& os, const TissueForge::DihedralHandle &h)
280{
281 os << h.str().c_str();
282 return os;
283}
284
285#endif // _MDCORE_INCLUDE_TFDIHEDRAL_H_
Tissue Forge rendering and visualization.
Definition tfAngle.h:38
Include Python header, disable linking to pythonX_d.lib on Windows in debug mode.
Definition tfAngleConfig.h:26
std::vector< int32_t > Dihedral_IdsForParticle(int32_t pid)
HRESULT Dihedral_Destroy(Dihedral *d)
Destroys a dihedral.
HRESULT dihedral_eval(struct Dihedral *d, int N, struct engine *e, FPTYPE *epot_out)
Evaluate a list of dihedraled interactions.
HRESULT dihedral_evalf(struct Dihedral *d, int N, struct engine *e, FPTYPE *f, FPTYPE *epot_out)
Evaluate a list of dihedraled interactions.
struct TissueForge::Dihedral Dihedral
HRESULT Dihedral_DestroyAll()
Destroys all dihedrals in the universe.
A handle to a dihedral bond.
Definition tfDihedral.h:129
bool decays()
Tests whether this bond decays.
bool check()
Check the validity of the handle.
std::vector< int32_t > getParts()
rendering::Style * getStyle()
void setDissociationEnergy(const FPTYPE &dissociation_energy)
HRESULT destroy()
Destroy the dihedral.
DihedralHandle(const int &_id)
Construct a new dihedral handle from an existing dihedral id.
static std::vector< DihedralHandle > items()
Gets all dihedrals in the universe.
bool has(const int32_t &pid)
Dihedral * get()
Gets the dihedral of this handle.
void setStyle(rendering::Style *style)
void setHalfLife(const FPTYPE &half_life)
std::string str() const
Get a summary string of the dihedral.
bool has(ParticleHandle *part)
Definition tfDihedral.h:54
FPTYPE half_life
Definition tfDihedral.h:68
static DihedralHandle * create(Potential *potential, ParticleHandle *p1, ParticleHandle *p2, ParticleHandle *p3, ParticleHandle *p4)
Creates a dihedral bond.
static Dihedral * fromString(const std::string &str)
Create from a JSON string representation.
std::string toString()
Get a JSON string representation.
static rendering::Style * styleDef()
Get the default style.
A handle to a particle.
Definition tfParticle.h:313
A special list with convenience methods for working with sets of particles.
Definition tfParticleList.h:52
A Potential object is a compiled interpolation of a given function. The Universe applies potentials t...
Definition tfPotential.h:213
Definition tfEngine.h:164
The Tissue Forge style type.
Definition tfStyle.h:46
int32_t HRESULT
Definition tf_port.h:255