Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

match build_powerplants FuelType #701

Merged
merged 7 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions scripts/add_electricity.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,13 @@ def attach_conventional_generators(
add_missing_carriers(n, carriers)
add_co2_emissions(n, costs, carriers)

# Replace carrier "natural gas" with the respective technology (OCGT or
# CCGT) to align with PyPSA names of "carriers" and avoid filtering "natural
# gas" powerplants in ppl.query("carrier in @carriers")
ppl.loc[ppl["carrier"] == "natural gas", "carrier"] = ppl.loc[
ppl["carrier"] == "natural gas", "technology"
]

ppl = (
ppl.query("carrier in @carriers")
.join(costs, on="carrier", rsuffix="_r")
Expand Down
15 changes: 10 additions & 5 deletions scripts/add_existing_baseyear.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,14 @@ def add_power_capacities_installed_before_baseyear(n, grouping_years, costs, bas
"Oil": "oil",
"OCGT": "OCGT",
"CCGT": "CCGT",
"Natural Gas": "gas",
"Bioenergy": "urban central solid biomass CHP",
}

# Replace Fueltype "Natural Gas" with the respective technology (OCGT or CCGT)
df_agg.loc[df_agg["Fueltype"] == "Natural Gas", "Fueltype"] = df_agg.loc[
df_agg["Fueltype"] == "Natural Gas", "Technology"
]

fueltype_to_drop = [
"Hydro",
"Wind",
Expand Down Expand Up @@ -601,12 +605,13 @@ def add_heating_capacities_installed_before_baseyear(

snakemake = mock_snakemake(
"add_existing_baseyear",
configfiles="config/test/config.myopic.yaml",
simpl="",
clusters="45",
ll="v1.0",
clusters="5",
ll="v1.5",
opts="",
sector_opts="8760H-T-H-B-I-A-solar+p3-dist1",
planning_horizons=2020,
sector_opts="24H-T-H-B-I-A-solar+p3-dist1",
planning_horizons=2030,
)

logging.basicConfig(level=snakemake.config["logging"]["level"])
Expand Down
10 changes: 6 additions & 4 deletions scripts/build_powerplants.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,15 @@ def add_custom_powerplants(ppl, custom_powerplants, custom_ppl_query=False):


def replace_natural_gas_technology(df):
mapping = {"Steam Turbine": "OCGT", "Combustion Engine": "OCGT"}
tech = df.Technology.replace(mapping).fillna("OCGT")
return df.Technology.where(df.Fueltype != "Natural Gas", tech)
mapping = {"Steam Turbine": "CCGT", "Combustion Engine": "OCGT"}
tech = df.Technology.replace(mapping).fillna("CCGT")
return df.Technology.mask(df.Fueltype == "Natural Gas", tech)


def replace_natural_gas_fueltype(df):
return df.Fueltype.where(df.Fueltype != "Natural Gas", df.Technology)
return df.Fueltype.mask(
(df.Technology == "OCGT") | (df.Technology == "CCGT"), "Natural Gas"
)


if __name__ == "__main__":
Expand Down