MercuryDPM  0.11
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
p3statistics.cpp
Go to the documentation of this file.
1 //Copyright (c) 2013-2014, The MercuryDPM Developers Team. All rights reserved.
2 //For the list of developers, see <http://www.MercuryDPM.org/Team>.
3 //
4 //Redistribution and use in source and binary forms, with or without
5 //modification, are permitted provided that the following conditions are met:
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 // * Neither the name MercuryDPM nor the
12 // names of its contributors may be used to endorse or promote products
13 // derived from this software without specific prior written permission.
14 //
15 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 //DISCLAIMED. IN NO EVENT SHALL THE MERCURYDPM DEVELOPERS TEAM BE LIABLE FOR ANY
19 //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 
26 #include <iostream> // ostream
27 #include <iomanip> // setw
28 #include <string.h>
29 #include <stdlib.h>
30 #include <sstream>
31 #include "StatisticsVector.h"
32 
35 int main(int argc, char *argv[]) {
36 
37  if (argc>1&&strcmp(argv[1],"-help")) std::cout << std::endl << "Get statistics for " << argv[1] << std::endl;
38 
39  //check for '-stattype' option
40  StatType T = XYZ;
41  for (int i = 2; i<argc; i++) {
42  if (!strcmp(argv[i],"-stattype")) {
43  if (!strcmp(argv[i+1],"XYZ")) T = XYZ;
44  else if (!strcmp(argv[i+1],"RAZ")) T = RAZ;
45  else if (!strcmp(argv[i+1],"RA")) T = RA;
46  else if (!strcmp(argv[i+1],"RZ")) T = RZ;
47  else if (!strcmp(argv[i+1],"AZ")) T = AZ;
48  else if (!strcmp(argv[i+1],"R")) T = R;
49  else if (!strcmp(argv[i+1],"A")) T = A;
50  else if (!strcmp(argv[i+1],"YZ")) T = YZ;
51  else if (!strcmp(argv[i+1],"XZ")) T = XZ;
52  else if (!strcmp(argv[i+1],"XY")) T = XY;
53  else if (!strcmp(argv[i+1],"X")) T = X;
54  else if (!strcmp(argv[i+1],"Y")) T = Y;
55  else if (!strcmp(argv[i+1],"Z")) T = Z;
56  else if (!strcmp(argv[i+1],"O")) T = O;
57  else {std::cerr << "stattype unknown" << std::endl; exit(-1);}
58  }
59  }
60  if (T==XY) { // averaging in z-direction
61  std::cout << "averaging in z-direction" << std::endl;
62  StatisticsVector<XY> stats(argc, argv);
63  stats.setDoPeriodicWalls(false);
64  stats.statistics_from_p3();
65  } else if (T==XZ) { // averaging in y-direction
66  std::cout << "averaging in y-direction" << std::endl;
67  StatisticsVector<XZ> stats(argc, argv);
68  stats.setDoPeriodicWalls(false);
69  stats.statistics_from_p3();
70  } else if (T==YZ) { // averaging in x-direction
71  std::cout << "averaging in x-direction" << std::endl;
72  StatisticsVector<YZ> stats(argc, argv);
73  stats.setDoPeriodicWalls(false);
74  stats.statistics_from_p3();
75  } else if (T==X) { // averaging in yz-direction
76  std::cout << "averaging in yz-direction" << std::endl;
77  StatisticsVector<X> stats(argc, argv);
78  stats.setDoPeriodicWalls(false);
79  stats.statistics_from_p3();
80  } else if (T==Y) { // averaging in yz-direction
81  std::cout << "averaging in xz-direction" << std::endl;
82  StatisticsVector<Y> stats(argc, argv);
83  stats.setDoPeriodicWalls(false);
84  stats.statistics_from_p3();
85  } else if (T==Z) { // averaging in yz-direction
86  std::cout << "averaging in xy-direction" << std::endl;
87  StatisticsVector<Z> stats(argc, argv);
88  stats.setDoPeriodicWalls(false);
89  stats.statistics_from_p3();
90  } else if (T==O) { // averaging in all directions
91  std::cout << "averaging in xyz-direction" << std::endl;
92  StatisticsVector<O> stats(argc, argv);
93  stats.setDoPeriodicWalls(false);
94  stats.statistics_from_p3();
95 // } else if (T==RAZ) { //no averaging
96 // std::cout << "cylindrical, no averaging" << std::endl;
97 // StatisticsVector<RAZ> stats(argc, argv);
98 // stats.statistics_from_p3();
99 // } else if (T==RA) { //no averaging
100 // std::cout << "cylindrical, Z averaging" << std::endl;
101 // StatisticsVector<RA> stats(argc, argv);
102 // stats.statistics_from_p3();
103 // } else if (T==RZ) { //no averaging
104 // std::cout << "cylindrical, A averaging" << std::endl;
105 // StatisticsVector<RZ> stats(argc, argv);
106 // stats.statistics_from_p3();
107 // } else if (T==AZ) { //no averaging
108 // std::cout << "cylindrical, R averaging" << std::endl;
109 // StatisticsVector<AZ> stats(argc, argv);
110 // stats.statistics_from_p3();
111 // } else if (T==A) { //no averaging
112 // std::cout << "cylindrical, RZ averaging" << std::endl;
113 // StatisticsVector<A> stats(argc, argv);
114 // stats.statistics_from_p3();
115 // } else if (T==R) { //no averaging
116 // std::cout << "cylindrical, AZ averaging" << std::endl;
117 // StatisticsVector<R> stats(argc, argv);
118 // stats.statistics_from_p3();
119  } else if (T==XYZ) { //no averaging
120  std::cout << "no averaging" << std::endl;
121  StatisticsVector<XYZ> stats(argc, argv);
122  std::cout << "stats" << std::endl;
123  stats.statistics_from_p3();
124  } else {std::cerr << "stattype not found" << std::endl; exit(-1); }
125  return 0;
126 }
127 
StatType
Creates averaged statistics (only valid if density field is homogenous along averaged direction) ...
void setDoPeriodicWalls(bool new_)
void statistics_from_p3()
this is a modified version of statistics_from_fstat_and_data. It is used to read p3d files ...
int main(int argc, char *argv[])
This code (p3dstatistics.cpp) can be used to create statistics from p3d files.
This class is used to extract statistical data from MD simulations.