def iron(param): # Defines the number of minutes in a day mins = 1440 # Initializes the active power vector. active_power = np.zeros(mins * param["Number of Days"][0]) # Repeats the following for each day. for j in range(int(round(param["Number of Days"][0]))): # Continues only if prob is OK. if 100 * rd.random() <= param["Probability [%]"][0]: # Computes the cycle. l1 = mins * j + rd_var.uni( param["Earliest Start [hour]"][0] * 60, param["Latest Start [hour]"][0] * 60 - param["Earliest Start [hour]"][0] * 60, True) l2 = l1 + rd_var.norm(param["Duration [min]"][0], param["Duration [min]"][1], True) power = rd_var.norm(param["Power [W]"][0], param["Power [W]"][1], False) active_power[l1:l2] += power return active_power
def tumble_dryer(param): # Defines the number of minutes in a day mins = 1440 # Initializes the active power vector. active_power = np.zeros(mins*param["Number of Days"][0]) # Repeats the following for each day. for j in range(int(round(param["Number of Days"][0]))): # Defines the default number of cycles (0) cycles = 0 # Computes the number of cycles if prob is OK. if 100*rd.random() <= param["Probability [%]"][0]: cycles = rd_var.norm(param["Number of Cycles"][0], param["Number of Cycles"][1], True, trunc_neg=0) # Continnues only if the number of cycles is not 0. if cycles != 0: # Computes the time window of each cycle. win = int(round(60*(param["Latest Start [hour]"][0]-param["Earliest Start [hour]"][0])/cycles)) # Initialises the end of last cycle. l2 = int(mins*j+60*param["Earliest Start [hour]"][0]) # Repeats the following for each cycle. for k in range(cycles): # Computes the beginning of the cycle. l1 = int(l2+rd_var.uni(0, win, True)) # Computes the duration of the first phase. l2 = l1+rd_var.norm(param["High Duration [min]"][0], param["High Duration [min]"][1], True) # Computes the parameters of the first phase. power = rd_var.norm(param["High Power [W]"][0], param["High Power [W]"][1], False) active_power[l1:l2] += power l1 = l2 # Computes the duration of the third phase. l2 = l1+rd_var.norm(param["Low Duration [min]"][0], param["Low Duration [min]"][1], True) # Computes the parameters of the second phase. power = rd_var.norm(param["Low Power [W]"][0], param["Low Power [W]"][1], False) active_power[l1:l2] += power l1 = l2 return active_power
def freezer(param): # Defines the number of minutes in a day mins = 1440 # Initializes the active power vector. active_power = np.zeros(mins*param["Number of Days"][0]) # Computes the parameters of the first period. on = rd_var.norm(param["Compressor On [min]"][0], param["Compressor On [min]"][1], True) off = rd_var.norm(param["Compressor Off [min]"][0], param["Compressor Off [min]"][1], True) power = rd_var.norm(param["Power [W]"][0], param["Power [W]"][1], False) peak_power = rd_var.norm(param["Power [W]"][0]/2.0, param["Power [W]"][0]/2.0, False, trunc_neg=-1, trunc_pos=1) # Computes the first period. tmp_power = np.zeros(on+off) tmp_power[0:on] = power for j in range(on): tmp_power[j] += peak_power*math.exp(-j) # Select initial point. start = rd_var.uni(0, on+off, True) tmp_power = tmp_power[start:] # Adds the initial period. l1 = 0 l2 = len(tmp_power) active_power[l1:l2] += tmp_power # Repeats the following until the end of the time vector. skip = False while l2 < mins*param["Number of Days"][0]: # Computes the parameters of the period. on = rd_var.norm(param["Compressor On [min]"][0], param["Compressor On [min]"][1], True) off = rd_var.norm(param["Compressor Off [min]"][0], param["Compressor Off [min]"][1], True) power = rd_var.norm(param["Power [W]"][0], param["Power [W]"][1], False) peak_power = rd_var.norm(param["Power [W]"][0]/2.0, param["Power [W]"][0]/2.0, False, trunc_neg=-1, trunc_pos=1) if skip: on += on skip = False # Computes and adds the period. tmp_power = np.zeros(on+off) tmp_power[0:on] = power for j in range(on): tmp_power[j] += peak_power*math.exp(-j) l1 = l2 l2 = min(l1+len(tmp_power), mins*param["Number of Days"][0]) if 100*rd.random() <= param["Cycle Probability [%]"][0]: active_power[l1:l2] += tmp_power[:l2-l1] else: skip = True return active_power
def base_load(param): # Defines the number of minutes in a day mins = 1440 # Initializes the active power vector. active_power = np.zeros(mins * param["Number of Days"][0]) # Computes the base load. l2 = 0 while l2 < len(active_power): l1 = l2 l2 = l1 + rd_var.norm(param["Duration [hour]"][0] * 60, param["Duration [hour]"][1] * 60, True) power = rd_var.norm(param["Power [W]"][0], param["Power [W]"][1], False, trunc_neg=-1, trunc_pos=1) active_power[l1:l2] += power return active_power
def microwave(param): # Defines the number of minutes in a day mins = 1440 # Initializes the active power vector. active_power = np.zeros(mins * param["Number of Days"][0]) # Repeats the following for each day. for j in range(int(round(param["Number of Days"][0]))): # Continues only if the day is a week day. if j % 7 != 5 and j % 7 != 6: # Computes a breakfast use if prob is OK. if 100 * rd.random() <= param["Breakfast Prob [%]"][0]: l1 = mins * j + rd_var.norm( param["Breakfast Time [hour]"][0] * 60, param["Breakfast Time [hour]"][1] * 60, True) l2 = l1 + rd_var.norm(param["Breakfast Duration [min]"][0], param["Breakfast Duration [min]"][1], True) power = rd_var.norm(param["Power [W]"][0], param["Power [W]"][1], False) active_power[l1:l2] += power # Computes a lunch use if prob is OK. if 100 * rd.random() <= param["Lunch Prob [%]"][0]: l1 = mins * j + rd_var.norm(param["Lunch Time [hour]"][0] * 60, param["Lunch Time [hour]"][1] * 60, True) l2 = l1 + rd_var.norm(param["Lunch Duration [min]"][0], param["Lunch Duration [min]"][1], True) power = rd_var.norm(param["Power [W]"][0], param["Power [W]"][1], False) active_power[l1:l2] += power # Computes a dinner use if prob is OK. if 100 * rd.random() <= param["Dinner Prob [%]"][0]: l1 = mins * j + rd_var.norm( param["Dinner Time [hour]"][0] * 60, param["Dinner Time [hour]"][1] * 60, True) l2 = l1 + rd_var.norm(param["Dinner Duration [min]"][0], param["Dinner Duration [min]"][1], True) power = rd_var.norm(param["Power [W]"][0], param["Power [W]"][1], False) active_power[l1:l2] += power # Continues only if the day is a weekend day. if j % 7 == 5 or j % 7 == 6: # Computes a breakfast use if prob is OK. if 100 * rd.random() <= param["Breakfast Prob (WE) [%]"][0]: l1 = mins * j + rd_var.norm( param["Breakfast Time (WE) [hour]"][0] * 60, param["Breakfast Time (WE) [hour]"][1] * 60, True) l2 = l1 + rd_var.norm( param["Breakfast Duration (WE) [min]"][0], param["Breakfast Duration (WE) [min]"][1], True) power = rd_var.norm(param["Power [W]"][0], param["Power [W]"][1], False) active_power[l1:l2] += power # Computes a lunch use if prob is OK. if 100 * rd.random() <= param["Lunch Prob (WE) [%]"][0]: l1 = mins * j + rd_var.norm( param["Lunch Time (WE) [hour]"][0] * 60, param["Lunch Time (WE) [hour]"][1] * 60, True) l2 = l1 + rd_var.norm(param["Lunch Duration (WE) [min]"][0], param["Lunch Duration (WE) [min]"][1], True) power = rd_var.norm(param["Power [W]"][0], param["Power [W]"][1], False) active_power[l1:l2] += power # Computes a dinner use if prob is OK. if 100 * rd.random() <= param["Dinner Prob (WE) [%]"][0]: l1 = mins * j + rd_var.norm( param["Dinner Time (WE) [hour]"][0] * 60, param["Dinner Time (WE) [hour]"][1] * 60, True) l2 = l1 + rd_var.norm(param["Dinner Duration (WE) [min]"][0], param["Dinner Duration (WE) [min]"][1], True) power = rd_var.norm(param["Power [W]"][0], param["Power [W]"][1], False) active_power[l1:l2] += power return active_power
def washing_machine(param): # Defines the number of minutes in a day mins = 1440 # Initializes the active power vector. active_power = np.zeros(mins*param["Number of Days"][0]) # Repeats the following for each day. for j in range(int(round(param["Number of Days"][0]))): # Defines the default number of cycles (0) cycles = 0 # Computes the number of cycles if prob is OK. if 100*rd.random() <= param["Probability [%]"][0]: cycles = rd_var.norm(param["Number of Cycles"][0], param["Number of Cycles"][1], True, trunc_neg=0) # Continnues only if the number of cycles is not 0. if cycles != 0: # Computes the time window of each cycle. win = int(round(60*(param["Latest Start [hour]"][0]-param["Earliest Start [hour]"][0])/cycles)) # Initialises the end of last cycle. l2 = int(mins*j+60*param["Earliest Start [hour]"][0]) # Repeats the following for each cycle. for k in range(cycles): # Computes the number of heating cycles. heat = rd_var.norm(param["Number of Heatings"][0], param["Number of Heatings"][1], True, trunc_neg=-1) # Computes the beginning of the cycle. l1 = int(l2+rd_var.uni(0, win, True)) # Repeats the following for each heating cycle. for l in range(heat): # Computes the parameters of the short washing. l2 = l1+rd_var.norm(param["Inter Heating Delay [min]"][0], param["Inter Heating Delay [min]"][1], True) power = rd_var.norm(param["Washing Power [W]"][0], param["Washing Power [W]"][1], False) active_power[l1:l2] += power l1 = l2 # Computes the parameters of the heating. l2 = l1+rd_var.norm(param["Heating Duration [min]"][0], param["Heating Duration [min]"][1], True) power = rd_var.norm(param["Heating Power [W]"][0], param["Heating Power [W]"][1], False) active_power[l1:l2] += power l1 = l2 # Computes the parameters of the washing. l2 = l1+rd_var.norm(param["Washing Duration [min]"][0], param["Washing Duration [min]"][1], True) power = rd_var.norm(param["Washing Power [W]"][0], param["Washing Power [W]"][1], False) active_power[l1:l2] += power l1 = l2 # Computes the parameters of the spinning. l2 = l1+rd_var.norm(param["Spinning Duration [min]"][0], param["Spinning Duration [min]"][1], True) power = rd_var.norm(param["Spinning Power [W]"][0], param["Spinning Power [W]"][1], False) active_power[l1:l2] += power l1 = l2 return active_power
def lighting(param): # Defines the number of minutes in a day mins = 1440 # Initializes the active power vector. active_power = np.zeros(mins * param["Number of Days"][0]) # Repeats the following for each day. for j in range(int(round(param["Number of Days"][0]))): # Continues only if the day is a week day. if j % 7 != 5 and j % 7 != 6: # Computes the morning bedrooms consumption. l1 = mins * j + rd_var.norm( param["Bedrooms Morning Time [h]"][0] * 60, param["Bedrooms Morning Time [h]"][1] * 60, True) l2 = l1 + rd_var.norm(param["Bedrooms Morning Duration [min]"][0], param["Bedrooms Morning Duration [min]"][1], True) power = rd_var.norm(param["Bedrooms Power [W]"][0], param["Bedrooms Power [W]"][1], False) active_power[l1:l2] += power # Computes the evening bedrooms consumption. l1 = mins * j + rd_var.norm( param["Bedrooms Evening Time [h]"][0] * 60, param["Bedrooms Evening Time [h]"][1] * 60, True) l2 = l1 + rd_var.norm(param["Bedrooms Evening Duration [min]"][0], param["Bedrooms Evening Duration [min]"][1], True) power = rd_var.norm(param["Bedrooms Power [W]"][0], param["Bedrooms Power [W]"][1], False) active_power[l1:l2] += power # Computes the morning bathrooms consumption. l1 = mins * j + rd_var.norm( param["Bathrooms Morning Time [h]"][0] * 60, param["Bathrooms Morning Time [h]"][1] * 60, True) l2 = l1 + rd_var.norm(param["Bathrooms Morning Duration [min]"][0], param["Bathrooms Morning Duration [min]"][1], True) power = rd_var.norm(param["Bathrooms Power [W]"][0], param["Bathrooms Power [W]"][1], False) active_power[l1:l2] += power # Computes the evening bathrooms consumption. l1 = mins * j + rd_var.norm( param["Bathrooms Evening Time [h]"][0] * 60, param["Bathrooms Evening Time [h]"][1] * 60, True) l2 = l1 + rd_var.norm(param["Bathrooms Evening Duration [min]"][0], param["Bathrooms Evening Duration [min]"][1], True) power = rd_var.norm(param["Bathrooms Power [W]"][0], param["Bathrooms Power [W]"][1], False) active_power[l1:l2] += power # Computes the morning kitchen consumption. l1 = mins * j + rd_var.norm( param["Kitchen Morning Time [h]"][0] * 60, param["Kitchen Morning Time [h]"][1] * 60, True) l2 = l1 + rd_var.norm(param["Kitchen Morning Duration [min]"][0], param["Kitchen Morning Duration [min]"][1], True) power = rd_var.norm(param["Kitchen Power [W]"][0], param["Kitchen Power [W]"][1], False) active_power[l1:l2] += power # Computes the evening kitchen consumption. l1 = mins * j + rd_var.norm( param["Kitchen Evening Time [h]"][0] * 60, param["Kitchen Evening Time [h]"][1] * 60, True) l2 = l1 + rd_var.norm(param["Kitchen Evening Duration [min]"][0], param["Kitchen Evening Duration [min]"][1], True) power = rd_var.norm(param["Kitchen Power [W]"][0], param["Kitchen Power [W]"][1], False) active_power[l1:l2] += power # Continues only if the day is a weekend day. if j % 7 == 5 or j % 7 == 6: # Computes the morning bedrooms consumption. l1 = mins * j + rd_var.norm( param["Bedrooms Morning Time (WE) [h]"][0] * 60, param["Bedrooms Morning Time (WE) [h]"][1] * 60, True) l2 = l1 + rd_var.norm(param["Bedrooms Morning Duration [min]"][0], param["Bedrooms Morning Duration [min]"][1], True) power = rd_var.norm(param["Bedrooms Power [W]"][0], param["Bedrooms Power [W]"][1], False) active_power[l1:l2] += power # Computes the evening bedrooms consumption. l1 = mins * j + rd_var.norm( param["Bedrooms Evening Time (WE) [h]"][0] * 60, param["Bedrooms Evening Time (WE) [h]"][1] * 60, True) l2 = l1 + rd_var.norm(param["Bedrooms Evening Duration [min]"][0], param["Bedrooms Evening Duration [min]"][1], True) power = rd_var.norm(param["Bedrooms Power [W]"][0], param["Bedrooms Power [W]"][1], False) active_power[l1:l2] += power # Computes the morning bathrooms consumption. l1 = mins * j + rd_var.norm( param["Bathrooms Morning Time (WE) [h]"][0] * 60, param["Bathrooms Morning Time (WE) [h]"][1] * 60, True) l2 = l1 + rd_var.norm(param["Bathrooms Morning Duration [min]"][0], param["Bathrooms Morning Duration [min]"][1], True) power = rd_var.norm(param["Bathrooms Power [W]"][0], param["Bathrooms Power [W]"][1], False) active_power[l1:l2] += power # Computes the evening bathrooms consumption. l1 = mins * j + rd_var.norm( param["Bathrooms Evening Time (WE) [h]"][0] * 60, param["Bathrooms Evening Time (WE) [h]"][1] * 60, True) l2 = l1 + rd_var.norm(param["Bathrooms Evening Duration [min]"][0], param["Bathrooms Evening Duration [min]"][1], True) power = rd_var.norm(param["Bathrooms Power [W]"][0], param["Bathrooms Power [W]"][1], False) active_power[l1:l2] += power # Computes the morning kitchen consumption. l1 = mins * j + rd_var.norm( param["Kitchen Morning Time (WE) [h]"][0] * 60, param["Kitchen Morning Time (WE) [h]"][1] * 60, True) l2 = l1 + rd_var.norm(param["Kitchen Morning Duration [min]"][0], param["Kitchen Morning Duration [min]"][1], True) power = rd_var.norm(param["Kitchen Power [W]"][0], param["Kitchen Power [W]"][1], False) active_power[l1:l2] += power # Computes the evening kitchen consumption. l1 = mins * j + rd_var.norm( param["Kitchen Evening Time (WE) [h]"][0] * 60, param["Kitchen Evening Time (WE) [h]"][1] * 60, True) l2 = l1 + rd_var.norm(param["Kitchen Evening Duration [min]"][0], param["Kitchen Evening Duration [min]"][1], True) power = rd_var.norm(param["Kitchen Power [W]"][0], param["Kitchen Power [W]"][1], False) active_power[l1:l2] += power # Computes the evening lounge consumption. l1 = mins * j + rd_var.norm(param["Lounge Evening Time [h]"][0] * 60, param["Lounge Evening Time [h]"][1] * 60, True) l2 = l1 + rd_var.norm(param["Lounge Evening Duration [min]"][0], param["Lounge Evening Duration [min]"][1], True) power = rd_var.norm(param["Lounge Power [W]"][0], param["Lounge Power [W]"][1], False) active_power[l1:l2] += power # No light between 8 am and 6 pm in the summer. if 90 <= j <= 272: active_power[mins * j + 480:mins * j + 1080] = 0 return active_power
def boiler(param): # Defines the number of minutes in a day mins = 1440 # Initializes the active power vector. volume = np.zeros(mins * param["Number of Days"][0]) # Repeats the following for each day. for j in range(int(round(param["Number of Days"][0]))): # Repeats the following for each person. for k in range(int(round(param["Number of People"][0]))): # Continues only if the day is a week day. if j % 7 != 5 and j % 7 != 6: # Computes a morning bath if prob is OK. if 100 * rd.random() <= param["Bath Morning Prob [%]"][0]: l1 = mins * j + rd_var.norm( param["Morning Time [hour]"][0] * 60, param["Morning Time [hour]"][1] * 60, True) l2 = l1 + rd_var.norm(param["Bath Duration [min]"][0], param["Bath Duration [min]"][1], True) vol = rd_var.norm(param["Bath Flow [l/min]"][0], param["Bath Flow [l/min]"][1], False) / 3 volume[l1:l2] += vol # Computes an afternoon bath if prob is OK. if 100 * rd.random() <= param["Bath Afternoon Prob [%]"][0]: l1 = mins * j + rd_var.norm( param["Afternoon Time [hour]"][0] * 60, param["Afternoon Time [hour]"][1] * 60, True) l2 = l1 + rd_var.norm(param["Bath Duration [min]"][0], param["Bath Duration [min]"][1], True) vol = rd_var.norm(param["Bath Flow [l/min]"][0], param["Bath Flow [l/min]"][1], False) / 3 volume[l1:l2] += vol # Computes an evening bath if prob is OK. if 100 * rd.random() <= param["Bath Evening Prob [%]"][0]: l1 = mins * j + rd_var.norm( param["Evening Time [hour]"][0] * 60, param["Evening Time [hour]"][1] * 60, True) l2 = l1 + rd_var.norm(param["Bath Duration [min]"][0], param["Bath Duration [min]"][1], True) vol = rd_var.norm(param["Bath Flow [l/min]"][0], param["Bath Flow [l/min]"][1], False) / 3 volume[l1:l2] += vol # Computes a morning shower if prob is OK. if 100 * rd.random() <= param["Shower Morning Prob [%]"][0]: l1 = mins * j + rd_var.norm( param["Morning Time [hour]"][0] * 60, param["Morning Time [hour]"][1] * 60, True) l2 = l1 + rd_var.norm(param["Shower Duration [min]"][0], param["Shower Duration [min]"][1], True) vol = rd_var.norm(param["Shower Flow [l/min]"][0], param["Shower Flow [l/min]"][1], False) / 3 volume[l1:l2] += vol # Computes an afternoon shower if prob is OK. if 100 * rd.random() <= param["Shower Afternoon Prob [%]"][0]: l1 = mins * j + rd_var.norm( param["Afternoon Time [hour]"][0] * 60, param["Afternoon Time [hour]"][1] * 60, True) l2 = l1 + rd_var.norm(param["Shower Duration [min]"][0], param["Shower Duration [min]"][1], True) vol = rd_var.norm(param["Shower Flow [l/min]"][0], param["Shower Flow [l/min]"][1], False) / 3 volume[l1:l2] += vol # Computes an evening shower if prob is OK. if 100 * rd.random() <= param["Shower Evening Prob [%]"][0]: l1 = mins * j + rd_var.norm( param["Evening Time [hour]"][0] * 60, param["Evening Time [hour]"][1] * 60, True) l2 = l1 + rd_var.norm(param["Shower Duration [min]"][0], param["Shower Duration [min]"][1], True) vol = rd_var.norm(param["Shower Flow [l/min]"][0], param["Shower Flow [l/min]"][1], False) / 3 volume[l1:l2] += vol # Continues only if the day is a weekend day. if j % 7 == 5 or j % 7 == 6: # Computes a morning bath if prob is OK. if 100 * rd.random() <= param["Bath Morning Prob (WE) [%]"][0]: l1 = mins * j + rd_var.norm( param["Morning Time (WE) [hour]"][0] * 60, param["Morning Time (WE) [hour]"][1] * 60, True) l2 = l1 + rd_var.norm(param["Bath Duration [min]"][0], param["Bath Duration [min]"][1], True) vol = rd_var.norm(param["Bath Flow [l/min]"][0], param["Bath Flow [l/min]"][1], False) / 3 volume[l1:l2] += vol # Computes an afternoon bath if prob is OK. if 100 * rd.random( ) <= param["Bath Afternoon Prob (WE) [%]"][0]: l1 = mins * j + rd_var.norm( param["Afternoon Time (WE) [hour]"][0] * 60, param["Afternoon Time (WE) [hour]"][1] * 60, True) l2 = l1 + rd_var.norm(param["Bath Duration [min]"][0], param["Bath Duration [min]"][1], True) vol = rd_var.norm(param["Bath Flow [l/min]"][0], param["Bath Flow [l/min]"][1], False) / 3 volume[l1:l2] += vol # Computes an evening bath if prob is OK. if 100 * rd.random() <= param["Bath Evening Prob (WE) [%]"][0]: l1 = mins * j + rd_var.norm( param["Evening Time (WE) [hour]"][0] * 60, param["Evening Time (WE) [hour]"][1] * 60, True) l2 = l1 + rd_var.norm(param["Bath Duration [min]"][0], param["Bath Duration [min]"][1], True) vol = rd_var.norm(param["Bath Flow [l/min]"][0], param["Bath Flow [l/min]"][1], False) / 3 volume[l1:l2] += vol # Computes a morning shower if prob is OK. if 100 * rd.random( ) <= param["Shower Morning Prob (WE) [%]"][0]: l1 = mins * j + rd_var.norm( param["Morning Time (WE) [hour]"][0] * 60, param["Morning Time (WE) [hour]"][1] * 60, True) l2 = l1 + rd_var.norm(param["Shower Duration [min]"][0], param["Shower Duration [min]"][1], True) vol = rd_var.norm(param["Shower Flow [l/min]"][0], param["Shower Flow [l/min]"][1], False) / 3 volume[l1:l2] += vol # Computes an afternoon shower if prob is OK. if 100 * rd.random( ) <= param["Shower Afternoon Prob (WE) [%]"][0]: l1 = mins * j + rd_var.norm( param["Afternoon Time (WE) [hour]"][0] * 60, param["Afternoon Time (WE) [hour]"][1] * 60, True) l2 = l1 + rd_var.norm(param["Shower Duration [min]"][0], param["Shower Duration [min]"][1], True) vol = rd_var.norm(param["Shower Flow [l/min]"][0], param["Shower Flow [l/min]"][1], False) / 3 volume[l1:l2] += vol # Computes an evening shower if prob is OK. if 100 * rd.random( ) <= param["Shower Evening Prob (WE) [%]"][0]: l1 = mins * j + rd_var.norm( param["Evening Time (WE) [hour]"][0] * 60, param["Evening Time (WE) [hour]"][1] * 60, True) l2 = l1 + rd_var.norm(param["Shower Duration [min]"][0], param["Shower Duration [min]"][1], True) vol = rd_var.norm(param["Shower Flow [l/min]"][0], param["Shower Flow [l/min]"][1], False) / 3 volume[l1:l2] += vol # Computes the number of times the sink is used. sink = rd_var.norm(param["Sink Cycles"][0], param["Sink Cycles"][1], True) # Repeats the following for each sink utilisation. for l in range(sink): # Computes the sink start, end and consumption. l1 = mins * j + rd_var.uni(0, mins, True) l2 = l1 + rd_var.norm(param["Sink Duration [min]"][0], param["Sink Duration [min]"][1], True) vol = rd_var.norm(param["Sink Flow [l/min]"][0], param["Sink Flow [l/min]"][1], False) / 3 volume[l1:l2] += vol return volume
def coffee_machine(param): # Defines the number of minutes in a day mins = 1440 # Initializes the active power vector. active_power = np.zeros(mins * param["Number of Days"][0]) # Repeats the following for each day. for j in range(int(round(param["Number of Days"][0]))): earliest = 0 latest = 0 # Continues only if the day is a week day. if j % 7 != 5 and j % 7 != 6: # Computes a breakfast use if prob is OK. if 100 * rd.random() <= param["Breakfast Prob [%]"][0]: l1 = mins * j + rd_var.norm( param["Breakfast Time [hour]"][0] * 60, param["Breakfast Time [hour]"][1] * 60, True) l2 = l1 + rd_var.norm(param["Duration [min]"][0], param["Duration [min]"][1], True) power = rd_var.norm(param["Power [W]"][0], param["Power [W]"][1], False) active_power[l1:l2] += power if earliest == 0: earliest = l2 if l1 > latest: latest = l1 # Computes a lunch use if prob is OK. if 100 * rd.random() <= param["Lunch Prob [%]"][0]: l1 = mins * j + rd_var.norm(param["Lunch Time [hour]"][0] * 60, param["Lunch Time [hour]"][1] * 60, True) l2 = l1 + rd_var.norm(param["Duration [min]"][0], param["Duration [min]"][1], True) power = rd_var.norm(param["Power [W]"][0], param["Power [W]"][1], False) active_power[l1:l2] += power if earliest == 0: earliest = l2 if l1 > latest: latest = l1 # Computes a dinner use if prob is OK. if 100 * rd.random() <= param["Dinner Prob [%]"][0]: l1 = mins * j + rd_var.norm( param["Dinner Time [hour]"][0] * 60, param["Dinner Time [hour]"][1] * 60, True) l2 = l1 + rd_var.norm(param["Duration [min]"][0], param["Duration [min]"][1], True) power = rd_var.norm(param["Power [W]"][0], param["Power [W]"][1], False) active_power[l1:l2] += power if earliest == 0: earliest = l2 if l1 > latest: latest = l1 # Continues only if the day is a weekend day. if j % 7 == 5 or j % 7 == 6: # Computes a breakfast use if prob is OK. if 100 * rd.random() <= param["Breakfast Prob (WE) [%]"][0]: l1 = mins * j + rd_var.norm( param["Breakfast Time (WE) [hour]"][0] * 60, param["Breakfast Time (WE) [hour]"][1] * 60, True) l2 = l1 + rd_var.norm(param["Duration [min]"][0], param["Duration [min]"][1], True) power = rd_var.norm(param["Power [W]"][0], param["Power [W]"][1], False) active_power[l1:l2] += power if earliest == 0: earliest = l2 if l1 > latest: latest = l1 # Computes a lunch use if prob is OK. if 100 * rd.random() <= param["Lunch Prob (WE) [%]"][0]: l1 = mins * j + rd_var.norm( param["Lunch Time (WE) [hour]"][0] * 60, param["Lunch Time (WE) [hour]"][1] * 60, True) l2 = l1 + rd_var.norm(param["Duration [min]"][0], param["Duration [min]"][1], True) power = rd_var.norm(param["Power [W]"][0], param["Power [W]"][1], False) active_power[l1:l2] += power if earliest == 0: earliest = l2 if l1 > latest: latest = l1 # Computes a dinner use if prob is OK. if 100 * rd.random() <= param["Dinner Prob (WE) [%]"][0]: l1 = mins * j + rd_var.norm( param["Dinner Time (WE) [hour]"][0] * 60, param["Dinner Time (WE) [hour]"][1] * 60, True) l2 = l1 + rd_var.norm(param["Duration [min]"][0], param["Duration [min]"][1], True) power = rd_var.norm(param["Power [W]"][0], param["Power [W]"][1], False) active_power[l1:l2] += power if earliest == 0: earliest = l2 if l1 > latest: latest = l1 # Computes the periodic heatings if the water is kept warm. if param["Keeps Water Warm?"][0] == "Yes": l1 = mins * j l2 = mins * (j + 1) daily_ac = active_power[l1:l2] nz_daily_ac = np.nonzero(daily_ac) nz_daily_ac = nz_daily_ac[0] index_on = [] index_off = [] for k in range(1, len(nz_daily_ac)): if nz_daily_ac[k] - nz_daily_ac[k - 1] > 1: index_on.append(mins * j + nz_daily_ac[k]) index_off.append(mins * j + nz_daily_ac[k - 1]) for k in range(len(index_on)): power = rd_var.norm(param["Power [W]"][0], param["Power [W]"][1], False) dt = rd_var.norm(param["Inter Heating Time [min]"][0], param["Inter Heating Time [min]"][1], True) active_power[index_off[k] + dt:index_on[k]:dt] = power return active_power