ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/io/MultipoleAtomTypesSectionParser.cpp
Revision: 2204
Committed: Fri Apr 15 22:04:00 2005 UTC (19 years, 2 months ago) by gezelter
File size: 7584 byte(s)
Log Message:
xemacs has been drafted to perform our indentation services

File Contents

# User Rev Content
1 gezelter 2204 /*
2 tim 2097 * 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 "io/MultipoleAtomTypesSectionParser.hpp"
43     #include "UseTheForce/ForceField.hpp"
44     #include "utils/NumericConstant.hpp"
45     #include "utils/simError.h"
46     namespace oopse {
47    
48 gezelter 2204 MultipoleAtomTypesSectionParser::MultipoleAtomTypesSectionParser() {
49 tim 2097 setSectionName("MultipoleAtomTypes");
50 gezelter 2204 }
51 tim 2097
52 gezelter 2204 void MultipoleAtomTypesSectionParser::parseLine(ForceField& ff,const std::string& line, int lineNo){
53 tim 2097 StringTokenizer tokenizer(line);
54     int nTokens = tokenizer.countTokens();
55    
56     // name multipole_type theta phi psi
57     // "name" must match the name in the AtomTypes section
58     // avaliable multipole type is d (dipole), s (split dipole) , q (quadrupoles), dq(dipole plus quadrupole)
59     // and sq(split dipole plus quadrupole)
60     // Directionality for dipoles and quadrupoles is given by three euler angles (phi, theta, psi),
61     //because the body-fixed reference frame for directional atoms is determined by the *mass*
62     //distribution and not by the charge distribution.
63     // Dipoles are given in units of Debye
64     // Quadrupoles are given in units of
65     // examples:
66 tim 2102 // name d phi theta psi dipole_moment
67     // name s phi theta psi dipole_moment splitdipole_distance
68     // name q phi theta psi Qxx Qyy Qzz
69     // name dq phi theta psi dipole_moment Qxx Qyy Qzz
70     // name sq phi theta psi dipole_moment splitdipole_distance Qxx Qyy Qzz
71 tim 2097
72     if (nTokens < 5) {
73 gezelter 2204 sprintf(painCave.errMsg, "MultipoleAtomTypesSectionParser Error: Not enough tokens at line %d\n",
74     lineNo);
75     painCave.isFatal = 1;
76     simError();
77 tim 2097 } else {
78    
79 gezelter 2204 std::string atomTypeName = tokenizer.nextToken();
80     std::string multipoleType = tokenizer.nextToken();
81     double phi = tokenizer.nextTokenAsDouble() * NumericConstant::PI /180.0;
82     double theta = tokenizer.nextTokenAsDouble() * NumericConstant::PI /180.0;
83     double psi = tokenizer.nextTokenAsDouble() * NumericConstant::PI /180.0;
84     nTokens -= 5;
85 tim 2097
86 gezelter 2204 AtomType* atomType = ff.getAtomType(atomTypeName);
87     if (atomType == NULL) {
88     sprintf(painCave.errMsg, "MultipoleAtomTypesSectionParser Error: Can not find matched AtomType[%s] at line %d\n",
89     atomTypeName.c_str(), lineNo);
90     painCave.isFatal = 1;
91     simError();
92     }
93 tim 2097
94 gezelter 2204 DirectionalAtomType* dAtomType = dynamic_cast<DirectionalAtomType*>(atomType);
95     if (dAtomType == NULL) {
96     sprintf(painCave.errMsg, "MultipoleAtomTypesSectionParser Error: Can not Cast Atom to DirectionalAtom at line %d\n", lineNo);
97     painCave.isFatal = 1;
98     simError();
99     }
100 tim 2097
101 gezelter 2204 RotMat3x3d electroBodyFrame(phi, theta, psi);
102     dAtomType->setElectroBodyFrame(electroBodyFrame);
103 tim 2097
104 gezelter 2204 if (multipoleType== "d") {
105     parseDipole(tokenizer, dAtomType, lineNo);
106     } else if (multipoleType== "s") {
107     parseSplitDipole(tokenizer, dAtomType, lineNo);
108     } else if (multipoleType== "q") {
109     parseQuadruple( tokenizer, dAtomType, lineNo);
110     } else if (multipoleType== "dq") {
111     parseDipole(tokenizer, dAtomType, lineNo);
112     parseQuadruple( tokenizer, dAtomType, lineNo);
113     } else if (multipoleType== "sq") {
114     parseSplitDipole(tokenizer, dAtomType, lineNo);
115     parseQuadruple( tokenizer, dAtomType, lineNo);
116     } else {
117     sprintf(painCave.errMsg, "MultipoleAtomTypesSectionParser Error: unrecognized multiple type at line %d\n",
118     lineNo);
119     painCave.isFatal = 1;
120     simError();
121     }
122     }
123 tim 2097
124 gezelter 2204 }
125 tim 2097
126 gezelter 2204 void MultipoleAtomTypesSectionParser::parseDipole(StringTokenizer& tokenizer,
127     DirectionalAtomType* dAtomType, int lineNo) {
128 tim 2097
129     if (tokenizer.hasMoreTokens()) {
130 gezelter 2204 double dipole = tokenizer.nextTokenAsDouble();
131 tim 2097
132 gezelter 2204 dAtomType->addProperty(new DoubleGenericData("Dipole", dipole));
133     dAtomType->setDipole();
134 tim 2097 } else {
135 gezelter 2204 sprintf(painCave.errMsg, "MultipoleAtomTypesSectionParser Error: Not enough tokens at line %d\n",
136     lineNo);
137     painCave.isFatal = 1;
138     simError();
139 tim 2097 }
140 gezelter 2204 }
141 tim 2097
142 gezelter 2204 void MultipoleAtomTypesSectionParser::parseSplitDipole(StringTokenizer& tokenizer,
143     DirectionalAtomType* dAtomType, int lineNo) {
144 tim 2097
145     if (tokenizer.hasMoreTokens()) {
146 gezelter 2204 parseDipole(tokenizer, dAtomType, lineNo);
147     double splitDipoleDistance = tokenizer.nextTokenAsDouble();
148     dAtomType->addProperty(new DoubleGenericData("SplitDipoleDistance", splitDipoleDistance));
149     dAtomType->setSplitDipole();
150 tim 2097 } else {
151 gezelter 2204 sprintf(painCave.errMsg, "MultipoleAtomTypesSectionParser Error: Not enough tokens at line %d\n",
152     lineNo);
153     painCave.isFatal = 1;
154     simError();
155 tim 2097 }
156 gezelter 2204 }
157 tim 2097
158 gezelter 2204 void MultipoleAtomTypesSectionParser::parseQuadruple(StringTokenizer& tokenizer,
159     DirectionalAtomType* dAtomType, int lineNo) {
160 tim 2097 int nTokens = tokenizer.countTokens();
161 tim 2120 if (nTokens >= 3) {
162 gezelter 2204 Vector3d Q;
163     Q[0] = tokenizer.nextTokenAsDouble();
164     Q[1] = tokenizer.nextTokenAsDouble();
165     Q[2] = tokenizer.nextTokenAsDouble();
166 tim 2097
167 gezelter 2204 double trace = Q[0] + Q[1] + Q[2];
168 tim 2097
169 gezelter 2204 if (fabs(trace) > oopse::epsilon) {
170     sprintf(painCave.errMsg, "MultipoleAtomTypesSectionParser Error: the trace of qudrupole moments is not zero at line %d\n",
171     lineNo);
172     painCave.isFatal = 1;
173     simError();
174     }
175 tim 2097
176 gezelter 2204 dAtomType->addProperty(new Vector3dGenericData("QuadrupoleMoments", Q));
177     dAtomType->setQuadrupole();
178 tim 2097 } else {
179 gezelter 2204 sprintf(painCave.errMsg, "MultipoleAtomTypesSectionParser Error: Not enough tokens at line %d\n",
180     lineNo);
181     painCave.isFatal = 1;
182     simError();
183 tim 2097 }
184 gezelter 2204 }
185 tim 2097
186    
187     } //end namespace oopse
188    
189    
190    

Properties

Name Value
svn:executable *