1 |
/* |
2 |
* Copyright (c) 2005 The University of Notre Dame. All Rights Reserved. |
3 |
* |
4 |
* The University of Notre Dame grants you ("Licensee") a |
5 |
* non-exclusive, royalty free, license to use, modify and |
6 |
* redistribute this software in source and binary code form, provided |
7 |
* that the following conditions are met: |
8 |
* |
9 |
* 1. Redistributions of source code must retain the above copyright |
10 |
* notice, this list of conditions and the following disclaimer. |
11 |
* |
12 |
* 2. Redistributions in binary form must reproduce the above copyright |
13 |
* notice, this list of conditions and the following disclaimer in the |
14 |
* documentation and/or other materials provided with the |
15 |
* distribution. |
16 |
* |
17 |
* This software is provided "AS IS," without a warranty of any |
18 |
* kind. All express or implied conditions, representations and |
19 |
* warranties, including any implied warranty of merchantability, |
20 |
* fitness for a particular purpose or non-infringement, are hereby |
21 |
* excluded. The University of Notre Dame and its licensors shall not |
22 |
* be liable for any damages suffered by licensee as a result of |
23 |
* using, modifying or distributing the software or its |
24 |
* derivatives. In no event will the University of Notre Dame or its |
25 |
* licensors be liable for any lost revenue, profit or data, or for |
26 |
* direct, indirect, special, consequential, incidental or punitive |
27 |
* damages, however caused and regardless of the theory of liability, |
28 |
* arising out of the use of or inability to use software, even if the |
29 |
* University of Notre Dame has been advised of the possibility of |
30 |
* such damages. |
31 |
* |
32 |
* SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your |
33 |
* research, please cite the appropriate papers when you publish your |
34 |
* work. Good starting points are: |
35 |
* |
36 |
* [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). |
37 |
* [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). |
38 |
* [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008). |
39 |
* [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010). |
40 |
* [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). |
41 |
*/ |
42 |
|
43 |
#ifndef INTEGRATORS_RNEMD_HPP |
44 |
#define INTEGRATORS_RNEMD_HPP |
45 |
#include "brains/SimInfo.hpp" |
46 |
#include "math/RandNumGen.hpp" |
47 |
#include "selection/SelectionEvaluator.hpp" |
48 |
#include "selection/SelectionManager.hpp" |
49 |
#include <iostream> |
50 |
|
51 |
using namespace std; |
52 |
namespace OpenMD { |
53 |
|
54 |
class RNEMD { |
55 |
public: |
56 |
RNEMD(SimInfo* info); |
57 |
~RNEMD(); |
58 |
|
59 |
void doRNEMD(); |
60 |
void doSwap(SelectionManager& smanA, SelectionManager& smanB); |
61 |
void doNIVS(SelectionManager& smanA, SelectionManager& smanB); |
62 |
void doVSS(SelectionManager& smanA, SelectionManager& smanB); |
63 |
RealType getDividingArea(); |
64 |
void collectData(); |
65 |
void getStarted(); |
66 |
void parseOutputFileFormat(const std::string& format); |
67 |
void writeOutputFile(); |
68 |
void writeReal(int index, unsigned int bin); |
69 |
void writeVector(int index, unsigned int bin); |
70 |
void writeRealErrorBars(int index, unsigned int bin); |
71 |
void writeVectorErrorBars(int index, unsigned int bin); |
72 |
|
73 |
private: |
74 |
|
75 |
enum RNEMDMethod { |
76 |
rnemdSwap, |
77 |
rnemdNIVS, |
78 |
rnemdVSS, |
79 |
rnemdUnkownMethod |
80 |
}; |
81 |
enum RNEMDFluxType { |
82 |
rnemdKE, // translational kinetic energy flux |
83 |
rnemdRotKE, // rotational kinetic energy flux |
84 |
rnemdFullKE, // full kinetic energy flux |
85 |
rnemdPx, // flux of momentum along x axis |
86 |
rnemdPy, // flux of momentum along y axis |
87 |
rnemdPz, // flux of momentum along z axis |
88 |
rnemdPvector, // flux of momentum vector |
89 |
rnemdLx, // flux of angular momentum along x axis |
90 |
rnemdLy, // flux of angular momentum along y axis |
91 |
rnemdLz, // flux of angular momentum along z axis |
92 |
rnemdLvector, // flux of angular momentum vector |
93 |
rnemdKePx, // flux of translational KE and x-momentum |
94 |
rnemdKePy, // flux of translational KE and y-momentum |
95 |
rnemdKePvector, // full combo flying platter |
96 |
rnemdKeLx, // flux of translational KE and x-angular momentum |
97 |
rnemdKeLy, // flux of translational KE and y-angular momentum |
98 |
rnemdKeLz, // flux of translational KE and z-angular momentum |
99 |
rnemdKeLvector, // full combo spinning platter |
100 |
rnemdUnknownFluxType |
101 |
}; |
102 |
|
103 |
enum OutputFields { |
104 |
BEGININDEX = 0, |
105 |
Z = BEGININDEX, |
106 |
R, |
107 |
TEMPERATURE, |
108 |
VELOCITY, |
109 |
ANGULARVELOCITY, |
110 |
DENSITY, |
111 |
ENDINDEX |
112 |
}; |
113 |
|
114 |
struct OutputData { |
115 |
string title; |
116 |
string units; |
117 |
string dataType; |
118 |
vector<BaseAccumulator*> accumulator; |
119 |
}; |
120 |
|
121 |
typedef bitset<ENDINDEX-BEGININDEX> OutputBitSet; |
122 |
typedef map<string, OutputFields> OutputMapType; |
123 |
|
124 |
SimInfo* info_; |
125 |
|
126 |
map<string, RNEMDMethod> stringToMethod_; |
127 |
map<string, RNEMDFluxType> stringToFluxType_; |
128 |
RNEMDMethod rnemdMethod_; |
129 |
RNEMDFluxType rnemdFluxType_; |
130 |
|
131 |
// object selection for specifying a particular species: |
132 |
string rnemdObjectSelection_; |
133 |
SelectionEvaluator evaluator_; |
134 |
SelectionManager seleMan_; |
135 |
|
136 |
// Geometric selections for the two regions for the exchange: |
137 |
string selectionA_; |
138 |
SelectionEvaluator evaluatorA_; |
139 |
SelectionManager seleManA_; |
140 |
string selectionB_; |
141 |
SelectionEvaluator evaluatorB_; |
142 |
SelectionManager seleManB_; |
143 |
SelectionManager commonA_; |
144 |
SelectionManager commonB_; |
145 |
bool hasSelectionA_; |
146 |
bool hasSelectionB_; |
147 |
bool hasSphereBRadius_; |
148 |
|
149 |
bool usePeriodicBoundaryConditions_; |
150 |
bool hasDividingArea_; |
151 |
RealType dividingArea_; |
152 |
|
153 |
int nBins_; |
154 |
RealType binWidth_; |
155 |
RealType slabWidth_; |
156 |
RealType slabACenter_; |
157 |
RealType slabBCenter_; |
158 |
RealType sphereARadius_; |
159 |
RealType sphereBRadius_; |
160 |
RealType areaA_; |
161 |
bool AisHull_; |
162 |
RealType areaB_; |
163 |
bool BisHull_; |
164 |
|
165 |
Vector3d coordinateOrigin_; |
166 |
|
167 |
RealType kineticFlux_; // target or desired *flux* |
168 |
Vector3d momentumFluxVector_; // target or desired *flux* |
169 |
Vector3d angularMomentumFluxVector_; // target or desired *flux* |
170 |
|
171 |
RealType kineticTarget_; // target or desired one-time exchange energy |
172 |
Vector3d momentumTarget_; // target or desired one-time exchange momentum |
173 |
Vector3d angularMomentumTarget_; // target or desired one-time |
174 |
// exchange angular momentum |
175 |
|
176 |
RealType kineticExchange_; // actual exchange energy (running total) |
177 |
Vector3d momentumExchange_; // actual exchange momentum (running total) |
178 |
Vector3d angularMomentumExchange_; // actual exchange momentum |
179 |
// (running total) |
180 |
RealType exchangeTime_; |
181 |
|
182 |
RealType targetJzpz2_; |
183 |
|
184 |
unsigned int trialCount_; |
185 |
unsigned int failTrialCount_; |
186 |
unsigned int failRootCount_; |
187 |
|
188 |
string rnemdFileName_; |
189 |
ofstream rnemdFile_; |
190 |
|
191 |
RealType runTime_, statusTime_; |
192 |
|
193 |
vector<OutputData> data_; |
194 |
OutputBitSet outputMask_; |
195 |
OutputMapType outputMap_; |
196 |
Accumulator* areaAccumulator_; |
197 |
bool doRNEMD_; |
198 |
bool hasData_; |
199 |
|
200 |
}; |
201 |
} |
202 |
#endif //INTEGRATORS_RNEMD_HPP |