Support country-specific mappings and custom transmission line types - #1933
Support country-specific mappings and custom transmission line types#1933danielelerede-oet wants to merge 31 commits into
Conversation
There was a problem hiding this comment.
Many thanks @danielelerede-oet !
Really like the proposal that enables custom line-types by country that is a long wanted feature! Adding a comment
| voltage,default,AU | ||
| 132,243-AL1/39-ST1A 110.0,243-AL1/39-ST1A 110.0 | ||
| 220,Al/St 240/40 2-bundle 220.0, | ||
| 275,Al/St 240/40 3-bundle 300.0,Al/St 240/40 3-bundle 300.0 | ||
| 300,Al/St 240/40 3-bundle 300.0, | ||
| 330,Al/St 240/40 4-bundle 380.0,Al/St 240/40 4-bundle 380.0 | ||
| 380,Al/St 240/40 4-bundle 380.0, | ||
| 500,Al/St 240/40 4-bundle 380.0,Al/St 560/50 4-bundle 750.0 | ||
| 750,Al/St 560/50 4-bundle 750.0, |
There was a problem hiding this comment.
Could we keep the assignment of line types in the config file and add the csv for the characteristics of custom line types that are not defined in pypsa?
The advantage is that for each country we can define only the relevant line types and avoid nan values. The higher the number of countries, the more complex the handling becomes with csv format
There was a problem hiding this comment.
The point is that this should address a slightly different case. In this PR, the csv file doesn't define the electrical characteristics of custom line types. It is supposed to only map each country and voltage level to a line type which is already existing in PyPSA (where applicable, as in the case of Australia).
The idea of having custom line types assigned to countries as the US where the mapping with already existing PyPSA line types is not accurated would be complementary to this country-specific assignment mechanism rather than a replacement for it.
Keeping the assignment in the config would also preserve the current limitation, since the purpose of this PR is precisely to support different mappings by country without adding country-specific configuration sections. Let me know what you think :)
|
Hi @davide-f @ekatef I have extended the PR beyond the mapping you checked in initial review that only accounted for countries with line types already defined in PyPSA (i.e. Australia). The PR now also covers the US case, where representative types are not available in the standard library. I added a central
The existing default mapping remains unchanged for countries without dedicated mappings. |
4608916 to
6cb2470
Compare
davide-f
left a comment
There was a problem hiding this comment.
Amazing Daniele! I'm adding few comments; this is a great feature!
As a comment: have you verified that linetypes properly propagate across scripts especially after cluster_network, just to avoid surprises?
When linetype is defined, pypsa internally may recalculate values by using linetype info and it is advisable to ensure the information is preserved.
dd0d77e to
48fc259
Compare
Yes @davide-f this should be ensured but I'm testing the model on the US to double-check |
@davide-f, this comment identified an important point. I checked the networks generated across the different workflow steps and found that the voltage-specific US line types are correctly assigned in elec.nc, but simplify_network subsequently remaps every line to the type associated with the configured base voltage. With the current 380 kV base voltage, the US mapping has no corresponding entry and therefore falls back to the default Al/St 240/40 4-bundle 380.0 type. The procedure preserves We could either retain the current behaviour or revise the simplification settings to use more representative regional base voltages and mapped line types: potentially A preliminary comparison on the same simplified network confirms that using a 345 kV base voltage with US_345kV:
Therefore, the regional simplification mapping is not merely a naming change: it materially affects the electrical representation, even though the thermal capacities remain unchanged. I will implement the US-specific mapping and rerun the network to quantify its impact on flows, congestion, dispatch and the objective. I'm now testing this in pypsa-meets-earth/pypsa-northamerica#43 : base_voltage:
default: 380.
AU: 330.
US: 345.In For the current US-only test, all buses and lines are simplified at 345 kV and use One crucial point remains open before using this implementation in multi-country networks: an AC interconnector could connect countries to which different simplification voltages are assigned. The current logic follows the country of I have not added a fail-fast test because we should first decide whether interconnected countries should share a common regional base voltage or whether voltage transitions should be represented explicitly (y preference would be to use a common simplification voltage for countries belonging to the same interconnected network). Result of test in PyPSA-NorthAmerica (PR #43)The |
|
@danielelerede-oet @davide-f looks an absolutely amazing work! @danielelerede-oet that is a very impactful improvement you have implemented to preserve the line type definition. We have experienced dropping of custom line parameters also in PyPSA-Zambia model, and can confirm that it's essential to get the linetype right. However, the fix we have applied has been an ad hoc solution. Tagging @tacwebservices who has worked a lot on examining regional representation the power grid and its' effects on modelling. |
davide-f
left a comment
There was a problem hiding this comment.
Thanks @danielelerede-oet ! Added a minor change.
As this PR adds a breaking change in the use of line_types, it is advisable to signal backcompatibility.
Yerbol has integrated an option to track migrations:
pypsa-earth/scripts/_helpers.py
Line 117 in 2970624
Please add the config references there to support the migrations. From a functional perspective I have only a comment left.
Many thanks!
| mapping = { | ||
| **linetypes["default"], | ||
| **linetypes.get(country, {}), | ||
| } |
There was a problem hiding this comment.
I'd revise the implementation: when country-specific options exist, the defaults are not used entirely, otherwise we risk mixing default and non-default linetypes for countries for small voltage differences
There was a problem hiding this comment.
Yeah, it's addressed now. It was already in my mind. Now the default and country-specific mappings are no longer merged. Country-specific line types are only used when lines.use_country_specific_types (as suggested by @ekatef ) is enabled and mappings are available for every configured country. Otherwise, the complete default mapping is used. This is evaluated separately for AC and DC line types, so default and country-specific line types are never mixed within the same category.
@davide-f I checked Since |
Co-authored-by: Davide Fioriti <67809479+davide-f@users.noreply.github.com>
Co-authored-by: Davide Fioriti <67809479+davide-f@users.noreply.github.com>
for more information, see https://pre-commit.ci
|
Thanks @davide-f I applied your latest comments too |
|
@carlosfv92 this PR may resolve the issues with the transmission capacity you reported in #1820 |
Description
This PR adds support for country-specific base voltages and transmission line-type mappings while preserving the existing PyPSA-Earth mappings as the default.
The use of country-specific line types is configurable through
lines.use_country_specific_types.When this option is enabled, country-specific mappings are used only if mappings are available for every configured country. Otherwise, the complete
defaultmapping is used. Availability is evaluated separately for AC and DC mappings, so country-specific and default mappings are not mixed within the same category.The country associated with a line is determined from
bus0, consistently across base-network construction, network simplification, and augmented connections. The closest available voltage is selected from the chosen mapping.Configuration
Line-type mappings remain in the configuration under:
The currently existing mapping is stored under
default. Optional country-specific mappings can be added using country codes.lines.use_country_specific_typesisfalse, the complete default mapping is used.trueand mappings exist for every configured country, the country-specific mappings are used.bus0.For example, if every configured country has an AC mapping but the DC mappings are incomplete, country-specific mappings are used for AC lines while the complete default mapping is used for DC lines.
Checklist
envs/environment.yamlanddoc/requirements.txt.config.default.yamlandconfig.tutorial.yaml.test/(note tests are changing the config.tutorial.yaml)doc/configtables/*.csvand line references are adjusted indoc/user-guide/configuration.mdanddoc/tutorials/electricity-model.md.doc/assets/scripts/extract_config_snippets.pyaccordingly.configs/bundle_config.yaml.doc/release-notes.mdis amended in the format of previous release notes, including reference to the requested PR.