From e4ce33d3e80e58e6af2af24605383b3493540484 Mon Sep 17 00:00:00 2001 From: Christina Pro Date: Thu, 21 Feb 2019 10:21:28 +0100 Subject: [PATCH 1/2] Minor change ==None to is None --- Corpus/stats.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Corpus/stats.py b/Corpus/stats.py index 15b7e82..447d926 100644 --- a/Corpus/stats.py +++ b/Corpus/stats.py @@ -26,7 +26,7 @@ def get_probability(rnd, prob, p_type='cum'): def sum_dict(dict_a, dict_b): ''' - Sum the values stored under the same keys in python dictionarys. + Sum the values stored under the same keys in python dictionaries. ''' # loop through the keys and sum both values given if len(dict_a.keys()) == 0: @@ -36,7 +36,7 @@ def sum_dict(dict_a, dict_b): else: sum_dict = dict() for key in dict_a.keys(): - if dict_a[key] == None: + if dict_a[key] is None: sum_dict.update({key:None}) elif key != 'time': sum_dict.update({key:dict_a[key]+dict_b[key]}) From c39bd4aff2601a21fdd2f0260015d903858fd40d Mon Sep 17 00:00:00 2001 From: Christina Pro Date: Tue, 26 Feb 2019 11:44:30 +0100 Subject: [PATCH 2/2] Fix Corpus/residential.py/cycle_load implementation --- Corpus/residential.py | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/Corpus/residential.py b/Corpus/residential.py index a34eb0d..cba35b8 100644 --- a/Corpus/residential.py +++ b/Corpus/residential.py @@ -721,22 +721,40 @@ def stochastic_load(self, nday, dow, clusterDict, occ): def cycle_load(self, nday): ''' Simulate cycling appliances, eg. fridges and freezers based on - average clycle length + average clycle length and delay between cycles ''' nbin = nday*24*60 P = np.zeros(nbin+1) - Q = np.zeros(nbin+1) - n_eq = 0 - left = random.gauss(self.delay, self.delay/4) - for tl in range(nbin+1): - if left <= 0: - n_eq += 1 - left += self.cycle_length - P[tl] = self.cycle_power - else: - left += -1 - P[tl] = self.standby_power + Q = np.zeros(nbin+1) #currently no data included (remains zero) + n_eq = 0 # number of cycles for calibration of `cal` parameter of appliance + + # define length of cycles (same for entire year, assumed to depend on appliance) + len_cycle=random.gauss(self.cycle_length, self.cycle_length/10) + # define duration of break between cycles (same for entire year) + delay=random.gauss(self.delay, self.delay/4) + + # start as OFF (assumption) + on=False #is it ON? + left = delay # time left until change of state + + for tl in range(nbin+1): # loop over every minute of the year + # if there is time LEFT until change of state, remain as is + # if time is up, change state: + if left <= 0: + on=not on # switch to opposite state ON/OFF + if on: # if switched ON + n_eq += 1 # add one to cycle counter + left = len_cycle #start counting 1 cycle length + else: # if switched OFF + left = delay #start counting time until next cycle + # either way, count downt the time until next change of state + left += -1 + # allocate correct power, depending on current state ON/OFF + if on: + P[tl] = self.cycle_power # instead of the average consumption, could be sampled from normal distribution as well + else: + P[tl] = self.standby_power r_eq = {'time':time, 'occ':None, 'P':P, 'Q':Q, 'QRad':P*self.frad, 'QCon':P*self.fconv, 'Wknds':None, 'mDHW':None}