ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-4/src/types/AtomType.cpp
(Generate patch)

Comparing branches/new_design/OOPSE-4/src/types/AtomType.cpp (file contents):
Revision 1740 by tim, Mon Nov 15 23:00:32 2004 UTC vs.
Revision 1787 by tim, Mon Nov 29 14:40:30 2004 UTC

# Line 7 | Line 7
7   #include "utils/simError.h"
8   #define __C
9   #include "UseTheForce/DarkSide/atype_interface.h"
10 <
11 < name_space oopse {
10 > #include "UseTheForce/DarkSide/lj_interface.h"
11 > #include "UseTheForce/DarkSide/eam_interface.h"
12 > #include "UseTheForce/DarkSide/charge_interface.h"
13 > namespace oopse {
14    AtomType::AtomType(){
15      
16      // initialize to an error:
17 <    atp_.ident = -1;
17 >    atp.ident = -1;
18  
19      // and mass_less:
20      mass_ = 0.0;
21      
22      // atom type is a Tabula Rasa:
23 <    atp_.is_Directional = 0;
24 <    atp_.is_LennardJones = 0;
25 <    atp_.is_Electrostatic = 0;
26 <    atp_.is_Charge = 0;
27 <    atp_.is_Dipole = 0;
28 <    atp_.is_Sticky = 0;
29 <    atp_.is_GayBerne = 0;
30 <    atp_.is_EAM = 0;
31 <    atp_.is_Shape = 0;
32 <    atp_.is_FLARB = 0;  
23 >    atp.is_Directional = 0;
24 >    atp.is_LennardJones = 0;
25 >    atp.is_Electrostatic = 0;
26 >    atp.is_Charge = 0;
27 >    atp.is_Dipole = 0;
28 >    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    }
34      
35 <  void AtomType::complete() {
35 >  void AtomType::makeFortranAtomType() {
36      
37      int status;
38  
# Line 43 | Line 45 | name_space oopse {
45        simError();
46      }
47      
48 <    if (atp_.ident == -1) {
48 >    if (atp.ident == -1) {
49        sprintf( painCave.errMsg,
50                 "Attempting to complete AtomType %s without setting the"
51                 " ident!/n", name_.c_str());
# Line 54 | Line 56 | name_space oopse {
56  
57      status = 0;
58  
59 <    makeAtype(&atp_, &status);  
59 >    makeAtype(&atp, &status);  
60      
61      if (status != 0) {
62        sprintf( painCave.errMsg,
# Line 65 | Line 67 | void AtomType::addProperty(GenericData* genData) {
67      }
68    }
69  
70 +
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 +                newLJtype(&atp.ident, &ljParam.sigma, &ljParam.epsilon, &isError);
85 +
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 +                newChargeType(&atp.ident, &charge, &isError);
117 +
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 +                                &eamParam.rvals[0], &eamParam.rhovals[0], &eamParam.Frhovals[0], &atp.ident, &isError );
152 +
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   void AtomType::addProperty(GenericData* genData) {
179      properties_.addProperty(genData);  
180   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines