OpenMD 3.0
Molecular Dynamics in the Open
Loading...
Searching...
No Matches
SequentialProps.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 <string>
48
50#include "applications/sequentialProps/COMVel.hpp"
51#include "applications/sequentialProps/CenterOfMass.hpp"
52#include "applications/sequentialProps/ContactAngle1.hpp"
53#include "applications/sequentialProps/ContactAngle2.hpp"
54#include "applications/sequentialProps/GCNSeq.hpp"
55#include "applications/sequentialProps/SequentialAnalyzer.hpp"
56#include "applications/sequentialProps/equipartitionTest.hpp"
57#include "brains/SimCreator.hpp"
58#include "brains/SimInfo.hpp"
59#include "utils/StringUtils.hpp"
60#include "utils/simError.h"
61
62using namespace OpenMD;
63
64int main(int argc, char* argv[]) {
65 gengetopt_args_info args_info;
66
67 // parse the command line option
68 if (cmdline_parser(argc, argv, &args_info) != 0) { exit(1); }
69
70 // get the dumpfile name and meta-data file name
71 std::string dumpFileName = args_info.input_arg;
72
73 std::string sele1;
74 std::string sele2;
75
76 // check the first selection argument, or set it to the environment
77 // variable, or failing that, set it to "select all"
78
79 if (args_info.sele1_given) {
80 sele1 = args_info.sele1_arg;
81 } else {
82 char* sele1Env = getenv("SELECTION1");
83 if (sele1Env) {
84 sele1 = sele1Env;
85 } else {
86 sele1 = "select all";
87 }
88 }
89
90 // check the second selection argument, or set it to the environment
91 // variable, or failing that, set it to the first selection
92
93 if (args_info.sele2_given) {
94 sele2 = args_info.sele2_arg;
95 } else {
96 char* sele2Env = getenv("SELECTION2");
97 if (sele2Env) {
98 sele2 = sele2Env;
99 } else {
100 // If sele2 is not specified, then the default behavior
101 // should be what is already intended for sele1
102 sele2 = sele1;
103 }
104 }
105
106 // parse md file and set up the system
107 SimCreator creator;
108 SimInfo* info = creator.createSim(dumpFileName, false);
109
110 SequentialAnalyzer* analyzer = NULL;
111 if (args_info.com_given) {
112 analyzer = new CenterOfMass(info, dumpFileName, sele1, sele2);
113 } else if (args_info.comvel_given) {
114 analyzer = new COMVel(info, dumpFileName, sele1, sele2);
115 } else if (args_info.testequi_given) {
116 analyzer = new Equipartition(info, dumpFileName, sele1, sele2);
117 } else if (args_info.gcn_given) {
118 if (args_info.rcut_given) {
119 analyzer = new GCNSeq(info, dumpFileName, sele1, sele2,
120 args_info.rcut_arg, args_info.nbins_arg);
121 } else {
122 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
123 "A cutoff radius (rcut) must be specified when calculating\n"
124 "\tGeneralized Coordinate Number");
125 painCave.severity = OPENMD_ERROR;
126 painCave.isFatal = 1;
127 simError();
128 }
129 } else if (args_info.ca1_given) {
130 RealType solidZ(0.0);
131 if (args_info.referenceZ_given)
132 solidZ = args_info.referenceZ_arg;
133 else {
134 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
135 "--referenceZ must be set if --ca1 is used\n");
136 painCave.severity = OPENMD_ERROR;
137 painCave.isFatal = 1;
138 simError();
139 }
140 RealType dropletR(0.0);
141 if (args_info.dropletR_given)
142 dropletR = args_info.dropletR_arg;
143 else {
144 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
145 "--dropletR must be set if --ca1 is used\n");
146 painCave.severity = OPENMD_ERROR;
147 painCave.isFatal = 1;
148 simError();
149 }
150
151 analyzer =
152 new ContactAngle1(info, dumpFileName, sele1, sele2, solidZ, dropletR);
153 } else if (args_info.ca2_given) {
154 RealType solidZ(0.0);
155 if (args_info.referenceZ_given)
156 solidZ = args_info.referenceZ_arg;
157 else {
158 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
159 "--referenceZ must be set if --ca2 is used\n");
160 painCave.severity = OPENMD_ERROR;
161 painCave.isFatal = 1;
162 simError();
163 }
164 RealType centroidX(0.0);
165 if (args_info.centroidX_given)
166 centroidX = args_info.centroidX_arg;
167 else {
168 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
169 "--centroidX must be set if --ca2 is used\n");
170 painCave.severity = OPENMD_ERROR;
171 painCave.isFatal = 1;
172 simError();
173 }
174 RealType centroidY(0.0);
175 if (args_info.centroidY_given)
176 centroidY = args_info.centroidY_arg;
177 else {
178 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
179 "--centroidY must be set if --ca2 is used\n");
180 painCave.severity = OPENMD_ERROR;
181 painCave.isFatal = 1;
182 simError();
183 }
184 RealType threshDens(0.0);
185 if (args_info.threshDens_given)
186 threshDens = args_info.threshDens_arg;
187 else {
188 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
189 "--threshDens must be set if --ca2 is used\n");
190 painCave.severity = OPENMD_ERROR;
191 painCave.isFatal = 1;
192 simError();
193 }
194 RealType bufferLength(0.0);
195 if (args_info.bufferLength_given)
196 bufferLength = args_info.bufferLength_arg;
197 else {
198 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
199 "--bufferLength must be set if --ca2 is used\n");
200 painCave.severity = OPENMD_ERROR;
201 painCave.isFatal = 1;
202 simError();
203 }
204
205 analyzer = new ContactAngle2(info, dumpFileName, sele1, sele2, solidZ,
206 centroidX, centroidY, threshDens, bufferLength,
207 args_info.nbins_arg, args_info.nbins_z_arg);
208 }
209
210 if (args_info.output_given) { analyzer->setOutputName(args_info.output_arg); }
211
212 analyzer->doSequence();
213
214 delete analyzer;
215 delete info;
216
217 return 0;
218}
The header file for the command line option parser generated by GNU Gengetopt version 2....
Calculates the contact angle of a droplet with a surface using a spherical cap approximation for the ...
Generalized Coordinate Number Sequence.
Definition GCNSeq.hpp:73
"applications/sequentialProps/SequentialAnalyzer"
The only responsibility of SimCreator is to parse the meta-data file and create a SimInfo instance ba...
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.