示例#1
0
def balance_conversion_plus_tiers_constraint_rule(backend_model, tier,
                                                  loc_tech, timestep):
    """
    Force all carrier_in_2/carrier_in_3 and carrier_out_2/carrier_out_3 to follow
    carrier_in and carrier_out (respectively).

    If `tier` in ['out_2', 'out_3']:

    .. container:: scrolling-wrapper

        .. math::

            \\sum_{loc::tech::carrier \\in loc::tech::carriers_{out}} (
            \\frac{\\boldsymbol{carrier_{prod}}(loc::tech::carrier, timestep)}{
                carrier\\_ratio(loc::tech::carrier, `out')} =
            \\sum_{loc::tech::carrier \\in loc::tech::carriers_{tier}} (
            \\frac{\\boldsymbol{carrier_{prod}}(loc::tech::carrier, timestep)}{
                carrier\\_ratio(loc::tech::carrier, tier)}
            \\quad \\forall \\text { tier } \\in [`out_2', `out_3'], \\forall loc::tech
                \\in loc::techs_{conversion^{+}}, \\forall timestep \\in timesteps

    If `tier` in ['in_2', 'in_3']:

    .. container:: scrolling-wrapper

        .. math::

            \\sum_{loc::tech::carrier \\in loc::tech::carriers_{in}}
            \\frac{\\boldsymbol{carrier_{con}}(loc::tech::carrier, timestep)}{
                carrier\\_ratio(loc::tech::carrier, `in')} =
            \\sum_{loc::tech::carrier \\in loc::tech::carriers_{tier}}
            \\frac{\\boldsymbol{carrier_{prod}}(loc::tech::carrier, timestep)}{
                carrier\\_ratio(loc::tech::carrier, tier)}
            \\quad \\forall \\text{ tier } \\in [`in_2', `in_3'], \\forall loc::tech
                \\in loc::techs_{conversion^{+}}, \\forall timestep \\in timesteps
    """
    primary_tier, decision_variable = get_conversion_plus_io(
        backend_model, tier)
    model_data_dict = backend_model.__calliope_model_data['data']

    loc_tech_carriers_1 = split_comma_list(
        model_data_dict['lookup_loc_techs_conversion_plus'][primary_tier,
                                                            loc_tech])
    loc_tech_carriers_2 = split_comma_list(
        model_data_dict['lookup_loc_techs_conversion_plus'][tier, loc_tech])

    c_1 = sum(decision_variable[loc_tech_carrier, timestep] /
              get_param(backend_model, 'carrier_ratios', (primary_tier,
                                                          loc_tech_carrier))
              for loc_tech_carrier in loc_tech_carriers_1)
    c_2 = sum(
        decision_variable[loc_tech_carrier, timestep] /
        get_param(backend_model, 'carrier_ratios', (tier, loc_tech_carrier))
        for loc_tech_carrier in loc_tech_carriers_2)

    return c_1 == c_2
示例#2
0
def balance_conversion_plus_tiers_constraint_rule(backend_model, tier, loc_tech, timestep):
    """
    Force all carrier_in_2/carrier_in_3 and carrier_out_2/carrier_out_3 to follow
    carrier_in and carrier_out (respectively).

    If `tier` in ['out_2', 'out_3']:

    .. container:: scrolling-wrapper

        .. math::

            \\sum_{loc::tech::carrier \\in loc::tech::carriers_{out}} (
            \\frac{\\boldsymbol{carrier_{prod}}(loc::tech::carrier, timestep)}{
                carrier\\_ratio(loc::tech::carrier, `out')} =
            \\sum_{loc::tech::carrier \\in loc::tech::carriers_{tier}} (
            \\frac{\\boldsymbol{carrier_{prod}}(loc::tech::carrier, timestep)}{
                carrier\\_ratio(loc::tech::carrier, tier)}
            \\quad \\forall \\text { tier } \\in [`out_2', `out_3'], \\forall loc::tech
                \\in loc::techs_{conversion^{+}}, \\forall timestep \\in timesteps

    If `tier` in ['in_2', 'in_3']:

    .. container:: scrolling-wrapper

        .. math::

            \\sum_{loc::tech::carrier \\in loc::tech::carriers_{in}}
            \\frac{\\boldsymbol{carrier_{con}}(loc::tech::carrier, timestep)}{
                carrier\\_ratio(loc::tech::carrier, `in')} =
            \\sum_{loc::tech::carrier \\in loc::tech::carriers_{tier}}
            \\frac{\\boldsymbol{carrier_{prod}}(loc::tech::carrier, timestep)}{
                carrier\\_ratio(loc::tech::carrier, tier)}
            \\quad \\forall \\text{ tier } \\in [`in_2', `in_3'], \\forall loc::tech
                \\in loc::techs_{conversion^{+}}, \\forall timestep \\in timesteps
    """
    primary_tier, decision_variable = get_conversion_plus_io(backend_model, tier)
    model_data_dict = backend_model.__calliope_model_data__['data']

    loc_tech_carriers_1 = split_comma_list(
        model_data_dict['lookup_loc_techs_conversion_plus'][primary_tier, loc_tech]
    )
    loc_tech_carriers_2 = split_comma_list(
        model_data_dict['lookup_loc_techs_conversion_plus'][tier, loc_tech]
    )

    c_1 = sum(decision_variable[loc_tech_carrier, timestep]
        / get_param(backend_model, 'carrier_ratios', (primary_tier, loc_tech_carrier))
        for loc_tech_carrier in loc_tech_carriers_1)
    c_2 = sum(decision_variable[loc_tech_carrier, timestep]
        / get_param(backend_model, 'carrier_ratios', (tier, loc_tech_carrier))
        for loc_tech_carrier in loc_tech_carriers_2)

    return c_1 == c_2
示例#3
0
def conversion_plus_prod_con_to_zero_constraint_rule(backend_model, loc_tech_carrier_tier, timestep):
    """
    Force any carrier production or consumption for a conversion plus technology to
    zero in timesteps where its carrier_ratio is zero
    """
    loc_tech_carrier, tier = loc_tech_carrier_tier.rsplit('::', 1)
    primary_tier, decision_variable = get_conversion_plus_io(backend_model, tier)

    carrier_ratio = get_param(
        backend_model, 'carrier_ratios', (tier, loc_tech_carrier, timestep)
    )
    if po.value(carrier_ratio) == 0:
        return decision_variable[loc_tech_carrier, timestep] == 0
    else:
        return po.Constraint.Skip
示例#4
0
def conversion_plus_prod_con_to_zero_constraint_rule(backend_model, tier,
                                                     carrier, node, tech,
                                                     timestep):
    """
    Force any carrier production or consumption for a conversion plus technology to
    zero in timesteps where its carrier_ratio is zero
    """
    primary_tier, decision_variable = get_conversion_plus_io(
        backend_model, tier)

    carrier_ratio = get_param(backend_model, "carrier_ratios",
                              (tier, carrier, node, tech, timestep))
    if po.value(carrier_ratio) == 0:
        return decision_variable[carrier, node, tech, timestep] == 0
    else:
        return po.Constraint.Skip
示例#5
0
def balance_conversion_plus_tiers_constraint_rule(backend_model, tier,
                                                  loc_tech, timestep):
    """
    Force all carrier_in_2/carrier_in_3 and carrier_out_2/carrier_out_3 to follow
    carrier_in and carrier_out (respectively).

    If `tier` in ['out_2', 'out_3']:

    .. container:: scrolling-wrapper

        .. math::

            \\sum_{loc::tech::carrier \\in loc::tech::carriers_{out}} (
            \\frac{\\boldsymbol{carrier_{prod}}(loc::tech::carrier, timestep)}{
                carrier\\_ratio(loc::tech::carrier, `out')} =
            \\sum_{loc::tech::carrier \\in loc::tech::carriers_{tier}} (
            \\frac{\\boldsymbol{carrier_{prod}}(loc::tech::carrier, timestep)}{
                carrier\\_ratio(loc::tech::carrier, tier)}
            \\quad \\forall \\text { tier } \\in [`out_2', `out_3'], \\forall loc::tech
                \\in loc::techs_{conversion^{+}}, \\forall timestep \\in timesteps

    If `tier` in ['in_2', 'in_3']:

    .. container:: scrolling-wrapper

        .. math::

            \\sum_{loc::tech::carrier \\in loc::tech::carriers_{in}}
            \\frac{\\boldsymbol{carrier_{con}}(loc::tech::carrier, timestep)}{
                carrier\\_ratio(loc::tech::carrier, `in')} =
            \\sum_{loc::tech::carrier \\in loc::tech::carriers_{tier}}
            \\frac{\\boldsymbol{carrier_{prod}}(loc::tech::carrier, timestep)}{
                carrier\\_ratio(loc::tech::carrier, tier)}
            \\quad \\forall \\text{ tier } \\in [`in_2', `in_3'], \\forall loc::tech
                \\in loc::techs_{conversion^{+}}, \\forall timestep \\in timesteps
    """
    primary_tier, decision_variable = get_conversion_plus_io(
        backend_model, tier)
    model_data_dict = backend_model.__calliope_model_data["data"]

    loc_tech_carriers_1 = split_comma_list(
        model_data_dict["lookup_loc_techs_conversion_plus"][primary_tier,
                                                            loc_tech])
    loc_tech_carriers_2 = split_comma_list(
        model_data_dict["lookup_loc_techs_conversion_plus"][tier, loc_tech])

    c_1 = []
    c_2 = []
    for loc_tech_carrier in loc_tech_carriers_1:
        carrier_ratio_1 = get_param(backend_model, "carrier_ratios",
                                    (primary_tier, loc_tech_carrier, timestep))
        if po.value(carrier_ratio_1) != 0:
            c_1.append(decision_variable[loc_tech_carrier, timestep] /
                       carrier_ratio_1)
    for loc_tech_carrier in loc_tech_carriers_2:
        carrier_ratio_2 = get_param(backend_model, "carrier_ratios",
                                    (tier, loc_tech_carrier, timestep))
        if po.value(carrier_ratio_2) != 0:
            c_2.append(decision_variable[loc_tech_carrier, timestep] /
                       carrier_ratio_2)
    if len(c_2) == 0:
        return po.Constraint.Skip
    else:
        return sum(c_1) == sum(c_2)
示例#6
0
def balance_conversion_plus_non_primary_constraint_rule(
        backend_model, tier, node, tech, timestep):
    """
    Force all carrier_in_2/carrier_in_3 and carrier_out_2/carrier_out_3 to follow
    carrier_in and carrier_out (respectively).

    If `tier` in ['out_2', 'out_3']:

    .. container:: scrolling-wrapper

        .. math::

            \\sum_{loc::tech::carrier \\in loc::tech::carriers_{out}} (
            \\frac{\\boldsymbol{carrier_{prod}}(loc::tech::carrier, timestep)}{
                carrier\\_ratio(loc::tech::carrier, `out')} =
            \\sum_{loc::tech::carrier \\in loc::tech::carriers_{tier}} (
            \\frac{\\boldsymbol{carrier_{prod}}(loc::tech::carrier, timestep)}{
                carrier\\_ratio(loc::tech::carrier, tier)}
            \\quad \\forall \\text { tier } \\in [`out_2', `out_3'], \\forall loc::tech
                \\in loc::techs_{conversion^{+}}, \\forall timestep \\in timesteps

    If `tier` in ['in_2', 'in_3']:

    .. container:: scrolling-wrapper

        .. math::

            \\sum_{loc::tech::carrier \\in loc::tech::carriers_{in}}
            \\frac{\\boldsymbol{carrier_{con}}(loc::tech::carrier, timestep)}{
                carrier\\_ratio(loc::tech::carrier, `in')} =
            \\sum_{loc::tech::carrier \\in loc::tech::carriers_{tier}}
            \\frac{\\boldsymbol{carrier_{prod}}(loc::tech::carrier, timestep)}{
                carrier\\_ratio(loc::tech::carrier, tier)}
            \\quad \\forall \\text{ tier } \\in [`in_2', `in_3'], \\forall loc::tech
                \\in loc::techs_{conversion^{+}}, \\forall timestep \\in timesteps
    """
    primary_tier, decision_variable = get_conversion_plus_io(
        backend_model, tier)

    carriers_1 = backend_model.carrier[primary_tier, :, tech].index()
    carriers_2 = backend_model.carrier[tier, :, tech].index()

    c_1 = []
    c_2 = []
    for idx in carriers_1:
        carrier_ratio_1 = get_param(
            backend_model,
            "carrier_ratios",
            (primary_tier, idx[1], node, tech, timestep),
        )
        if po.value(carrier_ratio_1) != 0:
            c_1.append(decision_variable[idx[1], node, tech, timestep] /
                       carrier_ratio_1)
    for idx in carriers_2:
        carrier_ratio_2 = get_param(backend_model, "carrier_ratios",
                                    (tier, idx[1], node, tech, timestep))
        if po.value(carrier_ratio_2) != 0:
            c_2.append(decision_variable[idx[1], node, tech, timestep] /
                       carrier_ratio_2)
    if len(c_2) == 0:
        return po.Constraint.Skip
    else:
        return po.quicksum(c_1) == po.quicksum(c_2)