ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/brains/ForceField.cpp
(Generate patch)

Comparing:
branches/development/src/UseTheForce/ForceField.cpp (file contents), Revision 1710 by gezelter, Fri May 18 21:44:02 2012 UTC vs.
branches/development/src/brains/ForceField.cpp (file contents), Revision 1808 by gezelter, Mon Oct 22 20:42:10 2012 UTC

# Line 44 | Line 44
44   * @file ForceField.cpp
45   * @author tlin
46   * @date 11/04/2004
47 * @time 22:51am
47   * @version 1.0
48   */
49    
50   #include <algorithm>
51 < #include "UseTheForce/ForceField.hpp"
51 > #include "brains/ForceField.hpp"
52   #include "utils/simError.h"
53 < #include "utils/Tuple.hpp"
53 >
54 > #include "io/OptionSectionParser.hpp"
55 > #include "io/BaseAtomTypesSectionParser.hpp"
56 > #include "io/DirectionalAtomTypesSectionParser.hpp"
57 > #include "io/AtomTypesSectionParser.hpp"
58 > #include "io/BendTypesSectionParser.hpp"
59 > #include "io/BondTypesSectionParser.hpp"
60 > #include "io/ChargeAtomTypesSectionParser.hpp"
61 > #include "io/EAMAtomTypesSectionParser.hpp"
62 > #include "io/FluctuatingChargeAtomTypesSectionParser.hpp"
63 > #include "io/GayBerneAtomTypesSectionParser.hpp"
64 > #include "io/InversionTypesSectionParser.hpp"
65 > #include "io/LennardJonesAtomTypesSectionParser.hpp"
66 > #include "io/MultipoleAtomTypesSectionParser.hpp"
67 > #include "io/NonBondedInteractionsSectionParser.hpp"
68 > #include "io/PolarizableAtomTypesSectionParser.hpp"
69 > #include "io/SCAtomTypesSectionParser.hpp"
70 > #include "io/ShapeAtomTypesSectionParser.hpp"
71 > #include "io/StickyAtomTypesSectionParser.hpp"
72 > #include "io/StickyPowerAtomTypesSectionParser.hpp"
73 > #include "io/TorsionTypesSectionParser.hpp"
74 >
75   #include "types/LennardJonesAdapter.hpp"
76 + #include "types/EAMAdapter.hpp"
77 + #include "types/SuttonChenAdapter.hpp"
78 + #include "types/GayBerneAdapter.hpp"
79 + #include "types/StickyAdapter.hpp"
80  
81   namespace OpenMD {
82  
83 <  ForceField::ForceField() {
83 >  ForceField::ForceField(std::string ffName) {
84  
85      char* tempPath;
86      tempPath = getenv("FORCE_PARAM_PATH");
# Line 66 | Line 90 | namespace OpenMD {
90        STR_DEFINE(ffPath_, FRC_PATH );
91      } else {
92        ffPath_ = tempPath;
93 +    }
94 +
95 +    setForceFieldFileName(ffName + ".frc");
96 +
97 +    /**
98 +     * The order of adding section parsers is important.
99 +     *
100 +     * OptionSectionParser must come first to set options for other
101 +     * parsers
102 +     *
103 +     * DirectionalAtomTypesSectionParser should be added before
104 +     * AtomTypesSectionParser, and these two section parsers will
105 +     * actually create "real" AtomTypes (AtomTypesSectionParser will
106 +     * create AtomType and DirectionalAtomTypesSectionParser will
107 +     * create DirectionalAtomType, which is a subclass of AtomType and
108 +     * should come first).
109 +     *
110 +     * Other AtomTypes Section Parsers will not create the "real"
111 +     * AtomType, they only add and set some attributes of the AtomType
112 +     * (via the Adapters). Thus ordering of these is not important.
113 +     * AtomTypesSectionParser should be added before other atom type
114 +     *
115 +     * The order of BondTypesSectionParser, BendTypesSectionParser and
116 +     * TorsionTypesSectionParser, etc. are not important.
117 +     */
118 +
119 +    spMan_.push_back(new OptionSectionParser(forceFieldOptions_));
120 +    spMan_.push_back(new BaseAtomTypesSectionParser());
121 +    spMan_.push_back(new DirectionalAtomTypesSectionParser(forceFieldOptions_));
122 +    spMan_.push_back(new AtomTypesSectionParser());
123 +
124 +    spMan_.push_back(new LennardJonesAtomTypesSectionParser(forceFieldOptions_));
125 +    spMan_.push_back(new ChargeAtomTypesSectionParser(forceFieldOptions_));
126 +    spMan_.push_back(new MultipoleAtomTypesSectionParser(forceFieldOptions_));
127 +    spMan_.push_back(new FluctuatingChargeAtomTypesSectionParser(forceFieldOptions_));
128 +    spMan_.push_back(new PolarizableAtomTypesSectionParser(forceFieldOptions_));
129 +    spMan_.push_back(new GayBerneAtomTypesSectionParser(forceFieldOptions_));
130 +    spMan_.push_back(new EAMAtomTypesSectionParser(forceFieldOptions_));
131 +    spMan_.push_back(new SCAtomTypesSectionParser(forceFieldOptions_));
132 +    spMan_.push_back(new ShapeAtomTypesSectionParser(forceFieldOptions_));
133 +    spMan_.push_back(new StickyAtomTypesSectionParser(forceFieldOptions_));
134 +    spMan_.push_back(new StickyPowerAtomTypesSectionParser(forceFieldOptions_));
135 +
136 +    spMan_.push_back(new BondTypesSectionParser(forceFieldOptions_));
137 +    spMan_.push_back(new BendTypesSectionParser(forceFieldOptions_));
138 +    spMan_.push_back(new TorsionTypesSectionParser(forceFieldOptions_));
139 +    spMan_.push_back(new InversionTypesSectionParser(forceFieldOptions_));
140 +
141 +    spMan_.push_back(new NonBondedInteractionsSectionParser(forceFieldOptions_));    
142 +  }
143 +
144 +  void ForceField::parse(const std::string& filename) {
145 +    ifstrstream* ffStream;
146 +
147 +    ffStream = openForceFieldFile(filename);
148 +
149 +    spMan_.parse(*ffStream, *this);
150 +
151 +    ForceField::AtomTypeContainer::MapTypeIterator i;
152 +    AtomType* at;
153 +
154 +    for (at = atomTypeCont_.beginType(i); at != NULL;
155 +         at = atomTypeCont_.nextType(i)) {
156 +
157 +      // useBase sets the responsibilities, and these have to be done
158 +      // after the atomTypes and Base types have all been scanned:
159 +
160 +      std::vector<AtomType*> ayb = at->allYourBase();      
161 +      if (ayb.size() > 1) {
162 +        for (int j = ayb.size()-1; j > 0; j--) {
163 +          
164 +          ayb[j-1]->useBase(ayb[j]);
165 +
166 +        }
167 +      }
168      }
169 +
170 +    delete ffStream;
171    }
172  
173    /**
# Line 637 | Line 738 | namespace OpenMD {
738    }
739    
740    RealType ForceField::getRcutFromAtomType(AtomType* at) {
741 <    RealType rcut = 0.0;
741 >    RealType rcut(0.0);
742      
743      LennardJonesAdapter lja = LennardJonesAdapter(at);
744      if (lja.isLennardJones()) {
745        rcut = 2.5 * lja.getSigma();
746      }
747 +    EAMAdapter ea = EAMAdapter(at);
748 +    if (ea.isEAM()) {
749 +      rcut = max(rcut, ea.getRcut());
750 +    }
751 +    SuttonChenAdapter sca = SuttonChenAdapter(at);
752 +    if (sca.isSuttonChen()) {
753 +      rcut = max(rcut, 2.0 * sca.getAlpha());
754 +    }
755 +    GayBerneAdapter gba = GayBerneAdapter(at);
756 +    if (gba.isGayBerne()) {
757 +      rcut = max(rcut, 2.5 * sqrt(2.0) * max(gba.getD(), gba.getL()));
758 +    }
759 +    StickyAdapter sa = StickyAdapter(at);
760 +    if (sa.isSticky()) {
761 +      rcut = max(rcut, max(sa.getRu(), sa.getRup()));
762 +    }
763 +
764      return rcut;    
765    }
766    

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines