Skip to content

Commit

Permalink
update global parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhanwei-Liu committed Nov 21, 2023
1 parent 9142a32 commit 514b404
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 38 deletions.
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"price": 0.01
},
"hydro_parameters": {
"ishydro": true,
"isinflow": true,
"error_threshold": 0.001,
"iteration_number": 3
},
Expand Down
72 changes: 36 additions & 36 deletions params.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@
"first_col_only": false,
"drop_na": true
},
"hydropower": {
"file_name": "hydropower",
"predefined_hydropower": {
"file_name": "predefined_hydropower",
"index_cols": [0, 1, 2],
"header_rows": [0, 1],
"unstack_levels": [0, 1, 2],
Expand Down Expand Up @@ -159,48 +159,48 @@
"first_col_only": true,
"drop_na": true
},
"static": {
"file_name": "static",
"reservoir_characteristics": {
"file_name": "reservoir_characteristics",
"index_cols": [0],
"header_rows": [0],
"unstack_levels": [-1],
"first_col_only": false,
"drop_na": false
},
"storage_downbound": {
"file_name": "storage_downbound",
"reservoir_storage_upper_bound": {
"file_name": "reservoir_storage_upper_bound",
"index_cols": [0, 1],
"header_rows": [0],
"unstack_levels": [0, 1],
"first_col_only": false,
"drop_na": true
},
"storage_end": {
"file_name": "storage_end",
"index_cols": [0],
"reservoir_storage_lower_bound": {
"file_name": "reservoir_storage_lower_bound",
"index_cols": [0, 1],
"header_rows": [0],
"unstack_levels": [0],
"unstack_levels": [0, 1],
"first_col_only": false,
"drop_na": true
},
"storage_init": {
"file_name": "storage_init",
"final_reservoir_storage_level": {
"file_name": "final_reservoir_storage_level",
"index_cols": [0],
"header_rows": [0],
"unstack_levels": [0],
"first_col_only": false,
"drop_na": true
},
"storage_upbound": {
"file_name": "storage_upbound",
"index_cols": [0, 1],
"initial_reservoir_storage_level": {
"file_name": "initial_reservoir_storage_level",
"index_cols": [0],
"header_rows": [0],
"unstack_levels": [0, 1],
"unstack_levels": [0],
"first_col_only": false,
"drop_na": true
},
"technology_fix_cost": {
"file_name": "technology_fix_cost",
"technology_fixed_OM_cost": {
"file_name": "technology_fixed_OM_cost",
"index_cols": [0],
"header_rows": [0],
"unstack_levels": [0],
Expand Down Expand Up @@ -231,48 +231,48 @@
"first_col_only": false,
"drop_na": true
},
"technology_variable_cost": {
"file_name": "technology_variable_cost",
"technology_variable_OM_cost": {
"file_name": "technology_variable_OM_cost",
"index_cols": [0],
"header_rows": [0],
"unstack_levels": [0],
"first_col_only": false,
"drop_na": true
},
"transline": {
"file_name": "transline",
"transmission_line_existing_capacity": {
"file_name": "transmission_line_existing_capacity",
"index_cols": [0],
"header_rows": [0],
"unstack_levels": [0],
"first_col_only": false,
"drop_na": true
},
"transline_efficiency": {
"file_name": "transline_efficiency",
"transmission_line_efficiency": {
"file_name": "transmission_line_efficiency",
"index_cols": [0],
"header_rows": [0],
"unstack_levels": [0],
"first_col_only": false,
"drop_na": true
},
"transline_fix_cost": {
"file_name": "transline_fix_cost",
"transmission_line_investment_cost": {
"file_name": "transmission_line_investment_cost",
"index_cols": [0],
"header_rows": [0],
"unstack_levels": [0],
"first_col_only": false,
"drop_na": true
},
"transline_investment_cost": {
"file_name": "transline_investment_cost",
"transmission_fixed_OM_cost": {
"file_name": "transmission_fixed_OM_cost",
"index_cols": [0],
"header_rows": [0],
"unstack_levels": [0],
"first_col_only": false,
"drop_na": true
},
"transline_variable_cost": {
"file_name": "transline_variable_cost",
"transmission_line_variable_OM_cost": {
"file_name": "transmission_line_variable_OM_cost",
"index_cols": [0],
"header_rows": [0],
"unstack_levels": [0],
Expand All @@ -287,24 +287,24 @@
"first_col_only": false,
"drop_na": true
},
"type": {
"file_name": "type",
"technology_type": {
"file_name": "technology_type",
"index_cols": [0],
"header_rows": [0],
"unstack_levels": null,
"first_col_only": true,
"drop_na": true
},
"zq": {
"file_name": "zq",
"reservoir_tailrace_level_discharge_function": {
"file_name": "reservoir_tailrace_level_discharge_function",
"index_cols": null,
"header_rows": [0],
"unstack_levels": null,
"first_col_only": false,
"drop_na": false
},
"zv": {
"file_name": "zv",
"reservoir_forebay_level_volume_function": {
"file_name": "reservoir_forebay_level_volume_function",
"index_cols": null,
"header_rows": [0],
"unstack_levels": null,
Expand Down
12 changes: 11 additions & 1 deletion run.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from prepshot.parameters import parse_arguments
from prepshot.solver import build_solver, solve_model
from prepshot.utils import extract_result, update_output_filename
import pandas as pd

# Name of the configuration file and parameters file in root directory.
CONFIG_FILENAME = 'config.json'
Expand Down Expand Up @@ -77,9 +78,18 @@ def run_model(parameters, output_filename, args):
solver = build_solver(parameters)
solved = solve_model(model, solver, parameters)
if solved:
ds = extract_result(model, ishydro=parameters['ishydro'])
ds = extract_result(model, isinflow=parameters['isinflow'])
ds.to_netcdf(f'{output_filename}.nc')
logging.info("Results are written to %s.nc", output_filename)
# Write results to excel files.
for key in ds.data_vars:
if len(ds[key].shape) == 0:
df = pd.DataFrame([ds[key].values.max()], columns=[key])
else:
df = ds[key].to_dataframe()
df.to_excel(f'{output_filename}_{key}.xlsx', merge_cells=False)
logging.info("Results are written to separate excel files")



def main():
Expand Down

0 comments on commit 514b404

Please sign in to comment.