ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-3.0/src/types/AtomType.cpp
Revision: 1815
Committed: Wed Dec 1 18:42:45 2004 UTC (19 years, 9 months ago) by tim
File size: 6117 byte(s)
Log Message:
except integrator and constraint, other directories get built

File Contents

# User Rev Content
1 gezelter 1632 #include <stdlib.h>
2     #include <stdio.h>
3     #include <string.h>
4     #include <iostream>
5    
6     #include "types/AtomType.hpp"
7     #include "utils/simError.h"
8     #define __C
9     #include "UseTheForce/DarkSide/atype_interface.h"
10 tim 1787 #include "UseTheForce/DarkSide/lj_interface.h"
11     #include "UseTheForce/DarkSide/eam_interface.h"
12     #include "UseTheForce/DarkSide/charge_interface.h"
13     namespace oopse {
14 gezelter 1632 AtomType::AtomType(){
15    
16     // initialize to an error:
17 tim 1787 atp.ident = -1;
18 gezelter 1652
19 tim 1740 // and mass_less:
20     mass_ = 0.0;
21 gezelter 1632
22     // atom type is a Tabula Rasa:
23 tim 1787 atp.is_Directional = 0;
24     atp.is_LennardJones = 0;
25     atp.is_Charge = 0;
26     atp.is_Dipole = 0;
27 tim 1815 atp.is_Quadrupole = 0;
28 tim 1787 atp.is_Sticky = 0;
29     atp.is_GayBerne = 0;
30     atp.is_EAM = 0;
31     atp.is_Shape = 0;
32     atp.is_FLARB = 0;
33 gezelter 1632 }
34    
35 tim 1769 void AtomType::makeFortranAtomType() {
36 gezelter 1632
37     int status;
38    
39 tim 1740 if (name_.empty()) {
40 gezelter 1632 sprintf( painCave.errMsg,
41     "Attempting to complete an AtomType without giving "
42 tim 1740 "it a name_!\n");
43 gezelter 1632 painCave.severity = OOPSE_ERROR;
44     painCave.isFatal = 1;
45     simError();
46     }
47    
48 tim 1787 if (atp.ident == -1) {
49 gezelter 1632 sprintf( painCave.errMsg,
50     "Attempting to complete AtomType %s without setting the"
51 tim 1740 " ident!/n", name_.c_str());
52 gezelter 1632 painCave.severity = OOPSE_ERROR;
53     painCave.isFatal = 1;
54     simError();
55     }
56    
57     status = 0;
58    
59 tim 1787 makeAtype(&atp, &status);
60 gezelter 1632
61     if (status != 0) {
62     sprintf( painCave.errMsg,
63 tim 1740 "Fortran rejected AtomType %s!\n", name_.c_str());
64 gezelter 1632 painCave.severity = OOPSE_ERROR;
65     painCave.isFatal = 1;
66     simError();
67     }
68     }
69 tim 1740
70 tim 1769
71     void AtomType::complete() {
72     int isError;
73     GenericData* data;
74    
75     //notify a new LJtype atom type is created
76     if (isLennardJones()) {
77     data = getPropertyByName("LennardJones");
78     if (data != NULL) {
79     LJParamGenericData* ljData = dynamic_cast<LJParamGenericData*>(data);
80    
81     if (ljData != NULL) {
82     LJParam ljParam = ljData->getData();
83    
84 tim 1787 newLJtype(&atp.ident, &ljParam.sigma, &ljParam.epsilon, &isError);
85 tim 1769
86     if (isError != 0) {
87     sprintf( painCave.errMsg,
88     "Fortran rejected newLJtype\n");
89     painCave.severity = OOPSE_ERROR;
90     painCave.isFatal = 1;
91     simError();
92     }
93    
94     } else {
95     sprintf( painCave.errMsg,
96     "Can not cast GenericData to LJParam\n");
97     painCave.severity = OOPSE_ERROR;
98     painCave.isFatal = 1;
99     simError();
100     }
101     } else {
102     sprintf( painCave.errMsg, "Can not find Parameters for LennardJones\n");
103     painCave.severity = OOPSE_ERROR;
104     painCave.isFatal = 1;
105     simError();
106     }
107     }
108    
109     if (isCharge()) {
110     data = getPropertyByName("Charge");
111     if (data != NULL) {
112     DoubleGenericData* doubleData= dynamic_cast<DoubleGenericData*>(data);
113    
114     if (doubleData != NULL) {
115     double charge = doubleData->getData();
116 tim 1787 newChargeType(&atp.ident, &charge, &isError);
117 tim 1769
118     if (isError != 0) {
119     sprintf( painCave.errMsg,
120     "Fortran rejected newChargeType\n");
121     painCave.severity = OOPSE_ERROR;
122     painCave.isFatal = 1;
123     simError();
124     }
125     } else {
126     sprintf( painCave.errMsg,
127     "Can not cast GenericData to DoubleGenericData\n");
128     painCave.severity = OOPSE_ERROR;
129     painCave.isFatal = 1;
130     simError();
131     }
132     } else {
133     sprintf( painCave.errMsg, "Can not find Charge Parameters\n");
134     painCave.severity = OOPSE_ERROR;
135     painCave.isFatal = 1;
136     simError();
137     }
138     }
139    
140     if (isEAM()) {
141     data = getPropertyByName("EAM");
142     if (data != NULL) {
143     EAMParamGenericData* eamData = dynamic_cast<EAMParamGenericData*>(data);
144    
145     if (eamData != NULL) {
146    
147     EAMParam eamParam = eamData->getData();
148    
149    
150     newEAMtype(&eamParam.latticeConstant, &eamParam.nrho, &eamParam.drho, &eamParam.nr, &eamParam.dr, &eamParam.rcut,
151 tim 1787 &eamParam.rvals[0], &eamParam.rhovals[0], &eamParam.Frhovals[0], &atp.ident, &isError );
152 tim 1769
153     if (isError != 0) {
154     sprintf( painCave.errMsg,
155     "Fortran rejected newEAMtype\n");
156     painCave.severity = OOPSE_ERROR;
157     painCave.isFatal = 1;
158     simError();
159     }
160     } else {
161     sprintf( painCave.errMsg,
162     "Can not cast GenericData to EAMParam\n");
163     painCave.severity = OOPSE_ERROR;
164     painCave.isFatal = 1;
165     simError();
166     }
167     } else {
168     sprintf( painCave.errMsg, "Can not find EAM Parameters\n");
169     painCave.severity = OOPSE_ERROR;
170     painCave.isFatal = 1;
171     simError();
172     }
173     }
174    
175    
176     }
177    
178 tim 1740 void AtomType::addProperty(GenericData* genData) {
179     properties_.addProperty(genData);
180 gezelter 1632 }
181 tim 1740
182     void AtomType::removeProperty(const std::string& propName) {
183     properties_.removeProperty(propName);
184     }
185    
186     void AtomType::clearProperties() {
187     properties_.clearProperties();
188     }
189    
190     std::vector<std::string> AtomType::getPropertyNames() {
191     return properties_.getPropertyNames();
192     }
193    
194     std::vector<GenericData*> AtomType::getProperties() {
195     return properties_.getProperties();
196     }
197    
198     GenericData* AtomType::getPropertyByName(const std::string& propName) {
199     return properties_.getPropertyByName(propName);
200     }
201     }