| 1 |
< |
#include <cstdlib> |
| 2 |
< |
#include <cstdio> |
| 3 |
< |
#include <cstring> |
| 1 |
> |
#include <stdlib.h> |
| 2 |
> |
#include <stdio.h> |
| 3 |
> |
#include <string.h> |
| 4 |
|
|
| 5 |
|
#include "Globals.hpp" |
| 6 |
|
#include "simError.h" |
| 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 |
+ |
#define G_USEINITTIME 34 |
| 56 |
|
|
| 50 |
– |
|
| 57 |
|
Globals::Globals(){ |
| 58 |
|
|
| 59 |
|
int i; |
| 60 |
+ |
|
| 61 |
+ |
hash_size = 23; |
| 62 |
+ |
hash_shift = 4; |
| 63 |
|
|
| 64 |
|
components = NULL; |
| 65 |
|
|
| 83 |
|
addHash( "boxY", G_BOXY ); |
| 84 |
|
addHash( "boxZ", G_BOXZ ); |
| 85 |
|
addHash( "sampleTime", G_SAMPLETIME ); |
| 86 |
+ |
addHash( "resetTime", G_RESETTIME ); |
| 87 |
|
addHash( "statusTime", G_STATUSTIME ); |
| 88 |
|
addHash( "electrostaticCutoffRadius", G_ECR ); |
| 89 |
|
addHash( "dielectric", G_DIELECTRIC ); |
| 96 |
|
addHash( "targetPressure", G_TARGETPRESSURE); |
| 97 |
|
addHash( "tauThermostat", G_TAUTHERMOSTAT); |
| 98 |
|
addHash( "tauBarostat", G_TAUBAROSTAT); |
| 99 |
< |
|
| 99 |
> |
addHash( "zconsTime", G_ZCONSTIME); |
| 100 |
> |
addHash( "nZconstraints", G_NZCONSTRAINTS); |
| 101 |
> |
addHash( "zconsTol", G_ZCONSTOL); |
| 102 |
> |
addHash( "zconsForcePolicy", G_ZCONSFORCEPOLICY); |
| 103 |
> |
addHash( "seed", G_SEED); |
| 104 |
> |
addHash( "useInitTime", G_USEINITTIME), |
| 105 |
> |
|
| 106 |
> |
|
| 107 |
|
// define some default values |
| 108 |
|
|
| 109 |
|
strcpy( mixingRule,"standard"); //default mixing rules to standard. |
| 110 |
|
usePBC = 1; //default periodic boundry conditions to on |
| 111 |
|
useRF = 0; |
| 112 |
+ |
useInitTime = 1; // default to pull init time from the init file |
| 113 |
|
|
| 114 |
|
have_force_field = 0; |
| 115 |
|
have_n_components = 0; |
| 129 |
|
have_box_z = 0; |
| 130 |
|
have_sample_time = 0; |
| 131 |
|
have_status_time = 0; |
| 132 |
+ |
have_reset_time = 0; |
| 133 |
|
have_thermal_time = 0; |
| 134 |
|
have_ecr = 0; |
| 135 |
|
have_dielectric = 0; |
| 138 |
|
have_target_pressure =0; |
| 139 |
|
have_q_mass = 0; |
| 140 |
|
have_tau_thermostat = 0; |
| 141 |
< |
have_tau_barostat = 0; |
| 142 |
< |
} |
| 141 |
> |
have_tau_barostat = 0; |
| 142 |
> |
have_zcons_time = 0; |
| 143 |
> |
have_n_zConstraints = 0; |
| 144 |
> |
have_zConstraints = 0; |
| 145 |
> |
have_zcons_tol = 0; |
| 146 |
> |
have_seed = 0; |
| 147 |
|
|
| 148 |
+ |
} |
| 149 |
+ |
|
| 150 |
|
Globals::~Globals(){ |
| 151 |
|
int i; |
| 152 |
|
|
| 219 |
|
return 0; |
| 220 |
|
} |
| 221 |
|
|
| 222 |
< |
int Globals::componentStartIndex( event* the_event ){ |
| 222 |
> |
int Globals::componentEnd( event* the_event ){ |
| 223 |
|
|
| 224 |
< |
current_component->startIndex( the_event->evt.si.array, |
| 225 |
< |
the_event->evt.si.n_elements ); |
| 224 |
> |
the_event->err_msg = current_component->checkMe(); |
| 225 |
> |
if( the_event->err_msg != NULL ) return 0; |
| 226 |
> |
|
| 227 |
|
return 1; |
| 228 |
|
} |
| 229 |
|
|
| 230 |
< |
int Globals::componentEnd( event* the_event ){ |
| 230 |
> |
int Globals::newZconstraint( event* the_event ){ |
| 231 |
> |
|
| 232 |
|
|
| 233 |
< |
the_event->err_msg = current_component->checkMe(); |
| 233 |
> |
int index = the_event->evt.blk_index; |
| 234 |
> |
char err[200]; |
| 235 |
> |
current_zConstraint = new ZconStamp( index ); |
| 236 |
> |
|
| 237 |
> |
have_zConstraints = 1; |
| 238 |
> |
|
| 239 |
> |
if( have_n_zConstraints && index < n_zConstraints ) |
| 240 |
> |
zConstraints[index] = current_zConstraint; |
| 241 |
> |
else{ |
| 242 |
> |
if( have_n_zConstraints ){ |
| 243 |
> |
sprintf( err, "Globals error, %d out of nZconstraints range", |
| 244 |
> |
index ); |
| 245 |
> |
the_event->err_msg = strdup( err ); |
| 246 |
> |
return 0; |
| 247 |
> |
} |
| 248 |
> |
else{ |
| 249 |
> |
the_event->err_msg = strdup("Globals error, nZconstraints" |
| 250 |
> |
" not given before" |
| 251 |
> |
" first zConstraint declaration." ); |
| 252 |
> |
return 0; |
| 253 |
> |
} |
| 254 |
> |
} |
| 255 |
> |
|
| 256 |
> |
return 1; |
| 257 |
> |
} |
| 258 |
> |
|
| 259 |
> |
|
| 260 |
> |
|
| 261 |
> |
int Globals::zConstraintAssign( event* the_event ){ |
| 262 |
> |
|
| 263 |
> |
switch( the_event->evt.asmt.asmt_type ){ |
| 264 |
> |
|
| 265 |
> |
case STRING: |
| 266 |
> |
return current_zConstraint->assignString( the_event->evt.asmt.lhs, |
| 267 |
> |
the_event->evt.asmt.rhs.sval, |
| 268 |
> |
&(the_event->err_msg)); |
| 269 |
> |
break; |
| 270 |
> |
|
| 271 |
> |
case DOUBLE: |
| 272 |
> |
return current_zConstraint->assignDouble( the_event->evt.asmt.lhs, |
| 273 |
> |
the_event->evt.asmt.rhs.dval, |
| 274 |
> |
&(the_event->err_msg)); |
| 275 |
> |
break; |
| 276 |
> |
|
| 277 |
> |
case INT: |
| 278 |
> |
return current_zConstraint->assignInt( the_event->evt.asmt.lhs, |
| 279 |
> |
the_event->evt.asmt.rhs.ival, |
| 280 |
> |
&(the_event->err_msg)); |
| 281 |
> |
break; |
| 282 |
> |
|
| 283 |
> |
default: |
| 284 |
> |
the_event->err_msg = strdup( "Globals error. Invalid zConstraint" |
| 285 |
> |
" assignment type" ); |
| 286 |
> |
return 0; |
| 287 |
> |
break; |
| 288 |
> |
} |
| 289 |
> |
return 0; |
| 290 |
> |
} |
| 291 |
> |
|
| 292 |
> |
int Globals::zConstraintEnd( event* the_event ){ |
| 293 |
> |
|
| 294 |
> |
the_event->err_msg = current_zConstraint->checkMe(); |
| 295 |
|
if( the_event->err_msg != NULL ) return 0; |
| 296 |
|
|
| 297 |
|
return 1; |
| 346 |
|
return 1; |
| 347 |
|
} |
| 348 |
|
break; |
| 349 |
+ |
|
| 350 |
+ |
case G_NZCONSTRAINTS: |
| 351 |
+ |
if( the_type == STRING ){ |
| 352 |
+ |
the_event->err_msg = |
| 353 |
+ |
strdup("Global error. nZconstraints is not a double or an int.\n" ); |
| 354 |
+ |
return 0; |
| 355 |
+ |
} |
| 356 |
|
|
| 357 |
+ |
else if( the_type == DOUBLE ){ |
| 358 |
+ |
n_zConstraints = (int)the_event->evt.asmt.rhs.dval; |
| 359 |
+ |
zConstraints = new ZconStamp*[n_zConstraints]; |
| 360 |
+ |
have_n_zConstraints = 1; |
| 361 |
+ |
return 1; |
| 362 |
+ |
} |
| 363 |
+ |
|
| 364 |
+ |
else{ |
| 365 |
+ |
n_zConstraints = the_event->evt.asmt.rhs.ival; |
| 366 |
+ |
zConstraints = new ZconStamp*[n_zConstraints]; |
| 367 |
+ |
have_n_zConstraints = 1; |
| 368 |
+ |
return 1; |
| 369 |
+ |
} |
| 370 |
+ |
break; |
| 371 |
+ |
|
| 372 |
|
case G_TARGETTEMP: |
| 373 |
|
switch( the_type ){ |
| 374 |
|
|
| 735 |
|
} |
| 736 |
|
break; |
| 737 |
|
|
| 738 |
< |
case G_THERMALTIME: |
| 738 |
> |
case G_RESETTIME: |
| 739 |
|
switch( the_type ){ |
| 740 |
|
|
| 741 |
|
case STRING: |
| 742 |
|
the_event->err_msg = |
| 743 |
+ |
strdup( "Global error. resetTime is not a double or int.\n" ); |
| 744 |
+ |
return 0; |
| 745 |
+ |
break; |
| 746 |
+ |
|
| 747 |
+ |
case DOUBLE: |
| 748 |
+ |
resetTime = the_event->evt.asmt.rhs.dval; |
| 749 |
+ |
have_reset_time = 1; |
| 750 |
+ |
return 1; |
| 751 |
+ |
break; |
| 752 |
+ |
|
| 753 |
+ |
case INT: |
| 754 |
+ |
resetTime = (double)the_event->evt.asmt.rhs.ival; |
| 755 |
+ |
have_reset_time = 1; |
| 756 |
+ |
return 1; |
| 757 |
+ |
break; |
| 758 |
+ |
|
| 759 |
+ |
default: |
| 760 |
+ |
the_event->err_msg = |
| 761 |
+ |
strdup( "Global error. resetTime unrecognized.\n" ); |
| 762 |
+ |
return 0; |
| 763 |
+ |
break; |
| 764 |
+ |
} |
| 765 |
+ |
break; |
| 766 |
+ |
|
| 767 |
+ |
case G_THERMALTIME: |
| 768 |
+ |
switch( the_type ){ |
| 769 |
+ |
|
| 770 |
+ |
case STRING: |
| 771 |
+ |
the_event->err_msg = |
| 772 |
|
strdup( "Global error. thermalTime is not a double or int.\n" ); |
| 773 |
|
return 0; |
| 774 |
|
break; |
| 898 |
|
strdup( "Global error. tempSet was not \"true\" or \"false\".\n" ); |
| 899 |
|
return 0; |
| 900 |
|
break; |
| 901 |
+ |
|
| 902 |
+ |
case G_USEINITTIME: |
| 903 |
+ |
if( the_type == STRING ){ |
| 904 |
+ |
|
| 905 |
+ |
if( !strcasecmp( "true", the_event->evt.asmt.rhs.sval )) useInitTime = 1; |
| 906 |
+ |
else if( !strcasecmp( "false", the_event->evt.asmt.rhs.sval )) useInitTime = 0; |
| 907 |
+ |
else{ |
| 908 |
+ |
the_event->err_msg = |
| 909 |
+ |
strdup( "Global error. useInitTime was not \"true\" or \"false\".\n" ); |
| 910 |
+ |
return 0; |
| 911 |
+ |
} |
| 912 |
+ |
return 1; |
| 913 |
+ |
} |
| 914 |
|
|
| 915 |
+ |
the_event->err_msg = |
| 916 |
+ |
strdup( "Global error. useInitTime was not \"true\" or \"false\".\n" ); |
| 917 |
+ |
return 0; |
| 918 |
+ |
break; |
| 919 |
+ |
|
| 920 |
|
case G_USEPBC: |
| 921 |
|
if( the_type == STRING ){ |
| 922 |
|
|
| 1039 |
|
break; |
| 1040 |
|
} |
| 1041 |
|
break; |
| 1042 |
+ |
|
| 1043 |
+ |
case G_ZCONSTIME: |
| 1044 |
+ |
switch( the_type ){ |
| 1045 |
+ |
|
| 1046 |
+ |
case STRING: |
| 1047 |
+ |
the_event->err_msg = |
| 1048 |
+ |
strdup( "Global error. zcons_time is not a double or int.\n" ); |
| 1049 |
+ |
return 0; |
| 1050 |
+ |
break; |
| 1051 |
+ |
|
| 1052 |
+ |
case DOUBLE: |
| 1053 |
+ |
zcons_time = the_event->evt.asmt.rhs.dval; |
| 1054 |
+ |
have_zcons_time = 1; |
| 1055 |
+ |
return 1; |
| 1056 |
+ |
break; |
| 1057 |
+ |
|
| 1058 |
+ |
case INT: |
| 1059 |
+ |
zcons_time = (double)the_event->evt.asmt.rhs.ival; |
| 1060 |
+ |
have_zcons_time = 1; |
| 1061 |
+ |
return 1; |
| 1062 |
+ |
break; |
| 1063 |
+ |
|
| 1064 |
+ |
default: |
| 1065 |
+ |
the_event->err_msg = |
| 1066 |
+ |
strdup( "Global error. zcons_time unrecognized.\n" ); |
| 1067 |
+ |
return 0; |
| 1068 |
+ |
break; |
| 1069 |
+ |
} |
| 1070 |
+ |
break; |
| 1071 |
|
|
| 1072 |
+ |
case G_ZCONSTOL: |
| 1073 |
+ |
switch( the_type ){ |
| 1074 |
+ |
|
| 1075 |
+ |
case STRING: |
| 1076 |
+ |
the_event->err_msg = |
| 1077 |
+ |
strdup( "Global error. zcons_tol is not a double or int.\n" ); |
| 1078 |
+ |
return 0; |
| 1079 |
+ |
break; |
| 1080 |
+ |
|
| 1081 |
+ |
case DOUBLE: |
| 1082 |
+ |
zcons_tol = the_event->evt.asmt.rhs.dval; |
| 1083 |
+ |
have_zcons_tol = 1; |
| 1084 |
+ |
return 1; |
| 1085 |
+ |
break; |
| 1086 |
+ |
|
| 1087 |
+ |
case INT: |
| 1088 |
+ |
zcons_tol = (double)the_event->evt.asmt.rhs.ival; |
| 1089 |
+ |
have_zcons_tol = 1; |
| 1090 |
+ |
return 1; |
| 1091 |
+ |
break; |
| 1092 |
+ |
|
| 1093 |
+ |
default: |
| 1094 |
+ |
the_event->err_msg = |
| 1095 |
+ |
strdup( "Global error. zcons_ol unrecognized.\n" ); |
| 1096 |
+ |
return 0; |
| 1097 |
+ |
break; |
| 1098 |
+ |
} |
| 1099 |
+ |
break; |
| 1100 |
+ |
|
| 1101 |
+ |
case G_ZCONSFORCEPOLICY: |
| 1102 |
+ |
switch( the_type ){ |
| 1103 |
+ |
|
| 1104 |
+ |
case STRING: |
| 1105 |
+ |
strcpy(zconsForcePolicy, the_event->evt.asmt.rhs.sval); |
| 1106 |
|
|
| 1107 |
+ |
for(int i = 0; zconsForcePolicy[i] != '\0'; i++) |
| 1108 |
+ |
{ |
| 1109 |
+ |
zconsForcePolicy[i] = toupper(zconsForcePolicy[i]); |
| 1110 |
+ |
} |
| 1111 |
+ |
have_zcons_force_policy = 1; |
| 1112 |
+ |
return 1; |
| 1113 |
+ |
break; |
| 1114 |
+ |
|
| 1115 |
+ |
case DOUBLE: |
| 1116 |
+ |
the_event->err_msg = |
| 1117 |
+ |
strdup( "Global error. zconsForcePolicy is not a double or int.\n" ); |
| 1118 |
+ |
return 0; |
| 1119 |
+ |
break; |
| 1120 |
+ |
|
| 1121 |
+ |
case INT: |
| 1122 |
+ |
the_event->err_msg = |
| 1123 |
+ |
strdup( "Global error. zconsForcePolicy is not a double or int.\n" ); |
| 1124 |
+ |
return 0; |
| 1125 |
+ |
break; |
| 1126 |
+ |
|
| 1127 |
+ |
default: |
| 1128 |
+ |
the_event->err_msg = |
| 1129 |
+ |
strdup( "Global error. zconsForcePolicy unrecognized.\n" ); |
| 1130 |
+ |
return 0; |
| 1131 |
+ |
break; |
| 1132 |
+ |
} |
| 1133 |
+ |
break; |
| 1134 |
|
// add more token cases here. |
| 1135 |
+ |
case G_SEED: |
| 1136 |
+ |
switch( the_type ){ |
| 1137 |
+ |
|
| 1138 |
+ |
case STRING: |
| 1139 |
+ |
the_event->err_msg = |
| 1140 |
+ |
strdup( "Global error. seed is not a string.\n" ); |
| 1141 |
+ |
return 0; |
| 1142 |
+ |
return 0; |
| 1143 |
+ |
break; |
| 1144 |
+ |
|
| 1145 |
+ |
case DOUBLE: |
| 1146 |
+ |
have_seed = 1; |
| 1147 |
+ |
seed = (int)the_event->evt.asmt.rhs.dval; |
| 1148 |
+ |
return 1; |
| 1149 |
+ |
break; |
| 1150 |
+ |
|
| 1151 |
+ |
case INT: |
| 1152 |
+ |
have_seed = 1; |
| 1153 |
+ |
seed = the_event->evt.asmt.rhs.ival ; |
| 1154 |
+ |
return 1; |
| 1155 |
+ |
break; |
| 1156 |
+ |
|
| 1157 |
+ |
default: |
| 1158 |
+ |
the_event->err_msg = |
| 1159 |
+ |
strdup( "Global error. seed unrecognized.\n" ); |
| 1160 |
+ |
return 0; |
| 1161 |
+ |
break; |
| 1162 |
+ |
} |
| 1163 |
+ |
break; |
| 1164 |
+ |
// add more token cases here. |
| 1165 |
|
|
| 1166 |
|
} |
| 1167 |
|
} |