Skip to content

Commit

Permalink
final update but check comments
Browse files Browse the repository at this point in the history
  • Loading branch information
oluchee committed Dec 1, 2019
1 parent eccfaa2 commit 18f2bba
Showing 1 changed file with 29 additions and 14 deletions.
43 changes: 29 additions & 14 deletions onsset/onsset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1432,20 +1432,9 @@ def closest_elec(unelec_node, elec_nodes):

#Runs the grid extension algorithm

# def new_connections(self,year,):

def set_scenario_variables(self, year, num_people_per_hh_rural, num_people_per_hh_urban, time_step, start_year,
urban_elec_ratio, rural_elec_ratio, urban_tier, rural_tier, end_year_pop,
productive_demand):
"""
Set the basic scenario parameters that differ based on urban/rural
So that they are in the table and can be read directly to calculate LCOEs
"""

if end_year_pop == 0:
self.df[SET_POP + "{}".format(year)] = self.df[SET_POP + "{}".format(year) + 'Low']
else:
self.df[SET_POP + "{}".format(year)] = self.df[SET_POP + "{}".format(year) + 'High']

def calculate_new_connections(self,year,time_step,start_year):
"""defining new connections for grid related purposes"""

logging.info('Calculate new connections')
# Calculate new connections for grid related purposes
Expand Down Expand Up @@ -1483,6 +1472,10 @@ def set_scenario_variables(self, year, num_people_per_hh_rural, num_people_per_h
self.df.loc[
self.df[SET_NEW_CONNECTIONS + "{}".format(year)] < 0, SET_NEW_CONNECTIONS + "{}".format(year)] = 0

#RESIDENTIAL DEMAND STARTS
def set_residential_demand(self,rural_tier,urban_tier,num_people_per_hh_rural,num_people_per_hh_urban,productive_demand):
"""defining residential demand per tier level for each target year"""

logging.info('Setting electrification demand as per target per year')

if max(self.df[SET_CAPITA_DEMAND]) == 0:
Expand Down Expand Up @@ -1548,6 +1541,11 @@ def set_scenario_variables(self, year, num_people_per_hh_rural, num_people_per_h
if int(productive_demand) == 1:
self.df[SET_CAPITA_DEMAND] += self.df[SET_EDU_DEMAND]

### RESIDENTIAL DEMAND ENDS

def calculate_total_demand_per_settlement(self,year):
""" calculate total demand for each settlement per year"""

self.df.loc[self.df[SET_URBAN] == 0, SET_ENERGY_PER_CELL + "{}".format(year)] = \
self.df[SET_CAPITA_DEMAND] * self.df[SET_NEW_CONNECTIONS + "{}".format(year)]
self.df.loc[self.df[SET_URBAN] == 1, SET_ENERGY_PER_CELL + "{}".format(year)] = \
Expand All @@ -1563,7 +1561,24 @@ def set_scenario_variables(self, year, num_people_per_hh_rural, num_people_per_h
self.df.loc[self.df[SET_URBAN] == 2, SET_TOTAL_ENERGY_PER_CELL] = \
self.df[SET_CAPITA_DEMAND] * self.df[SET_POP + "{}".format(year)]


def set_scenario_variables(self, year, num_people_per_hh_rural, num_people_per_hh_urban, time_step, start_year,
urban_elec_ratio, rural_elec_ratio, urban_tier, rural_tier, end_year_pop,
productive_demand):
"""
Set the basic scenario parameters that differ based on urban/rural
So that they are in the table and can be read directly to calculate LCOEs
"""

if end_year_pop == 0:
self.df[SET_POP + "{}".format(year)] = self.df[SET_POP + "{}".format(year) + 'Low']
else:
self.df[SET_POP + "{}".format(year)] = self.df[SET_POP + "{}".format(year) + 'High']


self.calculate_new_connections(year,time_step,start_year)
self.set_residential_demand(rural_tier,urban_tier,num_people_per_hh_rural,num_people_per_hh_urban,productive_demand)
self.calculate_total_demand_per_settlement(year)

def calculate_off_grid_lcoes(self, mg_hydro_calc, mg_wind_calc, mg_pv_calc,
sa_pv_calc, mg_diesel_calc, sa_diesel_calc,
Expand Down

0 comments on commit 18f2bba

Please sign in to comment.