-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmain.py
More file actions
68 lines (50 loc) · 2.08 KB
/
main.py
File metadata and controls
68 lines (50 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
__author__ = 'mustafa_dogan'
from model import *
plants = [
'Shasta',
'Keswick',
# 'Oroville',
# 'Bullards Bar',
# 'Englebright',
'Folsom',
'Nimbus',
'New Melones',
# 'Don Pedro',
# 'New Exchequer',
'Pine Flat'
]
# simulation start time: year, month, day, hour, minute
start = [2010,10,1,0,0]
# simulation end time: year, month, day, hour, minute
end = [2017,10,1,0,0]
# resampling frequency for creating averages. A: annual, M: monthly, W: weekly, D: daily, H: hourly
step = ['M']
# energy price data
price_path = 'inputs/price.csv'
# inflow data
flow_path = 'inputs/inflow/inflow_cms.csv'
# you must run the model in defined time-step (frequency) first
# before using warmstart option in order to get initial values of variables
warmstart = True
# call hydropower model class
hp_model = HYDROPOWER(start,end,step,overall_average=False,warmstart=warmstart,flow_path=flow_path,price_path=price_path,plants=plants)
# ************ Linear Model ************
# preprocess to create input network matrix
hp_model.preprocess_LP(plot_benefit_curves=False)
# create pyomo hydropower lp model
hp_model.create_pyomo_LP(datadir='model/data_lp.csv',display_model=False)
# solve lp model
hp_model.solve_pyomo_LP(solver='glpk',stream_solver=True,display_model_out=False,display_raw_results=False)
# postprocess and save results as csv time-series
hp_model.postprocess(save_path='outputs/linear_model')
# ************ Nonlinear Model ************
# preprocess to create input network matrix
hp_model.preprocess_NLP(warmstart_path='outputs/nonlinear_model')
# # print network schematic
# hp_model.print_schematic(datadir='model/data_nlp.csv',ts_condensed=True)
# create pyomo hydropower model
hp_model.create_pyomo_NLP(datadir='model/data_nlp.csv',display_model=False)
# solve the model
hp_model.solve_pyomo_NLP(solver='ipopt',stream_solver=True,display_model_out=False,display_raw_results=False,max_iter=3000,mu_init=1e-9)
# postprocess and save results as csv time-series
hp_model.postprocess(save_path='outputs/nonlinear_model')