def update_costs_investment_purchase_constraint(backend_model, cost, loc_tech): """ Add binary investment costs (cost * binary_purchased_unit) .. container:: scrolling-wrapper .. math:: \\boldsymbol{cost_{investment}}(cost, loc::tech) += \\boldsymbol{purchased}(loc::tech) \\times cost_{purchase}(cost, loc::tech) * timestep_{weight} * depreciation \\quad \\forall cost \\in costs, \\forall loc::tech \\in loc::techs_{cost_{investment}, purchase} """ model_data_dict = backend_model.__calliope_model_data__ ts_weight = get_timestep_weight(backend_model) depreciation_rate = model_data_dict['data']['cost_depreciation_rate'][(cost, loc_tech)] cost_purchase = get_param(backend_model, 'cost_purchase', (cost, loc_tech)) cost_of_purchase = ( backend_model.purchased[loc_tech] * cost_purchase * ts_weight * depreciation_rate ) if loc_tech_is_in(backend_model, loc_tech, 'loc_techs_transmission'): cost_of_purchase = cost_of_purchase / 2 backend_model.cost_investment_rhs[cost, loc_tech].expr += cost_of_purchase return None
def update_costs_investment_purchase_constraint(backend_model, cost, loc_tech): """ Add binary investment costs (cost * binary_purchased_unit) .. container:: scrolling-wrapper .. math:: \\boldsymbol{cost_{investment}}(cost, loc::tech) += \\boldsymbol{purchased}(loc::tech) \\times cost_{purchase}(cost, loc::tech) * timestep_{weight} * depreciation \\quad \\forall cost \\in costs, \\forall loc::tech \\in loc::techs_{cost_{investment}, purchase} """ model_data_dict = backend_model.__calliope_model_data__ ts_weight = get_timestep_weight(backend_model) depreciation_rate = model_data_dict['data']['cost_depreciation_rate'][( cost, loc_tech)] cost_purchase = get_param(backend_model, 'cost_purchase', (cost, loc_tech)) cost_of_purchase = (backend_model.purchased[loc_tech] * cost_purchase * ts_weight * depreciation_rate) backend_model.cost_investment_rhs[cost, loc_tech].expr += cost_of_purchase return None
def update_costs_investment_units_constraint(backend_model, cost, loc_tech): """ Add MILP investment costs (cost * number of units purchased) .. container:: scrolling-wrapper .. math:: \\boldsymbol{cost_{investment}}(cost, loc::tech) += \\boldsymbol{units}(loc::tech) \\times cost_{purchase}(cost, loc::tech) * timestep_{weight} * depreciation \\quad \\forall cost \\in costs, \\forall loc::tech \\in loc::techs_{cost_{investment}, milp} """ model_data_dict = backend_model.__calliope_model_data__ ts_weight = get_timestep_weight(backend_model) depreciation_rate = model_data_dict['data']['cost_depreciation_rate'][( cost, loc_tech)] cost_purchase = get_param(backend_model, 'cost_purchase', (cost, loc_tech)) cost_of_purchase = (backend_model.units[loc_tech] * cost_purchase * ts_weight * depreciation_rate) if loc_tech_is_in(backend_model, loc_tech, 'loc_techs_transmission'): cost_of_purchase = cost_of_purchase / 2 backend_model.cost_investment_rhs[cost, loc_tech].expr += cost_of_purchase return None
def cost_investment_constraint_rule(backend_model, cost, loc_tech): """ Calculate costs from capacity decision variables. Transmission technologies "exist" at two locations, so their cost is divided by 2. .. container:: scrolling-wrapper .. math:: \\boldsymbol{cost_{investment}}(cost, loc::tech) = cost_{fractional\\_om}(cost, loc::tech) + cost_{fixed\\_om}(cost, loc::tech) + cost_{con}(cost, loc::tech) cost_{con}(cost, loc::tech) = depreciation\\_rate * ts\\_weight * (cost_{energy\\_cap}(cost, loc::tech) \\times \\boldsymbol{energy_{cap}}(loc::tech) + cost_{storage\\_cap}(cost, loc::tech) \\times \\boldsymbol{storage_{cap}}(loc::tech) + cost_{resource\\_cap}(cost, loc::tech) \\times \\boldsymbol{resource_{cap}}(loc::tech) + cost_{resource\\_area}(cost, loc::tech)) \\times \\boldsymbol{resource_{area}}(loc::tech) depreciation\\_rate = \\begin{cases} = 1 / plant\\_life,& \\text{if } interest\\_rate = 0\\\\ = \\frac{interest\\_rate \\times (1 + interest\\_rate)^{plant\\_life}}{(1 + interest\\_rate)^{plant\\_life} - 1},& \\text{if } interest\\_rate \\gt 0\\\\ \\end{cases} ts\\_weight = \\sum_{timestep \\in timesteps} (time\\_res(timestep) \\times weight(timestep)) \\times \\frac{1}{8760} """ model_data_dict = backend_model.__calliope_model_data__ def _get_investment_cost(capacity_decision_variable, calliope_set): """ Conditionally add investment costs, if the relevant set of technologies exists. Both inputs are strings. """ if loc_tech_is_in(backend_model, loc_tech, calliope_set): _cost = (getattr(backend_model, capacity_decision_variable)[loc_tech] * get_param(backend_model, 'cost_' + capacity_decision_variable, (cost, loc_tech))) return _cost else: return 0 cost_energy_cap = (backend_model.energy_cap[loc_tech] * get_param(backend_model, 'cost_energy_cap', (cost, loc_tech))) cost_storage_cap = _get_investment_cost('storage_cap', 'loc_techs_store') cost_resource_cap = _get_investment_cost('resource_cap', 'loc_techs_supply_plus') cost_resource_area = _get_investment_cost('resource_area', 'loc_techs_area') cost_om_annual_investment_fraction = get_param(backend_model, 'cost_om_annual_investment_fraction', (cost, loc_tech)) cost_om_annual = get_param(backend_model, 'cost_om_annual', (cost, loc_tech)) ts_weight = get_timestep_weight(backend_model) depreciation_rate = model_data_dict['data']['cost_depreciation_rate'].get((cost, loc_tech), 0) cost_con = ( depreciation_rate * ts_weight * (cost_energy_cap + cost_storage_cap + cost_resource_cap + cost_resource_area) ) # Transmission technologies exist at two locations, thus their cost is divided by 2 if loc_tech_is_in(backend_model, loc_tech, 'loc_techs_transmission'): cost_con = cost_con / 2 cost_fractional_om = cost_om_annual_investment_fraction * cost_con cost_fixed_om = cost_om_annual * backend_model.energy_cap[loc_tech] * ts_weight backend_model.cost_investment_rhs[cost, loc_tech].expr = ( cost_fractional_om + cost_fixed_om + cost_con ) return ( backend_model.cost_investment[cost, loc_tech] == backend_model.cost_investment_rhs[cost, loc_tech] )
def cost_investment_constraint_rule(backend_model, cost, loc_tech): """ Calculate costs from capacity decision variables. Transmission technologies "exist" at two locations, so their cost is divided by 2. .. container:: scrolling-wrapper .. math:: \\boldsymbol{cost_{investment}}(cost, loc::tech) = cost_{fractional\\_om}(cost, loc::tech) + cost_{fixed\\_om}(cost, loc::tech) + cost_{con}(cost, loc::tech) cost_{con}(cost, loc::tech) = depreciation\\_rate * ts\\_weight * (cost_{energy\\_cap}(cost, loc::tech) \\times \\boldsymbol{energy_{cap}}(loc::tech) + cost_{storage\\_cap}(cost, loc::tech) \\times \\boldsymbol{storage_{cap}}(loc::tech) + cost_{resource\\_cap}(cost, loc::tech) \\times \\boldsymbol{resource_{cap}}(loc::tech) + cost_{resource\\_area}(cost, loc::tech)) \\times \\boldsymbol{resource_{area}}(loc::tech) depreciation\\_rate = \\begin{cases} = 1 / plant\\_life,& \\text{if } interest\\_rate = 0\\\\ = \\frac{interest\\_rate \\times (1 + interest\\_rate)^{plant\\_life}}{(1 + interest\\_rate)^{plant\\_life} - 1},& \\text{if } interest\\_rate \\gt 0\\\\ \\end{cases} ts\\_weight = \\sum_{timestep \\in timesteps} (time\\_res(timestep) \\times weight(timestep)) \\times \\frac{1}{8760} """ model_data_dict = backend_model.__calliope_model_data__ def _get_investment_cost(capacity_decision_variable, calliope_set): """ Conditionally add investment costs, if the relevant set of technologies exists. Both inputs are strings. """ if loc_tech_is_in(backend_model, loc_tech, calliope_set): _cost = ( getattr(backend_model, capacity_decision_variable)[loc_tech] * get_param(backend_model, 'cost_' + capacity_decision_variable, (cost, loc_tech))) return _cost else: return 0 cost_energy_cap = (backend_model.energy_cap[loc_tech] * get_param(backend_model, 'cost_energy_cap', (cost, loc_tech))) cost_storage_cap = _get_investment_cost('storage_cap', 'loc_techs_store') cost_resource_cap = _get_investment_cost('resource_cap', 'loc_techs_supply_plus') cost_resource_area = _get_investment_cost('resource_area', 'loc_techs_area') cost_om_annual_investment_fraction = get_param( backend_model, 'cost_om_annual_investment_fraction', (cost, loc_tech)) cost_om_annual = get_param(backend_model, 'cost_om_annual', (cost, loc_tech)) ts_weight = get_timestep_weight(backend_model) depreciation_rate = model_data_dict['data']['cost_depreciation_rate'].get( (cost, loc_tech), 0) cost_con = (depreciation_rate * ts_weight * (cost_energy_cap + cost_storage_cap + cost_resource_cap + cost_resource_area)) # Transmission technologies exist at two locations, thus their cost is divided by 2 if loc_tech_is_in(backend_model, loc_tech, 'loc_techs_transmission'): cost_con = cost_con / 2 cost_fractional_om = cost_om_annual_investment_fraction * cost_con cost_fixed_om = cost_om_annual * backend_model.energy_cap[ loc_tech] * ts_weight backend_model.cost_investment_rhs[cost, loc_tech].expr = (cost_fractional_om + cost_fixed_om + cost_con) return (backend_model.cost_investment[cost, loc_tech] == backend_model.cost_investment_rhs[cost, loc_tech])
def cost_investment_constraint_rule(backend_model, cost, loc_tech): """ Calculate costs from capacity decision variables .. container:: scrolling-wrapper .. math:: """ model_data_dict = backend_model.__calliope_model_data__ def _get_investment_cost(capacity_decision_variable, calliope_set): """ Conditionally add investment costs, if the relevant set of technologies exists. Both inputs are strings. """ if loc_tech_is_in(backend_model, loc_tech, calliope_set): _cost = ( getattr(backend_model, capacity_decision_variable)[loc_tech] * get_param(backend_model, 'cost_' + capacity_decision_variable, (cost, loc_tech))) return _cost else: return 0 cost_energy_cap = (backend_model.energy_cap[loc_tech] * get_param(backend_model, 'cost_energy_cap', (cost, loc_tech))) cost_storage_cap = _get_investment_cost('storage_cap', 'loc_techs_store') cost_resource_cap = _get_investment_cost('resource_cap', 'loc_techs_supply_plus') cost_resource_area = _get_investment_cost('resource_area', 'loc_techs_area') cost_om_annual_investment_fraction = get_param( backend_model, 'cost_om_annual_investment_fraction', (cost, loc_tech)) cost_om_annual = get_param(backend_model, 'cost_om_annual', (cost, loc_tech)) ts_weight = get_timestep_weight(backend_model) depreciation_rate = model_data_dict['data']['cost_depreciation_rate'].get( (cost, loc_tech), 0) cost_con = (depreciation_rate * ts_weight * (cost_energy_cap + cost_storage_cap + cost_resource_cap + cost_resource_area)) # Transmission technologies exist at two locations, thus their cost is divided by 2 if loc_tech_is_in(backend_model, loc_tech, 'loc_techs_transmission'): cost_con = cost_con / 2 cost_fractional_om = cost_om_annual_investment_fraction * cost_con cost_fixed_om = cost_om_annual * backend_model.energy_cap[ loc_tech] * ts_weight backend_model.cost_investment_rhs[cost, loc_tech].expr = (cost_fractional_om + cost_fixed_om + cost_con) return (backend_model.cost_investment[cost, loc_tech] == backend_model.cost_investment_rhs[cost, loc_tech])
def cost_investment_expression_rule(backend_model, cost, node, tech): """ Calculate costs from capacity decision variables. Transmission technologies "exist" at two locations, so their cost is divided by 2. .. container:: scrolling-wrapper .. math:: \\boldsymbol{cost_{investment}}(cost, loc::tech) = cost_{fractional\\_om}(cost, loc::tech) + cost_{fixed\\_om}(cost, loc::tech) + cost_{cap}(cost, loc::tech) cost_{cap}(cost, loc::tech) = depreciation\\_rate * ts\\_weight * (cost_{energy\\_cap}(cost, loc::tech) \\times \\boldsymbol{energy_{cap}}(loc::tech) + cost_{storage\\_cap}(cost, loc::tech) \\times \\boldsymbol{storage_{cap}}(loc::tech) + cost_{resource\\_cap}(cost, loc::tech) \\times \\boldsymbol{resource_{cap}}(loc::tech) + cost_{resource\\_area}(cost, loc::tech)) \\times \\boldsymbol{resource_{area}}(loc::tech) depreciation\\_rate = \\begin{cases} = 1 / plant\\_life,& \\text{if } interest\\_rate = 0\\\\ = \\frac{interest\\_rate \\times (1 + interest\\_rate)^{plant\\_life}}{(1 + interest\\_rate)^{plant\\_life} - 1},& \\text{if } interest\\_rate \\gt 0\\\\ \\end{cases} ts\\_weight = \\sum_{timestep \\in timesteps} (time\\_res(timestep) \\times weight(timestep)) \\times \\frac{1}{8760} """ def _get_investment_cost(capacity_decision_variable): """ Conditionally add investment costs, if the relevant set of technologies exists. Both inputs are strings. """ if loc_tech_is_in(backend_model, (node, tech), capacity_decision_variable + "_index"): _cost = getattr( backend_model, capacity_decision_variable)[node, tech] * get_param( backend_model, "cost_" + capacity_decision_variable, (cost, node, tech)) return _cost else: return 0 cost_energy_cap = backend_model.energy_cap[node, tech] * get_param( backend_model, "cost_energy_cap", (cost, node, tech)) cost_storage_cap = _get_investment_cost("storage_cap") cost_resource_cap = _get_investment_cost("resource_cap") cost_resource_area = _get_investment_cost("resource_area") cost_om_annual_investment_fraction = get_param( backend_model, "cost_om_annual_investment_fraction", (cost, node, tech)) cost_om_annual = get_param(backend_model, "cost_om_annual", (cost, node, tech)) if loc_tech_is_in(backend_model, (node, tech), "units_index"): cost_of_purchase = (get_param(backend_model, "cost_purchase", (cost, node, tech)) * backend_model.units[node, tech]) elif loc_tech_is_in(backend_model, (node, tech), "purchased_index"): cost_of_purchase = (get_param(backend_model, "cost_purchase", (cost, node, tech)) * backend_model.purchased[node, tech]) else: cost_of_purchase = 0 ts_weight = get_timestep_weight(backend_model) depreciation_rate = get_param(backend_model, "cost_depreciation_rate", (cost, node, tech)) cost_cap = (depreciation_rate * ts_weight * (cost_energy_cap + cost_storage_cap + cost_resource_cap + cost_resource_area + cost_of_purchase)) # Transmission technologies exist at two locations, thus their cost is divided by 2 if backend_model.inheritance[tech].value.endswith("transmission"): cost_cap = cost_cap / 2 cost_fractional_om = cost_om_annual_investment_fraction * cost_cap cost_fixed_om = cost_om_annual * backend_model.energy_cap[node, tech] * ts_weight return cost_fractional_om + cost_fixed_om + cost_cap