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} diff --git a/Corpus/stats.py b/Corpus/stats.py index c90cd6d..e78d769 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: