Skip to content

Commit

Permalink
working on finding bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Eggimann committed Feb 22, 2019
1 parent 43384ac commit 4b504e3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
1 change: 0 additions & 1 deletion energy_demand/enduse_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -1688,7 +1688,6 @@ def generic_fuel_switch(

if switch_defined is True:
for fueltype_new_int in fuel_switch.keys():

if fuel_switch[fueltype_new_int][curr_yr] != 0:

# Get fueltype to switch to (new)
Expand Down
16 changes: 5 additions & 11 deletions energy_demand/scripts/init_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def switch_calculations(
narrative_timesteps.update(get_all_narrative_timesteps(service_switches))
narrative_timesteps.update(get_all_narrative_timesteps(fuel_switches))
narrative_timesteps.update(get_all_narrative_timesteps(capacity_switches))

# ========================================================================================
# Capacity switches
#
Expand Down Expand Up @@ -229,14 +229,6 @@ def switch_calculations(
techs_affected_spatial_f=data['assumptions'].techs_affected_spatial_f,
service_switches_from_capacity=service_switches_incl_cap)

'''print(share_s_tech_ey_p.keys())
try:
print("aa " + str(share_s_tech_ey_p['E06000001'][2050]))
except:
print("FFAIL")
print("aa " + str(share_s_tech_ey_p['electrical_equipment']['E06000001'][2050]))
pass
raise Exception("TT")'''
# ========================================================================================
# Fuel switches
#
Expand All @@ -249,7 +241,7 @@ def switch_calculations(
for enduse in data['enduses'][submodel_name]:
for sector in data['sectors'][submodel_name]:
print("... calculating fuel switches {} {} {}".format(submodel_name, enduse, sector))
print("======d======= " + str(data['assumptions'].fuel_tech_p_by[enduse][sector]))
#print("======d======= " + str(data['assumptions'].fuel_tech_p_by[enduse][sector]))
print("Z " + str(s_fueltype_by_p[sector][enduse]))
diffusion_param_tech[enduse][sector] = sig_param_calc_incl_fuel_switch(
narrative_timesteps,
Expand Down Expand Up @@ -697,7 +689,9 @@ def sig_param_calc_incl_fuel_switch(
# ------------------------------------------
if crit_switch_service:
print(".... service switch")
print("KK " + str(share_s_tech_ey_p))
if enduse == 'is_space_heating' and 'E06000001' not in share_s_tech_ey_p.keys():
print(".ttt "+ str(share_s_tech_ey_p))
#print("KK " + str(share_s_tech_ey_p))
# Calculate only from service switch
s_tech_switched_p = share_s_tech_ey_p

Expand Down
9 changes: 7 additions & 2 deletions energy_demand/scripts/s_fuel_to_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,16 @@ def get_s_fueltype_tech(
# Convert service per enduse
for fueltype in s_fueltype_by_p[enduse][sector]:
with np.errstate(divide='ignore'):
s_fueltype_by_p[enduse][sector][fueltype] = s_fueltype_by_p[enduse][sector][fueltype] / total_s
if total_s == 0:
s_fueltype_by_p[enduse][sector][fueltype] = 0
else:
s_fueltype_by_p[enduse][sector][fueltype] = s_fueltype_by_p[enduse][sector][fueltype] / total_s

#TODO KAMEL OLD ORIGINAL s_fueltype_by_p[enduse][sector][fueltype] = s_fueltype_by_p[enduse][sector][fueltype] / total_s

#warnings.filterwarnings('ignore') # Ignore warnings
# Test if the energy service for all technologies is 100%
# Test if within fueltype always 100 energy service
# Test if within fueltype always 100 energy service
for enduse, s_p_techs in s_tech_by_p.items():
sum_enduse = sum(s_p_techs.values())
if round(sum_enduse, 2) != 0: # if total is zero, no demand provided
Expand Down

0 comments on commit 4b504e3

Please sign in to comment.