How to use input_value method in robotframework-appiumlibrary

Best Python code snippet using robotframework-appiumlibrary_python

prepare_slave_param_csv_vtest2.py

Source:prepare_slave_param_csv_vtest2.py Github

copy

Full Screen

1##This function writes the parameters and master decision variables into a csv file for the slave to read2def prepare_slave_param_csv_vtest2 (var_converted, demand, weather_data, piecewise_steps):3 ##var_converted --- essentially just the master decision variables 4 ##demand --- demand data 5 ##weather_data --- weather data 6 ##piecewise_steps --- the piecewise linear steps7 8 mdv_slave_param = nwk_choice_3_mdv (var_converted, demand, weather_data, piecewise_steps)9 10 return mdv_slave_param11############################################################################################################################################################################12############################################################################################################################################################################13############################################################################################################################################################################14##Additional functions 15##A function to prepare the return values if the network choice is 316def nwk_choice_3_mdv (var_converted, demand, weather_and_ct_coeff, piecewise_steps):17 ##var_converted --- essentially just the master decision variables 18 ##demand --- demand data 19 ##weather_data --- weather data 20 ##piecewise_steps --- the piecewise linear steps21 22 import pandas as pd23 24 ##Initiate dataframe to hold the written values 25 mdv_slave_param = pd.DataFrame(columns = ['Name', 'Value', 'Unit'])26 27 ##############################################################################################################28 ##chiller_evap_flow_consol_4nc 29 input_value = {}30 input_value['Name'] = 'chiller_evap_flow_consol_4nc_tenwkflow' 31 input_value['Value'] = var_converted[1]32 input_value['Unit'] = 'm3/h'33 34 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]35 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])36 mdv_slave_param = mdv_slave_param.append(temp_df, ignore_index=True) 37 38 ############################################################################################################## 39 ##chiller_ret_4nc40 input_value = {}41 input_value['Name'] = 'chiller_ret_4nc_etret' 42 input_value['Value'] = var_converted[0]43 input_value['Unit'] = 'K'44 45 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]46 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])47 mdv_slave_param = mdv_slave_param.append(temp_df, ignore_index=True) 48 49 ##############################################################################################################50 ##chiller1_evap_4nc 51 input_value = {}52 input_value['Name'] = 'chiller1_evap_4nc_etret' 53 input_value['Value'] = var_converted[0]54 input_value['Unit'] = 'K'55 56 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]57 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])58 mdv_slave_param = mdv_slave_param.append(temp_df, ignore_index=True) 59 60 input_value = {}61 input_value['Name'] = 'chiller1_evap_4nc_ctin' 62 input_value['Value'] = var_converted[2]63 input_value['Unit'] = 'K'64 65 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]66 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])67 mdv_slave_param = mdv_slave_param.append(temp_df, ignore_index=True) 68 69 input_value = {}70 input_value['Name'] = 'chiller1_evap_4nc_tenwkflow' 71 input_value['Value'] = var_converted[1]72 input_value['Unit'] = 'm3/h'73 74 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]75 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])76 mdv_slave_param = mdv_slave_param.append(temp_df, ignore_index=True) 77 78 input_value = {}79 input_value['Name'] = 'chiller1_evap_4nc_piecewise_steps' 80 input_value['Value'] = piecewise_steps81 input_value['Unit'] = '-'82 83 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]84 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])85 mdv_slave_param = mdv_slave_param.append(temp_df, ignore_index=True) 86 87 ############################################################################################################## 88 ##chiller1_evap_nwk_4nc89 input_value = {}90 input_value['Name'] = 'chiller1_evap_nwk_4nc_piecewise_steps' 91 input_value['Value'] = piecewise_steps92 input_value['Unit'] = '-'93 94 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]95 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])96 mdv_slave_param = mdv_slave_param.append(temp_df, ignore_index=True) 97 input_value = {}98 input_value['Name'] = 'chiller1_evap_nwk_4nc_tenwkflow' 99 input_value['Value'] = var_converted[1]100 input_value['Unit'] = 'm3/h'101 102 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]103 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])104 mdv_slave_param = mdv_slave_param.append(temp_df, ignore_index=True)105 ##############################################################################################################106 ##chiller1_evap_pump_4nc 107 input_value = {}108 input_value['Name'] = 'chiller1_evap_pump_4nc_piecewise_steps' 109 input_value['Value'] = piecewise_steps110 input_value['Unit'] = '-'111 112 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]113 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])114 mdv_slave_param = mdv_slave_param.append(temp_df, ignore_index=True) 115 116 ############################################################################################################## 117 ##chiller2_evap_4nc118 input_value = {}119 input_value['Name'] = 'chiller2_evap_4nc_etret' 120 input_value['Value'] = var_converted[0]121 input_value['Unit'] = 'K'122 123 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]124 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])125 mdv_slave_param = mdv_slave_param.append(temp_df, ignore_index=True) 126 input_value = {}127 input_value['Name'] = 'chiller2_evap_4nc_ctin' 128 input_value['Value'] = var_converted[2]129 input_value['Unit'] = 'K'130 131 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]132 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])133 mdv_slave_param = mdv_slave_param.append(temp_df, ignore_index=True) 134 135 input_value = {}136 input_value['Name'] = 'chiller2_evap_4nc_tenwkflow' 137 input_value['Value'] = var_converted[1]138 input_value['Unit'] = 'm3/h'139 140 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]141 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])142 mdv_slave_param = mdv_slave_param.append(temp_df, ignore_index=True) 143 144 input_value = {}145 input_value['Name'] = 'chiller2_evap_4nc_piecewise_steps' 146 input_value['Value'] = piecewise_steps147 input_value['Unit'] = '-'148 149 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]150 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])151 mdv_slave_param = mdv_slave_param.append(temp_df, ignore_index=True) 152 153 ############################################################################################################## 154 ##chiller2_evap_nwk_4nc155 input_value = {}156 input_value['Name'] = 'chiller2_evap_nwk_4nc_piecewise_steps' 157 input_value['Value'] = piecewise_steps158 input_value['Unit'] = '-'159 160 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]161 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])162 mdv_slave_param = mdv_slave_param.append(temp_df, ignore_index=True) 163 input_value = {}164 input_value['Name'] = 'chiller2_evap_nwk_4nc_tenwkflow' 165 input_value['Value'] = var_converted[1]166 input_value['Unit'] = 'm3/h'167 168 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]169 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])170 mdv_slave_param = mdv_slave_param.append(temp_df, ignore_index=True)171 172 ##############################################################################################################173 ##chiller2_evap_pump_4nc 174 input_value = {}175 input_value['Name'] = 'chiller2_evap_pump_4nc_piecewise_steps' 176 input_value['Value'] = piecewise_steps177 input_value['Unit'] = '-'178 179 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]180 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])181 mdv_slave_param = mdv_slave_param.append(temp_df, ignore_index=True) 182 183 ############################################################################################################## 184 ##chiller3_evap_4nc185 input_value = {}186 input_value['Name'] = 'chiller3_evap_4nc_etret' 187 input_value['Value'] = var_converted[0]188 input_value['Unit'] = 'K'189 190 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]191 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])192 mdv_slave_param = mdv_slave_param.append(temp_df, ignore_index=True) 193 input_value = {}194 input_value['Name'] = 'chiller3_evap_4nc_ctin' 195 input_value['Value'] = var_converted[2]196 input_value['Unit'] = 'K'197 198 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]199 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])200 mdv_slave_param = mdv_slave_param.append(temp_df, ignore_index=True) 201 202 input_value = {}203 input_value['Name'] = 'chiller3_evap_4nc_tenwkflow' 204 input_value['Value'] = var_converted[1]205 input_value['Unit'] = 'm3/h'206 207 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]208 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])209 mdv_slave_param = mdv_slave_param.append(temp_df, ignore_index=True) 210 211 input_value = {}212 input_value['Name'] = 'chiller3_evap_4nc_piecewise_steps' 213 input_value['Value'] = piecewise_steps214 input_value['Unit'] = '-'215 216 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]217 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])218 mdv_slave_param = mdv_slave_param.append(temp_df, ignore_index=True) 219 220 ############################################################################################################## 221 ##chiller3_evap_nwk_4nc222 input_value = {}223 input_value['Name'] = 'chiller3_evap_nwk_4nc_piecewise_steps' 224 input_value['Value'] = piecewise_steps225 input_value['Unit'] = '-'226 227 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]228 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])229 mdv_slave_param = mdv_slave_param.append(temp_df, ignore_index=True) 230 input_value = {}231 input_value['Name'] = 'chiller3_evap_nwk_4nc_tenwkflow' 232 input_value['Value'] = var_converted[1]233 input_value['Unit'] = 'm3/h'234 235 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]236 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])237 mdv_slave_param = mdv_slave_param.append(temp_df, ignore_index=True)238 239 ##############################################################################################################240 ##chiller3_evap_pump_4nc 241 input_value = {}242 input_value['Name'] = 'chiller3_evap_pump_4nc_piecewise_steps' 243 input_value['Value'] = piecewise_steps244 input_value['Unit'] = '-'245 246 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]247 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])248 mdv_slave_param = mdv_slave_param.append(temp_df, ignore_index=True)249 250 ##############################################################################################################251 ##cp_nwk_4nc 252 input_value = {}253 input_value['Name'] = 'cp_nwk_4nc_tenwkflow' 254 input_value['Value'] = var_converted[1]255 input_value['Unit'] = 'm3/h'256 257 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]258 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])259 mdv_slave_param = mdv_slave_param.append(temp_df, ignore_index=True) 260 261 ##############################################################################################################262 ##dist_nwk_pump_4nc 263 input_value = {}264 input_value['Name'] = 'dist_nwk_pump_4nc_nwk_choice' 265 input_value['Value'] = 3266 input_value['Unit'] = '-'267 268 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]269 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])270 mdv_slave_param = mdv_slave_param.append(temp_df, ignore_index=True) 271 272 input_value = {}273 input_value['Name'] = 'dist_nwk_pump_4nc_piecewise_steps' 274 input_value['Value'] = piecewise_steps275 input_value['Unit'] = '-'276 277 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]278 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])279 mdv_slave_param = mdv_slave_param.append(temp_df, ignore_index=True) 280 281 ##############################################################################################################282 ##gv2_nwk_4nc 283 input_value = {}284 input_value['Name'] = 'gv2_nwk_4nc_piecewise_steps' 285 input_value['Value'] = piecewise_steps286 input_value['Unit'] = '-'287 288 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]289 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])290 mdv_slave_param = mdv_slave_param.append(temp_df, ignore_index=True) 291 292 input_value = {}293 input_value['Name'] = 'gv2_nwk_4nc_tenwkflow' 294 input_value['Value'] = var_converted[1]295 input_value['Unit'] = 'm3/h'296 297 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]298 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])299 mdv_slave_param = mdv_slave_param.append(temp_df, ignore_index=True) 300 ##############################################################################################################301 ##gv2_substation_4nc 302 input_value = {}303 input_value['Name'] = 'gv2_substation_4nc_demand' 304 input_value['Value'] = demand['ss_gv2_demand'][0]305 input_value['Unit'] = 'kWh'306 307 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]308 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])309 mdv_slave_param = mdv_slave_param.append(temp_df, ignore_index=True) 310 input_value = {}311 input_value['Name'] = 'gv2_substation_4nc_tenwkflow' 312 input_value['Value'] = var_converted[1]313 input_value['Unit'] = 'm3/h'314 315 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]316 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])317 mdv_slave_param = mdv_slave_param.append(temp_df, ignore_index=True) 318 ##############################################################################################################319 ##hsb_nwk_4nc 320 input_value = {}321 input_value['Name'] = 'hsb_nwk_4nc_piecewise_steps' 322 input_value['Value'] = piecewise_steps323 input_value['Unit'] = '-'324 325 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]326 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])327 mdv_slave_param = mdv_slave_param.append(temp_df, ignore_index=True) 328 329 input_value = {}330 input_value['Name'] = 'hsb_nwk_4nc_tenwkflow' 331 input_value['Value'] = var_converted[1]332 input_value['Unit'] = 'm3/h'333 334 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]335 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])336 mdv_slave_param = mdv_slave_param.append(temp_df, ignore_index=True) 337 ##############################################################################################################338 ##hsb_substation_4nc 339 input_value = {}340 input_value['Name'] = 'hsb_substation_4nc_demand' 341 input_value['Value'] = demand['ss_hsb_demand'][0]342 input_value['Unit'] = 'kWh'343 344 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]345 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])346 mdv_slave_param = mdv_slave_param.append(temp_df, ignore_index=True) 347 input_value = {}348 input_value['Name'] = 'hsb_substation_4nc_tenwkflow' 349 input_value['Value'] = var_converted[1]350 input_value['Unit'] = 'm3/h'351 352 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]353 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])354 mdv_slave_param = mdv_slave_param.append(temp_df, ignore_index=True) 355 ##############################################################################################################356 ##ice_nwk_4nc 357 input_value = {}358 input_value['Name'] = 'ice_nwk_4nc_piecewise_steps' 359 input_value['Value'] = piecewise_steps360 input_value['Unit'] = '-'361 362 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]363 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])364 mdv_slave_param = mdv_slave_param.append(temp_df, ignore_index=True) 365 366 input_value = {}367 input_value['Name'] = 'ice_nwk_4nc_tenwkflow' 368 input_value['Value'] = var_converted[1]369 input_value['Unit'] = 'm3/h'370 371 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]372 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])373 mdv_slave_param = mdv_slave_param.append(temp_df, ignore_index=True) 374 375 ##############################################################################################################376 ##pfa_nwk_4nc 377 input_value = {}378 input_value['Name'] = 'pfa_nwk_4nc_piecewise_steps' 379 input_value['Value'] = piecewise_steps380 input_value['Unit'] = '-'381 382 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]383 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])384 mdv_slave_param = mdv_slave_param.append(temp_df, ignore_index=True) 385 386 input_value = {}387 input_value['Name'] = 'pfa_nwk_4nc_tenwkflow' 388 input_value['Value'] = var_converted[1]389 input_value['Unit'] = 'm3/h'390 391 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]392 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])393 mdv_slave_param = mdv_slave_param.append(temp_df, ignore_index=True) 394 ##############################################################################################################395 ##pfa_substation_4nc 396 input_value = {}397 input_value['Name'] = 'pfa_substation_4nc_demand' 398 input_value['Value'] = demand['ss_pfa_demand'][0]399 input_value['Unit'] = 'kWh'400 401 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]402 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])403 mdv_slave_param = mdv_slave_param.append(temp_df, ignore_index=True) 404 input_value = {}405 input_value['Name'] = 'pfa_substation_4nc_tenwkflow' 406 input_value['Value'] = var_converted[1]407 input_value['Unit'] = 'm3/h'408 409 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]410 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])411 mdv_slave_param = mdv_slave_param.append(temp_df, ignore_index=True) 412 413 ##############################################################################################################414 ##ser_nwk_4nc 415 input_value = {}416 input_value['Name'] = 'ser_nwk_4nc_piecewise_steps' 417 input_value['Value'] = piecewise_steps418 input_value['Unit'] = '-'419 420 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]421 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])422 mdv_slave_param = mdv_slave_param.append(temp_df, ignore_index=True) 423 424 input_value = {}425 input_value['Name'] = 'ser_nwk_4nc_tenwkflow' 426 input_value['Value'] = var_converted[1]427 input_value['Unit'] = 'm3/h'428 429 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]430 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])431 mdv_slave_param = mdv_slave_param.append(temp_df, ignore_index=True) 432 ##############################################################################################################433 ##ser_substation_4nc 434 input_value = {}435 input_value['Name'] = 'ser_substation_4nc_demand' 436 input_value['Value'] = demand['ss_ser_demand'][0]437 input_value['Unit'] = 'kWh'438 439 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]440 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])441 mdv_slave_param = mdv_slave_param.append(temp_df, ignore_index=True) 442 input_value = {}443 input_value['Name'] = 'ser_substation_4nc_tenwkflow' 444 input_value['Value'] = var_converted[1]445 input_value['Unit'] = 'm3/h'446 447 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]448 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])449 mdv_slave_param = mdv_slave_param.append(temp_df, ignore_index=True) 450 451 ##############################################################################################################452 ##tro_nwk_4nc 453 input_value = {}454 input_value['Name'] = 'tro_nwk_4nc_piecewise_steps' 455 input_value['Value'] = piecewise_steps456 input_value['Unit'] = '-'457 458 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]459 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])460 mdv_slave_param = mdv_slave_param.append(temp_df, ignore_index=True) 461 462 input_value = {}463 input_value['Name'] = 'tro_nwk_4nc_tenwkflow' 464 input_value['Value'] = var_converted[1]465 input_value['Unit'] = 'm3/h'466 467 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]468 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])469 mdv_slave_param = mdv_slave_param.append(temp_df, ignore_index=True)470 471 return mdv_slave_param...

Full Screen

Full Screen

units.py

Source:units.py Github

copy

Full Screen

1import numpy as np2import sys3import json4def fetch_unit_list(cur):5 #TODO Fetch from db and parse as a dict of dicts6 cur.execute('USE unit_list_chembddb;')7 cur.execute('SELECT unit_str from MAIN where id=1;')8 unit_list = cur.fetchall()9 print(unit_list)10 unit_list = json.loads(unit_list[0][0])11 return unit_list12def create_unit_list(cur,con):13 property_list = {14 'density':{'g/cm^3 (default)': 1.0, 'kg/m^3': 0.001, 'lb/ft^3': 62.43, 'lb/gal' : 8.35, 'kg/litre': 1.0},15 'energy':{'eV (default)': 1.0, 'Eh': 0.036749, 'J':1.6022e-19, 'Cal/mol':23061.0, 'J/mol':96487.0,'kJ/mol':96.487,'kJ':1.6022e-22,'kCal/mol':23.061, 'Cal':3.8293E-20,'kCal':3.83E-23},16 'polarizability':{'Bohr^3 (default)': 1.0, 'Angstrom': 0.14819},17 'solubility parameters':{'Cal^1/2 cm^-3/2 (default)': 1.0, 'J^1/2 m^-3/2': 2.05 * 10**3, 'MPa^1/2': 2.045},18 'dipole moment':{'Debye (default)': 1.0, 'C-m': 3.34 * 10**30, 'esu-cm': 1 * 10**-18, 'au': 0.3935},19 'quadrupole moment':{'C/m^2 (default)': 1.0, 'C/cm^2': 10000},20 'ratio': {'NA':1.0}21 }22 23 cur.execute('CREATE DATABASE unit_list_chembddb;')24 cur.execute('CREATE TABLE unit_list_chembddb.Main(`id` INT NOT NULL AUTO_INCREMENT, `unit_str` VARCHAR(10000) DEFAULT \'NONE\', PRIMARY KEY (`id`));')25 insert_unit_list(cur,con,property_list)26 return property_list27def insert_unit_list(cur,con,property_list):28 fordb = json.dumps(property_list)29 cur.execute('USE unit_list_chembddb;')30 cur.execute('INSERT INTO Main(id, unit_str) VALUE(1,%s);',[fordb])31 con.commit()32def unit_converter(prop, input_unit, input_val, output_unit):33 f1 = False34 if type(input_value) == float or type(input_value) == list:35 f1 = True36 37 if f1 == False:38 print("Please enter a valid data type of float or list")39 sys.exit()40 41 42 output_value = []43 density = {'g/cm^3': 1.0, 'kg/m^3': 1000.0, 'lb/ft^3': 62.43, 'lb/gal' : 8.35, 'kg/litre': 1.0}44 #dynamic_viscosity = {'kg_per_meter_second': 1.0, 'Poise': 0.1}45 #kinematic_viscosity = {'Stoke': 1.0, 'm^2_per_second': 1*10**-3}46 #mw = {'gram_per_mol': 1.0, 'kg_per_mol': 0.001, 'lb_per_mol' : 0.002205}47 #vdwr = {'pm': 1.0, 'angstrom': 0.01, 'm' : 1* 10**-12, 'cm': 1*10**-10, 'mm': 1*10**-9}48 #ir = {'pm': 1.0, 'angstrom': 0.01, 'm' : 1* 10**-12, 'cm': 1*10**-10, 'mm': 1*10**-9}49 en = {'eV': 1.0, 'Eh': 0.036749, 'J':1.6022e-19, 'Cal/mol':23061.0, 'J/mol':96487.0,'kJ/mol':96.487,'kJ':1.6022e-22,'kCal/mol':23.061, 'Cal':3.8293E-20,'kCal':3.83E-23}50 #pres = {'bar': 1.0, 'Pa': 1* 10**5, 'mmHg' : 750.062, 'psi': 14.5, 'atm': 0.987, 'torr': 750.062}51 #am = {'Da': 1.0, 'kg': 1.66 * 10**-27, 'amu' : 182.888, 'MeV_per_csquare': 931.494}52 pv = {'Bohr^3': 1.0, 'Angstrom': 0.14819}53 sp = {'Cal^1/2 cm^-3/2': 1.0, 'J^1/2 m^-3/2': 2.05 * 10**3, 'MPa^1/2': 2.045}54 dm = {'Debye': 1.0, 'C-m': 3.34 * 10**30, 'esu-cm': 1 * 10**-18, 'au': 0.3935}55 qm = {'C/m^2': 1.0, 'C/cm^2': 10000}56 57 # Unit conversion for density58 if prop.lower() in ['density','number density']:59 #output_value = []60 61 if type(input_value) == list:62 input_val = list(input_value)63 for value in input_val:64 if input_unit == 'gram_per_cm^3':65 t1 = density[output_unit]66 cal = t1 * value67 output_value.append(cal)68 else:69 #Converting to reference units70 t1 = (1 / density[input_unit]) * value71 t2 = t1 * density[output_unit]72 output_value.append(t2)73 74 75 if type(input_value) == float:76 if input_unit == 'gram_per_cm^3':77 t1 = density[output_unit]78 cal = t1 * input_value79 output_value.append(cal)80 else:81 t1 = (1/ density[input_unit]) * input_value82 t2 = t1 * density[output_unit]83 output_value.append(t2)84 85 # Unit conversion for dynamic viscosity 86 #if prop.lower() == 'dynamic_viscosity':87 88 # #output_value = []89 90 # if type(input_value) == list:91 # input_val = list(input_value)92 # for value in input_val:93 # if input_unit == 'kg_per_meter_second':94 # t1 = dynamic_viscosity[output_unit]95 # cal = t1 * value96 # output_value.append(cal)97 # else:98 # t1 = (1 / dyanmic_viscosity[input_unit]) * value99 # t2 = t1 * dynamic_viscosity[output_unit]100 # output_value.append(t2)101 102 103 # if type(input_value) == float:104 # if input_unit == 'kg_per_meter_second':105 # t1 = dynamic_viscosity[output_unit]106 # cal = t1 * input_value107 # output_value.append(cal)108 # else:109 # t1 = (1/dynamic_viscosity[input_unit]) * input_value110 # t2 = t1 * dynamic_viscosity[output_unit]111 # output_value.append(t2) 112 113 # Unit conversion for kinematic viscosity 114 #if prop == 'kinematic_viscosity':115 116 # #output_value = []117 118 # if type(input_value) == list:119 # input_val = list(input_value)120 # for value in input_val:121 # if input_unit == 'Stoke':122 # t1 = kinematic_viscosity[output_unit]123 # cal = t1 * value124 # output_value.append(cal)125 # else:126 # t1 = (1 /kinematic_viscosity[input_unit])* value127 # t2 = t1 * kinematic_viscosity[output_unit]128 # output_value.append(t2)129 130 131 # if type(input_value) == float:132 # if input_unit == 'Stoke':133 # t1 = Kinematic_viscosity[output_unit]134 # cal = t1 * input_value135 # output_value.append(cal)136 # else:137 # t1 = (1/kinematic_viscosity[input_unit]) * input_value138 # t2 = t1 * kinematic_viscosity[output_unit]139 # output_value.append(t2)140 141 # Unit conversion for Molecular Weight 142 #if prop == 'Molecular Weight':143 144 # #output_value = []145 146 # if type(input_value) == list:147 # input_val = list(input_value)148 # for value in input_val:149 # if input_unit == 'gram_per_mol':150 # t1 = mw[output_unit]151 # cal = t1 * value152 # output_value.append(cal)153 # else:154 # t1 = (1 / mw[input_unit])* value155 # t2 = t1 * mw[output_unit]156 # output_value.append(t2)157 158 159 # if type(input_value) == float:160 # if input_unit == 'gram_per_mol':161 # t1 = mw[output_unit]162 # cal = t1 * input_value163 # output_value.append(cal)164 # else:165 # t1 = (1/ mw[input_unit])*input_value166 # t2 = t1 * mw[output_unit]167 # output_value.append(t2) 168 169 # Unit conversion for Van Der Waals Radius 170 #if prop == 'Van Der Waals Radius':171 172 # #output_value = []173 174 # if type(input_value) == list:175 # input_val = list(input_value)176 # for value in input_val:177 # if input_unit == 'pm':178 # t1 = vdwr[output_unit]179 # cal = t1 * value180 # output_value.append(cal)181 # else:182 # t1 = (1 /vdwr[input_unit])* value183 # t2 = t1 * vdwr[output_unit]184 # output_value.append(t2)185 186 187 # if type(input_value) == float:188 # if input_unit == 'pm':189 # t1 = vdwr[output_unit]190 # cal = t1 * input_value191 # output_value.append(cal)192 # else:193 # t1 = (1/vdwr[input_unit])* input_value194 # t2 = t1 * vdwr[output_unit]195 # output_value.append(t2)196 197 # Unit conversion for Ionic Radius 198 #if prop == 'Ionic Radius':199 200 # #output_value = []201 202 # if type(input_value) == list:203 # input_val = list(input_value)204 # for value in input_val:205 # if input_unit == 'pm':206 # t1 = ir[output_unit]207 # cal = t1 * value208 # output_value.append(cal)209 # else:210 # t1 = (1/ir[input_unit])*value211 # t2 = t1 * ir[output_unit]212 # output_value.append(t2)213 214 215 # if type(input_value) == float:216 # if input_unit == 'pm':217 # t1 = ir[output_unit]218 # cal = t1 * input_value219 # output_value.append(cal)220 # else:221 # t1 = (1/ir[input_unit])* input_value222 # t2 = t1 * ir[output_unit]223 # output_value.append(t2)224 225 # Unit conversion for Energy 226 if prop.lower() == 'energy':227 228 #output_value = []229 230 if type(input_value) == list:231 input_val = list(input_value)232 for value in input_val:233 if input_unit == 'Joules':234 t1 = en[output_unit]235 cal = t1 * value236 output_value.append(cal)237 else:238 t1 = (1 /en[input_unit]) * value239 t2 = t1 * en[output_unit]240 output_value.append(t2)241 242 243 if type(input_value) == float:244 if input_unit == 'Joules':245 t1 = en[output_unit]246 cal = t1 * input_value247 output_value.append(cal)248 else:249 t1 = (1/en[input_unit])* input_value250 t2 = t1 * en[output_unit]251 output_value.append(t2)252 253 # Unit conversion for Pressure 254 if prop == 'Pressure':255 256 #output_value = []257 258 if type(input_value) == list:259 input_val = list(input_value)260 for value in input_val:261 if input_unit == 'bar':262 t1 = pres[output_unit]263 cal = t1 * value264 output_value.append(cal)265 else:266 t1 = (1 /pres[input_unit])* value267 t2 = t1 * pres[output_unit]268 output_value.append(t2)269 270 271 if type(input_value) == float:272 if input_unit == 'bar':273 t1 = pres[output_unit]274 cal = t1 * input_value275 output_value.append(cal)276 else:277 t1 = (1/pres[input_unit]) * input_value278 t2 = t1 * pres[output_unit]279 output_value.append(t2)280 281 # Unit conversion for Atomic Mass 282 if prop == 'Atomic Mass':283 284 #output_value = []285 286 if type(input_value) == list:287 input_val = list(input_value)288 for value in input_val:289 if input_unit == 'Da':290 t1 = am[output_unit]291 cal = t1 * value292 output_value.append(cal)293 else:294 t1 = (1 /am[input_unit])* value295 t2 = t1 * am[output_unit]296 output_value.append(t2)297 298 299 if type(input_value) == float:300 if input_unit == 'Da':301 t1 = am[output_unit]302 cal = t1 * input_value303 output_value.append(cal)304 else:305 t1 = (1/am[input_unit])* input_value306 t2 = t1 * am[output_unit]307 output_value.append(t2)308 309 # Unit conversion for Polarizability Volume 310 if prop.lower() == 'polarizability':311 312 #output_value = []313 314 if type(input_value) == list:315 input_val = list(input_value)316 for value in input_val:317 if input_unit == 'Bohr^3':318 t1 = pv[output_unit]319 cal = t1 * value320 output_value.append(cal)321 else:322 t1 = (1 /pv[input_unit]) * value323 t2 = t1 * pv[output_unit]324 output_value.append(t2)325 326 327 if type(input_value) == float:328 if input_unit == 'Bohr^3':329 t1 = pv[output_unit]330 cal = t1 * input_value331 output_value.append(cal)332 else:333 t1 = (1/pv[input_unit])* input_value334 t2 = t1 * pv[output_unit]335 output_value.append(t2)336 337 # Unit conversion for Solubility Parameter 338 if prop.lower() == 'solubility parameter':339 340 #output_value = []341 342 if type(input_value) == list:343 input_val = list(input_value)344 for value in input_val:345 if input_unit == 'cal^1/2 cm^-3/2':346 t1 = sp[output_unit]347 cal = t1 * value348 output_value.append(cal)349 else:350 t1 = (1/sp[input_unit]) *value351 t2 = t1 * sp[output_unit]352 output_value.append(t2)353 354 355 if type(input_value) == float:356 if input_unit == 'cal^1/2 cm^-3/2':357 t1 = sp[output_unit]358 cal = t1 * input_value359 output_value.append(cal)360 else:361 t1 = (1/sp[input_unit]) *input_value362 t2 = t1 * sp[output_unit]363 output_value.append(t2)364 # Unit conversion for Dipole Moment 365 if prop.lower() == 'dipole moment':366 367 #output_value = []368 369 if type(input_value) == list:370 input_val = list(input_value)371 for value in input_val:372 if input_unit == 'debye':373 t1 = dm[output_unit]374 cal = t1 * value375 output_value.append(cal)376 else:377 t1 = (1 /dm[input_unit]) * value378 t2 = t1 * dm[output_unit]379 output_value.append(t2)380 381 382 if type(input_value) == float:383 if input_unit == 'debye':384 t1 = dm[output_unit]385 cal = t1 * input_value386 output_value.append(cal)387 else:388 t1 = (1/dm[input_unit])* input_value389 t2 = t1 * dm[output_unit]390 output_value.append(t2)391 # Unit conversion for Quadrupole Moment 392 if prop.lower() == 'quadrupole moment':393 394 #output_value = []395 396 if type(input_value) == list:397 input_val = list(input_value)398 for value in input_val:399 if input_unit == 'coulomb_per_m^2':400 t1 = qm[output_unit]401 cal = t1 * value402 output_value.append(cal)403 else:404 t1 = (1 /qm[input_unit]) * value405 t2 = t1 * qm[output_unit]406 output_value.append(t2)407 408 409 if type(input_value) == float:410 if input_unit == 'coulomb_per_m^2':411 t1 = qm[output_unit]412 cal = t1 * input_value413 output_value.append(cal)414 else:415 t1 = (1/qm[input_unit])* input_value416 t2 = t1 * qm[output_unit]417 output_value.append(t2)418 419 # Unit conversion for Temperature 420 if prop.lower() == 'temperature':421 #output_value = []422 423 if type(input_value) == list:424 input_val = list(input_value)425 for value in input_val:426 if input_unit == 'K':427 if output_unit == 'C':428 cal = value -273.15429 output_value.append(cal)430 if output_unit == 'F':431 cal = (value - 273.15) * 9/5 + 32432 output_value.append(cal)433 elif input_unit == 'C':434 if output_unit == 'K':435 cal = value + 273.15436 output_value.append(cal)437 if output_unit == 'F':438 cal = (value * 9/5) + 32439 output_value.append(cal)440 elif input_unit == 'F':441 if output_unit == 'C':442 cal = (value - 32) * 5/9443 output_value.append(cal)444 if output_unit == 'K':445 cal = (value - 32) * 5/9 + 273.15446 output_value.append(cal)447 448 if type(input_value) == float:449 if input_unit == 'K':450 if output_unit == 'C':451 cal = input_value -273.15452 output_value.append(cal)453 if output_unit == 'F':454 cal = (input_value - 273.15) * 9/5 + 32455 output_value.append(cal)456 elif input_unit == 'C':457 if output_unit == 'K':458 cal = inpput_value + 273.15459 output_value.append(cal)460 if output_unit == 'F':461 cal = (input_value * 9/5) + 32462 output_value.append(cal)463 elif input_unit == 'F':464 if output_unit == 'C':465 cal = (input_value - 32) * 5/9466 output_value.append(cal)467 if output_unit == 'K':468 cal = (input_value - 32) * 5/9 + 273.15469 output_value.append(cal)470 ...

Full Screen

Full Screen

mrs_manual_edit.py

Source:mrs_manual_edit.py Github

copy

Full Screen

1##This script contains functions which need to be manually edited for the solver to run 2##This function takes in manual inputs from the used to build the parameters for the MILP solver 3def mrs_manual_edit_milp_param (cooling_load_data, weather_condition, ga_inputs, piecewise_linear_steps):4 5 ##cooling_load_data --- the associated cooling load data 6 ##weather_condition --- the associated weather condition7 ##ga_inputs --- inputs from the genetic algorithm8 ##piecewise_linear_steps --- the number of pieces used to linearize the models 9 import pandas as pd 10 11 ##Manually some input parameters 12 cond_temp = weather_condition['T_WB'][0] + 5 + 273.15 ##Just an assumption for the condenser temperature 13 14 ##Initiate a dataframe to hold values 15 milp_param = pd.DataFrame(columns = ['Name', 'Value', 'Unit'])16 17 ##############################################################################################################18 ##chiller_evap_flow_consol 19 input_value = {}20 input_value['Name'] = 'chiller_evap_flow_consol_tenwkflow' ##Name of the parameter format = <model name>_<parameter name>21 input_value['Value'] = ga_inputs['evap_flow'][0] ##Value of the parameter22 input_value['Unit'] = 'm3/h' ##Units of the parameter23 24 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]25 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])26 milp_param = milp_param.append(temp_df, ignore_index=True) 27 28 ############################################################################################################## 29 ##chiller_ret30 input_value = {}31 input_value['Name'] = 'chiller_ret_etret' 32 input_value['Value'] = ga_inputs['tin_evap'][0]33 input_value['Unit'] = 'K'34 35 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]36 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])37 milp_param = milp_param.append(temp_df, ignore_index=True) 38 39 ##############################################################################################################40 ##chiller1_evap 41 input_value = {}42 input_value['Name'] = 'chiller1_evap_etret' 43 input_value['Value'] = ga_inputs['tin_evap'][0]44 input_value['Unit'] = 'K'45 46 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]47 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])48 milp_param = milp_param.append(temp_df, ignore_index=True) 49 50 input_value = {}51 input_value['Name'] = 'chiller1_evap_ctin' 52 input_value['Value'] = cond_temp53 input_value['Unit'] = 'K'54 55 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]56 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])57 milp_param = milp_param.append(temp_df, ignore_index=True) 58 59 input_value = {}60 input_value['Name'] = 'chiller1_evap_tenwkflow' 61 input_value['Value'] = ga_inputs['evap_flow'][0]62 input_value['Unit'] = 'm3/h'63 64 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]65 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])66 milp_param = milp_param.append(temp_df, ignore_index=True) 67 68 input_value = {}69 input_value['Name'] = 'chiller1_evap_piecewise_steps' 70 input_value['Value'] = piecewise_linear_steps71 input_value['Unit'] = '-'72 73 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]74 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])75 milp_param = milp_param.append(temp_df, ignore_index=True) 76 77 ############################################################################################################## 78 ##chiller1_evap_nwk79 input_value = {}80 input_value['Name'] = 'chiller1_evap_nwk_piecewise_steps' 81 input_value['Value'] = piecewise_linear_steps82 input_value['Unit'] = '-'83 84 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]85 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])86 milp_param = milp_param.append(temp_df, ignore_index=True) 87 input_value = {}88 input_value['Name'] = 'chiller1_evap_nwk_tenwkflow' 89 input_value['Value'] = ga_inputs['evap_flow'][0]90 input_value['Unit'] = 'm3/h'91 92 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]93 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])94 milp_param = milp_param.append(temp_df, ignore_index=True)95 ##############################################################################################################96 ##chiller1_evap_pump 97 input_value = {}98 input_value['Name'] = 'chiller1_evap_pump_piecewise_steps' 99 input_value['Value'] = piecewise_linear_steps100 input_value['Unit'] = '-'101 102 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]103 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])104 milp_param = milp_param.append(temp_df, ignore_index=True) 105 ############################################################################################################## 106 ##chiller2_evap107 input_value = {}108 input_value['Name'] = 'chiller2_evap_etret' 109 input_value['Value'] = ga_inputs['tin_evap'][0]110 input_value['Unit'] = 'K'111 112 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]113 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])114 milp_param = milp_param.append(temp_df, ignore_index=True) 115 input_value = {}116 input_value['Name'] = 'chiller2_evap_ctin' 117 input_value['Value'] = cond_temp118 input_value['Unit'] = 'K'119 120 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]121 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])122 milp_param = milp_param.append(temp_df, ignore_index=True) 123 124 input_value = {}125 input_value['Name'] = 'chiller2_evap_tenwkflow' 126 input_value['Value'] = ga_inputs['evap_flow'][0]127 input_value['Unit'] = 'm3/h'128 129 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]130 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])131 milp_param = milp_param.append(temp_df, ignore_index=True) 132 133 input_value = {}134 input_value['Name'] = 'chiller2_evap_piecewise_steps' 135 input_value['Value'] = piecewise_linear_steps136 input_value['Unit'] = '-'137 138 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]139 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])140 milp_param = milp_param.append(temp_df, ignore_index=True) 141 ############################################################################################################## 142 ##chiller2_evap_nwk143 input_value = {}144 input_value['Name'] = 'chiller2_evap_nwk_piecewise_steps' 145 input_value['Value'] = piecewise_linear_steps146 input_value['Unit'] = '-'147 148 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]149 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])150 milp_param = milp_param.append(temp_df, ignore_index=True) 151 input_value = {}152 input_value['Name'] = 'chiller2_evap_nwk_tenwkflow' 153 input_value['Value'] = ga_inputs['evap_flow'][0]154 input_value['Unit'] = 'm3/h'155 156 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]157 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])158 milp_param = milp_param.append(temp_df, ignore_index=True) 159 160 ##############################################################################################################161 ##chiller2_evap_pump 162 input_value = {}163 input_value['Name'] = 'chiller2_evap_pump_piecewise_steps' 164 input_value['Value'] = piecewise_linear_steps165 input_value['Unit'] = '-'166 167 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]168 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])169 milp_param = milp_param.append(temp_df, ignore_index=True) 170 171 ##############################################################################################################172 ##cp_nwk 173 input_value = {}174 input_value['Name'] = 'cp_nwk_tenwkflow' 175 input_value['Value'] = ga_inputs['evap_flow'][0]176 input_value['Unit'] = 'm3/h'177 178 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]179 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])180 milp_param = milp_param.append(temp_df, ignore_index=True) 181 182 ##############################################################################################################183 ##dist_nwk_pump 184 input_value = {}185 input_value['Name'] = 'dist_nwk_pump_choice' ##There are 2 pumps to choose from pump 0 and pump 1186 input_value['Value'] = 0187 input_value['Unit'] = '-'188 189 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]190 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])191 milp_param = milp_param.append(temp_df, ignore_index=True) 192 193 input_value = {}194 input_value['Name'] = 'dist_nwk_pump_piecewise_steps' 195 input_value['Value'] = piecewise_linear_steps196 input_value['Unit'] = '-'197 198 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]199 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])200 milp_param = milp_param.append(temp_df, ignore_index=True) 201 202 ##############################################################################################################203 ##gv2_nwk 204 input_value = {}205 input_value['Name'] = 'gv2_nwk_piecewise_steps' 206 input_value['Value'] = piecewise_linear_steps207 input_value['Unit'] = '-'208 209 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]210 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])211 milp_param = milp_param.append(temp_df, ignore_index=True) 212 213 input_value = {}214 input_value['Name'] = 'gv2_nwk_tenwkflow' 215 input_value['Value'] = ga_inputs['evap_flow'][0]216 input_value['Unit'] = 'm3/h'217 218 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]219 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])220 milp_param = milp_param.append(temp_df, ignore_index=True) 221 ##############################################################################################################222 ##gv2_substation223 input_value = {}224 input_value['Name'] = 'gv2_substation_demand' 225 input_value['Value'] = cooling_load_data['gv2_ss'][0]226 input_value['Unit'] = 'kWh'227 228 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]229 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])230 milp_param = milp_param.append(temp_df, ignore_index=True) 231 input_value = {}232 input_value['Name'] = 'gv2_substation_tenwkflow' 233 input_value['Value'] = ga_inputs['evap_flow'][0]234 input_value['Unit'] = 'm3/h'235 236 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]237 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])238 milp_param = milp_param.append(temp_df, ignore_index=True) 239 240 ##############################################################################################################241 ##hsb_nwk 242 input_value = {}243 input_value['Name'] = 'hsb_nwk_piecewise_steps' 244 input_value['Value'] = piecewise_linear_steps245 input_value['Unit'] = '-'246 247 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]248 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])249 milp_param = milp_param.append(temp_df, ignore_index=True) 250 251 input_value = {}252 input_value['Name'] = 'hsb_nwk_tenwkflow' 253 input_value['Value'] = ga_inputs['evap_flow'][0]254 input_value['Unit'] = 'm3/h'255 256 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]257 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])258 milp_param = milp_param.append(temp_df, ignore_index=True) 259 260 ##############################################################################################################261 ##hsb_substation 262 input_value = {}263 input_value['Name'] = 'hsb_substation_demand' 264 input_value['Value'] = cooling_load_data['hsb_ss'][0]265 input_value['Unit'] = 'kWh'266 267 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]268 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])269 milp_param = milp_param.append(temp_df, ignore_index=True) 270 input_value = {}271 input_value['Name'] = 'hsb_substation_tenwkflow' 272 input_value['Value'] = ga_inputs['evap_flow'][0]273 input_value['Unit'] = 'm3/h'274 275 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]276 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])277 milp_param = milp_param.append(temp_df, ignore_index=True) 278 ##############################################################################################################279 ##ice_nwk 280 input_value = {}281 input_value['Name'] = 'ice_nwk_piecewise_steps' 282 input_value['Value'] = piecewise_linear_steps283 input_value['Unit'] = '-'284 285 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]286 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])287 milp_param = milp_param.append(temp_df, ignore_index=True) 288 289 input_value = {}290 input_value['Name'] = 'ice_nwk_tenwkflow' 291 input_value['Value'] = ga_inputs['evap_flow'][0]292 input_value['Unit'] = 'm3/h'293 294 temp_values = [input_value['Name'], input_value['Value'], input_value['Unit']]295 temp_df = pd.DataFrame(data = [temp_values], columns = ['Name', 'Value', 'Unit'])296 milp_param = milp_param.append(temp_df, ignore_index=True) ...

Full Screen

Full Screen

omm_readinputs.py

Source:omm_readinputs.py Github

copy

Full Screen

1"""2Generated by CHARMM-GUI (http://www.charmm-gui.org)3omm_readinputs.py4This module is for reading inputs in OpenMM.5Correspondance: jul316@lehigh.edu or wonpil@lehigh.edu6Last update: March 29, 20177"""8from simtk.unit import *9from simtk.openmm import *10from simtk.openmm.app import *11class _OpenMMReadInputs():12 def __init__(self):13 self.mini_nstep = 0 # Number of steps for minimization14 self.mini_Tol = 1.0 # Minimization energy tolerance15 self.gen_vel = 'no' # Generate initial velocities16 self.gen_temp = 300.0 # Temperature for generating initial velocities (K)17 self.gen_seed = None # Seed for generating initial velocities18 self.nstep = 0 # Number of steps to run19 self.dt = 0.001 # Time-step (ps)20 self.nstout = 100 # Writing output frequency (steps)21 self.nstdcd = 0 # Wrtiing coordinates trajectory frequency (steps)22 self.coulomb = PME # Electrostatic cut-off method23 self.ewald_Tol = 0.0005 # Ewald error tolerance24 self.vdw = 'Switch' # vdW cut-off method25 self.r_on = 1.0 # Switch-on distance (nm)26 self.r_off = 1.2 # Switch-off distance (nm)27 self.temp = 300.0 # Temperature (K)28 self.fric_coeff = 5 # Friction coefficient for Langevin dynamics29 self.drude_temp = 1.0 # Drude Temperature (K)30 self.drude_fric_coeff = 20 # Drude Friction coefficient for Langevin dynamics31 self.drude_hardwall = 0.025 # Drude Hardwall32 self.pcouple = 'no' # Turn on/off pressure coupling33 self.p_ref = 1.0 # Pressure (Pref or Pxx, Pyy, Pzz; bar)34 self.p_type = 'membrane' # MonteCarloBarotat type35 self.p_scale = True, True, True # For MonteCarloAnisotropicBarostat36 self.p_XYMode = MonteCarloMembraneBarostat.XYIsotropic # For MonteCarloMembraneBarostat37 self.p_ZMode = MonteCarloMembraneBarostat.ZFree # For MonteCarloMembraneBarostat38 self.p_tens = 0.0 # Sulface tension for MonteCarloMembraneBarostat (dyne/cm)39 self.p_freq = 15 # Pressure coupling frequency (steps)40 self.cons = HBonds # Constraints method41 self.rest = 'no' # Turn on/off restraints42 self.fc_pos = 0.0 # Positional restraint force constant43 def read(self, inputFile):44 for line in open(inputFile, 'r'):45 if line.find('#') >= 0: line = line.split('#')[0]46 line = line.strip()47 if len(line) > 0:48 segments = line.split('=')49 input_param = segments[0].upper().strip()50 try: input_value = segments[1].strip()51 except: input_value = None52 if input_value:53 if input_param == 'MINI_NSTEP': self.mini_nstep = int(input_value)54 if input_param == 'MINI_TOL': self.mini_Tol = float(input_value)55 if input_param == 'GEN_VEL':56 if input_value.upper() == 'YES': self.gen_vel = 'yes'57 if input_value.upper() == 'NO': self.gen_vel = 'no'58 if input_param == 'GEN_TEMP': self.gen_temp = float(input_value)59 if input_param == 'GEN_SEED': self.gen_seed = int(input_value)60 if input_param == 'NSTEP': self.nstep = int(input_value)61 if input_param == 'DT': self.dt = float(input_value)62 if input_param == 'NSTOUT': self.nstout = int(input_value)63 if input_param == 'NSTDCD': self.nstdcd = int(input_value)64 if input_param == 'COULOMB':65 if input_value.upper() == 'NOCUTOFF': self.coulomb = NoCutoff66 if input_value.upper() == 'CUTOFFNONPERIODIC': self.coulomb = CutoffNonPeriodic67 if input_value.upper() == 'CUTOFFPERIODIC': self.coulomb = CutoffPeriodic68 if input_value.upper() == 'EWALD': self.coulomb = Ewald69 if input_value.upper() == 'PME': self.coulomb = PME70 if input_param == 'EWALD_TOL': self.ewald_Tol = float(input_value)71 if input_param == 'VDW':72 if input_value.upper() == 'FORCE-SWITCH': self.vdw = 'Force-switch'73 if input_value.upper() == 'SWITCH': self.vdw = 'Switch'74 if input_value.upper() == 'LJPME': self.vdw = 'LJPME'75 if input_param == 'R_ON': self.r_on = float(input_value)76 if input_param == 'R_OFF': self.r_off = float(input_value)77 if input_param == 'TEMP': self.temp = float(input_value)78 if input_param == 'FRIC_COEFF': self.fric_coeff = float(input_value)79 if input_param == 'DRUDE_TEMP': self.drude_temp = float(input_value)80 if input_param == 'DRUDE_FRIC_COEFF': self.drude_fric_coeff = float(input_value)81 if input_param == 'DRUDE_HARDWALL': self.drude_hardwall = float(input_value)82 if input_param == 'PCOUPLE':83 if input_value.upper() == 'YES': self.pcouple = 'yes'84 if input_value.upper() == 'NO': self.pcouple = 'no'85 if input_param == 'P_REF':86 if input_value.find(',') < 0:87 self.p_ref = float(input_value)88 else:89 Pxx = float(input_value.split(',')[0])90 Pyy = float(input_value.split(',')[1])91 Pzz = float(input_value.split(',')[2])92 self.p_ref = Pxx, Pyy, Pzz93 if input_param == 'P_TYPE':94 if input_value.upper() == 'ISOTROPIC': self.p_type = 'isotropic'95 if input_value.upper() == 'MEMBRANE': self.p_type = 'membrane'96 if input_value.upper() == 'ANISOTROPIC': self.p_type = 'anisotropic'97 if input_param == 'P_SCALE':98 scaleX = True99 scaleY = True100 scaleZ = True101 if input_value.upper().find('X') < 0: scaleX = False102 if input_value.upper().find('Y') < 0: scaleY = False103 if input_value.upper().find('Z') < 0: scaleZ = False104 self.p_scale = scaleX, scaleY, scaleZ105 if input_param == 'P_XYMODE':106 if input_value.upper() == 'XYISOTROPIC': self.p_XYMode = MonteCarloMembraneBarostat.XYIsotropic107 if input_value.upper() == 'XYANISOTROPIC': self.p_XYMode = MonteCarloMembraneBarostat.XYAnisotropic108 if input_param == 'P_ZMODE':109 if input_value.upper() == 'ZFREE': self.p_ZMode = MonteCarloMembraneBarostat.ZFree110 if input_value.upper() == 'ZFIXED': self.p_ZMode = MonteCarloMembraneBarostat.ZFixed111 if input_value.upper() == 'CONSTANTVOLUME': self.p_ZMode = MonteCarloMembraneBarostat.ConstantVolume112 if input_param == 'P_TENS': self.p_tens = float(input_value)113 if input_param == 'P_FREQ': self.p_freq = int(input_value)114 if input_param == 'CONS':115 if input_value.upper() == 'NONE': self.cons = None116 if input_value.upper() == 'HBONDS': self.cons = HBonds117 if input_value.upper() == 'ALLBONDS': self.cons = AllBonds118 if input_value.upper() == 'HANGLES': self.cons = HAngles119 if input_param == 'REST':120 if input_value.upper() == 'YES': self.rest = 'yes'121 if input_value.upper() == 'NO': self.rest = 'no'122 if input_param == 'FC_POS': self.fc_pos = float(input_value)123 return self124def read_inputs(inputFile):...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run robotframework-appiumlibrary automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful