STORMM Source Documentation
Loading...
Searching...
No Matches
watcher.h
1// -*-c++-*-
2#ifndef STORMM_WATCHER_H
3#define STORMM_WATCHER_H
4
5#include "copyright.h"
6#include "Accelerator/hybrid.h"
7#include "Constants/behavior.h"
8#include "DataTypes/stormm_vector_types.h"
9#include "Synthesis/atomgraph_synthesis.h"
10#include "Synthesis/phasespace_synthesis.h"
11
12namespace stormm {
13namespace review {
14
15using card::Hybrid;
16using card::HybridTargetLevel;
17using constants::ExceptionResponse;
18using synthesis::AtomGraphSynthesis;
19using synthesis::PhaseSpaceSynthesis;
20
22constexpr int default_max_watcher_reports = 1000;
23
25constexpr int default_watcher_force_threshold = 128.0;
26
28constexpr int default_watcher_speed_threshold = 1.0;
29
32constexpr float minimum_force_threshold = 1.0;
33
36constexpr float minimum_speed_threshold = 1.0;
37
41public:
42
45 WatcherWriter(int nsystem_in, int max_reports_in, float force_limit_in, float speed_limit_in,
46 bool track_purge_in, int* nforce_in, int* nspeed_in, int* nrattle_in,
47 int* nshake_in, float4* forces_in, int* force_steps_in, int* force_stages_in,
48 float4* speeds_in, int* speed_steps_in, int* speed_stages_in,
49 uint2* rattle_fails_in, uint2* shake_fails_in, float* rattle_ext_in,
50 float* shake_ext_in, float* xvel_purge_in, float* yvel_purge_in,
51 float* zvel_purge_in, float* xang_purge_in, float* yang_purge_in,
52 float* zang_purge_in);
53
60 WatcherWriter(const WatcherWriter &original) = default;
61 WatcherWriter(WatcherWriter &&original) = default;
63
64 const int nsystem;
65 const int max_reports;
66 const float force_limit;
67 const float speed_limit;
69 const bool track_purge;
73 int* nforce;
74 int* nspeed;
76 int* nrattle;
78 int* nshake;
91 float* rattle_ext;
93 float* shake_ext;
94 float* xvel_purge;
98 float* yvel_purge;
99 float* zvel_purge;
100 float* xang_purge;
101 float* yang_purge;
102 float* zang_purge;
103};
104
108public:
109
113 WatcherReader(int nsystem_in, int max_reports_in, float force_limit_in, float speed_limit_in,
114 bool track_purge_in, const int* nforce_in, const int* nspeed_in,
115 const int* nrattle_in, const int* nshake_in, const float4* forces_in,
116 const int* force_steps_in, const int* force_stages_in, const float4* speeds_in,
117 const int* speed_steps_in, const int* speed_stages_in,
118 const uint2* rattle_fails_in, const uint2* shake_fails_in,
119 const float* rattle_ext_in, const float* shake_ext_in, const float* xvel_purge_in,
120 const float* yvel_purge_in, const float* zvel_purge_in, const float* xang_purge_in,
121 const float* yang_purge_in, const float* zang_purge_in);
122
125
132 WatcherReader(const WatcherReader &original) = default;
133 WatcherReader(WatcherReader &&original) = default;
135
136 const int nsystem;
137 const int max_reports;
138 const float force_limit;
139 const float speed_limit;
141 const bool track_purge;
145 const int* nforce;
146 const int* nspeed;
148 const int* nrattle;
150 const int* nshake;
152 const float4* forces;
153 const int* force_steps;
154 const int* force_stages;
156 const float4* speeds;
158 const int* speed_steps;
159 const int* speed_stages;
163 const float* rattle_ext;
165 const float* shake_ext;
166 const float* xvel_purge;
170 const float* yvel_purge;
171 const float* zvel_purge;
172 const float* xang_purge;
173 const float* yang_purge;
174 const float* zang_purge;
175};
176
182class Watcher {
183public:
184
188 Watcher(const PhaseSpaceSynthesis *poly_ps, const AtomGraphSynthesis &poly_ag,
189 float force_threshold_in = default_watcher_force_threshold,
190 float speed_threshold_in = default_watcher_speed_threshold,
191 bool track_momentum_purge_in = false, int max_reports_in = default_max_watcher_reports,
192 ExceptionResponse policy_in = ExceptionResponse::WARN);
193
194 Watcher(const PhaseSpaceSynthesis &poly_ps, const AtomGraphSynthesis &poly_ag,
195 float force_threshold_in = default_watcher_force_threshold,
196 float speed_threshold_in = default_watcher_speed_threshold,
197 bool track_momentum_purge_in = false, int max_reports_in = default_max_watcher_reports,
198 ExceptionResponse policy_in = ExceptionResponse::WARN);
200
208 Watcher(const Watcher &original);
209 Watcher(Watcher &&original);
210 Watcher& operator=(const Watcher &original);
211 Watcher& operator=(Watcher &&original);
213
215 int getReportCount() const;
216
218 int getSystemCount() const;
219
221 float getForceThreshold() const;
222
226 int getLargeForceCount(HybridTargetLevel tier = HybridTargetLevel::HOST) const;
227
232 std::vector<float4> getLargeForces(HybridTargetLevel tier = HybridTargetLevel::HOST) const;
233
238 std::vector<int> getLargeForceSteps(HybridTargetLevel tier = HybridTargetLevel::HOST) const;
239
246 std::vector<DynamicsStepStage>
247 getLargeForceStages(HybridTargetLevel tier = HybridTargetLevel::HOST) const;
248
250 float getSpeedThreshold() const;
251
255 int getHighSpeedCount(HybridTargetLevel tier = HybridTargetLevel::HOST) const;
256
261 std::vector<float4> getHighSpeeds(HybridTargetLevel tier = HybridTargetLevel::HOST) const;
262
267 std::vector<int> getHighSpeedSteps(HybridTargetLevel tier = HybridTargetLevel::HOST) const;
268
273 std::vector<DynamicsStepStage>
274 getHighSpeedStages(HybridTargetLevel tier = HybridTargetLevel::HOST) const;
275
280 int getFailedRattleCount(HybridTargetLevel tier = HybridTargetLevel::HOST) const;
281
287 int getFailedShakeCount(HybridTargetLevel tier = HybridTargetLevel::HOST) const;
288
294 std::vector<uint2> getRattleFailures(HybridTargetLevel tier = HybridTargetLevel::HOST) const;
295
301 std::vector<uint2> getShakeFailures(HybridTargetLevel tier = HybridTargetLevel::HOST) const;
302
308 std::vector<float> getRattleViolations(HybridTargetLevel tier = HybridTargetLevel::HOST) const;
309
315 std::vector<float> getShakeViolations(HybridTargetLevel tier = HybridTargetLevel::HOST) const;
316
325 const WatcherReader data(HybridTargetLevel tier = HybridTargetLevel::HOST) const;
326 WatcherWriter data(HybridTargetLevel tier = HybridTargetLevel::HOST);
328
333 void setForceThreshold(float force_threshold_in);
334
339 void setSpeedThreshold(float speed_threshold_in);
340
341private:
342
343 // General parameters
344 ExceptionResponse policy;
346 int max_reports;
347
348 // Track large forces on any given atom
349 float force_threshold;
351 Hybrid<int> large_force_count;
353 Hybrid<float4> large_forces;
358 Hybrid<int> large_force_steps;
359 Hybrid<int> large_force_stages;
361
362 // Track large velocities on any given atom
363 float speed_threshold;
365 Hybrid<int> high_speed_count;
367 Hybrid<float4> high_speeds;
372 Hybrid<int> high_speed_steps;
373 Hybrid<int> high_speed_stages;
375
376 // Track failed convergence in SHAKE or RATTLE groups
377 Hybrid<int> failed_rattle_count;
379 Hybrid<int> failed_shake_count;
381 Hybrid<uint2> rattle_group_failures;
386 Hybrid<uint2> shake_group_failures;
391 Hybrid<float> rattle_violations;
394 Hybrid<float> shake_violations;
397
398 // Track the amount of momentum purged with each cycle, if requested
399 bool track_momentum_purge;
400 Hybrid<float> x_velocity_purge;
402 Hybrid<float> y_velocity_purge;
404 Hybrid<float> z_velocity_purge;
406 Hybrid<float> x_angular_purge;
410 Hybrid<float> y_angular_purge;
412 Hybrid<float> z_angular_purge;
414
416 Hybrid<int> int_data;
417
419 Hybrid<float> float_data;
420
422 PhaseSpaceSynthesis *poly_ps_ptr;
423
425 AtomGraphSynthesis *poly_ag_ptr;
426
429 void allocate();
430
432 void validateForceThreshold() const;
433
435 void validateSpeedThreshold() const;
436};
437
438} // namespace review
439} // namespace stormm
440
441#endif
An evolution of GpuBuffer in pmemd.cuda, the Composite array has elements that are accessible from ei...
Definition hybrid.h:202
const WatcherReader data(HybridTargetLevel tier=HybridTargetLevel::HOST) const
Get the object's abstract.
Definition watcher.cpp:488
void setForceThreshold(float force_threshold_in)
Set the threshold at which the object will report large forces.
Definition watcher.cpp:520
int getLargeForceCount(HybridTargetLevel tier=HybridTargetLevel::HOST) const
Get the number of large forces on atoms found throughout the simulation.
Definition watcher.cpp:277
std::vector< uint2 > getRattleFailures(HybridTargetLevel tier=HybridTargetLevel::HOST) const
Get the list of RATTLE violations–group IDs in the "x" member of the tuple (as listed in the associat...
Definition watcher.cpp:432
std::vector< float > getShakeViolations(HybridTargetLevel tier=HybridTargetLevel::HOST) const
Get the violation of a constraint which failed to converge, or the maximum violation of any constrain...
Definition watcher.cpp:474
int getSystemCount() const
Get the number of systems from the associated coordinate synthesis.
Definition watcher.cpp:267
std::vector< int > getHighSpeedSteps(HybridTargetLevel tier=HybridTargetLevel::HOST) const
Get the list of step counts at which each high velocity in the list of all high veloicities was obser...
Definition watcher.cpp:371
int getFailedShakeCount(HybridTargetLevel tier=HybridTargetLevel::HOST) const
Get the number of times the SHAKE constraint iteration limit was reached (without the requested conve...
Definition watcher.cpp:419
float getForceThreshold() const
Get the threshold at which the object will report large forces on atoms.
Definition watcher.cpp:272
std::vector< float4 > getLargeForces(HybridTargetLevel tier=HybridTargetLevel::HOST) const
Get the list of large forces observed over the course of simulations on a set of systems.
Definition watcher.cpp:290
int getHighSpeedCount(HybridTargetLevel tier=HybridTargetLevel::HOST) const
Get the number of high velocities encountered in the simulation.
Definition watcher.cpp:344
std::vector< int > getLargeForceSteps(HybridTargetLevel tier=HybridTargetLevel::HOST) const
Get the list of step counts at which each large force in the list of all large forces was observed.
Definition watcher.cpp:304
std::vector< float4 > getHighSpeeds(HybridTargetLevel tier=HybridTargetLevel::HOST) const
Get the list of high velocities observed over the course of simulations on a set of systems.
Definition watcher.cpp:357
int getFailedRattleCount(HybridTargetLevel tier=HybridTargetLevel::HOST) const
Get the number of times the RATTLE constraint iteration limit was reached (without the requested conv...
Definition watcher.cpp:406
void setSpeedThreshold(float speed_threshold_in)
Set the threshold at which the object will report high particle speeds.
Definition watcher.cpp:526
Watcher(const PhaseSpaceSynthesis *poly_ps, const AtomGraphSynthesis &poly_ag, float force_threshold_in=default_watcher_force_threshold, float speed_threshold_in=default_watcher_speed_threshold, bool track_momentum_purge_in=false, int max_reports_in=default_max_watcher_reports, ExceptionResponse policy_in=ExceptionResponse::WARN)
The constructor requires a coordinate synthesis in order to allocate the proper amount of space for t...
Definition watcher.cpp:66
std::vector< DynamicsStepStage > getLargeForceStages(HybridTargetLevel tier=HybridTargetLevel::HOST) const
Get the points in the integration cycle at which each of the large forces were observed....
Definition watcher.cpp:318
int getReportCount() const
Get the maximum number of reports that the object is designed to hold.
Definition watcher.cpp:262
std::vector< DynamicsStepStage > getHighSpeedStages(HybridTargetLevel tier=HybridTargetLevel::HOST) const
Get the points in the integration cycle at which each high particle velocity was found.
Definition watcher.cpp:385
float getSpeedThreshold() const
Get the threshold at which the object will report large velocities on atoms.
Definition watcher.cpp:339
std::vector< float > getRattleViolations(HybridTargetLevel tier=HybridTargetLevel::HOST) const
Get the violation of a constraint which failed to converge, or the maximum violation of any constrain...
Definition watcher.cpp:460
std::vector< uint2 > getShakeFailures(HybridTargetLevel tier=HybridTargetLevel::HOST) const
Get the list of SHAKE violations–group IDs in the "x" member of the tuple (as listed in the associate...
Definition watcher.cpp:446
A collection of one or more AtomGraph objects, with similar components arranged in contiguous arrays ...
Definition atomgraph_synthesis.h:55
A fixed-precision representation of coordinates, velocities, and forces to manage a set of simulation...
Definition phasespace_synthesis.h:325
Definition stormm_vector_types.h:69
Definition stormm_vector_types.h:40
The read-only abstract for the Watcher class is available to make reports out of a Watcher object pas...
Definition watcher.h:107
const int * speed_stages
Definition watcher.h:159
const float * zang_purge
Angular momentum purges about the Z axis for each system.
Definition watcher.h:174
const float * xang_purge
Angular momentum purges about the X axis for each system.
Definition watcher.h:172
const float4 * forces
Cartesian components and atom indices of large forces.
Definition watcher.h:152
const float * yvel_purge
A compendium of Cartesian Y velocity purges for each system.
Definition watcher.h:170
WatcherReader(const WatcherReader &original)=default
Like most abstracts, the presence of const members makes copy and move assignment impossible except i...
const float speed_limit
Definition watcher.h:139
const int * force_steps
Steps on which each large force is observed.
Definition watcher.h:153
WatcherReader(int nsystem_in, int max_reports_in, float force_limit_in, float speed_limit_in, bool track_purge_in, const int *nforce_in, const int *nspeed_in, const int *nrattle_in, const int *nshake_in, const float4 *forces_in, const int *force_steps_in, const int *force_stages_in, const float4 *speeds_in, const int *speed_steps_in, const int *speed_stages_in, const uint2 *rattle_fails_in, const uint2 *shake_fails_in, const float *rattle_ext_in, const float *shake_ext_in, const float *xvel_purge_in, const float *yvel_purge_in, const float *zvel_purge_in, const float *xang_purge_in, const float *yang_purge_in, const float *zang_purge_in)
As with other abstracts, the constructor takes a list of all relevant pointers and critical constants...
Definition watcher.cpp:33
const float4 * speeds
Definition watcher.h:156
const int * force_stages
Definition watcher.h:154
const float * shake_ext
The extent to which each SHAKE group failed to converge.
Definition watcher.h:165
const int nsystem
The number of systems tracked by the Watcher object.
Definition watcher.h:136
const int * speed_steps
Steps on which each high speed is observed.
Definition watcher.h:158
const int * nforce
The number of forces observed to violate the stated bounds.
Definition watcher.h:145
const uint2 * rattle_fails
Details of RATTLE group convergence failures.
Definition watcher.h:161
const float * yang_purge
Angular momentum purges about the Y axis for each system.
Definition watcher.h:173
const int * nspeed
Definition watcher.h:146
const int max_reports
The maximum number of reports to present in any given category.
Definition watcher.h:137
const float * xvel_purge
Definition watcher.h:166
const int * nshake
Definition watcher.h:150
const float force_limit
The largest force (magnitude) that will not be reported.
Definition watcher.h:138
const float * zvel_purge
A compendium of Cartesian Z velocity purges for each system.
Definition watcher.h:171
const int * nrattle
Definition watcher.h:148
const float * rattle_ext
Definition watcher.h:163
const uint2 * shake_fails
Details of SHAKE group convergence failures.
Definition watcher.h:162
const bool track_purge
Definition watcher.h:141
The writeable abstract for a Watcher class will be provided as a formal argument to various molecular...
Definition watcher.h:40
float4 * speeds
Definition watcher.h:84
int * nshake
Definition watcher.h:78
const float force_limit
The largest force (magnitude) that will not be reported.
Definition watcher.h:66
WatcherWriter(int nsystem_in, int max_reports_in, float force_limit_in, float speed_limit_in, bool track_purge_in, int *nforce_in, int *nspeed_in, int *nrattle_in, int *nshake_in, float4 *forces_in, int *force_steps_in, int *force_stages_in, float4 *speeds_in, int *speed_steps_in, int *speed_stages_in, uint2 *rattle_fails_in, uint2 *shake_fails_in, float *rattle_ext_in, float *shake_ext_in, float *xvel_purge_in, float *yvel_purge_in, float *zvel_purge_in, float *xang_purge_in, float *yang_purge_in, float *zang_purge_in)
As with other abstracts, the constructor takes a list of all relevant pointers and critical constants...
Definition watcher.cpp:14
int * force_stages
Definition watcher.h:82
int * speed_stages
Definition watcher.h:87
float * shake_ext
The extent to which each SHAKE group failed to converge.
Definition watcher.h:93
int * force_steps
Steps on which each large force is observed.
Definition watcher.h:81
float * xvel_purge
Definition watcher.h:94
float * yvel_purge
A compendium of Cartesian Y velocity purges for each system.
Definition watcher.h:98
const int nsystem
The number of systems tracked by the Watcher object.
Definition watcher.h:64
int * nspeed
Definition watcher.h:74
int * nrattle
Definition watcher.h:76
WatcherWriter(const WatcherWriter &original)=default
Like most abstracts, the presence of const members makes copy and move assignment impossible except i...
float * zang_purge
Angular momentum purges about the Z axis for each system.
Definition watcher.h:102
float * zvel_purge
A compendium of Cartesian Z velocity purges for each system.
Definition watcher.h:99
uint2 * shake_fails
Details of SHAKE group convergence failures.
Definition watcher.h:90
int * nforce
The number of forces observed to violate the stated bounds.
Definition watcher.h:73
float4 * forces
Cartesian components and atom indices of large forces.
Definition watcher.h:80
const int max_reports
The maximum number of reports to present in any given category.
Definition watcher.h:65
const bool track_purge
Definition watcher.h:69
float * xang_purge
Angular momentum purges about the X axis for each system.
Definition watcher.h:100
uint2 * rattle_fails
Details of RATTLE group convergence failures.
Definition watcher.h:89
float * rattle_ext
Definition watcher.h:91
const float speed_limit
Definition watcher.h:67
float * yang_purge
Angular momentum purges about the Y axis for each system.
Definition watcher.h:101
int * speed_steps
Steps on which each high speed is observed.
Definition watcher.h:86