Skip to content

Commit

Permalink
Implemented fix for duty cylce repetition issue 78 (RAMP-project#78)
Browse files Browse the repository at this point in the history
- in Appliance -> .update_daily_use:
  - duration of switch-on event is corrected to be only as long as duty cylce
  - corrected duration of switch-on event is returned
- in Appliance -> .generate_load_profile
  - calculation of total time of operation is performed using corrected duration of switch-on event
  • Loading branch information
Johann Kraft committed Feb 2, 2024
1 parent f22eb60 commit bd860cf
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions ramp/core/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1417,12 +1417,21 @@ def update_daily_use(self, coincidence, power, indexes):
if evaluate in range(self.cw11[0], self.cw11[1]) or evaluate in range(
self.cw12[0], self.cw12[1]
):
# Correct selected switch_on windows for duty cycle duration (fix issue 78):
# Limit switch_on_window to duration of duty_cycle
indexes = indexes[0:len(self.random_cycle1)]
np.put(self.daily_use, indexes, (self.random_cycle1 * coincidence))
elif evaluate in range(self.cw21[0], self.cw21[1]) or evaluate in range(
self.cw22[0], self.cw22[1]
):
# Correct selected switch_on windows for duty cycle duration (fix issue 78):
# Limit switch_on_window to duration of duty_cycle
indexes = indexes[0:len(self.random_cycle2)]
np.put(self.daily_use, indexes, (self.random_cycle2 * coincidence))
else:
# Correct selected switch_on windows for duty cycle duration (fix issue 78):
# Limit switch_on_window to duration of duty_cycle
indexes = indexes[0:len(self.random_cycle3)]
np.put(self.daily_use, indexes, (self.random_cycle3 * coincidence))
else: # if no duty cycles are specified, a regular switch_on event is modelled
# randomises also the App Power if thermal_p_var is on
Expand All @@ -1434,6 +1443,10 @@ def update_daily_use(self, coincidence, power, indexes):
# updates the time ranges remaining for switch on events, excluding the current switch_on event
self.update_available_time_for_switch_on_events(indexes)

# return corrected indexes (where operation was actually planned after correction for duty cycles)
# this is required to correctly track the functioning time of an appliance (fix issue 78)
return indexes

def calc_rand_window(self, window_idx=1, window_range_limits=[0, 1440]):
_window = self.__getattribute__(f"window_{window_idx}")
_random_var = self.__getattribute__(f"random_var_{window_idx}")
Expand Down Expand Up @@ -1853,9 +1866,6 @@ def generate_load_profile(self, prof_i, peak_time_range, day_type, power):
if indexes is None:
break # exit cycle and go to next Appliance as there are no available windows anymore

# the count of total time is updated with the size of the indexes array
tot_time = tot_time + indexes.size

if tot_time > rand_time:
# the total functioning time is reached, a correction is applied to avoid overflow of indexes
indexes_adj = indexes[: -(tot_time - rand_time)]
Expand All @@ -1870,7 +1880,9 @@ def generate_load_profile(self, prof_i, peak_time_range, day_type, power):
# Computes how many of the 'n' of the Appliance instance are switched on simultaneously
coincidence = self.calc_coincident_switch_on(inside_peak_window)
# Update the daily use depending on existence of duty cycles of the Appliance instance
self.update_daily_use(coincidence, power=power, indexes=indexes_adj)
# Fix issue 78: update_daily_use now returns the indexes at which a switch_on_event
# actually occurred
indexes = self.update_daily_use(coincidence, power=power, indexes=indexes_adj)
break # exit cycle and go to next Appliance

else:
Expand All @@ -1880,4 +1892,11 @@ def generate_load_profile(self, prof_i, peak_time_range, day_type, power):

coincidence = self.calc_coincident_switch_on(inside_peak_window)
# Update the daily use depending on existence of duty cycles of the Appliance instance
self.update_daily_use(coincidence, power=power, indexes=indexes)
# Fix issue 78: update_daily_use now returns the indexes at which a switch_on_event
# actually occurred
indexes = self.update_daily_use(coincidence, power=power, indexes=indexes)

# the count of total time is updated with the size of the indexes array
# Fix issue 78: tot_time is now updated with the size of the indexes array after correction
# performed in update_daily_use
tot_time = tot_time + indexes.size

0 comments on commit bd860cf

Please sign in to comment.