Skip to content

Commit

Permalink
described non_param_assumptions in more detail
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Eggimann committed Jan 29, 2018
1 parent 816fb29 commit 206cdb3
Show file tree
Hide file tree
Showing 10 changed files with 273 additions and 130 deletions.
2 changes: 1 addition & 1 deletion config_data/technology_definition.csv
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ heat_pump_ASHP_hydrogen,hydrogen,3.6,3.6,2050,1,linear,2010,tech_heating_temp_de
heat_pump_GSHP_hydrogen,hydrogen,4.9,4.9,2050,1,linear,2010,tech_heating_temp_dep,1,OK_,,,4.9,,,,,,,,
district_heating_gas,gas,1,1,2050,1,linear,2010,tech_district_heating,1,,,,,,,,,,,,
district_heating_electricity,electricity,1,1,2050,1,linear,2010,tech_district_heating,1,,,,,,,,,,,,
district_heating_biomass,biomass,1,1,2050,1,linear,2010,district_heating,1,,,,,,,,,,,,
district_heating_biomass,biomass,1,1,2050,1,linear,2010,tech_district_heating,1,,,,,,,,,,,,
ss_cooling_tech_electricity,electricity,1,1,2050,1,linear,2010,tech_cooling_const,1,,,,,,,,,,,,
ss_cooling_tech_gas,gas,1,1,2050,1,linear,2010,tech_cooling_const,1,,,,,,,,,,,,
ss_cooling_tech_oil,oil,1,1,2050,1,linear,2010,tech_cooling_const,1,,,,,,,,,,,,
Expand Down
264 changes: 181 additions & 83 deletions energy_demand/assumptions/non_param_assumptions.py

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions energy_demand/assumptions/param_assumptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,15 +313,17 @@ def load_param_assump(paths, assumptions):
"units": '%'})

# How much of the floorarea is cooled in end year (example: 0.5 --> 50% of floorarea is cooled)
strategy_vars['cooled_floorarea__ss_cooling_humidification'] = 0.3 #TODO FIND NUMBER
# Carbon Trust. (2012). Air conditioning. Maximising comfort, minimising energy consumption.
strategy_vars['cooled_floorarea__ss_cooling_humidification'] = 0.4

# Year until floor area change is fully realised
strategy_vars['cooled_floorarea_yr_until_changed'] = yr_until_changed_all_things

# Penetration of cooling devices
# COLING_OENETRATION ()
# Or Assumkp Peneetration curve in relation to HDD from PAPER #Residential
# Assumption on recovered heat (lower heat demand based on heat recovery)

# ============================================================
# Heat recycling & Reuse
# ============================================================
Expand Down
30 changes: 18 additions & 12 deletions energy_demand/enduse_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,16 +466,16 @@ def demand_management(
# ------------------------------
# If peak shifting implemented, calculate new lp
# ------------------------------
peak_shift_crit = True
if peak_shift_crit:

# Calculate average for every day
if mode_constrained:
# Calculate average for every day for a single fueltype
average_fuel_yd = np.mean(fuel_yh, axis=1)
axis = 1
else:
# Calculate average for every day for multiple fueltypes
average_fuel_yd = np.mean(fuel_yh, axis=2)
axis = 2

# Calculate average for every day
average_fuel_yd = np.mean(fuel_yh, axis=axis)

# Calculate load factors (only inter_day load shifting as for now)
loadfactor_yd_cy = lf.calc_lf_d(
Expand Down Expand Up @@ -586,19 +586,25 @@ def assign_lp_no_techs(enduse, sector, load_profiles, fuel_new_y):
Returns
-------
fuel_yh
fuel_peak_dh
fuel_peak_h
fuel_yh : array
Fuel yh
fuel_peak_dh : array
Fuel for peak dh
fuel_peak_h : array
Fuel of peak hour
"""
_fuel = fuel_new_y[:, np.newaxis, np.newaxis]
fuel = fuel_new_y[:, np.newaxis, np.newaxis]

fuel_yh = load_profiles.get_lp(
enduse, sector, 'dummy_tech', 'shape_yh') * _fuel
enduse, sector, 'dummy_tech', 'shape_yh') * fuel

# Read dh profile from peak day
# Read dh profile from peak day. Get this day
# where the fuel demand across all fueltypes i
# highest
peak_day = get_peak_day_all_fueltypes(fuel_yh)

shape_peak_dh = lp.abs_to_rel(fuel_yh[:, peak_day, :])
shape_peak_dh = lp.abs_to_rel(
fuel_yh[:, peak_day, :])

enduse_peak_yd_factor = load_profiles.get_lp(
enduse, sector, 'dummy_tech', 'enduse_peak_yd_factor')
Expand Down
8 changes: 4 additions & 4 deletions energy_demand/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def energy_demand_model(data, fuel_in=0, fuel_in_elec=0):
# Load data
data = {}
data['criterias'] = {}
data['criterias']['mode_constrained'] = True #constrained_by_technologies
data['criterias']['mode_constrained'] = False #constrained_by_technologies
data['criterias']['plot_HDD_chart'] = False
data['criterias']['virtual_building_stock_criteria'] = True
data['criterias']['spatial_exliclit_diffusion'] = False
Expand Down Expand Up @@ -238,15 +238,15 @@ def energy_demand_model(data, fuel_in=0, fuel_in_elec=0):
# ----------------------------------
# Calculating COOLING CDD PARAMETER
# ----------------------------------
data['assumptions']['cdd_weekend_cfactors'] = hdd_cdd.get_cdd_weekend_correctionfactors(
data['assumptions']['cdd_weekend_cfactors'] = hdd_cdd.calc_weekend_corr_f(
data['assumptions']['model_yeardays_daytype'],
data['assumptions']['ss_t_cooling_weekend_factor'])

data['assumptions']['ss_weekend_f'] = hdd_cdd.get_cdd_weekend_correctionfactors(
data['assumptions']['ss_weekend_f'] = hdd_cdd.calc_weekend_corr_f(
data['assumptions']['model_yeardays_daytype'],
data['assumptions']['ss_weekend_factor'])

data['assumptions']['is_weekend_f'] = hdd_cdd.get_cdd_weekend_correctionfactors(
data['assumptions']['is_weekend_f'] = hdd_cdd.calc_weekend_corr_f(
data['assumptions']['model_yeardays_daytype'],
data['assumptions']['is_weekend_factor'])

Expand Down
26 changes: 21 additions & 5 deletions energy_demand/profiles/hdd_cdd.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,32 @@ def averaged_temp(temp_yh, nr_day_to_av):

return effective_temp_yh

def get_cdd_weekend_correctionfactors(model_yeardays_daytype, wkend_factor):
"""
def calc_weekend_corr_f(model_yeardays_daytype, wkend_factor):
"""Based on the factor 'wkend_factor' daily correction
factors get calculated for every modelled day in a year.abs
Arguments
---------
model_yeardays_daytype : list
Daytype for every modelled days in the base year
wkend_factor : float
This factors states how much energy deamnd differs
depending on whether a day is a weekend or working day
(e.g. 0.8 means that on a weekend, 80% less demand occurs)
Returns
--------
cdd_weekend_f : array
Factor to multiply cdd calculations for every
day in a year
"""
cdd_weekend_cfactors = np.ones((365))
cdd_weekend_f = np.ones((365))

for day_nr, day in enumerate(model_yeardays_daytype):
if day == 'holiday':
cdd_weekend_cfactors[day_nr] = wkend_factor
cdd_weekend_f[day_nr] = wkend_factor

return cdd_weekend_cfactors
return cdd_weekend_f

def calc_cdd(t_base_cooling, temp_yh, nr_day_to_av):
"""Calculate cooling degree days
Expand Down
26 changes: 24 additions & 2 deletions energy_demand/read_write/read_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def calc_av_per_season_fueltype(results_every_year, seasons, model_yeardays_dayt
results_every_year :
seasons :
model_yeardays_daytype :
Returns
Expand Down Expand Up @@ -1106,10 +1106,32 @@ def get_position(headings, name):
Arguments
---------
headings : list
List with names
name : str
Name of entry to find
Returns
-------
position : int
Position in list
"""
for position, value in enumerate(headings):
if str(value) == str(name):
return position

def read_np_array_from_txt(path_file_to_read):
return np.loadtxt(path_file_to_read, delimiter=',')
"""Read np array from textfile
Arguments
---------
path_file_to_read : str
File to path with stored array
Return
------
txt_array : array
Array containing read text
"""
txt_array = np.loadtxt(path_file_to_read, delimiter=',')
return txt_array
27 changes: 7 additions & 20 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from smif.model.sector_model import SectorModel
from pkg_resources import Requirement, resource_filename
from pyproj import Proj, transform
from pyinstrument import Profiler

from energy_demand.plotting import plotting_results
from energy_demand.basic import basic_functions
Expand All @@ -33,7 +32,6 @@
# must match smif project name for Local Authority Districts
REGION_SET_NAME = 'lad_uk_2016'
NR_OF_MODELLEd_REGIONS = 391 # uk: 391, england.: 380
PROFILER = False

class EDWrapper(SectorModel):
"""Energy Demand Wrapper
Expand All @@ -56,18 +54,18 @@ def before_model_run(self, data=None):
data = defaultdict(dict, data)

# Criteria
data['criterias']['mode_constrained'] = True # True: Technologies are defined in ED model and fuel is provided, False: Heat is delievered not per technologies
data['criterias']['mode_constrained'] = False # True: Technologies are defined in ED model and fuel is provided, False: Heat is delievered not per technologies
data['criterias']['virtual_building_stock_criteria'] = True # True: Run virtual building stock model
data['criterias']['plot_HDD_chart'] = False # True: Plotting of HDD vs gas chart
data['criterias']['validation_criteria'] = False # True: Plot validation plots
data['criterias']['spatial_exliclit_diffusion'] = False # True: Spatial explicit calculations
data['criterias']['writeYAML'] = False
data['criterias']['write_to_txt'] = True # True
data['criterias']['beyond_supply_outputs'] = True # True # If only for smif: FAlse, for other plots: True
data['criterias']['write_to_txt'] = True
data['criterias']['beyond_supply_outputs'] = False # If only for smif: FAlse, for other plots: True
data['criterias']['plot_crit'] = True
data['criterias']['plot_tech_lp'] = True

data['sim_param']['base_yr'] = 2015 # Base year
data['sim_param']['base_yr'] = 2015 # Base year
data['sim_param']['curr_yr'] = data['sim_param']['base_yr']
self.user_data['base_yr'] = data['sim_param']['base_yr']

Expand Down Expand Up @@ -168,20 +166,18 @@ def before_model_run(self, data=None):
# ----------------------------------
# Calculating COOLING CDD PARAMETER
# ----------------------------------
data['assumptions']['cdd_weekend_cfactors'] = hdd_cdd.get_cdd_weekend_correctionfactors(
data['assumptions']['cdd_weekend_cfactors'] = hdd_cdd.calc_weekend_corr_f(
data['assumptions']['model_yeardays_daytype'],
data['assumptions']['ss_t_cooling_weekend_factor'])

data['assumptions']['ss_weekend_f'] = hdd_cdd.get_cdd_weekend_correctionfactors(
data['assumptions']['ss_weekend_f'] = hdd_cdd.calc_weekend_corr_f(
data['assumptions']['model_yeardays_daytype'],
data['assumptions']['ss_weekend_factor'])

data['assumptions']['is_weekend_f'] = hdd_cdd.get_cdd_weekend_correctionfactors(
data['assumptions']['is_weekend_f'] = hdd_cdd.calc_weekend_corr_f(
data['assumptions']['model_yeardays_daytype'],
data['assumptions']['is_weekend_factor'])



# ------------
# Load load profiles of technologies
# ------------
Expand Down Expand Up @@ -365,17 +361,8 @@ def simulate(self, timestep, data=None):
# ---------------------------------------------
# Run energy demand model
# ---------------------------------------------
if PROFILER:
profiler = Profiler(use_signal=False)
profiler.start()

sim_obj = energy_demand_model(data)

if PROFILER:
profiler.stop()
logging.info("Profiler Results")
logging.info(profiler.output_text(unicode=True, color=True))

# ------------------------------------------------
# Validation base year: Hourly temporal validation
# ------------------------------------------------
Expand Down
12 changes: 12 additions & 0 deletions tests/profiles/test_hdd_cdd.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@
from energy_demand.profiles import hdd_cdd
import numpy as np

def calc_weekend_corr_f():
"""Testing
"""
wkend_factor = 0.5
model_yeardays_daytype = ['working_day', 'holiday']
result = hdd_cdd.calc_weekend_corr_f(
model_yeardays_daytype=model_yeardays_daytype,
wkend_factor=wkend_factor)

assert result[0] == 1.0
assert result[1] == wkend_factor

def test_averaged_temp():
"""Testing
"""
Expand Down
2 changes: 1 addition & 1 deletion yaml_parameters_scenario.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
climate_change_temp_d__Oct: 0
climate_change_temp_d__Sep: 0
climate_change_temp_diff_yr_until_changed: 2050
cooled_floorarea__ss_cooling_humidification: 0.3
cooled_floorarea__ss_cooling_humidification: 0.4
cooled_floorarea_yr_until_changed: 2050
demand_management_improvement__is_compressed_air: 0
demand_management_improvement__is_drying_separation: 0
Expand Down

0 comments on commit 206cdb3

Please sign in to comment.