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 |
+ |
#define G_SEED 32 |
54 |
+ |
#define G_RESETTIME 33 |
55 |
|
|
50 |
– |
|
56 |
|
Globals::Globals(){ |
57 |
|
|
58 |
|
int i; |
59 |
+ |
|
60 |
+ |
hash_size = 23; |
61 |
+ |
hash_shift = 4; |
62 |
|
|
63 |
|
components = NULL; |
64 |
|
|
82 |
|
addHash( "boxY", G_BOXY ); |
83 |
|
addHash( "boxZ", G_BOXZ ); |
84 |
|
addHash( "sampleTime", G_SAMPLETIME ); |
85 |
+ |
addHash( "resetTime", G_RESETTIME ); |
86 |
|
addHash( "statusTime", G_STATUSTIME ); |
87 |
|
addHash( "electrostaticCutoffRadius", G_ECR ); |
88 |
|
addHash( "dielectric", G_DIELECTRIC ); |
95 |
|
addHash( "targetPressure", G_TARGETPRESSURE); |
96 |
|
addHash( "tauThermostat", G_TAUTHERMOSTAT); |
97 |
|
addHash( "tauBarostat", G_TAUBAROSTAT); |
98 |
< |
|
98 |
> |
addHash( "zconsTime", G_ZCONSTIME); |
99 |
> |
addHash( "nZconstraints", G_NZCONSTRAINTS); |
100 |
> |
addHash( "zconsTol", G_ZCONSTOL); |
101 |
> |
addHash( "zconsForcePolicy", G_ZCONSFORCEPOLICY); |
102 |
> |
addHash( "seed", G_SEED); |
103 |
> |
|
104 |
> |
|
105 |
|
// define some default values |
106 |
|
|
107 |
|
strcpy( mixingRule,"standard"); //default mixing rules to standard. |
126 |
|
have_box_z = 0; |
127 |
|
have_sample_time = 0; |
128 |
|
have_status_time = 0; |
129 |
+ |
have_reset_time = 0; |
130 |
|
have_thermal_time = 0; |
131 |
|
have_ecr = 0; |
132 |
|
have_dielectric = 0; |
135 |
|
have_target_pressure =0; |
136 |
|
have_q_mass = 0; |
137 |
|
have_tau_thermostat = 0; |
138 |
< |
have_tau_barostat = 0; |
139 |
< |
} |
138 |
> |
have_tau_barostat = 0; |
139 |
> |
have_zcons_time = 0; |
140 |
> |
have_n_zConstraints = 0; |
141 |
> |
have_zConstraints = 0; |
142 |
> |
have_zcons_tol = 0; |
143 |
> |
have_seed = 0; |
144 |
|
|
145 |
+ |
} |
146 |
+ |
|
147 |
|
Globals::~Globals(){ |
148 |
|
int i; |
149 |
|
|
216 |
|
return 0; |
217 |
|
} |
218 |
|
|
219 |
< |
int Globals::componentStartIndex( event* the_event ){ |
219 |
> |
int Globals::componentEnd( event* the_event ){ |
220 |
|
|
221 |
< |
current_component->startIndex( the_event->evt.si.array, |
222 |
< |
the_event->evt.si.n_elements ); |
221 |
> |
the_event->err_msg = current_component->checkMe(); |
222 |
> |
if( the_event->err_msg != NULL ) return 0; |
223 |
> |
|
224 |
|
return 1; |
225 |
|
} |
226 |
|
|
227 |
< |
int Globals::componentEnd( event* the_event ){ |
227 |
> |
int Globals::newZconstraint( event* the_event ){ |
228 |
> |
|
229 |
|
|
230 |
< |
the_event->err_msg = current_component->checkMe(); |
230 |
> |
int index = the_event->evt.blk_index; |
231 |
> |
char err[200]; |
232 |
> |
current_zConstraint = new ZconStamp( index ); |
233 |
> |
|
234 |
> |
have_zConstraints = 1; |
235 |
> |
|
236 |
> |
if( have_n_zConstraints && index < n_zConstraints ) |
237 |
> |
zConstraints[index] = current_zConstraint; |
238 |
> |
else{ |
239 |
> |
if( have_n_zConstraints ){ |
240 |
> |
sprintf( err, "Globals error, %d out of nZconstraints range", |
241 |
> |
index ); |
242 |
> |
the_event->err_msg = strdup( err ); |
243 |
> |
return 0; |
244 |
> |
} |
245 |
> |
else{ |
246 |
> |
the_event->err_msg = strdup("Globals error, nZconstraints" |
247 |
> |
" not given before" |
248 |
> |
" first zConstraint declaration." ); |
249 |
> |
return 0; |
250 |
> |
} |
251 |
> |
} |
252 |
> |
|
253 |
> |
return 1; |
254 |
> |
} |
255 |
> |
|
256 |
> |
|
257 |
> |
|
258 |
> |
int Globals::zConstraintAssign( event* the_event ){ |
259 |
> |
|
260 |
> |
switch( the_event->evt.asmt.asmt_type ){ |
261 |
> |
|
262 |
> |
case STRING: |
263 |
> |
return current_zConstraint->assignString( the_event->evt.asmt.lhs, |
264 |
> |
the_event->evt.asmt.rhs.sval, |
265 |
> |
&(the_event->err_msg)); |
266 |
> |
break; |
267 |
> |
|
268 |
> |
case DOUBLE: |
269 |
> |
return current_zConstraint->assignDouble( the_event->evt.asmt.lhs, |
270 |
> |
the_event->evt.asmt.rhs.dval, |
271 |
> |
&(the_event->err_msg)); |
272 |
> |
break; |
273 |
> |
|
274 |
> |
case INT: |
275 |
> |
return current_zConstraint->assignInt( the_event->evt.asmt.lhs, |
276 |
> |
the_event->evt.asmt.rhs.ival, |
277 |
> |
&(the_event->err_msg)); |
278 |
> |
break; |
279 |
> |
|
280 |
> |
default: |
281 |
> |
the_event->err_msg = strdup( "Globals error. Invalid zConstraint" |
282 |
> |
" assignment type" ); |
283 |
> |
return 0; |
284 |
> |
break; |
285 |
> |
} |
286 |
> |
return 0; |
287 |
> |
} |
288 |
> |
|
289 |
> |
int Globals::zConstraintEnd( event* the_event ){ |
290 |
> |
|
291 |
> |
the_event->err_msg = current_zConstraint->checkMe(); |
292 |
|
if( the_event->err_msg != NULL ) return 0; |
293 |
|
|
294 |
|
return 1; |
343 |
|
return 1; |
344 |
|
} |
345 |
|
break; |
346 |
+ |
|
347 |
+ |
case G_NZCONSTRAINTS: |
348 |
+ |
if( the_type == STRING ){ |
349 |
+ |
the_event->err_msg = |
350 |
+ |
strdup("Global error. nZconstraints is not a double or an int.\n" ); |
351 |
+ |
return 0; |
352 |
+ |
} |
353 |
+ |
|
354 |
+ |
else if( the_type == DOUBLE ){ |
355 |
+ |
n_zConstraints = (int)the_event->evt.asmt.rhs.dval; |
356 |
+ |
zConstraints = new ZconStamp*[n_zConstraints]; |
357 |
+ |
have_n_zConstraints = 1; |
358 |
+ |
return 1; |
359 |
+ |
} |
360 |
+ |
|
361 |
+ |
else{ |
362 |
+ |
n_zConstraints = the_event->evt.asmt.rhs.ival; |
363 |
+ |
zConstraints = new ZconStamp*[n_zConstraints]; |
364 |
+ |
have_n_zConstraints = 1; |
365 |
+ |
return 1; |
366 |
+ |
} |
367 |
+ |
break; |
368 |
|
|
369 |
|
case G_TARGETTEMP: |
370 |
|
switch( the_type ){ |
732 |
|
} |
733 |
|
break; |
734 |
|
|
735 |
< |
case G_THERMALTIME: |
735 |
> |
case G_RESETTIME: |
736 |
|
switch( the_type ){ |
737 |
|
|
738 |
|
case STRING: |
739 |
|
the_event->err_msg = |
740 |
+ |
strdup( "Global error. resetTime is not a double or int.\n" ); |
741 |
+ |
return 0; |
742 |
+ |
break; |
743 |
+ |
|
744 |
+ |
case DOUBLE: |
745 |
+ |
resetTime = the_event->evt.asmt.rhs.dval; |
746 |
+ |
have_reset_time = 1; |
747 |
+ |
return 1; |
748 |
+ |
break; |
749 |
+ |
|
750 |
+ |
case INT: |
751 |
+ |
resetTime = (double)the_event->evt.asmt.rhs.ival; |
752 |
+ |
have_reset_time = 1; |
753 |
+ |
return 1; |
754 |
+ |
break; |
755 |
+ |
|
756 |
+ |
default: |
757 |
+ |
the_event->err_msg = |
758 |
+ |
strdup( "Global error. resetTime unrecognized.\n" ); |
759 |
+ |
return 0; |
760 |
+ |
break; |
761 |
+ |
} |
762 |
+ |
break; |
763 |
+ |
|
764 |
+ |
case G_THERMALTIME: |
765 |
+ |
switch( the_type ){ |
766 |
+ |
|
767 |
+ |
case STRING: |
768 |
+ |
the_event->err_msg = |
769 |
|
strdup( "Global error. thermalTime is not a double or int.\n" ); |
770 |
|
return 0; |
771 |
|
break; |
1018 |
|
break; |
1019 |
|
} |
1020 |
|
break; |
1021 |
+ |
|
1022 |
+ |
case G_ZCONSTIME: |
1023 |
+ |
switch( the_type ){ |
1024 |
+ |
|
1025 |
+ |
case STRING: |
1026 |
+ |
the_event->err_msg = |
1027 |
+ |
strdup( "Global error. zcons_time is not a double or int.\n" ); |
1028 |
+ |
return 0; |
1029 |
+ |
break; |
1030 |
+ |
|
1031 |
+ |
case DOUBLE: |
1032 |
+ |
zcons_time = the_event->evt.asmt.rhs.dval; |
1033 |
+ |
have_zcons_time = 1; |
1034 |
+ |
return 1; |
1035 |
+ |
break; |
1036 |
+ |
|
1037 |
+ |
case INT: |
1038 |
+ |
zcons_time = (double)the_event->evt.asmt.rhs.ival; |
1039 |
+ |
have_zcons_time = 1; |
1040 |
+ |
return 1; |
1041 |
+ |
break; |
1042 |
+ |
|
1043 |
+ |
default: |
1044 |
+ |
the_event->err_msg = |
1045 |
+ |
strdup( "Global error. zcons_time unrecognized.\n" ); |
1046 |
+ |
return 0; |
1047 |
+ |
break; |
1048 |
+ |
} |
1049 |
+ |
break; |
1050 |
|
|
1051 |
+ |
case G_ZCONSTOL: |
1052 |
+ |
switch( the_type ){ |
1053 |
+ |
|
1054 |
+ |
case STRING: |
1055 |
+ |
the_event->err_msg = |
1056 |
+ |
strdup( "Global error. zcons_tol is not a double or int.\n" ); |
1057 |
+ |
return 0; |
1058 |
+ |
break; |
1059 |
+ |
|
1060 |
+ |
case DOUBLE: |
1061 |
+ |
zcons_tol = the_event->evt.asmt.rhs.dval; |
1062 |
+ |
have_zcons_tol = 1; |
1063 |
+ |
return 1; |
1064 |
+ |
break; |
1065 |
+ |
|
1066 |
+ |
case INT: |
1067 |
+ |
zcons_tol = (double)the_event->evt.asmt.rhs.ival; |
1068 |
+ |
have_zcons_tol = 1; |
1069 |
+ |
return 1; |
1070 |
+ |
break; |
1071 |
+ |
|
1072 |
+ |
default: |
1073 |
+ |
the_event->err_msg = |
1074 |
+ |
strdup( "Global error. zcons_ol unrecognized.\n" ); |
1075 |
+ |
return 0; |
1076 |
+ |
break; |
1077 |
+ |
} |
1078 |
+ |
break; |
1079 |
+ |
|
1080 |
+ |
case G_ZCONSFORCEPOLICY: |
1081 |
+ |
switch( the_type ){ |
1082 |
+ |
|
1083 |
+ |
case STRING: |
1084 |
+ |
strcpy(zconsForcePolicy, the_event->evt.asmt.rhs.sval); |
1085 |
+ |
|
1086 |
+ |
for(int i = 0; zconsForcePolicy[i] != '\0'; i++) |
1087 |
+ |
{ |
1088 |
+ |
zconsForcePolicy[i] = toupper(zconsForcePolicy[i]); |
1089 |
+ |
} |
1090 |
+ |
have_zcons_force_policy = 1; |
1091 |
+ |
return 1; |
1092 |
+ |
break; |
1093 |
+ |
|
1094 |
+ |
case DOUBLE: |
1095 |
+ |
the_event->err_msg = |
1096 |
+ |
strdup( "Global error. zconsForcePolicy is not a double or int.\n" ); |
1097 |
+ |
return 0; |
1098 |
+ |
break; |
1099 |
+ |
|
1100 |
+ |
case INT: |
1101 |
+ |
the_event->err_msg = |
1102 |
+ |
strdup( "Global error. zconsForcePolicy is not a double or int.\n" ); |
1103 |
+ |
return 0; |
1104 |
+ |
break; |
1105 |
+ |
|
1106 |
+ |
default: |
1107 |
+ |
the_event->err_msg = |
1108 |
+ |
strdup( "Global error. zconsForcePolicy unrecognized.\n" ); |
1109 |
+ |
return 0; |
1110 |
+ |
break; |
1111 |
+ |
} |
1112 |
+ |
break; |
1113 |
+ |
// add more token cases here. |
1114 |
+ |
case G_SEED: |
1115 |
+ |
switch( the_type ){ |
1116 |
+ |
|
1117 |
+ |
case STRING: |
1118 |
+ |
the_event->err_msg = |
1119 |
+ |
strdup( "Global error. seed is not a string.\n" ); |
1120 |
+ |
return 0; |
1121 |
+ |
return 0; |
1122 |
+ |
break; |
1123 |
+ |
|
1124 |
+ |
case DOUBLE: |
1125 |
+ |
have_seed = 1; |
1126 |
+ |
seed = (int)the_event->evt.asmt.rhs.dval; |
1127 |
+ |
return 1; |
1128 |
+ |
break; |
1129 |
+ |
|
1130 |
+ |
case INT: |
1131 |
+ |
have_seed = 1; |
1132 |
+ |
seed = the_event->evt.asmt.rhs.ival ; |
1133 |
+ |
return 1; |
1134 |
+ |
break; |
1135 |
+ |
|
1136 |
+ |
default: |
1137 |
+ |
the_event->err_msg = |
1138 |
+ |
strdup( "Global error. seed unrecognized.\n" ); |
1139 |
+ |
return 0; |
1140 |
+ |
break; |
1141 |
+ |
} |
1142 |
+ |
break; |
1143 |
+ |
// add more token cases here. |
1144 |
+ |
|
1145 |
|
} |
1146 |
|
} |
1147 |
|
|