ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/io/StickyPowerAtomTypesSectionParser.cpp
Revision: 2501
Committed: Thu Dec 8 15:38:49 2005 UTC (18 years, 7 months ago) by chuckv
File size: 4649 byte(s)
Log Message:
Wow thats alot o' files. Now passing forceFieldOptions to all of the parsers.

File Contents

# User Rev Content
1 chrisfen 2220 /*
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 "io/StickyPowerAtomTypesSectionParser.hpp"
43     #include "types/AtomType.hpp"
44     #include "types/DirectionalAtomType.hpp"
45     #include "UseTheForce/ForceField.hpp"
46     #include "utils/simError.h"
47     namespace oopse {
48    
49 chuckv 2501 StickyPowerAtomTypesSectionParser::StickyPowerAtomTypesSectionParser(ForceFieldOptions& options) : options_(options){
50 chrisfen 2220 setSectionName("StickyPowerAtomTypes");
51     }
52    
53     void StickyPowerAtomTypesSectionParser::parseLine(ForceField& ff,
54     const std::string& line,
55     int lineNo){
56     StringTokenizer tokenizer(line);
57     int nTokens = tokenizer.countTokens();
58    
59     //in AtomTypeSection, a line at least contains 8 tokens
60     //atomTypeName and 7 different sticky parameters
61     if (nTokens < 8) {
62     sprintf(painCave.errMsg,
63     "StickyPowerAtomTypesSectionParser Error: Not enough tokens at "
64     "line %d\n",
65     lineNo);
66     painCave.isFatal = 1;
67     simError();
68     } else {
69    
70     std::string atomTypeName = tokenizer.nextToken();
71     AtomType* atomType = ff.getAtomType(atomTypeName);
72    
73     if (atomType != NULL) {
74     DirectionalAtomType* dAtomType = dynamic_cast<DirectionalAtomType*>(atomType);
75    
76     if (dAtomType != NULL) {
77     StickyParam sticky;
78     sticky.w0 = tokenizer.nextTokenAsDouble();
79     sticky.v0 = tokenizer.nextTokenAsDouble();
80     sticky.v0p = tokenizer.nextTokenAsDouble();
81     sticky.rl = tokenizer.nextTokenAsDouble();
82     sticky.ru = tokenizer.nextTokenAsDouble();
83     sticky.rlp = tokenizer.nextTokenAsDouble();
84     sticky.rup = tokenizer.nextTokenAsDouble();
85    
86     dAtomType->addProperty(new StickyParamGenericData("Sticky", sticky));
87     dAtomType->setStickyPower();
88     } else {
89     sprintf(painCave.errMsg,
90     "StickyPowerAtomTypesSectionParser Error: Not enough tokens "
91     "at line %d\n",
92     lineNo);
93     painCave.isFatal = 1;
94     simError();
95     std::cerr << "StickyPowerAtomTypesSectionParser Warning:"
96     << std::endl;
97     }
98     } else {
99     sprintf(painCave.errMsg,
100     "StickyPowerAtomTypesSectionParser Error: Can not find matched "
101     "AtomType %s\n",
102     atomTypeName.c_str());
103     painCave.isFatal = 1;
104     simError();
105    
106     }
107    
108     }
109    
110     }
111    
112     } //end namespace oopse
113    
114    
115