| 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. Acknowledgement of the program authors must be made in any | 
| 10 | < | *    publication of scientific results based in part on use of the | 
| 11 | < | *    program.  An acceptable form of acknowledgement is citation of | 
| 12 | < | *    the article in which the program was described (Matthew | 
| 13 | < | *    A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher | 
| 14 | < | *    J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented | 
| 15 | < | *    Parallel Simulation Engine for Molecular Dynamics," | 
| 16 | < | *    J. Comput. Chem. 26, pp. 252-271 (2005)) | 
| 17 | < | * | 
| 18 | < | * 2. Redistributions of source code must retain the above copyright | 
| 19 | < | *    notice, this list of conditions and the following disclaimer. | 
| 20 | < | * | 
| 21 | < | * 3. Redistributions in binary form must reproduce the above copyright | 
| 22 | < | *    notice, this list of conditions and the following disclaimer in the | 
| 23 | < | *    documentation and/or other materials provided with the | 
| 24 | < | *    distribution. | 
| 25 | < | * | 
| 26 | < | * This software is provided "AS IS," without a warranty of any | 
| 27 | < | * kind. All express or implied conditions, representations and | 
| 28 | < | * warranties, including any implied warranty of merchantability, | 
| 29 | < | * fitness for a particular purpose or non-infringement, are hereby | 
| 30 | < | * excluded.  The University of Notre Dame and its licensors shall not | 
| 31 | < | * be liable for any damages suffered by licensee as a result of | 
| 32 | < | * using, modifying or distributing the software or its | 
| 33 | < | * derivatives. In no event will the University of Notre Dame or its | 
| 34 | < | * licensors be liable for any lost revenue, profit or data, or for | 
| 35 | < | * direct, indirect, special, consequential, incidental or punitive | 
| 36 | < | * damages, however caused and regardless of the theory of liability, | 
| 37 | < | * arising out of the use of or inability to use software, even if the | 
| 38 | < | * University of Notre Dame has been advised of the possibility of | 
| 39 | < | * such damages. | 
| 40 | < | */ | 
| 41 | < |  | 
| 42 | < | #include "applications/staticProps/SCDOrderParameter.hpp" | 
| 43 | < | #include "utils/simError.h" | 
| 44 | < | #include "io/DumpReader.hpp" | 
| 45 | < | #include "primitives/Molecule.hpp" | 
| 46 | < | #include "utils/NumericConstant.hpp" | 
| 47 | < | namespace oopse { | 
| 48 | < |  | 
| 49 | < | SCDElem::SCDElem(SimInfo* info, const std::string& sele1, const std::string& sele2, | 
| 50 | < | const std::string& sele3) : sele1_(sele1), sele2_(sele2), sele3_(sele3){ | 
| 51 | < | SelectionManager seleMan1_(info); | 
| 52 | < | SelectionManager seleMan2_(info); | 
| 53 | < | SelectionManager seleMan3_(info); | 
| 54 | < | SelectionEvaluator evaluator1_(info); | 
| 55 | < | SelectionEvaluator evaluator2_(info); | 
| 56 | < | SelectionEvaluator evaluator3_(info); | 
| 57 | < |  | 
| 58 | < | evaluator1_.loadScriptString(sele1_); | 
| 59 | < | evaluator2_.loadScriptString(sele2_); | 
| 60 | < | evaluator3_.loadScriptString(sele3_); | 
| 61 | < |  | 
| 62 | < | if (!evaluator1_.isDynamic()) { | 
| 63 | < | seleMan1_.setSelectionSet(evaluator1_.evaluate()); | 
| 64 | < | }else { | 
| 65 | < | sprintf( painCave.errMsg, | 
| 66 | < | "dynamic selection is not allowed\n"); | 
| 67 | < | painCave.severity = OOPSE_ERROR; | 
| 68 | < | painCave.isFatal = 1; | 
| 69 | < | simError(); | 
| 70 | < | } | 
| 71 | < |  | 
| 72 | < | if (!evaluator2_.isDynamic()) { | 
| 73 | < | seleMan2_.setSelectionSet(evaluator2_.evaluate()); | 
| 74 | < | }else { | 
| 75 | < | sprintf( painCave.errMsg, | 
| 76 | < | "dynamic selection is not allowed\n"); | 
| 77 | < | painCave.severity = OOPSE_ERROR; | 
| 78 | < | painCave.isFatal = 1; | 
| 79 | < | simError(); | 
| 80 | < | } | 
| 81 | < |  | 
| 82 | < | if (!evaluator3_.isDynamic()) { | 
| 83 | < | seleMan3_.setSelectionSet(evaluator3_.evaluate()); | 
| 84 | < | }else { | 
| 85 | < | sprintf( painCave.errMsg, | 
| 86 | < | "dynamic selection is not allowed\n"); | 
| 87 | < | painCave.severity = OOPSE_ERROR; | 
| 88 | < | painCave.isFatal = 1; | 
| 89 | < | simError(); | 
| 90 | < | } | 
| 91 | < |  | 
| 92 | < | int nselected1 = seleMan1_.getSelectionCount(); | 
| 93 | < | int nselected2 = seleMan2_.getSelectionCount(); | 
| 94 | < | int nselected3 = seleMan3_.getSelectionCount(); | 
| 95 | < |  | 
| 96 | < | if ( nselected1 != nselected2 || nselected1 != nselected3 ) { | 
| 97 | < | sprintf( painCave.errMsg, | 
| 98 | < | "The number of selected Stuntdoubles must be the same\n"); | 
| 99 | < | painCave.severity = OOPSE_ERROR; | 
| 100 | < | painCave.isFatal = 1; | 
| 101 | < | simError(); | 
| 102 | < | } | 
| 103 | < |  | 
| 104 | < | int i; | 
| 105 | < | int j; | 
| 106 | < | int k; | 
| 107 | < | StuntDouble* sd1; | 
| 108 | < | StuntDouble* sd2; | 
| 109 | < | StuntDouble* sd3; | 
| 110 | < | for (sd1 = seleMan1_.beginSelected(i), sd2 = seleMan2_.beginSelected(j), sd3 = seleMan3_.beginSelected(k); | 
| 111 | < | sd1 != NULL && sd2 != NULL && sd3 != NULL; | 
| 112 | < | sd1 = seleMan1_.nextSelected(i), sd2 = seleMan2_.nextSelected(j), sd3 = seleMan3_.nextSelected(k)) { | 
| 113 | < | tuples_.push_back(make_tuple3(sd1, sd2, sd3)); | 
| 114 | < | } | 
| 115 | < |  | 
| 116 | < | } | 
| 117 | < |  | 
| 118 | < | RealType SCDElem::calcSCD(Snapshot* snapshot) { | 
| 119 | < | std::vector<SDTuple3>::iterator i; | 
| 120 | < | Vector3d normal(0.0, 0.0, 1.0); | 
| 121 | < | RealType scd = 0.0; | 
| 122 | < | for (i = tuples_.begin(); i != tuples_.end(); ++i) { | 
| 123 | < | //Egberts B. and Berendsen H.J.C, J.Chem.Phys. 89(6), 3718-3732, 1988 | 
| 124 | < |  | 
| 125 | < | Vector3d zAxis =   i->third->getPos() - i->first->getPos(); | 
| 126 | < | snapshot->wrapVector(zAxis); | 
| 127 | < | Vector3d v12 =  i->second->getPos() - i->first->getPos(); | 
| 128 | < | snapshot->wrapVector(v12); | 
| 129 | < | Vector3d xAxis = cross(v12, zAxis); | 
| 130 | < | Vector3d yAxis = cross(zAxis, xAxis); | 
| 131 | < |  | 
| 132 | < | xAxis.normalize(); | 
| 133 | < | yAxis.normalize(); | 
| 134 | < | zAxis.normalize(); | 
| 135 | < | RealType cosThetaX = dot(xAxis, normal); | 
| 136 | < | RealType sxx = 0.5*(3*cosThetaX * cosThetaX - 1.0); | 
| 137 | < | RealType cosThetaY = dot(yAxis, normal); | 
| 138 | < | RealType syy = 0.5*(3*cosThetaY * cosThetaY - 1.0); | 
| 139 | < | scd += 2.0/3.0*sxx + 1.0/3.0*syy; | 
| 140 | < | } | 
| 141 | < | scd /= tuples_.size(); | 
| 142 | < | return scd; | 
| 143 | < |  | 
| 144 | < | } | 
| 145 | < |  | 
| 146 | < | SCDOrderParameter::SCDOrderParameter(SimInfo* info, const std::string& filename, | 
| 147 | < | const std::string& sele1, const std::string& sele2, const std::string& sele3) | 
| 148 | < | : StaticAnalyser(info, filename) { | 
| 149 | < |  | 
| 150 | < | setOutputName(getPrefix(filename) + ".scd"); | 
| 151 | < |  | 
| 152 | < | scdElems_.push_back(SCDElem(info, sele1, sele2, sele3)); | 
| 153 | < | scdParam_.resize(scdElems_.size()); | 
| 154 | < | std::fill(scdParam_.begin(), scdParam_.end(), 0.0); | 
| 155 | < |  | 
| 156 | < | } | 
| 157 | < |  | 
| 158 | < | SCDOrderParameter::SCDOrderParameter(SimInfo* info, const std::string& filename, | 
| 159 | < | const std::string& molname, int beginIndex, int endIndex) | 
| 160 | < | : StaticAnalyser(info, filename) { | 
| 161 | < |  | 
| 162 | < | setOutputName(getPrefix(filename) + ".scd"); | 
| 163 | < |  | 
| 164 | < | assert(beginIndex >=0 && endIndex >=0 && beginIndex <= endIndex - 2); | 
| 165 | < | for (int i = beginIndex; i <= endIndex -2 ; ++i) { | 
| 166 | < | std::string selectionTemplate = "select " + molname + "."; | 
| 167 | < | std::string sele1 = selectionTemplate + OOPSE_itoa(i); | 
| 168 | < | std::string sele2 = selectionTemplate + OOPSE_itoa(i+1); | 
| 169 | < | std::string sele3 = selectionTemplate + OOPSE_itoa(i+2); | 
| 170 | < |  | 
| 171 | < | scdElems_.push_back(SCDElem(info, sele1, sele2, sele3)); | 
| 172 | < | } | 
| 173 | < |  | 
| 174 | < | scdParam_.resize(scdElems_.size()); | 
| 175 | < | std::fill(scdParam_.begin(), scdParam_.end(), 0.0); | 
| 176 | < | } | 
| 177 | < |  | 
| 178 | < |  | 
| 179 | < | void SCDOrderParameter::process() { | 
| 180 | < | Molecule* mol; | 
| 181 | < | RigidBody* rb; | 
| 182 | < | SimInfo::MoleculeIterator mi; | 
| 183 | < | Molecule::RigidBodyIterator rbIter; | 
| 184 | < |  | 
| 185 | < | DumpReader reader(info_, dumpFilename_); | 
| 186 | < | int nFrames = reader.getNFrames(); | 
| 187 | < |  | 
| 188 | < | for (int i = 0; i < nFrames; i += step_) { | 
| 189 | < | reader.readFrame(i); | 
| 190 | < | currentSnapshot_ = info_->getSnapshotManager()->getCurrentSnapshot(); | 
| 191 | < |  | 
| 192 | < |  | 
| 193 | < | for (mol = info_->beginMolecule(mi); mol != NULL; mol = info_->nextMolecule(mi)) { | 
| 194 | < | //change the positions of atoms which belong to the rigidbodies | 
| 195 | < | for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { | 
| 196 | < | rb->updateAtoms(); | 
| 197 | < | } | 
| 198 | < |  | 
| 199 | < | } | 
| 200 | < |  | 
| 201 | < | for (std::size_t j = 0; j < scdElems_.size(); ++j) { | 
| 202 | < | scdParam_[j] += scdElems_[j].calcSCD(currentSnapshot_); | 
| 203 | < | } | 
| 204 | < |  | 
| 205 | < | } | 
| 206 | < |  | 
| 207 | < | int nProcessed = nFrames /step_; | 
| 208 | < | for (std::size_t j = 0; j < scdElems_.size(); ++j) { | 
| 209 | < | scdParam_[j] /= nProcessed; | 
| 210 | < | } | 
| 211 | < |  | 
| 212 | < | writeSCD(); | 
| 213 | < |  | 
| 214 | < | } | 
| 215 | < |  | 
| 216 | < | void SCDOrderParameter::writeSCD() { | 
| 217 | < |  | 
| 218 | < | std::ofstream os(getOutputFileName().c_str()); | 
| 219 | < | os << "#scd parameter\n"; | 
| 220 | < | for (std::size_t i = 0; i < scdElems_.size(); ++i) { | 
| 221 | < | os <<  "#[column " << i+1 << "]\t" | 
| 222 | < | <<  "sele1: \"" << scdElems_[i].getSelection1() << "\",\t" | 
| 223 | < | <<  "sele2: \"" << scdElems_[i].getSelection2() << "\",\t" | 
| 224 | < | <<  "sele3: \"" << scdElems_[i].getSelection3() << "\"\n"; | 
| 225 | < | } | 
| 226 | < |  | 
| 227 | < | for (std::size_t i = 0; i < scdElems_.size(); ++i) { | 
| 228 | < | os <<  scdParam_[i]<< "\t"; | 
| 229 | < | } | 
| 230 | < | os << std::endl; | 
| 231 | < | } | 
| 232 | < |  | 
| 233 | < |  | 
| 234 | < | } | 
| 235 | < |  | 
| 236 | < |  | 
| 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. Acknowledgement of the program authors must be made in any | 
| 10 | > | *    publication of scientific results based in part on use of the | 
| 11 | > | *    program.  An acceptable form of acknowledgement is citation of | 
| 12 | > | *    the article in which the program was described (Matthew | 
| 13 | > | *    A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher | 
| 14 | > | *    J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented | 
| 15 | > | *    Parallel Simulation Engine for Molecular Dynamics," | 
| 16 | > | *    J. Comput. Chem. 26, pp. 252-271 (2005)) | 
| 17 | > | * | 
| 18 | > | * 2. Redistributions of source code must retain the above copyright | 
| 19 | > | *    notice, this list of conditions and the following disclaimer. | 
| 20 | > | * | 
| 21 | > | * 3. Redistributions in binary form must reproduce the above copyright | 
| 22 | > | *    notice, this list of conditions and the following disclaimer in the | 
| 23 | > | *    documentation and/or other materials provided with the | 
| 24 | > | *    distribution. | 
| 25 | > | * | 
| 26 | > | * This software is provided "AS IS," without a warranty of any | 
| 27 | > | * kind. All express or implied conditions, representations and | 
| 28 | > | * warranties, including any implied warranty of merchantability, | 
| 29 | > | * fitness for a particular purpose or non-infringement, are hereby | 
| 30 | > | * excluded.  The University of Notre Dame and its licensors shall not | 
| 31 | > | * be liable for any damages suffered by licensee as a result of | 
| 32 | > | * using, modifying or distributing the software or its | 
| 33 | > | * derivatives. In no event will the University of Notre Dame or its | 
| 34 | > | * licensors be liable for any lost revenue, profit or data, or for | 
| 35 | > | * direct, indirect, special, consequential, incidental or punitive | 
| 36 | > | * damages, however caused and regardless of the theory of liability, | 
| 37 | > | * arising out of the use of or inability to use software, even if the | 
| 38 | > | * University of Notre Dame has been advised of the possibility of | 
| 39 | > | * such damages. | 
| 40 | > | */ | 
| 41 | > |  | 
| 42 | > | #include "applications/staticProps/SCDOrderParameter.hpp" | 
| 43 | > | #include "utils/simError.h" | 
| 44 | > | #include "io/DumpReader.hpp" | 
| 45 | > | #include "primitives/Molecule.hpp" | 
| 46 | > | #include "utils/NumericConstant.hpp" | 
| 47 | > | namespace oopse { | 
| 48 | > |  | 
| 49 | > | SCDElem::SCDElem(SimInfo* info, const std::string& sele1, | 
| 50 | > | const std::string& sele2, const std::string& sele3) : sele1_(sele1), sele2_(sele2), sele3_(sele3){ | 
| 51 | > |  | 
| 52 | > | usePeriodicBoundaryConditions_ = info->getSimParams()->getUsePeriodicBoundaryConditions(); | 
| 53 | > |  | 
| 54 | > | SelectionManager seleMan1_(info); | 
| 55 | > | SelectionManager seleMan2_(info); | 
| 56 | > | SelectionManager seleMan3_(info); | 
| 57 | > | SelectionEvaluator evaluator1_(info); | 
| 58 | > | SelectionEvaluator evaluator2_(info); | 
| 59 | > | SelectionEvaluator evaluator3_(info); | 
| 60 | > |  | 
| 61 | > | evaluator1_.loadScriptString(sele1_); | 
| 62 | > | evaluator2_.loadScriptString(sele2_); | 
| 63 | > | evaluator3_.loadScriptString(sele3_); | 
| 64 | > |  | 
| 65 | > | if (!evaluator1_.isDynamic()) { | 
| 66 | > | seleMan1_.setSelectionSet(evaluator1_.evaluate()); | 
| 67 | > | }else { | 
| 68 | > | sprintf( painCave.errMsg, | 
| 69 | > | "dynamic selection is not allowed\n"); | 
| 70 | > | painCave.severity = OOPSE_ERROR; | 
| 71 | > | painCave.isFatal = 1; | 
| 72 | > | simError(); | 
| 73 | > | } | 
| 74 | > |  | 
| 75 | > | if (!evaluator2_.isDynamic()) { | 
| 76 | > | seleMan2_.setSelectionSet(evaluator2_.evaluate()); | 
| 77 | > | }else { | 
| 78 | > | sprintf( painCave.errMsg, | 
| 79 | > | "dynamic selection is not allowed\n"); | 
| 80 | > | painCave.severity = OOPSE_ERROR; | 
| 81 | > | painCave.isFatal = 1; | 
| 82 | > | simError(); | 
| 83 | > | } | 
| 84 | > |  | 
| 85 | > | if (!evaluator3_.isDynamic()) { | 
| 86 | > | seleMan3_.setSelectionSet(evaluator3_.evaluate()); | 
| 87 | > | }else { | 
| 88 | > | sprintf( painCave.errMsg, | 
| 89 | > | "dynamic selection is not allowed\n"); | 
| 90 | > | painCave.severity = OOPSE_ERROR; | 
| 91 | > | painCave.isFatal = 1; | 
| 92 | > | simError(); | 
| 93 | > | } | 
| 94 | > |  | 
| 95 | > | int nselected1 = seleMan1_.getSelectionCount(); | 
| 96 | > | int nselected2 = seleMan2_.getSelectionCount(); | 
| 97 | > | int nselected3 = seleMan3_.getSelectionCount(); | 
| 98 | > |  | 
| 99 | > | if ( nselected1 != nselected2 || nselected1 != nselected3 ) { | 
| 100 | > | sprintf( painCave.errMsg, | 
| 101 | > | "The number of selected Stuntdoubles must be the same\n"); | 
| 102 | > | painCave.severity = OOPSE_ERROR; | 
| 103 | > | painCave.isFatal = 1; | 
| 104 | > | simError(); | 
| 105 | > | } | 
| 106 | > |  | 
| 107 | > | int i; | 
| 108 | > | int j; | 
| 109 | > | int k; | 
| 110 | > | StuntDouble* sd1; | 
| 111 | > | StuntDouble* sd2; | 
| 112 | > | StuntDouble* sd3; | 
| 113 | > | for (sd1 = seleMan1_.beginSelected(i), sd2 = seleMan2_.beginSelected(j), sd3 = seleMan3_.beginSelected(k); | 
| 114 | > | sd1 != NULL && sd2 != NULL && sd3 != NULL; | 
| 115 | > | sd1 = seleMan1_.nextSelected(i), sd2 = seleMan2_.nextSelected(j), sd3 = seleMan3_.nextSelected(k)) { | 
| 116 | > | tuples_.push_back(make_tuple3(sd1, sd2, sd3)); | 
| 117 | > | } | 
| 118 | > |  | 
| 119 | > | } | 
| 120 | > |  | 
| 121 | > | RealType SCDElem::calcSCD(Snapshot* snapshot) { | 
| 122 | > | std::vector<SDTuple3>::iterator i; | 
| 123 | > | Vector3d normal(0.0, 0.0, 1.0); | 
| 124 | > | RealType scd = 0.0; | 
| 125 | > | for (i = tuples_.begin(); i != tuples_.end(); ++i) { | 
| 126 | > | //Egberts B. and Berendsen H.J.C, J.Chem.Phys. 89(6), 3718-3732, 1988 | 
| 127 | > |  | 
| 128 | > | Vector3d zAxis =   i->third->getPos() - i->first->getPos(); | 
| 129 | > | if (usePeriodicBoundaryConditions_) | 
| 130 | > | snapshot->wrapVector(zAxis); | 
| 131 | > | Vector3d v12 =  i->second->getPos() - i->first->getPos(); | 
| 132 | > | if (usePeriodicBoundaryConditions_) | 
| 133 | > | snapshot->wrapVector(v12); | 
| 134 | > | Vector3d xAxis = cross(v12, zAxis); | 
| 135 | > | Vector3d yAxis = cross(zAxis, xAxis); | 
| 136 | > |  | 
| 137 | > | xAxis.normalize(); | 
| 138 | > | yAxis.normalize(); | 
| 139 | > | zAxis.normalize(); | 
| 140 | > | RealType cosThetaX = dot(xAxis, normal); | 
| 141 | > | RealType sxx = 0.5*(3*cosThetaX * cosThetaX - 1.0); | 
| 142 | > | RealType cosThetaY = dot(yAxis, normal); | 
| 143 | > | RealType syy = 0.5*(3*cosThetaY * cosThetaY - 1.0); | 
| 144 | > | scd += 2.0/3.0*sxx + 1.0/3.0*syy; | 
| 145 | > | } | 
| 146 | > | scd /= tuples_.size(); | 
| 147 | > | return scd; | 
| 148 | > |  | 
| 149 | > | } | 
| 150 | > |  | 
| 151 | > | SCDOrderParameter::SCDOrderParameter(SimInfo* info, const std::string& filename, | 
| 152 | > | const std::string& sele1, const std::string& sele2, const std::string& sele3) | 
| 153 | > | : StaticAnalyser(info, filename) { | 
| 154 | > |  | 
| 155 | > | setOutputName(getPrefix(filename) + ".scd"); | 
| 156 | > |  | 
| 157 | > | scdElems_.push_back(SCDElem(info, sele1, sele2, sele3)); | 
| 158 | > | scdParam_.resize(scdElems_.size()); | 
| 159 | > | std::fill(scdParam_.begin(), scdParam_.end(), 0.0); | 
| 160 | > |  | 
| 161 | > | } | 
| 162 | > |  | 
| 163 | > | SCDOrderParameter::SCDOrderParameter(SimInfo* info, const std::string& filename, | 
| 164 | > | const std::string& molname, int beginIndex, int endIndex) | 
| 165 | > | : StaticAnalyser(info, filename) { | 
| 166 | > |  | 
| 167 | > | setOutputName(getPrefix(filename) + ".scd"); | 
| 168 | > |  | 
| 169 | > | assert(beginIndex >=0 && endIndex >=0 && beginIndex <= endIndex - 2); | 
| 170 | > | for (int i = beginIndex; i <= endIndex -2 ; ++i) { | 
| 171 | > | std::string selectionTemplate = "select " + molname + "."; | 
| 172 | > | std::string sele1 = selectionTemplate + OOPSE_itoa(i); | 
| 173 | > | std::string sele2 = selectionTemplate + OOPSE_itoa(i+1); | 
| 174 | > | std::string sele3 = selectionTemplate + OOPSE_itoa(i+2); | 
| 175 | > |  | 
| 176 | > | scdElems_.push_back(SCDElem(info, sele1, sele2, sele3)); | 
| 177 | > | } | 
| 178 | > |  | 
| 179 | > | scdParam_.resize(scdElems_.size()); | 
| 180 | > | std::fill(scdParam_.begin(), scdParam_.end(), 0.0); | 
| 181 | > | } | 
| 182 | > |  | 
| 183 | > |  | 
| 184 | > | void SCDOrderParameter::process() { | 
| 185 | > | Molecule* mol; | 
| 186 | > | RigidBody* rb; | 
| 187 | > | SimInfo::MoleculeIterator mi; | 
| 188 | > | Molecule::RigidBodyIterator rbIter; | 
| 189 | > |  | 
| 190 | > | DumpReader reader(info_, dumpFilename_); | 
| 191 | > | int nFrames = reader.getNFrames(); | 
| 192 | > |  | 
| 193 | > | for (int i = 0; i < nFrames; i += step_) { | 
| 194 | > | reader.readFrame(i); | 
| 195 | > | currentSnapshot_ = info_->getSnapshotManager()->getCurrentSnapshot(); | 
| 196 | > |  | 
| 197 | > |  | 
| 198 | > | for (mol = info_->beginMolecule(mi); mol != NULL; mol = info_->nextMolecule(mi)) { | 
| 199 | > | //change the positions of atoms which belong to the rigidbodies | 
| 200 | > | for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { | 
| 201 | > | rb->updateAtoms(); | 
| 202 | > | } | 
| 203 | > |  | 
| 204 | > | } | 
| 205 | > |  | 
| 206 | > | for (std::size_t j = 0; j < scdElems_.size(); ++j) { | 
| 207 | > | scdParam_[j] += scdElems_[j].calcSCD(currentSnapshot_); | 
| 208 | > | } | 
| 209 | > |  | 
| 210 | > | } | 
| 211 | > |  | 
| 212 | > | int nProcessed = nFrames /step_; | 
| 213 | > | for (std::size_t j = 0; j < scdElems_.size(); ++j) { | 
| 214 | > | scdParam_[j] /= nProcessed; | 
| 215 | > | } | 
| 216 | > |  | 
| 217 | > | writeSCD(); | 
| 218 | > |  | 
| 219 | > | } | 
| 220 | > |  | 
| 221 | > | void SCDOrderParameter::writeSCD() { | 
| 222 | > |  | 
| 223 | > | std::ofstream os(getOutputFileName().c_str()); | 
| 224 | > | os << "#scd parameter\n"; | 
| 225 | > | for (std::size_t i = 0; i < scdElems_.size(); ++i) { | 
| 226 | > | os <<  "#[column " << i+1 << "]\t" | 
| 227 | > | <<  "sele1: \"" << scdElems_[i].getSelection1() << "\",\t" | 
| 228 | > | <<  "sele2: \"" << scdElems_[i].getSelection2() << "\",\t" | 
| 229 | > | <<  "sele3: \"" << scdElems_[i].getSelection3() << "\"\n"; | 
| 230 | > | } | 
| 231 | > |  | 
| 232 | > | for (std::size_t i = 0; i < scdElems_.size(); ++i) { | 
| 233 | > | os <<  scdParam_[i]<< "\t"; | 
| 234 | > | } | 
| 235 | > | os << std::endl; | 
| 236 | > | } | 
| 237 | > |  | 
| 238 | > |  | 
| 239 | > | } | 
| 240 | > |  | 
| 241 | > |  |