46 |
|
#define G_TARGETPRESSURE 25 |
47 |
|
#define G_TAUTHERMOSTAT 26 |
48 |
|
#define G_TAUBAROSTAT 27 |
49 |
+ |
#define G_ZCONSTIME 28 |
50 |
+ |
#define G_NZCONSTRAINTS 29 |
51 |
+ |
#define G_ZCONSTOL 30 |
52 |
+ |
#define G_ZCONSFORCEPOLICY 31 |
53 |
|
|
50 |
– |
|
54 |
|
Globals::Globals(){ |
55 |
|
|
56 |
|
int i; |
89 |
|
addHash( "targetPressure", G_TARGETPRESSURE); |
90 |
|
addHash( "tauThermostat", G_TAUTHERMOSTAT); |
91 |
|
addHash( "tauBarostat", G_TAUBAROSTAT); |
92 |
< |
|
92 |
> |
addHash( "zconsTime", G_ZCONSTIME); |
93 |
> |
addHash( "nZconstraints", G_NZCONSTRAINTS); |
94 |
> |
addHash( "zconsTol", G_ZCONSTOL); |
95 |
> |
addHash( "zconsForcePolicy", G_ZCONSFORCEPOLICY); |
96 |
> |
|
97 |
> |
|
98 |
|
// define some default values |
99 |
|
|
100 |
|
strcpy( mixingRule,"standard"); //default mixing rules to standard. |
127 |
|
have_target_pressure =0; |
128 |
|
have_q_mass = 0; |
129 |
|
have_tau_thermostat = 0; |
130 |
< |
have_tau_barostat = 0; |
131 |
< |
} |
130 |
> |
have_tau_barostat = 0; |
131 |
> |
have_zcons_time = 0; |
132 |
> |
have_n_zConstraints = 0; |
133 |
> |
have_zConstraints = 0; |
134 |
> |
have_zcons_tol = 0; |
135 |
|
|
136 |
+ |
} |
137 |
+ |
|
138 |
|
Globals::~Globals(){ |
139 |
|
int i; |
140 |
|
|
207 |
|
return 0; |
208 |
|
} |
209 |
|
|
210 |
< |
int Globals::componentStartIndex( event* the_event ){ |
210 |
> |
int Globals::componentEnd( event* the_event ){ |
211 |
|
|
212 |
< |
current_component->startIndex( the_event->evt.si.array, |
213 |
< |
the_event->evt.si.n_elements ); |
212 |
> |
the_event->err_msg = current_component->checkMe(); |
213 |
> |
if( the_event->err_msg != NULL ) return 0; |
214 |
> |
|
215 |
|
return 1; |
216 |
|
} |
217 |
|
|
218 |
< |
int Globals::componentEnd( event* the_event ){ |
218 |
> |
int Globals::newZconstraint( event* the_event ){ |
219 |
> |
|
220 |
|
|
221 |
< |
the_event->err_msg = current_component->checkMe(); |
221 |
> |
int index = the_event->evt.blk_index; |
222 |
> |
char err[200]; |
223 |
> |
current_zConstraint = new ZconStamp( index ); |
224 |
> |
|
225 |
> |
have_zConstraints = 1; |
226 |
> |
|
227 |
> |
if( have_n_zConstraints && index < n_zConstraints ) |
228 |
> |
zConstraints[index] = current_zConstraint; |
229 |
> |
else{ |
230 |
> |
if( have_n_zConstraints ){ |
231 |
> |
sprintf( err, "Globals error, %d out of nZconstraints range", |
232 |
> |
index ); |
233 |
> |
the_event->err_msg = strdup( err ); |
234 |
> |
return 0; |
235 |
> |
} |
236 |
> |
else{ |
237 |
> |
the_event->err_msg = strdup("Globals error, nZconstraints" |
238 |
> |
" not given before" |
239 |
> |
" first zConstraint declaration." ); |
240 |
> |
return 0; |
241 |
> |
} |
242 |
> |
} |
243 |
> |
|
244 |
> |
return 1; |
245 |
> |
} |
246 |
> |
|
247 |
> |
|
248 |
> |
|
249 |
> |
int Globals::zConstraintAssign( event* the_event ){ |
250 |
> |
|
251 |
> |
switch( the_event->evt.asmt.asmt_type ){ |
252 |
> |
|
253 |
> |
case STRING: |
254 |
> |
return current_zConstraint->assignString( the_event->evt.asmt.lhs, |
255 |
> |
the_event->evt.asmt.rhs.sval, |
256 |
> |
&(the_event->err_msg)); |
257 |
> |
break; |
258 |
> |
|
259 |
> |
case DOUBLE: |
260 |
> |
return current_zConstraint->assignDouble( the_event->evt.asmt.lhs, |
261 |
> |
the_event->evt.asmt.rhs.dval, |
262 |
> |
&(the_event->err_msg)); |
263 |
> |
break; |
264 |
> |
|
265 |
> |
case INT: |
266 |
> |
return current_zConstraint->assignInt( the_event->evt.asmt.lhs, |
267 |
> |
the_event->evt.asmt.rhs.ival, |
268 |
> |
&(the_event->err_msg)); |
269 |
> |
break; |
270 |
> |
|
271 |
> |
default: |
272 |
> |
the_event->err_msg = strdup( "Globals error. Invalid zConstraint" |
273 |
> |
" assignment type" ); |
274 |
> |
return 0; |
275 |
> |
break; |
276 |
> |
} |
277 |
> |
return 0; |
278 |
> |
} |
279 |
> |
|
280 |
> |
int Globals::zConstraintEnd( event* the_event ){ |
281 |
> |
|
282 |
> |
the_event->err_msg = current_zConstraint->checkMe(); |
283 |
|
if( the_event->err_msg != NULL ) return 0; |
284 |
|
|
285 |
|
return 1; |
331 |
|
n_components = the_event->evt.asmt.rhs.ival; |
332 |
|
components = new Component*[n_components]; |
333 |
|
have_n_components = 1; |
334 |
+ |
return 1; |
335 |
+ |
} |
336 |
+ |
break; |
337 |
+ |
|
338 |
+ |
case G_NZCONSTRAINTS: |
339 |
+ |
if( the_type == STRING ){ |
340 |
+ |
the_event->err_msg = |
341 |
+ |
strdup("Global error. nZconstraints is not a double or an int.\n" ); |
342 |
+ |
return 0; |
343 |
+ |
} |
344 |
+ |
|
345 |
+ |
else if( the_type == DOUBLE ){ |
346 |
+ |
n_zConstraints = (int)the_event->evt.asmt.rhs.dval; |
347 |
+ |
zConstraints = new ZconStamp*[n_zConstraints]; |
348 |
+ |
have_n_zConstraints = 1; |
349 |
|
return 1; |
350 |
|
} |
351 |
+ |
|
352 |
+ |
else{ |
353 |
+ |
n_zConstraints = the_event->evt.asmt.rhs.ival; |
354 |
+ |
zConstraints = new ZconStamp*[n_zConstraints]; |
355 |
+ |
have_n_zConstraints = 1; |
356 |
+ |
return 1; |
357 |
+ |
} |
358 |
|
break; |
359 |
|
|
360 |
|
case G_TARGETTEMP: |
723 |
|
} |
724 |
|
break; |
725 |
|
|
726 |
< |
case G_THERMALTIME: |
726 |
> |
case G_THERMALTIME: |
727 |
|
switch( the_type ){ |
728 |
|
|
729 |
|
case STRING: |
980 |
|
break; |
981 |
|
} |
982 |
|
break; |
983 |
+ |
|
984 |
+ |
case G_ZCONSTIME: |
985 |
+ |
switch( the_type ){ |
986 |
+ |
|
987 |
+ |
case STRING: |
988 |
+ |
the_event->err_msg = |
989 |
+ |
strdup( "Global error. zcons_time is not a double or int.\n" ); |
990 |
+ |
return 0; |
991 |
+ |
break; |
992 |
+ |
|
993 |
+ |
case DOUBLE: |
994 |
+ |
zcons_time = the_event->evt.asmt.rhs.dval; |
995 |
+ |
have_zcons_time = 1; |
996 |
+ |
return 1; |
997 |
+ |
break; |
998 |
+ |
|
999 |
+ |
case INT: |
1000 |
+ |
zcons_time = (double)the_event->evt.asmt.rhs.ival; |
1001 |
+ |
have_zcons_time = 1; |
1002 |
+ |
return 1; |
1003 |
+ |
break; |
1004 |
+ |
|
1005 |
+ |
default: |
1006 |
+ |
the_event->err_msg = |
1007 |
+ |
strdup( "Global error. zcons_time unrecognized.\n" ); |
1008 |
+ |
return 0; |
1009 |
+ |
break; |
1010 |
+ |
} |
1011 |
+ |
break; |
1012 |
|
|
1013 |
+ |
case G_ZCONSTOL: |
1014 |
+ |
switch( the_type ){ |
1015 |
+ |
|
1016 |
+ |
case STRING: |
1017 |
+ |
the_event->err_msg = |
1018 |
+ |
strdup( "Global error. zcons_tol is not a double or int.\n" ); |
1019 |
+ |
return 0; |
1020 |
+ |
break; |
1021 |
+ |
|
1022 |
+ |
case DOUBLE: |
1023 |
+ |
zcons_tol = the_event->evt.asmt.rhs.dval; |
1024 |
+ |
have_zcons_tol = 1; |
1025 |
+ |
return 1; |
1026 |
+ |
break; |
1027 |
+ |
|
1028 |
+ |
case INT: |
1029 |
+ |
zcons_tol = (double)the_event->evt.asmt.rhs.ival; |
1030 |
+ |
have_zcons_tol = 1; |
1031 |
+ |
return 1; |
1032 |
+ |
break; |
1033 |
+ |
|
1034 |
+ |
default: |
1035 |
+ |
the_event->err_msg = |
1036 |
+ |
strdup( "Global error. zcons_ol unrecognized.\n" ); |
1037 |
+ |
return 0; |
1038 |
+ |
break; |
1039 |
+ |
} |
1040 |
+ |
break; |
1041 |
+ |
|
1042 |
+ |
case G_ZCONSFORCEPOLICY: |
1043 |
+ |
switch( the_type ){ |
1044 |
+ |
|
1045 |
+ |
case STRING: |
1046 |
+ |
strcpy(zconsForcePolicy, the_event->evt.asmt.rhs.sval); |
1047 |
|
|
1048 |
+ |
for(int i = 0; zconsForcePolicy[i] != '\0'; i++) |
1049 |
+ |
{ |
1050 |
+ |
zconsForcePolicy[i] = toupper(zconsForcePolicy[i]); |
1051 |
+ |
} |
1052 |
+ |
have_zcons_force_policy = 1; |
1053 |
+ |
return 1; |
1054 |
+ |
break; |
1055 |
+ |
|
1056 |
+ |
case DOUBLE: |
1057 |
+ |
the_event->err_msg = |
1058 |
+ |
strdup( "Global error. zconsForcePolicy is not a double or int.\n" ); |
1059 |
+ |
return 0; |
1060 |
+ |
break; |
1061 |
+ |
|
1062 |
+ |
case INT: |
1063 |
+ |
the_event->err_msg = |
1064 |
+ |
strdup( "Global error. zconsForcePolicy is not a double or int.\n" ); |
1065 |
+ |
return 0; |
1066 |
+ |
break; |
1067 |
+ |
|
1068 |
+ |
default: |
1069 |
+ |
the_event->err_msg = |
1070 |
+ |
strdup( "Global error. zconsForcePolicy unrecognized.\n" ); |
1071 |
+ |
return 0; |
1072 |
+ |
break; |
1073 |
+ |
} |
1074 |
+ |
break; |
1075 |
|
// add more token cases here. |
1076 |
|
|
1077 |
|
} |