OpenMD 3.1
Molecular Dynamics in the Open
Loading...
Searching...
No Matches
DynamicProps.cpp
1/*
2 * Copyright (c) 2004-present, The University of Notre Dame. All rights
3 * reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 *
15 * 3. Neither the name of the copyright holder nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 * SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your
32 * research, please cite the appropriate papers when you publish your
33 * work. Good starting points are:
34 *
35 * [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).
36 * [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).
37 * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008).
38 * [4] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
39 * [5] Kuang & Gezelter, Mol. Phys., 110, 691-701 (2012).
40 * [6] Lamichhane, Gezelter & Newman, J. Chem. Phys. 141, 134109 (2014).
41 * [7] Lamichhane, Newman & Gezelter, J. Chem. Phys. 141, 134110 (2014).
42 * [8] Bhattarai, Newman & Gezelter, Phys. Rev. B 99, 094106 (2019).
43 */
44
45#include <fstream>
46#include <iostream>
47#include <memory>
48#include <string>
49
50#include "DynamicPropsCmd.hpp"
51#include "applications/dynamicProps/AngularVelVelOutProdCorrFunc.hpp"
52#include "applications/dynamicProps/AngularVelocityAutoOutProductCorrFunc.hpp"
53#include "applications/dynamicProps/BondCorrFunc.hpp"
54#include "applications/dynamicProps/ChargeKineticCorrFunc.hpp"
55#include "applications/dynamicProps/ChargeOrientationCorrFunc.hpp"
56#include "applications/dynamicProps/CollectiveDipoleDisplacement.hpp"
57#include "applications/dynamicProps/CurrentDensityAutoCorrFunc.hpp"
58#include "applications/dynamicProps/DipoleCorrFunc.hpp"
59#include "applications/dynamicProps/DirectionalRCorrFunc.hpp"
60#include "applications/dynamicProps/Displacement.hpp"
61#include "applications/dynamicProps/ForTorCorrFunc.hpp"
62#include "applications/dynamicProps/ForceAutoCorrFunc.hpp"
64#include "applications/dynamicProps/HBondJump.hpp"
65#include "applications/dynamicProps/HBondPersistence.hpp"
66#include "applications/dynamicProps/LegendreCorrFunc.hpp"
67#include "applications/dynamicProps/LegendreCorrFuncZ.hpp"
68#include "applications/dynamicProps/MomAngMomCorrFunc.hpp"
69#include "applications/dynamicProps/OnsagerCorrFunc.hpp"
70#include "applications/dynamicProps/RCorrFunc.hpp"
71#include "applications/dynamicProps/RotAngleDisplacement.hpp"
72#include "applications/dynamicProps/SelectionCorrFunc.hpp"
73#include "applications/dynamicProps/StressCorrFunc.hpp"
74#include "applications/dynamicProps/SystemDipoleCorrFunc.hpp"
75#include "applications/dynamicProps/ThetaCorrFunc.hpp"
76#include "applications/dynamicProps/TorForCorrFunc.hpp"
77#include "applications/dynamicProps/TorqueAutoCorrFunc.hpp"
78#include "applications/dynamicProps/VCorrFunc.hpp"
79#include "applications/dynamicProps/VelAngularVelOutProdCorrFunc.hpp"
80#include "applications/dynamicProps/VelocityAutoOutProductCorrFunc.hpp"
81#include "applications/dynamicProps/WCorrFunc.hpp"
82#include "applications/dynamicProps/cOHz.hpp"
83#include "applications/dynamicProps/MeanDisplacement.hpp"
84#include "brains/SimCreator.hpp"
85#include "brains/SimInfo.hpp"
86#include "utils/Revision.hpp"
87#include "utils/StringUtils.hpp"
88#include "utils/simError.h"
89
90using namespace OpenMD;
91
92int main(int argc, char* argv[]) {
93 struct gengetopt_args_info args_info;
94
95 // parse the command line option
96
97 if (cmdline_parser(argc, argv, &args_info) != 0) {
99 exit(1);
100 }
101
102 // get the dumpfile name and meta-data file name
103 std::string dumpFileName = args_info.input_arg;
104
105 std::string sele1;
106 std::string sele2;
107
108 // check the first selection argument, or set it to the environment
109 // variable, or failing that, set it to "select all"
110
111 if (args_info.sele1_given) {
112 sele1 = args_info.sele1_arg;
113 } else {
114 char* sele1Env = getenv("SELECTION1");
115 if (sele1Env) {
116 sele1 = sele1Env;
117 } else {
118 sele1 = "select all";
119 }
120 }
121
122 // check the second selection argument, or set it to the environment
123 // variable, or failing that, set it to the first selection
124
125 if (args_info.sele2_given) {
126 sele2 = args_info.sele2_arg;
127 } else {
128 char* sele2Env = getenv("SELECTION2");
129 if (sele2Env) {
130 sele2 = sele2Env;
131 } else {
132 // If sele2 is not specified, then the default behavior
133 // should be what is already intended for sele1
134 sele2 = sele1;
135 }
136 }
137
138 // convert privilegedAxis to corresponding integer
139 // x axis -> 0
140 // y axis -> 1
141 // z axis -> 2 (default)
142
143 int privilegedAxis;
144 switch (args_info.privilegedAxis_arg) {
145 case privilegedAxis_arg_x:
146 privilegedAxis = 0;
147 break;
148 case privilegedAxis_arg_y:
149 privilegedAxis = 1;
150 break;
151 case privilegedAxis_arg_z:
152 default:
153 privilegedAxis = 2;
154 break;
155 }
156
157 // use the memory string to figure out how much memory we can use:
158 // char *end;
159 // long long int memSize = memparse(args_info.memory_arg, &end);
160
161 // We don't really need to print this out anymore:
162 // snprintf( painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
163 // "Amount of memory being used: %llu bytes\n", memSize);
164 // painCave.severity = OPENMD_INFO;
165 // painCave.isFatal = 0;
166 // simError();
167
168 // parse md file and set up the system
169 SimCreator creator;
170 SimInfo* info = creator.createSim(dumpFileName, false);
171
172 RealType maxLen;
173 if (args_info.length_given) {
174 maxLen = args_info.length_arg;
175 } else {
176 maxLen = 100.0;
177 }
178
179 std::unique_ptr<DynamicProperty> corrFunc {nullptr};
180
181 if (args_info.sdcorr_given) {
182 corrFunc = std::make_unique<SystemDipoleCorrFunc>(info, dumpFileName, sele1,
183 sele2);
184 } else if (args_info.selecorr_given) {
185 corrFunc =
186 std::make_unique<SelectionCorrFunc>(info, dumpFileName, sele1, sele2);
187 } else if (args_info.dcorr_given) {
188 corrFunc =
189 std::make_unique<DipoleCorrFunc>(info, dumpFileName, sele1, sele2);
190 } else if (args_info.rcorr_given) {
191 corrFunc = std::make_unique<RCorrFunc>(info, dumpFileName, sele1, sele2);
192 } else if (args_info.r_rcorr_given) {
193 corrFunc = std::make_unique<RCorrFuncR>(info, dumpFileName, sele1, sele2);
194 } else if (args_info.thetacorr_given) {
195 corrFunc =
196 std::make_unique<ThetaCorrFunc>(info, dumpFileName, sele1, sele2);
197 } else if (args_info.drcorr_given) {
198 corrFunc = std::make_unique<DirectionalRCorrFunc>(info, dumpFileName, sele1,
199 sele2);
200 } else if (args_info.rcorrZ_given) {
201 corrFunc = std::make_unique<RCorrFuncZ>(
202 info, dumpFileName, sele1, sele2, args_info.nzbins_arg, privilegedAxis);
203 } else if (args_info.vcorr_given) {
204 corrFunc = std::make_unique<VCorrFunc>(info, dumpFileName, sele1, sele2);
205 } else if (args_info.vcorrZ_given) {
206 corrFunc = std::make_unique<VCorrFuncZ>(info, dumpFileName, sele1, sele2);
207 } else if (args_info.vcorrR_given) {
208 corrFunc = std::make_unique<VCorrFuncR>(info, dumpFileName, sele1, sele2);
209 } else if (args_info.wcorr_given) {
210 corrFunc = std::make_unique<WCorrFunc>(info, dumpFileName, sele1, sele2);
211 } else if (args_info.pjcorr_given) {
212 corrFunc =
213 std::make_unique<MomAngMomCorrFunc>(info, dumpFileName, sele1, sele2);
214 } else if (args_info.ftcorr_given) {
215 corrFunc =
216 std::make_unique<ForTorCorrFunc>(info, dumpFileName, sele1, sele2);
217 } else if (args_info.ckcorr_given) {
218 corrFunc = std::make_unique<ChargeKineticCorrFunc>(
219 info, dumpFileName, sele1, sele2, args_info.rcut_arg);
220 } else if (args_info.cscorr_given) {
221 if (args_info.dipoleX_given && args_info.dipoleY_given &&
222 args_info.dipoleZ_given) {
223 corrFunc = std::make_unique<ChargeOrientationCorrFunc>(
224 info, dumpFileName, sele1, sele2, args_info.dipoleX_arg,
225 args_info.dipoleY_arg, args_info.dipoleZ_arg, args_info.rcut_arg);
226 }
227 } else if (args_info.facorr_given) {
228 corrFunc =
229 std::make_unique<ForceAutoCorrFunc>(info, dumpFileName, sele1, sele2);
230 } else if (args_info.tfcorr_given) {
231 corrFunc =
232 std::make_unique<TorForCorrFunc>(info, dumpFileName, sele1, sele2);
233 } else if (args_info.tacorr_given) {
234 corrFunc =
235 std::make_unique<TorqueAutoCorrFunc>(info, dumpFileName, sele1, sele2);
236 } else if (args_info.bondcorr_given) {
237 corrFunc = std::make_unique<BondCorrFunc>(info, dumpFileName, sele1, sele2);
238 } else if (args_info.stresscorr_given) {
239 corrFunc =
240 std::make_unique<StressCorrFunc>(info, dumpFileName, sele1, sele2);
241 } else if (args_info.freqfluccorr_given) {
242 corrFunc =
243 std::make_unique<FreqFlucCorrFunc>(info, dumpFileName, sele1, sele2);
244 } else if (args_info.lcorr_given) {
245 int order(0);
246 if (args_info.order_given)
247 order = args_info.order_arg;
248 else {
249 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
250 "--order must be set if --lcorr is set\n");
251 painCave.severity = OPENMD_ERROR;
252 painCave.isFatal = 1;
253 simError();
254 }
255
256 corrFunc = std::make_unique<LegendreCorrFunc>(info, dumpFileName, sele1,
257 sele2, order);
258 } else if (args_info.lcorrZ_given) {
259 int order(0);
260 if (args_info.order_given)
261 order = args_info.order_arg;
262 else {
263 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
264 "--order must be set if --lcorrZ is set\n");
265 painCave.severity = OPENMD_ERROR;
266 painCave.isFatal = 1;
267 simError();
268 }
269
270 corrFunc = std::make_unique<LegendreCorrFuncZ>(
271 info, dumpFileName, sele1, sele2, order, args_info.nzbins_arg,
272 privilegedAxis);
273
274 } else if (args_info.cohZ_given) {
275 int order(0);
276 if (args_info.order_given)
277 order = args_info.order_arg;
278 else {
279 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
280 "--order must be set if --cohZ is set\n");
281 painCave.severity = OPENMD_ERROR;
282 painCave.isFatal = 1;
283 simError();
284 }
285
286 corrFunc = std::make_unique<COHZ>(info, dumpFileName, sele1, sele2, order,
287 args_info.nzbins_arg, privilegedAxis);
288
289 } else if (args_info.jumptime_given) {
290 corrFunc = std::make_unique<HBondJump>(
291 info, dumpFileName, sele1, sele2, args_info.OOcut_arg,
292 args_info.thetacut_arg, args_info.OHcut_arg);
293 } else if (args_info.jumptimeZ_given) {
294 corrFunc = std::make_unique<HBondJumpZ>(
295 info, dumpFileName, sele1, sele2, args_info.OOcut_arg,
296 args_info.thetacut_arg, args_info.OHcut_arg, args_info.nzbins_arg,
297 privilegedAxis);
298 } else if (args_info.jumptimeR_given) {
299 if (args_info.sele3_given) {
300 corrFunc = std::make_unique<HBondJumpR>(
301 info, dumpFileName, sele1, sele2, args_info.sele3_arg,
302 args_info.OOcut_arg, args_info.thetacut_arg, args_info.OHcut_arg,
303 maxLen, args_info.nbins_arg);
304 } else {
305 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
306 "--sele3 must be set if --jumptimeR is set\n");
307 painCave.severity = OPENMD_ERROR;
308 painCave.isFatal = 1;
309 simError();
310 }
311 } else if (args_info.persistence_given) {
312 corrFunc = std::make_unique<HBondPersistence>(
313 info, dumpFileName, sele1, sele2, args_info.OOcut_arg,
314 args_info.thetacut_arg, args_info.OHcut_arg);
315 } else if (args_info.disp_given) {
316 corrFunc = std::make_unique<Displacement>(info, dumpFileName, sele1, sele2);
317 } else if (args_info.dispZ_given) {
318 corrFunc = std::make_unique<DisplacementZ>(
319 info, dumpFileName, sele1, sele2, args_info.nzbins_arg, privilegedAxis);
320 } else if (args_info.current_given) {
321 corrFunc = std::make_unique<CurrentDensityAutoCorrFunc>(info, dumpFileName,
322 sele1, sele2);
323 } else if (args_info.onsager_given) {
324 if (args_info.sele1_given) {
325 corrFunc =
326 std::make_unique<OnsagerCorrFunc>(info, dumpFileName, sele1, sele2);
327 } else {
328 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
329 "--sele1 must be set for Center of Mass Rcorr\n");
330 painCave.severity = OPENMD_ERROR;
331 painCave.isFatal = 1;
332 simError();
333 }
334 } else if (args_info.ddisp_given) {
335 corrFunc = std::make_unique<CollectiveDipoleDisplacement>(
336 info, dumpFileName, sele1, sele2);
337 } else if (args_info.vaOutProdcorr_given) {
338 corrFunc = std::make_unique<VelocityAutoOutProductCorrFunc>(
339 info, dumpFileName, sele1, sele2);
340 } else if (args_info.waOutProdcorr_given) {
341 corrFunc = std::make_unique<AngularVelocityAutoOutProductCorrFunc>(
342 info, dumpFileName, sele1, sele2);
343 } else if (args_info.vwOutProdcorr_given) {
344 corrFunc = std::make_unique<VelAngularVelOutProdCorrFunc>(
345 info, dumpFileName, sele1, sele2);
346 } else if (args_info.wvOutProdcorr_given) {
347 corrFunc = std::make_unique<AngularVelVelOutProdCorrFunc>(
348 info, dumpFileName, sele1, sele2);
349 } else if (args_info.rotAngleDisp_given) {
350 corrFunc = std::make_unique<RotAngleDisplacement>(info, dumpFileName, sele1,
351 sele2);
352 } else if (args_info.meandisp_given) {
353 corrFunc = std::make_unique<MeanDisplacement>(info, dumpFileName, sele1,
354 sele2);
355 }
356
357 if (args_info.output_given) { corrFunc->setOutputName(args_info.output_arg); }
358
359 corrFunc->doCorrelate();
360
361 delete info;
362 return 0;
363}
The header file for the command line option parser generated by GNU Gengetopt version 2....
Frequency Fluctuation Correlation Function.
The only responsibility of SimCreator is to parse the meta-data file and create a SimInfo instance ba...
SimInfo * createSim(const std::string &mdFileName, bool loadInitCoords=true)
Setup Simulation.
One of the heavy-weight classes of OpenMD, SimInfo maintains objects and variables relating to the cu...
Definition SimInfo.hpp:93
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.
Where the command line options are stored.
int cmdline_parser(int argc, char **argv, struct gengetopt_args_info *args_info)
The command line parser.
void cmdline_parser_print_help(void)
Print the help.