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

Gas sanity checks eGon100RE #1129

Open
wants to merge 31 commits into
base: dev
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
e15b0aa
Update CHANGELOG
Dec 14, 2022
e57797e
Create new functions reused in sanity_checks
Dec 14, 2022
db0ae44
Add sanity checks for gas in Germany in eGon2035
Dec 14, 2022
241b915
Format documentation
Dec 14, 2022
9b33d5a
Separate definition and insertion in the DB of abroad gas buses
Dec 19, 2022
4ea1031
New imports and apply isort
AmeliaNadal Dec 29, 2022
e78faea
Complete sanity checks of gas buses
AmeliaNadal Dec 29, 2022
543ea5a
Add functions sanity_check_gas_one_port and sanity_check_gas_links
AmeliaNadal Dec 29, 2022
5f7f388
Add sanity checks for gas abroad
AmeliaNadal Dec 29, 2022
09a922f
Correct typo and formating
AmeliaNadal Dec 29, 2022
ef8eb38
Increase dataset version
AmeliaNadal Dec 29, 2022
030d27e
Merge branch 'dev' into features/#864_gas_sanity_checks_eGon2035
AmeliaNadal Feb 1, 2023
91acb66
Add sanity checks abroads
AmeliaNadal Feb 1, 2023
fd246f6
Correct typo
AmeliaNadal Feb 1, 2023
3ee36a8
Remove f-string without interpolation
AmeliaNadal Feb 10, 2023
e9d3c5c
Adapt sanity check to account for changes of PR #1101
AmeliaNadal Feb 10, 2023
6185d1f
Merge branch 'dev' into features/#864_gas_sanity_checks_eGon2035
AmeliaNadal Feb 10, 2023
84b9be5
Bypass SSL verification
AmeliaNadal Feb 14, 2023
6924eaa
Update CHANGELOG
AmeliaNadal Feb 15, 2023
cee7f9f
Increase dataset version
AmeliaNadal Feb 15, 2023
6f135eb
Merge branch 'features/#864_gas_sanity_checks_eGon2035' into features…
AmeliaNadal Feb 20, 2023
e901673
Update CHANGELOG
AmeliaNadal Feb 20, 2023
cf580eb
Isolate calculation of global industrial gas demand
AmeliaNadal Feb 20, 2023
d7a3eea
Increase dataset version
AmeliaNadal Feb 20, 2023
cf9464b
Insert first gas sanity checks for eGon100RE
AmeliaNadal Feb 20, 2023
d97f693
Generalize sanity checks for gas generators
AmeliaNadal Feb 20, 2023
514b164
Add additional checks for gas sector in Germany
AmeliaNadal Feb 21, 2023
3c4e7bc
Merge branch 'fixes/#1102_TYNDP_url' into features/#1067-gas_sanitych…
AmeliaNadal Feb 21, 2023
c2b32cf
Merge branch 'dev' into features/#1067-gas_sanitycheck_eGon100RE
AmeliaNadal Mar 27, 2023
aaf5aa9
Merge branch 'dev' into features/#1067-gas_sanitycheck_eGon100RE
AmeliaNadal Mar 31, 2023
79f3fea
Increase dataset version
AmeliaNadal Mar 31, 2023
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
Prev Previous commit
Next Next commit
Insert first gas sanity checks for eGon100RE
  • Loading branch information
AmeliaNadal committed Feb 20, 2023
commit cf9464bfa9f2812a08948d235cfd884fdb9058fb
89 changes: 84 additions & 5 deletions src/egon/data/datasets/sanity_checks.py
Original file line number Diff line number Diff line change
@@ -58,6 +58,9 @@
from egon.data.datasets.hydrogen_etrago.storage import (
calculate_and_map_saltcavern_storage_potential,
)
from egon.data.datasets.industrial_gas_demand import (
calculate_total_demand_100RE,
)
from egon.data.datasets.power_plants.pv_rooftop_buildings import (
PV_CAP_PER_SQ_M,
ROOF_FACTOR,
@@ -98,6 +101,7 @@ def __init__(self, dependencies):
sanitycheck_home_batteries,
etrago_eGon2035_gas_DE,
etrago_eGon2035_gas_abroad,
etrago_eGon100RE_gas_DE,
sanitycheck_dsm,
},
)
@@ -1457,11 +1461,11 @@ def sanity_check_gas_buses(scn):
"H2_grid": "H2_feedin",
"H2_saltcavern": "power_to_H2",
},
# "eGon100RE": {
# "CH4": "CH4",
# "H2_grid": "H2_retrofit",
# "H2_saltcavern": "H2_extension",
# }
"eGon100RE": {
"CH4": "CH4",
"H2_grid": "H2_retrofit",
"H2_saltcavern": "H2_gridextension",
},
}
for key in corresponding_carriers[scn]:
isolated_gas_buses = db.select_dataframe(
@@ -2337,6 +2341,81 @@ def etrago_eGon2035_gas_abroad():
print("Testmode is on, skipping sanity check.")


def etrago_eGon100RE_gas_DE():
"""Execute basic sanity checks for the gas sector in eGon100RE

Returns print statements as sanity checks for the gas sector in
the eGon100RE scenario for the following components in Germany:
* Buses: with the function :py:func:`sanity_check_gas_buses`
* Loads: for the carriers 'CH4_for_industry' and 'H2_for_industry'
the deviation is calculated between the sum of the loads in the
database and the loads calcultaed by p-e-s
* Generators: with the function :py:func:`sanity_check_gas_generators_DE`
* Stores: deviations for stores with following carriers are
calculated:
* 'CH4': with the function :py:func:`sanity_check_CH4_stores`
* 'H2_underground': with the function :py:func:`sanity_check_H2_saltcavern_stores`
* 'H2': the deviation is calculated between the sum of the
capacities of the stores with carrier 'H2' in the database
and the sum of the capacity the gas grid allocated to H2

"""
scn = "eGon100RE"
TESTMODE_OFF = True
if TESTMODE_OFF:
logger.info(f"Gas sanity checks for scenario {scn}")

# Buses
sanity_check_gas_buses(scn)

# Loads
logger.info("LOADS")

H2_d, CH4_d = calculate_total_demand_100RE()

for carrier, total_ind_gas_d in zip(
["H2_for_industry", "CH4_for_industry"], [H2_d, CH4_d]
):

output_gas_demand = db.select_dataframe(
f"""SELECT (SUM(
(SELECT SUM(p)
FROM UNNEST(b.p_set) p)))::numeric as load
FROM grid.egon_etrago_load a
JOIN grid.egon_etrago_load_timeseries b
ON (a.load_id = b.load_id)
JOIN grid.egon_etrago_bus c
ON (a.bus=c.bus_id)
AND b.scn_name = '{scn}'
AND a.scn_name = '{scn}'
AND c.scn_name = '{scn}'
AND c.country = 'DE'
AND a.carrier = '{carrier}';
""",
warning=False,
)["load"].values[0]

input_gas_demand = total_ind_gas_d

e_demand = (
round(
(output_gas_demand - input_gas_demand) / input_gas_demand,
2,
)
* 100
)
logger.info(f"Deviation {carrier}: {e_demand} %")

# Generators
sanity_check_gas_generators_DE(scn)

# Stores
logger.info("STORES")
sanity_check_CH4_stores(scn)
sanity_check_H2_saltcavern_stores(scn)
# Check for H2 should be implemented when H2 stores are in dev


def sanitycheck_dsm():
def df_from_series(s: pd.Series):
return pd.DataFrame.from_dict(dict(zip(s.index, s.values)))