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 |
#include <iostream> |
44 |
#include <fstream> |
45 |
#include <string> |
46 |
|
47 |
#include "brains/SimCreator.hpp" |
48 |
#include "brains/SimInfo.hpp" |
49 |
#include "io/DumpReader.hpp" |
50 |
#include "utils/simError.h" |
51 |
|
52 |
#include "applications/staticProps/StaticPropsCmd.h" |
53 |
#include "applications/staticProps/StaticAnalyser.hpp" |
54 |
#include "applications/staticProps/GofR.hpp" |
55 |
#include "applications/staticProps/GofZ.hpp" |
56 |
#include "applications/staticProps/GofRZ.hpp" |
57 |
#include "applications/staticProps/GofRAngle.hpp" |
58 |
#include "applications/staticProps/GofAngle2.hpp" |
59 |
#include "applications/staticProps/GofXyz.hpp" |
60 |
#include "applications/staticProps/TwoDGofR.hpp" |
61 |
#include "applications/staticProps/P2OrderParameter.hpp" |
62 |
#include "applications/staticProps/BondOrderParameter.hpp" |
63 |
#include "applications/staticProps/BOPofR.hpp" |
64 |
#include "applications/staticProps/RippleOP.hpp" |
65 |
#include "applications/staticProps/SCDOrderParameter.hpp" |
66 |
#include "applications/staticProps/DensityPlot.hpp" |
67 |
#include "applications/staticProps/ObjectCount.hpp" |
68 |
#include "applications/staticProps/RhoZ.hpp" |
69 |
#include "applications/staticProps/pAngle.hpp" |
70 |
#include "applications/staticProps/BondAngleDistribution.hpp" |
71 |
#include "applications/staticProps/NanoVolume.hpp" |
72 |
#include "applications/staticProps/NanoLength.hpp" |
73 |
#if defined(HAVE_FFTW_H) || defined(HAVE_DFFTW_H) || defined(HAVE_FFTW3_H) |
74 |
#include "applications/staticProps/Hxy.hpp" |
75 |
#endif |
76 |
#include "applications/staticProps/RhoR.hpp" |
77 |
#include "applications/staticProps/AngleR.hpp" |
78 |
#include "applications/staticProps/TetrahedralityParam.hpp" |
79 |
#include "applications/staticProps/TetrahedralityParamZ.hpp" |
80 |
#include "applications/staticProps/TetrahedralityParamXYZ.hpp" |
81 |
#include "applications/staticProps/RNEMDStats.hpp" |
82 |
#include "applications/staticProps/NitrileFrequencyMap.hpp" |
83 |
#include "applications/staticProps/MultipoleSum.hpp" |
84 |
#include "applications/staticProps/SurfaceDiffusion.hpp" |
85 |
|
86 |
using namespace OpenMD; |
87 |
|
88 |
int main(int argc, char* argv[]){ |
89 |
|
90 |
|
91 |
gengetopt_args_info args_info; |
92 |
|
93 |
//parse the command line option |
94 |
if (cmdline_parser (argc, argv, &args_info) != 0) { |
95 |
exit(1) ; |
96 |
} |
97 |
|
98 |
//get the dumpfile name |
99 |
std::string dumpFileName = args_info.input_arg; |
100 |
std::string sele1; |
101 |
std::string sele2; |
102 |
std::string sele3; |
103 |
|
104 |
// check the first selection argument, or set it to the environment |
105 |
// variable, or failing that, set it to "select all" |
106 |
|
107 |
if (args_info.sele1_given) { |
108 |
sele1 = args_info.sele1_arg; |
109 |
} else { |
110 |
char* sele1Env= getenv("SELECTION1"); |
111 |
if (sele1Env) { |
112 |
sele1 = sele1Env; |
113 |
} else { |
114 |
sele1 = "select all"; |
115 |
} |
116 |
} |
117 |
|
118 |
// check the second selection argument, or set it to the environment |
119 |
// variable, or failing that, set it to the first selection |
120 |
|
121 |
if (args_info.sele2_given) { |
122 |
sele2 = args_info.sele2_arg; |
123 |
} else { |
124 |
char* sele2Env = getenv("SELECTION2"); |
125 |
if (sele2Env) { |
126 |
sele2 = sele2Env; |
127 |
} else { |
128 |
//If sele2 is not specified, then the default behavior |
129 |
//should be what is already intended for sele1 |
130 |
sele2 = sele1; |
131 |
} |
132 |
} |
133 |
|
134 |
// check the third selection argument, which is only set if |
135 |
// requested by the user |
136 |
|
137 |
if (args_info.sele3_given) sele3 = args_info.sele3_arg; |
138 |
|
139 |
bool batchMode; |
140 |
if (args_info.scd_given){ |
141 |
if (args_info.sele1_given && |
142 |
args_info.sele2_given && args_info.sele3_given) { |
143 |
batchMode = false; |
144 |
} else if (args_info.molname_given && |
145 |
args_info.begin_given && args_info.end_given) { |
146 |
if (args_info.begin_arg < 0 || |
147 |
args_info.end_arg < 0 || args_info.begin_arg > args_info.end_arg-2) { |
148 |
sprintf( painCave.errMsg, |
149 |
"below conditions are not satisfied:\n" |
150 |
"0 <= begin && 0<= end && begin <= end-2\n"); |
151 |
painCave.severity = OPENMD_ERROR; |
152 |
painCave.isFatal = 1; |
153 |
simError(); |
154 |
} |
155 |
batchMode = true; |
156 |
} else{ |
157 |
sprintf( painCave.errMsg, |
158 |
"either --sele1, --sele2, --sele3 are specified," |
159 |
" or --molname, --begin, --end are specified\n"); |
160 |
painCave.severity = OPENMD_ERROR; |
161 |
painCave.isFatal = 1; |
162 |
simError(); |
163 |
} |
164 |
} |
165 |
|
166 |
//parse md file and set up the system |
167 |
SimCreator creator; |
168 |
SimInfo* info = creator.createSim(dumpFileName); |
169 |
|
170 |
RealType maxLen; |
171 |
RealType zmaxLen; |
172 |
if (args_info.length_given) { |
173 |
maxLen = args_info.length_arg; |
174 |
if (args_info.zlength_given){ |
175 |
zmaxLen = args_info.zlength_arg; |
176 |
} |
177 |
} else { |
178 |
Mat3x3d hmat = info->getSnapshotManager()->getCurrentSnapshot()->getHmat(); |
179 |
maxLen = std::min(std::min(hmat(0, 0), hmat(1, 1)), hmat(2, 2)) /2.0; |
180 |
zmaxLen = hmat(2,2); |
181 |
} |
182 |
|
183 |
StaticAnalyser* analyser; |
184 |
if (args_info.gofr_given){ |
185 |
analyser= new GofR(info, dumpFileName, sele1, sele2, maxLen, |
186 |
args_info.nbins_arg); |
187 |
} else if (args_info.gofz_given) { |
188 |
analyser= new GofZ(info, dumpFileName, sele1, sele2, maxLen, |
189 |
args_info.nbins_arg); |
190 |
} else if (args_info.r_z_given) { |
191 |
analyser = new GofRZ(info, dumpFileName, sele1, sele2, maxLen, zmaxLen, |
192 |
args_info.nbins_arg, args_info.nbins_z_arg); |
193 |
} else if (args_info.r_theta_given) { |
194 |
if (args_info.sele3_given) |
195 |
analyser = new GofRTheta(info, dumpFileName, sele1, sele2, sele3, maxLen, |
196 |
args_info.nbins_arg, args_info.nanglebins_arg); |
197 |
else |
198 |
analyser = new GofRTheta(info, dumpFileName, sele1, sele2, maxLen, |
199 |
args_info.nbins_arg, args_info.nanglebins_arg); |
200 |
} else if (args_info.r_omega_given) { |
201 |
if (args_info.sele3_given) |
202 |
analyser = new GofROmega(info, dumpFileName, sele1, sele2, sele3, maxLen, |
203 |
args_info.nbins_arg, args_info.nanglebins_arg); |
204 |
else |
205 |
analyser = new GofROmega(info, dumpFileName, sele1, sele2, maxLen, |
206 |
args_info.nbins_arg, args_info.nanglebins_arg); |
207 |
|
208 |
} else if (args_info.theta_omega_given) { |
209 |
if (args_info.sele3_given) |
210 |
analyser = new GofAngle2(info, dumpFileName, sele1, sele2, sele3, |
211 |
args_info.nanglebins_arg); |
212 |
else |
213 |
analyser = new GofAngle2(info, dumpFileName, sele1, sele2, |
214 |
args_info.nanglebins_arg); |
215 |
} else if (args_info.gxyz_given) { |
216 |
if (args_info.refsele_given) { |
217 |
analyser= new GofXyz(info, dumpFileName, sele1, sele2, |
218 |
args_info.refsele_arg, maxLen, args_info.nbins_arg); |
219 |
} else { |
220 |
sprintf( painCave.errMsg, |
221 |
"--refsele must set when --gxyz is used"); |
222 |
painCave.severity = OPENMD_ERROR; |
223 |
painCave.isFatal = 1; |
224 |
simError(); |
225 |
} |
226 |
} else if (args_info.twodgofr_given){ |
227 |
if (args_info.dz_given) { |
228 |
analyser= new TwoDGofR(info, dumpFileName, sele1, sele2, maxLen, |
229 |
args_info.dz_arg, args_info.nbins_arg); |
230 |
} else { |
231 |
sprintf( painCave.errMsg, |
232 |
"A slab width (dz) must be specified when calculating TwoDGofR"); |
233 |
painCave.severity = OPENMD_ERROR; |
234 |
painCave.isFatal = 1; |
235 |
simError(); |
236 |
} |
237 |
} else if (args_info.p2_given) { |
238 |
if (args_info.sele1_given) { |
239 |
if (args_info.sele2_given) |
240 |
analyser = new P2OrderParameter(info, dumpFileName, sele1, sele2); |
241 |
else |
242 |
if (args_info.seleoffset_given) |
243 |
analyser = new P2OrderParameter(info, dumpFileName, sele1, |
244 |
args_info.seleoffset_arg); |
245 |
else |
246 |
analyser = new P2OrderParameter(info, dumpFileName, sele1); |
247 |
} else { |
248 |
sprintf( painCave.errMsg, |
249 |
"At least one selection script (--sele1) must be specified when calculating P2 order parameters"); |
250 |
painCave.severity = OPENMD_ERROR; |
251 |
painCave.isFatal = 1; |
252 |
simError(); |
253 |
} |
254 |
} else if (args_info.rp2_given){ |
255 |
analyser = new RippleOP(info, dumpFileName, sele1, sele2); |
256 |
} else if (args_info.bo_given){ |
257 |
if (args_info.rcut_given) { |
258 |
analyser = new BondOrderParameter(info, dumpFileName, sele1, |
259 |
args_info.rcut_arg, |
260 |
args_info.nbins_arg); |
261 |
} else { |
262 |
sprintf( painCave.errMsg, |
263 |
"A cutoff radius (rcut) must be specified when calculating Bond Order Parameters"); |
264 |
painCave.severity = OPENMD_ERROR; |
265 |
painCave.isFatal = 1; |
266 |
simError(); |
267 |
} |
268 |
} else if (args_info.multipole_given){ |
269 |
analyser = new MultipoleSum(info, dumpFileName, sele1, |
270 |
maxLen, args_info.nbins_arg); |
271 |
} else if (args_info.tet_param_given) { |
272 |
if (args_info.rcut_given) { |
273 |
analyser = new TetrahedralityParam(info, dumpFileName, sele1, |
274 |
args_info.rcut_arg, |
275 |
args_info.nbins_arg); |
276 |
} else { |
277 |
sprintf( painCave.errMsg, |
278 |
"A cutoff radius (rcut) must be specified when calculating Tetrahedrality Parameters"); |
279 |
painCave.severity = OPENMD_ERROR; |
280 |
painCave.isFatal = 1; |
281 |
simError(); |
282 |
} |
283 |
} else if (args_info.tet_param_z_given) { |
284 |
if (args_info.rcut_given) { |
285 |
analyser = new TetrahedralityParamZ(info, dumpFileName, sele1, sele2, |
286 |
args_info.rcut_arg, |
287 |
args_info.nbins_arg); |
288 |
} else { |
289 |
sprintf( painCave.errMsg, |
290 |
"A cutoff radius (rcut) must be specified when calculating Tetrahedrality Parameters"); |
291 |
painCave.severity = OPENMD_ERROR; |
292 |
painCave.isFatal = 1; |
293 |
simError(); |
294 |
} |
295 |
} else if (args_info.tet_param_xyz_given) { |
296 |
if (!args_info.rcut_given) { |
297 |
sprintf( painCave.errMsg, |
298 |
"A cutoff radius (rcut) must be specified when calculating" |
299 |
" Tetrahedrality Parameters"); |
300 |
painCave.severity = OPENMD_ERROR; |
301 |
painCave.isFatal = 1; |
302 |
simError(); |
303 |
} |
304 |
if (!args_info.voxelSize_given) { |
305 |
sprintf( painCave.errMsg, |
306 |
"A voxel size must be specified when calculating" |
307 |
" volume-resolved Tetrahedrality Parameters"); |
308 |
painCave.severity = OPENMD_ERROR; |
309 |
painCave.isFatal = 1; |
310 |
simError(); |
311 |
} |
312 |
if (!args_info.gaussWidth_given) { |
313 |
sprintf( painCave.errMsg, |
314 |
"A gaussian width must be specified when calculating" |
315 |
" volume-resolved Tetrahedrality Parameters"); |
316 |
painCave.severity = OPENMD_ERROR; |
317 |
painCave.isFatal = 1; |
318 |
simError(); |
319 |
} |
320 |
analyser = new TetrahedralityParamXYZ(info, dumpFileName, sele1, sele2, |
321 |
args_info.rcut_arg, |
322 |
args_info.voxelSize_arg, |
323 |
args_info.gaussWidth_arg); |
324 |
} else if (args_info.ior_given){ |
325 |
if (args_info.rcut_given) { |
326 |
analyser = new IcosahedralOfR(info, dumpFileName, sele1, |
327 |
args_info.rcut_arg, |
328 |
args_info.nbins_arg, maxLen); |
329 |
} else { |
330 |
sprintf( painCave.errMsg, |
331 |
"A cutoff radius (rcut) must be specified when calculating Bond Order Parameters"); |
332 |
painCave.severity = OPENMD_ERROR; |
333 |
painCave.isFatal = 1; |
334 |
simError(); |
335 |
} |
336 |
} else if (args_info.for_given){ |
337 |
if (args_info.rcut_given) { |
338 |
analyser = new FCCOfR(info, dumpFileName, sele1, args_info.rcut_arg, |
339 |
args_info.nbins_arg, maxLen); |
340 |
} else { |
341 |
sprintf( painCave.errMsg, |
342 |
"A cutoff radius (rcut) must be specified when calculating Bond Order Parameters"); |
343 |
painCave.severity = OPENMD_ERROR; |
344 |
painCave.isFatal = 1; |
345 |
simError(); |
346 |
} |
347 |
} else if (args_info.bad_given){ |
348 |
if (args_info.rcut_given) { |
349 |
analyser = new BondAngleDistribution(info, dumpFileName, sele1, |
350 |
args_info.rcut_arg, |
351 |
args_info.nbins_arg); |
352 |
} else { |
353 |
sprintf( painCave.errMsg, |
354 |
"A cutoff radius (rcut) must be specified when calculating Bond Angle Distributions"); |
355 |
painCave.severity = OPENMD_ERROR; |
356 |
painCave.isFatal = 1; |
357 |
simError(); |
358 |
} |
359 |
} else if (args_info.scd_given) { |
360 |
if (batchMode) { |
361 |
analyser = new SCDOrderParameter(info, dumpFileName, |
362 |
args_info.molname_arg, |
363 |
args_info.begin_arg, args_info.end_arg); |
364 |
} else{ |
365 |
analyser = new SCDOrderParameter(info, dumpFileName, |
366 |
sele1, sele2, sele3); |
367 |
} |
368 |
}else if (args_info.density_given) { |
369 |
analyser= new DensityPlot(info, dumpFileName, sele1, sele2, maxLen, |
370 |
args_info.nbins_arg); |
371 |
} else if (args_info.count_given) { |
372 |
analyser = new ObjectCount(info, dumpFileName, sele1 ); |
373 |
} else if (args_info.slab_density_given) { |
374 |
analyser = new RhoZ(info, dumpFileName, sele1, args_info.nbins_arg); |
375 |
} else if (args_info.rnemdz_given) { |
376 |
analyser = new RNEMDZ(info, dumpFileName, sele1, args_info.nbins_arg); |
377 |
} else if (args_info.rnemdr_given) { |
378 |
analyser = new RNEMDR(info, dumpFileName, sele1, args_info.nbins_arg); |
379 |
} else if (args_info.rnemdrt_given) { |
380 |
analyser = new RNEMDRTheta(info, dumpFileName, sele1, |
381 |
args_info.nbins_arg, args_info.nanglebins_arg); |
382 |
} else if (args_info.nitrile_given) { |
383 |
analyser = new NitrileFrequencyMap(info, dumpFileName, sele1, |
384 |
args_info.nbins_arg); |
385 |
} else if (args_info.p_angle_given) { |
386 |
if (args_info.sele1_given) { |
387 |
if (args_info.sele2_given) |
388 |
analyser = new pAngle(info, dumpFileName, sele1, sele2, |
389 |
args_info.nbins_arg); |
390 |
else |
391 |
if (args_info.seleoffset_given) { |
392 |
if (args_info.seleoffset2_given) { |
393 |
analyser = new pAngle(info, dumpFileName, sele1, |
394 |
args_info.seleoffset_arg, |
395 |
args_info.seleoffset2_arg, |
396 |
args_info.nbins_arg); |
397 |
} else { |
398 |
analyser = new pAngle(info, dumpFileName, sele1, |
399 |
args_info.seleoffset_arg, |
400 |
args_info.nbins_arg); |
401 |
} |
402 |
} else |
403 |
analyser = new pAngle(info, dumpFileName, sele1, |
404 |
args_info.nbins_arg); |
405 |
} else { |
406 |
sprintf( painCave.errMsg, |
407 |
"At least one selection script (--sele1) must be specified when " |
408 |
"calculating P(angle) distributions"); |
409 |
painCave.severity = OPENMD_ERROR; |
410 |
painCave.isFatal = 1; |
411 |
simError(); |
412 |
} |
413 |
#if defined(HAVE_FFTW_H) || defined(HAVE_DFFTW_H) || defined(HAVE_FFTW3_H) |
414 |
}else if (args_info.hxy_given) { |
415 |
analyser = new Hxy(info, dumpFileName, sele1, args_info.nbins_x_arg, |
416 |
args_info.nbins_y_arg, args_info.nbins_arg); |
417 |
#endif |
418 |
}else if (args_info.surfDiffusion_given){ |
419 |
analyser = new SurfaceDiffusion(info, dumpFileName, sele1, maxLen); |
420 |
}else if (args_info.rho_r_given) { |
421 |
if (args_info.radius_given){ |
422 |
analyser = new RhoR(info, dumpFileName, sele1, maxLen,args_info.nbins_arg,args_info.radius_arg); |
423 |
}else{ |
424 |
sprintf( painCave.errMsg, |
425 |
"A particle radius (radius) must be specified when calculating Rho(r)"); |
426 |
painCave.severity = OPENMD_ERROR; |
427 |
painCave.isFatal = 1; |
428 |
simError(); |
429 |
} |
430 |
} else if (args_info.hullvol_given) { |
431 |
analyser = new NanoVolume(info, dumpFileName, sele1); |
432 |
} else if (args_info.rodlength_given) { |
433 |
analyser = new NanoLength(info, dumpFileName, sele1); |
434 |
} else if (args_info.angle_r_given) { |
435 |
analyser = new AngleR(info, dumpFileName, sele1, maxLen,args_info.nbins_arg); |
436 |
} |
437 |
|
438 |
if (args_info.output_given) { |
439 |
analyser->setOutputName(args_info.output_arg); |
440 |
} |
441 |
if (args_info.step_given) { |
442 |
analyser->setStep(args_info.step_arg); |
443 |
} |
444 |
|
445 |
analyser->process(); |
446 |
|
447 |
delete analyser; |
448 |
delete info; |
449 |
|
450 |
return 0; |
451 |
} |