예제 #1
0
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
예제 #2
0
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
예제 #3
0
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
예제 #4
0
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
예제 #5
0
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