-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathprecalculate_assumptions.py
118 lines (94 loc) · 4.07 KB
/
precalculate_assumptions.py
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import solve
import hashlib, json
import pandas as pd
from server import sanitise_assumptions, compute_weather_hash, compute_results_hash
countries = "country:" + pd.Index(solve.get_country_multipolygons().keys())
regions = "region:" + pd.Index(solve.get_region_multipolygons().keys())
country_names = solve.get_country_names()
locations = countries.append(regions)
years = range(2011,2013)
techs = ["solar","onwind"]
cf_exponents = [2.,1.,0.]
assumption_years = [2020,2030,2050]
base_assumptions = {"wind" : True,
"solar" : True,
"battery" : True,
"hydrogen" : True,
"dispatchable1": False,
"dispatchable2": False,
"co2_limit": False,
"dispatchable1_cost" : 400,
"dispatchable1_marginal_cost" : 50,
"dispatchable1_emissions" : 500,
"dispatchable1_discount" : 10,
"dispatchable2_cost" : 6000,
"dispatchable2_marginal_cost" : 10,
"dispatchable2_emissions" : 0,
"dispatchable2_discount" : 10,
"co2_emissions" : 0,
"load" : 100.0,
"hydrogen_load" : 0.0,
"frequency" : 3,
"discount_rate" : 5.0,
"version" : solve.current_version}
#copied from static/solver.js
tech_assumptions = {"2020" : {"wind_cost" : 1120,
"solar_cost" : 420,
"battery_energy_cost" : 232,
"battery_power_cost" : 270,
"hydrogen_energy_cost" : 0.7,
"hydrogen_electrolyser_cost" : 1100,
"hydrogen_electrolyser_efficiency" : 58,
"hydrogen_turbine_cost" : 880,
"hydrogen_turbine_efficiency" : 56,
},
"2030" : {"wind_cost" : 1040,
"solar_cost" : 300,
"battery_energy_cost" : 142,
"battery_power_cost" : 160,
"hydrogen_energy_cost" : 0.7,
"hydrogen_electrolyser_cost" : 600,
"hydrogen_electrolyser_efficiency" : 62,
"hydrogen_turbine_cost" : 830,
"hydrogen_turbine_efficiency" : 58,
},
"2050" : {"wind_cost" : 960,
"solar_cost" : 240,
"battery_energy_cost" : 75,
"battery_power_cost" : 60,
"hydrogen_energy_cost" : 0.7,
"hydrogen_electrolyser_cost" : 400,
"hydrogen_electrolyser_efficiency" : 67,
"hydrogen_turbine_cost" : 800,
"hydrogen_turbine_efficiency" : 60,
}
}
assumptions = base_assumptions.copy()
for location in locations:
assumptions["location"] = location
if location[:len("country:")] == "country:":
assumptions["location_name"] = country_names[location[len("country:"):]]
elif location[:len("region:")] == "region:":
assumptions["location_name"] = location[len("region:"):]
else:
assumptions["location_name"] = "None"
print(assumptions["location"],assumptions["location_name"])
for cf_exponent in cf_exponents:
for year in years:
assumptions["cf_exponent"] = cf_exponent
assumptions["year"] = year
for assumption_year in assumption_years:
assumptions.update(tech_assumptions[str(assumption_year)])
error_message, assumptions = sanitise_assumptions(assumptions)
if error_message is not None:
print(error_message)
sys.exit()
assumptions["weather_hex"] = compute_weather_hash(assumptions)
if assumption_year == 2030:
assumptions["job_type"] = "weather"
with open('data/weather-assumptions-{}.json'.format(assumptions['weather_hex']), 'w') as fp:
json.dump(assumptions,fp)
assumptions["results_hex"] = compute_results_hash(assumptions)
assumptions["job_type"] = "solve"
with open('data/results-assumptions-{}.json'.format(assumptions['results_hex']), 'w') as fp:
json.dump(assumptions,fp)