Пример #1
0
def test_calc_eff_cy():
    """Testing
    """
    other_enduse_mode_info = {'diff_method': 'linear'},

    out_value = tech_related.calc_eff_cy(
        base_yr=2015,
        curr_yr=2020,
        eff_by=1.0,
        eff_ey=2.0,
        yr_until_changed=2020,
        other_enduse_mode_info=other_enduse_mode_info,
        eff_achieved_f=1.0,
        diff_method='linear')

    assert out_value == 2.0

    other_enduse_mode_info = {
        'sigmoid': {
            'sig_midpoint': 0,
            'sig_steepness': 1
        }
    }

    out_value = tech_related.calc_eff_cy(
        base_yr=2015,
        curr_yr=2020,
        eff_by=1.0,
        eff_ey=2.0,
        yr_until_changed=2020,
        other_enduse_mode_info=other_enduse_mode_info,
        eff_achieved_f=1.0,
        diff_method='sigmoid')

    assert out_value == 2.0
Пример #2
0
    def __init__(self,
                 name,
                 tech_type,
                 fueltype_str=None,
                 eff_achieved=None,
                 diff_method=None,
                 eff_by=None,
                 eff_ey=None,
                 year_eff_ey=None,
                 market_entry=None,
                 tech_max_share=None,
                 other_enduse_mode_info=None,
                 base_yr=None,
                 curr_yr=None,
                 fueltypes=None,
                 temp_by=None,
                 temp_cy=None,
                 t_base_heating_by=None,
                 t_base_heating_cy=None,
                 description=''):
        """Contructor
        """
        self.name = name
        self.tech_type = tech_type
        self.description = description
        self.fueltype_str = fueltype_str
        self.fueltype_int = tech_related.get_fueltype_int(
            fueltypes, fueltype_str)
        self.eff_achieved_f = eff_achieved
        self.diff_method = diff_method
        self.market_entry = market_entry
        self.tech_max_share = tech_max_share

        if tech_type == 'placeholder_tech':
            self.eff_by = 1.0
            self.eff_cy = 1.0
        elif tech_type == 'heat_pump':
            self.eff_by = tech_related.calc_hp_eff(temp_by, eff_by,
                                                   t_base_heating_by)

            self.eff_cy = tech_related.calc_hp_eff(
                temp_cy,
                tech_related.calc_eff_cy(base_yr, curr_yr, eff_by, eff_ey,
                                         year_eff_ey, other_enduse_mode_info,
                                         self.eff_achieved_f,
                                         self.diff_method), t_base_heating_cy)
        else:
            self.eff_by = eff_by
            self.eff_cy = tech_related.calc_eff_cy(base_yr, curr_yr, eff_by,
                                                   eff_ey, year_eff_ey,
                                                   other_enduse_mode_info,
                                                   self.eff_achieved_f,
                                                   self.diff_method)
def test_calc_eff_cy():
    """Testing
    """
    out_value = tech_related.calc_eff_cy(
        base_yr=2015,
        curr_yr=2020,
        eff_by=1.0,
        eff_ey=2.0,
        yr_until_changed=2020,
        f_eff_achieved=1.0,
        diff_method='linear')

    assert out_value == 2.0

    out_value = tech_related.calc_eff_cy(
        base_yr=2015,
        curr_yr=2020,
        eff_by=1.0,
        eff_ey=2.0,
        yr_until_changed=2020,
        f_eff_achieved=1.0,
        diff_method='sigmoid')

    assert out_value == 2.0
Пример #4
0
def create_service_switch(narrative_timesteps, enduse, sector, switch,
                          enduse_capacity_switches, technologies,
                          fuel_shares_enduse_by, base_yr, fuel_enduse_y):
    """Generate service switch based on capacity assumptions

    Arguments
    ---------
    narrative_timesteps : list
        Narrative timesteps
    enduse : dict
        Enduse
    switch : obj
        Capacity switch
    enduse_capacity_switches : list
        All capacity switches of an enduse (see warning)
    technologies : dict
        Technologies
    fuel_shares_enduse_by : dict
        Fuel shares per enduse for base year
    base_yr : int
        base year
    fuel_enduse_y : dict
        Fuels

    Returns
    ------
    service_switches : dict
        Service switches

    Major steps
    -------
        1.  Convert fuel per technology to service in ey
        2.  Convert installed capacity to service of ey and add service
        3.  Calculate percentage of service for ey
        4.  Write out as service switch
    """
    service_switches_enduse = []

    for switch_yr in narrative_timesteps:

        # Get switches of narrative timestep
        capacity_switches = get_switches_of_enduse(enduse_capacity_switches,
                                                   enduse,
                                                   year=switch_yr,
                                                   crit_region=False)

        # ---------------------------------------------
        # Calculate service per technology for switch_yr
        # ---------------------------------------------
        service_enduse_tech = {}

        for fueltype, tech_fuel_shares in fuel_shares_enduse_by.items():
            for tech, fuel_share_by in tech_fuel_shares.items():

                # Efficiency of year when capacity is fully installed
                eff_cy = tech_related.calc_eff_cy(
                    base_yr, switch.switch_yr, technologies[tech].eff_by,
                    technologies[tech].eff_ey, technologies[tech].year_eff_ey,
                    technologies[tech].eff_achieved,
                    technologies[tech].diff_method)

                # Convert to service (fuel * fuelshare * eff)
                s_tech_ey_y = fuel_enduse_y[fueltype] * fuel_share_by * eff_cy
                service_enduse_tech[tech] = s_tech_ey_y

        # -------------------------------------------
        # Calculate service of installed capacity of
        # increased (installed) technologies
        # -------------------------------------------
        for switch in capacity_switches:
            eff_cy = tech_related.calc_eff_cy(
                base_yr, switch.switch_yr,
                technologies[switch.technology_install].eff_by,
                technologies[switch.technology_install].eff_ey,
                technologies[switch.technology_install].year_eff_ey,
                technologies[switch.technology_install].eff_achieved,
                technologies[switch.technology_install].diff_method)

            # Convert installed capacity to service
            installed_capacity_ey = switch.installed_capacity * eff_cy

            # Add capacity
            service_enduse_tech[
                switch.technology_install] += installed_capacity_ey

        # -------------------------------------------
        # Calculate service in % per enduse
        # -------------------------------------------
        tot_s = sum(service_enduse_tech.values())
        for tech, service_tech in service_enduse_tech.items():
            service_enduse_tech[tech] = service_tech / tot_s

        # -------------------------------------------
        # Add to switch of technology_install
        # -------------------------------------------
        for tech, s_tech_p in service_enduse_tech.items():

            service_switch = read_data.ServiceSwitch(enduse=enduse,
                                                     sector=sector,
                                                     technology_install=tech,
                                                     service_share_ey=s_tech_p,
                                                     switch_yr=switch_yr)

            service_switches_enduse.append(service_switch)

    return service_switches_enduse
Пример #5
0
def create_service_switch(
        enduse,
        sector,
        switch,
        enduse_capacity_switches,
        technologies,
        other_enduse_mode_info,
        fuel_shares_enduse_by,
        base_yr,
        fuel_enduse_y
    ):
    """Generate service switch based on capacity assumptions

    Arguments
    ---------
    enduse : dict
        Enduse
    switch : obj
        Capacity switch
    enduse_capacity_switches : list
        All capacity switches of an enduse (see warning)
    technologies : dict
        Technologies
    other_enduse_mode_info : dict
        OTher diffusion information
    fuel_shares_enduse_by : dict
        Fuel shares per enduse for base year
    base_yr : int
        base year
    fuel_enduse_y : dict
        Fuels

    Returns
    ------
    service_switches : dict
        Service switches

    Major steps
    -------
        1.  Convert fuel per technology to service in ey
        2.  Convert installed capacity to service of ey and add service
        3.  Calculate percentage of service for ey
        4.  Write out as service switch

    Warning
    -------
        -   The year until the switch happens must be the same for all switches
    """
    # ------------
    # Calculate year until switch happens
    # -----------
    for switch in enduse_capacity_switches:
        switch_yr = switch.switch_yr
        continue

    # ---------------------------------------------
    # Calculate service per technology for end year
    # ---------------------------------------------
    service_enduse_tech = {}

    for fueltype, tech_fuel_shares in fuel_shares_enduse_by.items():
        for tech, fuel_share_by in tech_fuel_shares.items():

            # Efficiency of year when capacity is fully installed
            eff_ey = tech_related.calc_eff_cy(
                base_yr,
                switch.switch_yr,
                technologies[tech].eff_by,
                technologies[tech].eff_ey,
                technologies[tech].year_eff_ey,
                other_enduse_mode_info,
                technologies[tech].eff_achieved,
                technologies[tech].diff_method)

            # Convert to service (fuel * fuelshare * eff)
            s_tech_ey_y = fuel_enduse_y[fueltype] * fuel_share_by * eff_ey
            service_enduse_tech[tech] = s_tech_ey_y

    # -------------------------------------------
    # Calculate service of installed capacity of increased
    # (installed) technologies
    # -------------------------------------------
    for switch in enduse_capacity_switches:

        eff_ey = tech_related.calc_eff_cy(
            base_yr,
            switch.switch_yr,
            technologies[switch.technology_install].eff_by,
            technologies[switch.technology_install].eff_ey,
            technologies[switch.technology_install].year_eff_ey,
            other_enduse_mode_info,
            technologies[switch.technology_install].eff_achieved,
            technologies[switch.technology_install].diff_method)

        # Convert installed capacity to service
        installed_capacity_ey = switch.installed_capacity * eff_ey

        # Add capacity
        service_enduse_tech[switch.technology_install] += installed_capacity_ey

    # -------------------------------------------
    # Calculate service in % per enduse
    # -------------------------------------------
    tot_s = sum(service_enduse_tech.values())
    for tech, service_tech in service_enduse_tech.items():
        service_enduse_tech[tech] = service_tech / tot_s

    # -------------------------------------------
    # Add to switch of technology_install
    # -------------------------------------------
    service_switches_enduse = []
    for tech, s_tech_p in service_enduse_tech.items():

        service_switch = read_data.ServiceSwitch(
            enduse=enduse,
            sector=sector,
            technology_install=tech,
            service_share_ey=s_tech_p,
            switch_yr=switch_yr)

        service_switches_enduse.append(service_switch)

    return service_switches_enduse