Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cycle load issue #16 #18

Merged
merged 3 commits into from
Jul 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 30 additions & 12 deletions Corpus/residential.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion Corpus/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down