ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-2.0/src/UseTheForce/EAM.cpp
Revision: 1917
Committed: Tue Jan 11 15:53:14 2005 UTC (19 years, 6 months ago) by tim
File size: 4946 byte(s)
Log Message:
minor fix

File Contents

# Content
1 /*
2 * Copyright (C) 2000-2004 Object Oriented Parallel Simulation Engine (OOPSE) project
3 *
4 * Contact: oopse@oopse.org
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public License
8 * as published by the Free Software Foundation; either version 2.1
9 * of the License, or (at your option) any later version.
10 * All we ask is that proper credit is given for our work, which includes
11 * - but is not limited to - adding the above copyright notice to the beginning
12 * of your source code files, and to any copyright notice that you may distribute
13 * with programs based on this work.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 *
24 */
25
26 #include "UseTheForce/EAM.hpp"
27 #include "UseTheForce/DarkSide/lj_interface.h"
28 #include "UseTheForce/DarkSide/charge_interface.h"
29 #include "UseTheForce/DarkSide/dipole_interface.h"
30 #include "UseTheForce/DarkSide/sticky_interface.h"
31 #include "UseTheForce/ForceFieldFactory.hpp"
32 #include "io/DirectionalAtomTypesSectionParser.hpp"
33 #include "io/AtomTypesSectionParser.hpp"
34 #include "io/LennardJonesAtomTypesSectionParser.hpp"
35 #include "io/ElectrostaticAtomTypesSectionParser.hpp"
36 #include "io/EAMAtomTypesSectionParser.hpp"
37 #include "io/StickyAtomTypesSectionParser.hpp"
38 #include "io/BondTypesSectionParser.hpp"
39 #include "io/BendTypesSectionParser.hpp"
40 #include "io/TorsionTypesSectionParser.hpp"
41 #include "UseTheForce/ForceFieldCreator.hpp"
42 #include "utils/simError.h"
43 namespace oopse {
44
45 EAM::EAM(){
46
47 //set default force field filename
48 setForceFieldFileName("EAM.frc");
49
50 //the order of adding section parsers are important
51 //DirectionalAtomTypesSectionParser should be added before AtomTypesSectionParser Since
52 //These two section parsers will actually create "real" AtomTypes (AtomTypesSectionParser will create
53 //AtomType and DirectionalAtomTypesSectionParser will creat DirectionalAtomType which is a subclass
54 //of AtomType, therefore it should come first). Other AtomTypes Section Parser will not create the
55 //"real" AtomType, they only add and set some attribute of the AtomType. Thus their order are not
56 //important. AtomTypesSectionParser should be added before other atom type section parsers.
57 //Make sure they are added after DirectionalAtomTypesSectionParser and AtomTypesSectionParser.
58 //The order of BondTypesSectionParser, BendTypesSectionParser and TorsionTypesSectionParser are
59 //not important.
60 spMan_.push_back(new DirectionalAtomTypesSectionParser());
61 spMan_.push_back(new AtomTypesSectionParser());
62 spMan_.push_back(new LennardJonesAtomTypesSectionParser());
63 spMan_.push_back(new ElectrostaticAtomTypesSectionParser());
64 spMan_.push_back(new EAMAtomTypesSectionParser());
65 spMan_.push_back(new StickyAtomTypesSectionParser());
66 spMan_.push_back(new BondTypesSectionParser());
67 spMan_.push_back(new BendTypesSectionParser());
68 spMan_.push_back(new TorsionTypesSectionParser());
69
70 }
71
72 void EAM::parse(const std::string& filename) {
73 ifstrstream* ffStream;
74 ffStream = openForceFieldFile(filename);
75
76 spMan_.parse(*ffStream, *this);
77
78 ForceField::AtomTypeContainer::MapTypeIterator i;
79 AtomType* at;
80
81 for (at = atomTypeCont_.beginType(i); at != NULL; at = atomTypeCont_.nextType(i)) {
82 at->makeFortranAtomType();
83 }
84
85 for (at = atomTypeCont_.beginType(i); at != NULL; at = atomTypeCont_.nextType(i)) {
86 at->complete();
87 }
88
89 }
90
91
92 double EAM::getRcutFromAtomType(AtomType* at){
93 double rcut = 0.0;
94 if (at->isEAM()) {
95 GenericData* data = at->getPropertyByName("EAM");
96 if (data != NULL) {
97 EAMParamGenericData* eamData = dynamic_cast<EAMParamGenericData*>(data);
98
99 if (eamData != NULL) {
100
101 EAMParam& eamParam = eamData->getData();
102 rcut = eamParam.rcut;
103 } else {
104 sprintf( painCave.errMsg,
105 "Can not cast GenericData to EAMParam\n");
106 painCave.severity = OOPSE_ERROR;
107 painCave.isFatal = 1;
108 simError();
109 }
110 } else {
111 sprintf( painCave.errMsg, "Can not find EAM Parameters\n");
112 painCave.severity = OOPSE_ERROR;
113 painCave.isFatal = 1;
114 simError();
115 }
116 } else {
117 rcut = ForceField::getRcutFromAtomType(at);
118 }
119
120 return rcut;
121 }
122
123 } //end namespace oopse