Prevent attempt to re-add existing carriers.
This commit is contained in:
parent
134a05f6f1
commit
16dcad0176
@ -16,6 +16,8 @@ Upcoming Release
|
|||||||
|
|
||||||
* Bugfix: Correct typo in the CPLEX solver configuration in ``config.default.yaml``.
|
* Bugfix: Correct typo in the CPLEX solver configuration in ``config.default.yaml``.
|
||||||
|
|
||||||
|
* Bugfix: Error in ``add_electricity`` where carriers were added multiple times to the network, resulting in a non-unique carriers error.
|
||||||
|
|
||||||
* Renamed script file from PyPSA-EUR ``build_load_data`` to ``build_electricity_demand`` and ``retrieve_load_data`` to ``retrieve_electricity_demand``.
|
* Renamed script file from PyPSA-EUR ``build_load_data`` to ``build_electricity_demand`` and ``retrieve_load_data`` to ``retrieve_electricity_demand``.
|
||||||
|
|
||||||
* Fix docs readthedocs built
|
* Fix docs readthedocs built
|
||||||
|
@ -122,6 +122,13 @@ def calculate_annuity(n, r):
|
|||||||
else:
|
else:
|
||||||
return 1 / n
|
return 1 / n
|
||||||
|
|
||||||
|
def add_missing_carriers(n, carriers):
|
||||||
|
"""
|
||||||
|
Function to add missing carriers to the network without raising errors.
|
||||||
|
"""
|
||||||
|
missing_carriers = set(carriers) - set(n.carriers.index)
|
||||||
|
if len(missing_carriers) > 0:
|
||||||
|
n.madd("Carrier", missing_carriers)
|
||||||
|
|
||||||
def sanitize_carriers(n, config):
|
def sanitize_carriers(n, config):
|
||||||
"""
|
"""
|
||||||
@ -152,9 +159,7 @@ def sanitize_carriers(n, config):
|
|||||||
|
|
||||||
for c in n.iterate_components():
|
for c in n.iterate_components():
|
||||||
if "carrier" in c.df:
|
if "carrier" in c.df:
|
||||||
missing_carrier = set(c.df.carrier.unique()) - set(n.carriers.index) - {""}
|
add_missing_carriers(n, c.df)
|
||||||
if len(missing_carrier):
|
|
||||||
n.madd("Carrier", missing_carrier)
|
|
||||||
|
|
||||||
carrier_i = n.carriers.index
|
carrier_i = n.carriers.index
|
||||||
nice_names = (
|
nice_names = (
|
||||||
@ -354,7 +359,7 @@ def update_transmission_costs(n, costs, length_factor=1.0):
|
|||||||
def attach_wind_and_solar(
|
def attach_wind_and_solar(
|
||||||
n, costs, input_profiles, carriers, extendable_carriers, line_length_factor=1
|
n, costs, input_profiles, carriers, extendable_carriers, line_length_factor=1
|
||||||
):
|
):
|
||||||
n.madd("Carrier", carriers)
|
add_missing_carriers(n, carriers)
|
||||||
|
|
||||||
for car in carriers:
|
for car in carriers:
|
||||||
if car == "hydro":
|
if car == "hydro":
|
||||||
@ -416,7 +421,7 @@ def attach_conventional_generators(
|
|||||||
conventional_inputs,
|
conventional_inputs,
|
||||||
):
|
):
|
||||||
carriers = list(set(conventional_carriers) | set(extendable_carriers["Generator"]))
|
carriers = list(set(conventional_carriers) | set(extendable_carriers["Generator"]))
|
||||||
n.madd("Carrier", carriers)
|
add_missing_carriers(n, carriers)
|
||||||
add_co2_emissions(n, costs, carriers)
|
add_co2_emissions(n, costs, carriers)
|
||||||
|
|
||||||
ppl = (
|
ppl = (
|
||||||
@ -473,7 +478,7 @@ def attach_conventional_generators(
|
|||||||
|
|
||||||
|
|
||||||
def attach_hydro(n, costs, ppl, profile_hydro, hydro_capacities, carriers, **params):
|
def attach_hydro(n, costs, ppl, profile_hydro, hydro_capacities, carriers, **params):
|
||||||
n.madd("Carrier", carriers)
|
add_missing_carriers(n, carriers)
|
||||||
add_co2_emissions(n, costs, carriers)
|
add_co2_emissions(n, costs, carriers)
|
||||||
|
|
||||||
ppl = (
|
ppl = (
|
||||||
@ -606,7 +611,7 @@ def attach_extendable_generators(n, costs, ppl, carriers):
|
|||||||
logger.warning(
|
logger.warning(
|
||||||
"The function `attach_extendable_generators` is deprecated in v0.5.0."
|
"The function `attach_extendable_generators` is deprecated in v0.5.0."
|
||||||
)
|
)
|
||||||
n.madd("Carrier", carriers)
|
add_missing_carriers(n, carriers)
|
||||||
add_co2_emissions(n, costs, carriers)
|
add_co2_emissions(n, costs, carriers)
|
||||||
|
|
||||||
for tech in carriers:
|
for tech in carriers:
|
||||||
|
Loading…
Reference in New Issue
Block a user