Пример #1
0
    def test_eload_w_heat(self):
        #  Total number of occupants in apartment
        nb_occ = 5

        timestep = 60

        #  Generate occupancy object
        occ_obj = occ.Occupancy(number_occupants=nb_occ)

        #  Get radiation
        (q_direct, q_diffuse) = loadrad.get_rad_from_try_path()

        #  Convert 3600 s timestep to given timestep
        q_direct = cr.change_resolution(q_direct, old_res=3600,
                                        new_res=timestep)
        q_diffuse = cr.change_resolution(q_diffuse, old_res=3600,
                                         new_res=timestep)

        #  Generate stochastic electric power object
        el_load_obj = eload.ElectricLoad(occ_profile=occ_obj.occupancy,
                                         total_nb_occ=nb_occ,
                                         q_direct=q_direct,
                                         q_diffuse=q_diffuse,
                                         is_sfh=False,
                                         prev_heat_dev=True,
                                         randomize_appliances=False,
                                         light_config=2,
                                         season_light_mod=True,
                                         timestep=timestep)
def example_stoch_el_load(do_plot=False):
    #  Total number of occupants in apartment
    nb_occ = 3

    #  Generate occupancy object
    occ_obj = occ.Occupancy(number_occupants=nb_occ)

    #  Get radiation
    (q_direct, q_diffuse) = loadrad.get_rad_from_try_path()

    #  Generate stochastic electric power object
    el_load_obj = eload.ElectricLoad(occ_profile=occ_obj.occupancy,
                                     total_nb_occ=nb_occ,
                                     q_direct=q_direct, q_diffuse=q_diffuse)

    occ_profile = cr.change_resolution(values=occ_obj.occupancy,
                                      old_res=600,
                                      new_res=60)
    if do_plot:
        fig = plt.figure()
        fig.add_subplot(211)
        plt.plot(occ_profile[0:1440], label='occupancy')
        plt.xlabel('Timestep in minutes')
        plt.ylabel('Number of active occupants')

        fig.add_subplot(212)
        plt.plot(el_load_obj.loadcurve[0:1440], label='El. load')
        plt.xlabel('Timestep in minutes')
        plt.ylabel('Electric power in W')

        plt.tight_layout()
        plt.show()
        plt.close()
Пример #3
0
    def __init__(self,
                 environment,
                 number_occupants,
                 initial_day=1,
                 nb_days=365,
                 do_profile=True):
        """
        Constructor of occupancy object.

        If occupancy profile is generated with do_profile == True, profile
        is saved with timestep of 600 seconds on Occupancy.occupancy.
        To return profile in other timestep, use method
        get_occ_profile_in_curr_timestep.

        Parameters
        ----------
        environment : object
            Environment of pyCity
        number_occupants : int
            Maximum number of occupants within apartment (range from 1 to 5)
        initial_day : int, optional
            Initial day. 1-5 correspond to Monday-Friday, 6-7 to Saturday and
            Sunday
        nb_days : int, optional
            Number of days, which should be used to generate profile
            (default: 365)
        do_profile : bool, optional
            Defines, if user profile should be generated (default: True).
            If set to False, only number of occupants is saved and no
            profile is generated.
        """

        assert number_occupants > 0, ('At least 1 person has to be defined ' +
                                      'as occupant')
        assert number_occupants <= 5, ('Max. allowed number of occupants ' +
                                       'per apartment is 5')

        assert nb_days > 0, 'Number of days must be larger than zero.'

        assert initial_day in [1, 2, 3, 4, 5, 6, 7]

        self._kind = 'occupancy'
        self.environment = environment
        self.number_occupants = number_occupants
        self.initial_day = initial_day
        self.nb_days = nb_days
        self.occupancy = None  # Occupancy profile

        if do_profile:
            occupancy = occ.Occupancy(number_occupants=number_occupants,
                                      initial_day=initial_day,
                                      nb_days=nb_days,
                                      do_profile=do_profile)

            occupancy.gen_occ_profile(nb_days=nb_days)

            #  Save occupancy profile
            self.occupancy = copy.copy(occupancy.occupancy)
def exampe_occupancy(do_plot=False):

    #  Instanciate occupancy object
    occupancy_object = occ.Occupancy(number_occupants=3)

    #  Pointer to occupancy profile
    occupancy_profile = occupancy_object.occupancy

    print('Maximum number of active occupants:')
    print(np.max(occupancy_profile))

    if do_plot:
        plt.figure()
        plt.plot(occupancy_profile[:200])
        plt.ylabel('Number of active occupants')
        plt.show()
Пример #5
0
def exampe_occupancy(do_plot=False):

    #  Instanciate occupancy object
    occupancy_object = occ.Occupancy(number_occupants=3)

    #  Pointer to occupancy profile
    occupancy_profile = occupancy_object.occupancy

    print('Maximum number of active occupants:')
    print(np.max(occupancy_profile))

    timestep = 600
    #  Generate time array for plotting
    timesteps = int(24 * 3600 / timestep)  # Number of timesteps per day
    time_array = np.arange(0, timesteps * timestep, timestep) / 3600

    if do_plot:
        plt.figure()
        plt.plot(time_array[:144], occupancy_profile[:144])
        plt.xlabel('Time in hours')
        plt.ylabel('Number of active occupants')
        plt.show()
Пример #6
0
def main():  # pragma: no cover
    #  Total number of occupants in apartment
    nb_occ = 3

    timestep = 60

    import richardsonpy.classes.occupancy as occ

    #  Generate occupancy object
    occ_obj = occ.Occupancy(number_occupants=nb_occ)

    #  Get radiation
    (q_direct, q_diffuse) = loadrad.get_rad_from_try_path()

    #  Convert 3600 s timestep to given timestep
    q_direct = cr.change_resolution(q_direct, old_res=3600, new_res=timestep)
    q_diffuse = cr.change_resolution(q_diffuse, old_res=3600, new_res=timestep)

    #  Generate stochastic electric power object
    el_load_obj = ElectricLoad(occ_profile=occ_obj.occupancy,
                               total_nb_occ=nb_occ,
                               q_direct=q_direct,
                               q_diffuse=q_diffuse)

    occ_profile = cr.change_resolution(values=occ_obj.occupancy,
                                       old_res=600,
                                       new_res=timestep)

    import matplotlib.pyplot as plt

    fig = plt.figure()
    fig.add_subplot(211)
    plt.title('Occupancy and electric load for 24 hours')
    plt.plot(occ_profile[0:1440], label='occupancy')
    plt.xlabel('Timestep in minutes')
    plt.ylabel('Number of active occupants')

    fig.add_subplot(212)
    plt.plot(el_load_obj.loadcurve[0:1440], label='El. load')
    plt.xlabel('Timestep in minutes')
    plt.ylabel('Electric power in W')

    plt.tight_layout()
    plt.show()
    plt.close()

    fig = plt.figure()
    fig.add_subplot(211)
    plt.title('Annual occupancy and electric load profiles')
    plt.plot(occ_profile, label='occupancy')
    plt.xlabel('Timestep in minutes')
    plt.ylabel('Number of active occupants')

    fig.add_subplot(212)
    plt.plot(el_load_obj.loadcurve, label='El. load')
    plt.xlabel('Timestep in minutes')
    plt.ylabel('Electric power in W')

    plt.tight_layout()
    plt.show()
    plt.close()

    sum_el_energy = sum(el_load_obj.loadcurve) * 60 / 3600000
    print('Electric energy in kWh: ', sum_el_energy)
Пример #7
0
def example_stoch_el_load(do_plot=False):
    #  Total number of occupants in apartment
    nb_occ = 3

    timestep = 60  # in seconds

    #  Generate occupancy object (necessary as input for electric load gen.)
    occ_obj = occ.Occupancy(number_occupants=nb_occ)

    #  Get radiation (necessary for lighting usage calculation)
    (q_direct, q_diffuse) = loadrad.get_rad_from_try_path()

    #  Convert 3600 s timestep to given timestep
    q_direct = cr.change_resolution(q_direct, old_res=3600, new_res=timestep)
    q_diffuse = cr.change_resolution(q_diffuse, old_res=3600, new_res=timestep)

    #  Generate stochastic electric power object
    el_load_obj = eload.ElectricLoad(occ_profile=occ_obj.occupancy,
                                     total_nb_occ=nb_occ,
                                     q_direct=q_direct,
                                     q_diffuse=q_diffuse,
                                     timestep=timestep)

    #  Copy occupancy object, before changing its resolution
    #  (occ_obj.occupancy is the pointer to the occupancy profile array)
    occ_profile_copy = copy.copy(occ_obj.occupancy)

    #  Change resolution of occupancy object (to match
    #  resolution of el. load profile; necessary for plotting)
    occ_profile_copy = cr.change_resolution(values=occ_profile_copy,
                                            old_res=600,
                                            new_res=timestep)

    #  Calculate el. energy in kWh
    energy_el_kwh = sum(el_load_obj.loadcurve) * timestep / (3600 * 1000)

    print('Electric energy demand in kWh: ')
    print(energy_el_kwh)

    if do_plot:
        #  Generate time array for plotting
        timesteps = int(24 * 3600 / timestep)  # Number of timesteps per day

        time_array = np.arange(0, timesteps * timestep, timestep) / 3600

        fig = plt.figure()
        fig.add_subplot(211)
        plt.plot(time_array, occ_profile_copy[0:timesteps])
        plt.xlabel('Timestep in hours')
        plt.ylabel('Number of active occupants')
        plt.xlim([0, 24])

        fig.add_subplot(212)
        plt.plot(time_array, el_load_obj.loadcurve[0:timesteps])
        plt.xlabel('Timestep in hours')
        plt.ylabel('Electric power in W')
        plt.xlim([0, 24])

        plt.tight_layout()
        plt.show()
        plt.close()
Пример #8
0
        if save_app_light:
            self.light_load = light_load
            self.app_load = app_load

        self.loadcurve = loadcurve


if __name__ == '__main__':
    #  Total number of occupants in apartment
    nb_occ = 3

    import richardsonpy.classes.occupancy as occ

    #  Generate occupancy object
    occ_obj = occ.Occupancy(number_occupants=nb_occ)

    #  Get radiation
    (q_direct, q_diffuse) = loadrad.get_rad_from_try_path()

    #  Generate stochastic electric power object
    el_load_obj = ElectricLoad(occ_profile=occ_obj.occupancy,
                               total_nb_occ=nb_occ,
                               q_direct=q_direct, q_diffuse=q_diffuse)

    occ_profile = cr.change_resolution(values=occ_obj.occupancy,
                                      old_res=600,
                                      new_res=60)

    import matplotlib.pyplot as plt