Tissue Forge C++ 0.2.1
Interactive, particle-based physics, chemistry and biology modeling and simulation environment
Loading...
Searching...
No Matches
tfAngle.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
27#ifndef _MDCORE_INCLUDE_TFANGLE_H_
28#define _MDCORE_INCLUDE_TFANGLE_H_
29
30#include <mdcore_config.h>
31#include "tfPotential.h"
32#include <tfParticleList.h>
33
34
35namespace TissueForge {
36
37
38 namespace rendering {
39 struct Style;
40 }
41
42
43 typedef enum AngleFlags {
44
45 // none type angles are initial state, and can be
46 // re-assigned if ref count is 1 (only owned by engine).
47 ANGLE_NONE = 0,
48 ANGLE_ACTIVE = 1 << 0
49 } AngleFlags;
50
51 struct AngleHandle;
52 struct ParticleHandle;
53
60 typedef struct CAPI_EXPORT Angle {
61
62 uint32_t flags;
63
64 /* id of particles involved */
65 int i, j, k;
66
67 uint32_t id;
68
69 uint64_t creation_time;
70
74 FPTYPE half_life;
75
76 /* potential energy required to break this bond */
77 FPTYPE dissociation_energy;
78
79 /* potential energy of this bond */
80 FPTYPE potential_energy;
81
82 /* id of the potential. */
83 struct Potential *potential;
84
85 struct rendering::Style *style;
86
91
92 void init(Potential *potential,
93 struct ParticleHandle *p1,
94 struct ParticleHandle *p2,
95 struct ParticleHandle *p3,
96 uint32_t flags=0);
97
110 static AngleHandle *create(Potential *potential,
111 struct ParticleHandle *p1,
112 struct ParticleHandle *p2,
113 struct ParticleHandle *p3,
114 uint32_t flags=0);
115
119 std::string toString();
120
128 static Angle *fromString(const std::string &str);
129
131
137 struct CAPI_EXPORT AngleHandle {
138 int id;
139
146
150 std::string str() const;
151
158 bool check();
159
166
170 static std::vector<AngleHandle> items();
171
177 bool decays();
178
179 struct ParticleHandle *operator[](unsigned int index);
180
182 bool has(const int32_t &pid);
183
185 bool has(ParticleHandle *part);
186
188 FloatP_t getAngle();
189
191 FPTYPE getEnergy();
192
194 std::vector<int32_t> getParts();
195
198
201
203 uint32_t getId();
204
207
209 void setDissociationEnergy(const FPTYPE &dissociation_energy);
210
212 FPTYPE getHalfLife();
213
215 void setHalfLife(const FPTYPE &half_life);
216
219
222
224 FPTYPE getAge();
225
226 AngleHandle() : id(-1) {}
227
233 AngleHandle(const int &_id);
234 };
235
242
249
250 /* associated functions */
251
260 HRESULT angle_eval(struct Angle *a, int N, struct engine *e, FPTYPE *epot_out);
261
273 HRESULT angle_evalf(struct Angle *a, int N, struct engine *e, FPTYPE *f, FPTYPE *epot_out);
274
278 std::vector<int32_t> Angle_IdsForParticle(int32_t pid);
279
280 inline bool operator< (const TissueForge::AngleHandle& lhs, const TissueForge::AngleHandle& rhs) { return lhs.id < rhs.id; }
281 inline bool operator> (const TissueForge::AngleHandle& lhs, const TissueForge::AngleHandle& rhs) { return rhs < lhs; }
282 inline bool operator<=(const TissueForge::AngleHandle& lhs, const TissueForge::AngleHandle& rhs) { return !(lhs > rhs); }
283 inline bool operator>=(const TissueForge::AngleHandle& lhs, const TissueForge::AngleHandle& rhs) { return !(lhs < rhs); }
284 inline bool operator==(const TissueForge::AngleHandle& lhs, const TissueForge::AngleHandle& rhs) { return lhs.id == rhs.id; }
285 inline bool operator!=(const TissueForge::AngleHandle& lhs, const TissueForge::AngleHandle& rhs) { return !(lhs == rhs); }
286
287
288};
289
290
291inline std::ostream &operator<<(std::ostream& os, const TissueForge::AngleHandle &h)
292{
293 os << h.str().c_str();
294 return os;
295}
296
297#endif // _MDCORE_INCLUDE_TFANGLE_H_
Include Python header, disable linking to pythonX_d.lib on Windows in debug mode.
Definition tfAngleConfig.h:26
HRESULT angle_eval(struct Angle *a, int N, struct engine *e, FPTYPE *epot_out)
Evaluate a list of angleed interactions.
HRESULT angle_evalf(struct Angle *a, int N, struct engine *e, FPTYPE *f, FPTYPE *epot_out)
Evaluate a list of angleed interactions.
HRESULT Angle_DestroyAll()
Destroys all angles in the universe.
std::vector< int32_t > Angle_IdsForParticle(int32_t pid)
HRESULT Angle_Destroy(Angle *a)
Destroys an angle.
struct TissueForge::Angle Angle
A bond concerning an angle.
A handle to an angle bond.
Definition tfAngle.h:137
bool decays()
Tests whether this bond decays.
Potential * getPotential()
HRESULT destroy()
Destroy the angle.
static std::vector< AngleHandle > items()
Gets all angles in the universe.
bool has(ParticleHandle *part)
Angle * get()
Gets the angle of this handle.
void setHalfLife(const FPTYPE &half_life)
bool check()
Check the validity of the handle.
void setStyle(rendering::Style *style)
std::vector< int32_t > getParts()
rendering::Style * getStyle()
ParticleList getPartList()
std::string str() const
Get a summary string of the angle.
bool has(const int32_t &pid)
AngleHandle(const int &_id)
Construct a new angle handle from an existing angle id.
void setDissociationEnergy(const FPTYPE &dissociation_energy)
A bond concerning an angle.
Definition tfAngle.h:60
static rendering::Style * styleDef()
Get the default style.
static AngleHandle * create(Potential *potential, struct ParticleHandle *p1, struct ParticleHandle *p2, struct ParticleHandle *p3, uint32_t flags=0)
Creates an angle bond.
FPTYPE half_life
Definition tfAngle.h:74
std::string toString()
Get a JSON string representation.
static Angle * fromString(const std::string &str)
Create from a JSON string representation.
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