-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update from @aliebman #1
base: master
Are you sure you want to change the base?
Changes from all commits
8b01cda
ba95d55
28835da
a7f5954
db7a8f2
09c428d
ff58eac
9e6c229
f01fdef
d1fb8b0
5ecf5b8
3b20b2b
ca20fa0
726baba
736bac2
2796752
0a1f2ec
966e26a
4b62327
8b17781
dba69ea
88a93f8
6d8d477
83e0423
1624c26
24508e6
ad2930b
256a88a
53da2a8
d03282a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
|
||
|
||
def init_year_correction_factor(model): | ||
#pylint: disable=unused-argument | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wait, what argument is being ignored? o.O |
||
'''Calculate factor to adjust dispatch periods different to 8760 hours''' | ||
ystr = model.t.last() | ||
year = int(ystr[:4]) | ||
|
@@ -23,81 +24,109 @@ def init_year_correction_factor(model): | |
|
||
|
||
def init_zones_in_regions(model): | ||
#pylint: disable=unused-argument | ||
'''Return zones in region tuples for declared regions''' | ||
for i in cemo.const.ZONES_IN_REGIONS: | ||
if i[0] in model.regions and i[1] in model.zones: | ||
yield i | ||
|
||
|
||
def init_region_intercons(model): | ||
#pylint: disable=unused-argument | ||
'''Return regional interconnectors for declared regions''' | ||
for i in cemo.const.REGION_INTERCONS: | ||
if i[0] in model.regions and i[1] in model.regions: | ||
yield i | ||
|
||
|
||
def init_stor_rt_eff(model, tech): | ||
#pylint: disable=unused-argument | ||
'''Default return efficiency for storage techs''' | ||
return cemo.const.DEFAULT_STOR_PROPS["rt_eff"].get(tech, 0) | ||
|
||
|
||
def init_stor_charge_hours(model, tech): | ||
#pylint: disable=unused-argument | ||
'''Default charge hours for storage tech''' | ||
return cemo.const.DEFAULT_STOR_PROPS["charge_hours"].get(tech, 0) | ||
|
||
|
||
def init_hyb_col_mult(model, tech): | ||
#pylint: disable=unused-argument | ||
'''Default collector multiple for hybrid tech''' | ||
return cemo.const.DEFAULT_HYB_PROPS["col_mult"].get(tech, 0) | ||
|
||
|
||
def init_hyb_charge_hours(model, tech): | ||
#pylint: disable=unused-argument | ||
'''Default charge hours for hybrid tech''' | ||
return cemo.const.DEFAULT_HYB_PROPS["charge_hours"].get(tech, 0) | ||
|
||
|
||
def init_intercon_prop_factor(m, source, dest): | ||
def init_intercon_prop_factor(model, source, dest): | ||
#pylint: disable=unused-argument | ||
'''Initialise interconnector proportioning factors''' | ||
return cemo.const.INTERCON_PROP_FACTOR.get(source).get(dest, 0) | ||
|
||
|
||
def init_intercon_trans_limit(m, source, dest): | ||
def init_intercon_trans_limit(model, source, dest): | ||
#pylint: disable=unused-argument | ||
'''Initialise interconecto transmission limits''' | ||
return cemo.const.INTERCON_TRANS_LIMIT.get(source).get(dest) | ||
|
||
|
||
def init_default_fuel_price(model, zone, tech): | ||
#pylint: disable=unused-argument | ||
'''Assign default price across zone and technologies''' | ||
return cemo.const.DEFAULT_FUEL_PRICE.get(tech, 100.0) | ||
|
||
|
||
def init_default_heat_rate(model, zone, tech): | ||
#pylint: disable=unused-argument | ||
'''Initialise default heat rate for fuel based generators in each zone''' | ||
return cemo.const.DEFAULT_HEAT_RATE.get(tech, 15.0) | ||
|
||
|
||
def init_default_fuel_emit_rate(model, tech): | ||
#pylint: disable=unused-argument | ||
'''Default fuel emission rate for fuel based generators''' | ||
return cemo.const.DEFAULT_FUEL_EMIT_RATE.get(tech, 800) | ||
|
||
|
||
def init_cost_retire(model, tech): | ||
#pylint: disable=unused-argument | ||
'''Default retirement/rehabilitation cost in $/MW per technology''' | ||
return cemo.const.DEFAULT_RETIREMENT_COST.get(tech, 60000.0) | ||
|
||
|
||
def init_default_lifetime(model, tech): | ||
#pylint: disable=unused-argument | ||
'''Default lifetime for technologies''' | ||
return cemo.const.DEFAULT_TECH_LIFETIME.get(tech, 30.0) | ||
|
||
|
||
def init_gen_build_limit(model, zone, tech): | ||
#pylint: disable=unused-argument | ||
''' Default build limits per technology and per zone''' | ||
return cemo.const.DEFAULT_BUILD_LIMIT.get(zone).get(tech, 100000) | ||
|
||
|
||
def init_fcr(model, tech): | ||
#pylint: disable=unused-argument | ||
'''Calculate fixed charge rate for each technology''' | ||
return model.all_tech_discount_rate / ( | ||
(model.all_tech_discount_rate + 1)**model.all_tech_lifetime[tech] - | ||
1) + model.all_tech_discount_rate | ||
|
||
|
||
def init_cap_factor(model, zone, tech, time): | ||
#pylint: disable=unused-argument | ||
'''Default capacity factor per hour per technology and per zone. | ||
Note:Default to zero means technology does not generate''' | ||
return cemo.const.GEN_CAP_FACTOR.get(tech, 0) | ||
|
||
|
||
def init_max_hydro(model, zone): | ||
#pylint: disable=unused-argument | ||
'''Default maximum hydro generation per year in each zone''' | ||
return cemo.const.DEFAULT_HYDRO_MWH_MAX.get(zone, 0) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -138,10 +138,10 @@ def jsonify(inst): | |
|
||
def jsoninit(inst): | ||
'''Produce JSON output sufficient to initialise a cemo model''' | ||
input = jsonify(inst) | ||
inp = jsonify(inst) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why truncate? |
||
out = {} | ||
out.update(input['sets']) | ||
out.update(input['params']) | ||
out.update(inp['sets']) | ||
out.update(inp['params']) | ||
|
||
del out['zones_per_region'] | ||
del out['gen_tech_per_zone'] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,7 +49,7 @@ def roundup(cap): | |
Catching small negative numbers due to solver numerical tolerance. | ||
Let big negative numners pass to raise exception. | ||
''' | ||
if cap > -1e-6 and cap < 0: | ||
if -1e-6 < cap < 0: | ||
return 0 | ||
return round(cap, 2) | ||
|
||
|
@@ -119,12 +119,12 @@ def __init__(self, cfgfile, solver='cbc', log=False, tmpdir=tempfile.mkdtemp() + | |
self.nem_re_disp_ratio = json.loads(Scenario['nem_re_disp_ratio']) | ||
# Keep track of policy options to configure model instances down the line | ||
self.model_options = { | ||
'nem_ret_ratio': (True if self.nem_ret_ratio is not None else False), | ||
'nem_ret_gwh': (True if self.nem_ret_gwh is not None else False), | ||
'region_ret_ratio': (True if self.region_ret_ratio is not None else False), | ||
'emitlimit': (True if self.emitlimit is not None else False), | ||
'nem_disp_ratio': (True if self.nem_disp_ratio is not None else False), | ||
'nem_re_disp_ratio': (True if self.nem_re_disp_ratio is not None else False), | ||
'nem_ret_ratio': self.nem_ret_ratio is not None, | ||
'nem_ret_gwh': self.nem_ret_gwh is not None, | ||
'region_ret_ratio': self.region_ret_ratio is not None, | ||
'emitlimit': self.emitlimit is not None, | ||
'nem_disp_ratio': self.nem_disp_ratio is not None, | ||
'nem_re_disp_ratio': self.nem_re_disp_ratio is not None | ||
} | ||
|
||
self.discountrate = Scenario['discountrate'] | ||
|
@@ -339,7 +339,7 @@ def exogenous_capacity(self, a): | |
|
||
def tracetechs(self): # TODO refactor this and how tech sets populate template | ||
self.fueltech = {} | ||
self.committech ={} | ||
self.committech = {} | ||
self.regentech = {} | ||
self.dispgentech = {} | ||
self.redispgentech = {} | ||
|
@@ -496,7 +496,12 @@ def produce_exogenous_capacity(self, year): | |
exogenous_capacity += '#Exogenous capacity entry ' + key + '\n' | ||
exogenous_capacity += 'param ' + key + ':=\n' | ||
exogenous_capacity += cap[['zone', 'tech', 'value'] | ||
].to_string(header=False, index=False) | ||
].to_string(header=False, index=False, | ||
formatters={ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we make the formatter a constant? |
||
'zone': lambda x: '%i' % x, | ||
'tech': lambda x: '%i' % x, | ||
'value': lambda x: '%10.2f' % x, | ||
}) | ||
exogenous_capacity += '\n;\n' | ||
|
||
return exogenous_capacity | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,7 +48,7 @@ def _techsinregion(instance, region): # pragma: no cover | |
techsinregion = techsinregion | instance.gen_tech_per_zone[z]() | ||
techsinregion = techsinregion | instance.hyb_tech_per_zone[z]() | ||
techsinregion = techsinregion | instance.stor_tech_per_zone[z]() | ||
return sorted(techsinregion, key=lambda x: cemo.const.DISPLAY_ORDER.index(x)) | ||
return sorted(techsinregion, key=cemo.const.DISPLAY_ORDER.index) | ||
|
||
|
||
def palette(instance, techsinregion): # pragma: no cover | ||
|
@@ -211,7 +211,7 @@ def _printemissionrate(instance): | |
emrate = sum(value(cemo.rules.emissions(instance, r)) | ||
for r in instance.regions) /\ | ||
(sum(value(cemo.rules.dispatch(instance, r)) for r in instance.regions)+1.0e-12) | ||
print("Total Emission rate: %s kg/MWh" % str(emrate)) | ||
print("Total Emission rate: %6.3f kg/MWh" % emrate) | ||
|
||
|
||
def _printunserved(instance): | ||
|
@@ -281,11 +281,11 @@ def printstats(instance): | |
print("End of results for %s" % instance.name, flush=True) | ||
|
||
|
||
def plotcluster(cluster, row=3, col=4, ylim=[5500, 16000]): # pragma: no cover | ||
def plotcluster(cluster, row=3, col=4, ylim=None): # pragma: no cover | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps use a more common default value method? Also, what is 5500 and 16000? |
||
# Plot cluster result from full set of weeks, cluster weeks and weights | ||
t = range(1, cluster.nplen + 1) | ||
# Make row * col subplots | ||
f, axarr = plt.subplots(row, col, sharex=True) | ||
axarr = plt.subplots(row, col, sharex=True)[1] | ||
# Plot each observation in their respective cluster plot | ||
for i in range(cluster.periods): | ||
axarr.flat[cluster.cluster[i] - | ||
|
@@ -302,6 +302,10 @@ def plotcluster(cluster, row=3, col=4, ylim=[5500, 16000]): # pragma: no cover | |
marker='+') # closest observation | ||
# make yrange the same in all plots | ||
for ax in axarr.flat: | ||
ax.set_ylim(ylim[0], ylim[1]) | ||
if ylim is None: | ||
# default | ||
ax.set_ylim(5500, 16000) | ||
else: | ||
ax.set_ylim(ylim[0], ylim[1]) | ||
# Show results | ||
plt.show(figsize=(14, 9)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
appdirs==1.4.3 | ||
atomicwrites==1.3.0 | ||
attrs==19.1.0 | ||
cycler==0.10.0 | ||
kiwisolver==1.0.1 | ||
matplotlib==3.0.3 | ||
more-itertools==7.0.0 | ||
nose==1.3.7 | ||
numpy==1.16.2 | ||
pandas==0.24.2 | ||
pluggy==0.9.0 | ||
ply==3.11 | ||
py==1.8.0 | ||
PyMySQL==0.9.3 | ||
Pyomo==5.6.1 | ||
pyparsing==2.3.1 | ||
pytest==4.4.0 | ||
python-dateutil==2.8.0 | ||
pytz==2018.9 | ||
PyUtilib==5.6.5 | ||
scipy==1.2.1 | ||
si-prefix==1.2.2 | ||
six==1.12.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Supports a default versus all.
Should this be range(1, 6) @aliebman to advise?