ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libBASS/Globals.cpp
(Generate patch)

Comparing trunk/OOPSE/libBASS/Globals.cpp (file contents):
Revision 659 by tim, Thu Jul 31 15:38:08 2003 UTC vs.
Revision 704 by tim, Wed Aug 20 19:11:51 2003 UTC

# Line 47 | Line 47
47   #define G_TAUTHERMOSTAT  26
48   #define G_TAUBAROSTAT    27
49   #define G_ZCONSTIME      28
50 < #define G_ZCONSMOLINDEX  29
50 > #define G_NZCONSTRAINTS  29
51 > #define G_ZCONSTOL 30
52 > #define G_ZCONSFORCEPOLICY 31
53 > #define G_SEED                        32
54  
52
55   Globals::Globals(){
56    
57    int i;
# Line 88 | Line 90 | Globals::Globals(){
90    addHash( "targetPressure",                       G_TARGETPRESSURE);
91    addHash( "tauThermostat",                        G_TAUTHERMOSTAT);
92    addHash( "tauBarostat",                          G_TAUBAROSTAT);
93 <  addHash( "zconsTime",     G_ZCONSTIME);
94 <  addHash( "zconsMolIndex", G_ZCONSMOLINDEX);
93 >  addHash( "zconsTime",                            G_ZCONSTIME);
94 >  addHash( "nZconstraints",                        G_NZCONSTRAINTS);
95 >  addHash( "zconsTol",                               G_ZCONSTOL);
96 >  addHash( "zconsForcePolicy",                    G_ZCONSFORCEPOLICY);
97 >  addHash( "seed",                                     G_SEED);
98 >        
99 >        
100    // define some default values
101  
102    strcpy( mixingRule,"standard");  //default mixing rules to standard.
# Line 122 | Line 129 | Globals::Globals(){
129    have_target_pressure =0;
130    have_q_mass =         0;
131    have_tau_thermostat = 0;
132 <  have_tau_barostat =   0;
133 <  have_zcons_time = 0;
134 <  have_index_of_all_zcons_mols = 0;
135 < }
132 >  have_tau_barostat   = 0;
133 >  have_zcons_time     = 0;
134 >  have_n_zConstraints = 0;
135 >  have_zConstraints   = 0;
136 >  have_zcons_tol = 0;
137 >  have_seed = 0;
138  
139 + }
140 +
141   Globals::~Globals(){
142    int i;
143  
# Line 199 | Line 210 | int Globals::componentStartIndex( event* the_event ){
210    return 0;
211   }
212  
213 < int Globals::componentStartIndex( event* the_event ){
213 > int Globals::componentEnd( event* the_event ){
214  
215 <  current_component->startIndex( the_event->evt.si.array,
216 <                                 the_event->evt.si.n_elements );
215 >  the_event->err_msg = current_component->checkMe();
216 >  if( the_event->err_msg != NULL ) return 0;
217 >
218    return 1;
219   }
220  
221 < int Globals::componentEnd( event* the_event ){
221 > int Globals::newZconstraint( event* the_event ){
222 >  
223  
224 <  the_event->err_msg = current_component->checkMe();
224 >  int index = the_event->evt.blk_index;
225 >  char err[200];
226 >  current_zConstraint = new ZconStamp( index );
227 >  
228 >  have_zConstraints = 1;
229 >
230 >  if( have_n_zConstraints && index < n_zConstraints )
231 >    zConstraints[index] = current_zConstraint;
232 >  else{
233 >    if( have_n_zConstraints ){
234 >      sprintf( err, "Globals error, %d out of nZconstraints range",
235 >               index );
236 >      the_event->err_msg = strdup( err );
237 >      return 0;
238 >    }
239 >    else{
240 >      the_event->err_msg = strdup("Globals error, nZconstraints"
241 >                                  " not given before"
242 >                                  " first zConstraint declaration." );
243 >      return 0;
244 >    }
245 >  }  
246 >
247 >  return 1;
248 > }
249 >
250 >
251 >
252 > int Globals::zConstraintAssign( event* the_event ){
253 >
254 >  switch( the_event->evt.asmt.asmt_type ){
255 >    
256 >  case STRING:
257 >    return current_zConstraint->assignString( the_event->evt.asmt.lhs,
258 >                                              the_event->evt.asmt.rhs.sval,
259 >                                              &(the_event->err_msg));
260 >    break;
261 >    
262 >  case DOUBLE:
263 >    return current_zConstraint->assignDouble( the_event->evt.asmt.lhs,
264 >                                              the_event->evt.asmt.rhs.dval,
265 >                                              &(the_event->err_msg));
266 >    break;
267 >    
268 >  case INT:
269 >    return current_zConstraint->assignInt( the_event->evt.asmt.lhs,
270 >                                           the_event->evt.asmt.rhs.ival,
271 >                                           &(the_event->err_msg));
272 >    break;
273 >    
274 >  default:
275 >    the_event->err_msg = strdup( "Globals error. Invalid zConstraint"
276 >                                 " assignment type" );
277 >    return 0;
278 >    break;
279 >  }
280 >  return 0;
281 > }
282 >
283 > int Globals::zConstraintEnd( event* the_event ){
284 >
285 >  the_event->err_msg = current_zConstraint->checkMe();
286    if( the_event->err_msg != NULL ) return 0;
287  
288    return 1;
# Line 260 | Line 334 | int Globals::globalAssign( event* the_event ){
334          n_components = the_event->evt.asmt.rhs.ival;
335          components = new Component*[n_components];
336          have_n_components = 1;
337 +        return 1;
338 +      }
339 +      break;
340 +
341 +    case G_NZCONSTRAINTS:
342 +      if( the_type == STRING ){
343 +        the_event->err_msg =
344 +          strdup("Global error. nZconstraints is not a double or an int.\n" );
345 +        return 0;
346 +      }
347 +      
348 +      else if( the_type == DOUBLE ){
349 +        n_zConstraints = (int)the_event->evt.asmt.rhs.dval;
350 +        zConstraints = new ZconStamp*[n_zConstraints];
351 +        have_n_zConstraints = 1;
352          return 1;
353        }
354 +      
355 +      else{
356 +        n_zConstraints = the_event->evt.asmt.rhs.ival;
357 +        zConstraints = new ZconStamp*[n_zConstraints];
358 +        have_n_zConstraints = 1;
359 +        return 1;
360 +      }
361        break;
362        
363      case G_TARGETTEMP:
# Line 630 | Line 726 | int Globals::globalAssign( event* the_event ){
726        }
727        break;
728  
729 <   case G_THERMALTIME:
729 >    case G_THERMALTIME:
730        switch( the_type ){
731          
732        case STRING:
# Line 888 | Line 984 | int Globals::globalAssign( event* the_event ){
984        }
985        break;
986        
987 <   case G_ZCONSTIME:
987 >    case G_ZCONSTIME:
988        switch( the_type ){
989          
990        case STRING:
# Line 899 | Line 995 | int Globals::globalAssign( event* the_event ){
995          
996        case DOUBLE:
997          zcons_time = the_event->evt.asmt.rhs.dval;
998 +        have_zcons_time = 1;
999          return 1;
1000          break;
1001          
# Line 915 | Line 1012 | int Globals::globalAssign( event* the_event ){
1012          break;
1013        }
1014        break;
1015 <  
1016 <   case G_ZCONSMOLINDEX:
1015 >
1016 >    case G_ZCONSTOL:
1017        switch( the_type ){
1018          
1019        case STRING:
1020          the_event->err_msg =
1021 <          strdup( "Global error. zconsMolIndex is not a  int.\n" );
1021 >          strdup( "Global error. zcons_tol is not a double or int.\n" );
1022          return 0;
1023          break;
1024 <                
1024 >        
1025 >      case DOUBLE:
1026 >        zcons_tol = the_event->evt.asmt.rhs.dval;
1027 >        have_zcons_tol = 1;
1028 >        return 1;
1029 >        break;
1030 >        
1031        case INT:
1032 <        zconsMolIndex.push_back(the_event->evt.asmt.rhs.ival);
1033 <        have_index_of_all_zcons_mols = 1;
1034 <        return 1;
1032 >        zcons_tol = (double)the_event->evt.asmt.rhs.ival;
1033 >        have_zcons_tol = 1;
1034 >        return 1;
1035          break;
1036          
1037        default:
1038          the_event->err_msg =
1039 <          strdup( "Global error. zconsMolIndex unrecognized.\n" );
1039 >          strdup( "Global error. zcons_ol unrecognized.\n" );
1040          return 0;
1041          break;
1042        }
1043        break;
1044 +  
1045 +    case G_ZCONSFORCEPOLICY:
1046 +      switch( the_type ){
1047 +        
1048 +      case STRING:
1049 +   strcpy(zconsForcePolicy, the_event->evt.asmt.rhs.sval);
1050  
1051 +   for(int i = 0; zconsForcePolicy[i] != '\0'; i++)
1052 +        {
1053 +      zconsForcePolicy[i] = toupper(zconsForcePolicy[i]);
1054 +   }
1055 +        have_zcons_force_policy = 1;
1056 +   return 1;
1057 +        break;
1058 +        
1059 +      case DOUBLE:
1060 +        the_event->err_msg =
1061 +          strdup( "Global error. zconsForcePolicy is not a double or int.\n" );
1062 +        return 0;
1063 +        break;
1064 +        
1065 +      case INT:
1066 +        the_event->err_msg =
1067 +          strdup( "Global error. zconsForcePolicy is not a double or int.\n" );
1068 +        return 0;
1069 +        break;
1070 +        
1071 +      default:
1072 +        the_event->err_msg =
1073 +          strdup( "Global error. zconsForcePolicy unrecognized.\n" );
1074 +        return 0;
1075 +        break;
1076 +      }
1077 +      break;
1078        // add more token cases here.
1079 +    case G_SEED:
1080 +      switch( the_type ){
1081 +        
1082 +      case STRING:
1083 +   the_event->err_msg =
1084 +          strdup( "Global error. seed is not a string.\n" );
1085 +        return 0;
1086 +   return 0;
1087 +        break;
1088 +        
1089 +      case DOUBLE:
1090 +   have_seed = 1;
1091 +   seed = (int)the_event->evt.asmt.rhs.dval;
1092 +        return 1;
1093 +        break;
1094 +        
1095 +      case INT:
1096 +   have_seed = 1;
1097 +   seed =  the_event->evt.asmt.rhs.ival ;
1098 +        return 1;
1099 +        break;
1100 +        
1101 +      default:
1102 +        the_event->err_msg =
1103 +          strdup( "Global error. seed unrecognized.\n" );
1104 +        return 0;
1105 +        break;
1106 +      }
1107 +      break;
1108 +      // add more token cases here.
1109  
1110      }
1111    }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines