Skip to content
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
16 changes: 4 additions & 12 deletions doc/components.rst
Original file line number Diff line number Diff line change
Expand Up @@ -438,18 +438,10 @@ these are used in the LOPF and the `example of a CHP with a fixed
power-heat ratio
<https://pypsa.readthedocs.io/en/latest/examples/chp-fixed-heat-power-ratio.html>`_.

To define the new columns ``bus2``, ``efficiency2``, ``bus3``,
``efficiency3``, etc. in ``network.links`` you need to override the
standard component attributes by passing ``pypsa.Network()`` an
``override_component_attrs`` argument. See the section
:ref:`custom_components` and the `example of a CHP with a fixed
power-heat ratio
<https://pypsa.readthedocs.io/en/latest/examples/chp-fixed-heat-power-ratio.html>`_.


If the column ``bus2`` exists, values in the column are not compulsory
for all links; if the link has no 2nd output, simply leave it empty
``network.links.at["my_link","bus2"] = ""``.
The columns ``bus2``, ``efficiency2``, ``bus3``, ``efficiency3``, etc. in
``network.links`` are automatically added to the component attributes. The
values in these columns are not compulsory; if the link has no 2nd output,
simply leave it empty ``network.links.at["my_link","bus2"] = ""`` or as NaN.

For links with multiple inputs in fixed ratio to one of the inputs,
you can define the other inputs as outputs with a negative efficiency
Expand Down
9 changes: 9 additions & 0 deletions doc/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,18 @@ Upcoming Release
now allows the passing of a list of buses for which aggregation of __all__ carriers is desired. Generation from
a carrier at a bus is aggregated now if: It is __either__ in the passed list of aggregated carriers, __or__ in the
list of aggregated buses.
* PyPSA now supports stand-by cost terms. A new column
`stand_by_cost` was added to generators and links. The stand-by
cost is added to the objective function when calling
``n.optimize()``.
* Links with multiple inputs/outputs are now supported by default. The Link
component attributes are automatically extended if a link with ``bus2``,
``bus3``, etc. are added to the network. Overriding component attributes
at network initialisation is no longer required.
* The ``n.optimize`` accessor now provides functionality for rolling horizon optimisation using ``n.optimize.optimize_with_rolling_horizon()`` which splits whole optimization of the whole time span into multiple subproblems which are solved consecutively. This is useful for operational optimizations with a high spatial resolution.
* PyPSA now supports stand-by cost terms. A new column`stand_by_cost` was added to generators and links. The stand-by cost is added to the objective function when calling ``n.optimize()``.


PyPSA 0.24.0 (27th June 2023)
=================================

Expand Down
76 changes: 13 additions & 63 deletions examples/notebooks/biomass-synthetic-fuels-carbon-management.ipynb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -26,79 +27,18 @@
"import matplotlib.pyplot as plt"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"First tell PyPSA that links can have multiple outputs by overriding the component_attrs. This can be done for as many buses as you need with format busi for i = 2,3,4,5,.... \n",
"\n",
"See https://pypsa.org/doc/components.html#link-with-multiple-outputs-or-inputs"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"override_component_attrs = pypsa.descriptors.Dict(\n",
" {k: v.copy() for k, v in pypsa.components.component_attrs.items()}\n",
")\n",
"override_component_attrs[\"Link\"].loc[\"bus2\"] = [\n",
" \"string\",\n",
" np.nan,\n",
" np.nan,\n",
" \"2nd bus\",\n",
" \"Input (optional)\",\n",
"]\n",
"override_component_attrs[\"Link\"].loc[\"bus3\"] = [\n",
" \"string\",\n",
" np.nan,\n",
" np.nan,\n",
" \"3rd bus\",\n",
" \"Input (optional)\",\n",
"]\n",
"override_component_attrs[\"Link\"].loc[\"efficiency2\"] = [\n",
" \"static or series\",\n",
" \"per unit\",\n",
" 1.0,\n",
" \"2nd bus efficiency\",\n",
" \"Input (optional)\",\n",
"]\n",
"override_component_attrs[\"Link\"].loc[\"efficiency3\"] = [\n",
" \"static or series\",\n",
" \"per unit\",\n",
" 1.0,\n",
" \"3rd bus efficiency\",\n",
" \"Input (optional)\",\n",
"]\n",
"override_component_attrs[\"Link\"].loc[\"p2\"] = [\n",
" \"series\",\n",
" \"MW\",\n",
" 0.0,\n",
" \"2nd bus output\",\n",
" \"Output\",\n",
"]\n",
"override_component_attrs[\"Link\"].loc[\"p3\"] = [\n",
" \"series\",\n",
" \"MW\",\n",
" 0.0,\n",
" \"3rd bus output\",\n",
" \"Output\",\n",
"]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"n = pypsa.Network(override_component_attrs=override_component_attrs)\n",
"n = pypsa.Network()\n",
"n.set_snapshots(range(10))"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -116,6 +56,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -139,6 +80,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -163,6 +105,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -204,6 +147,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -229,6 +173,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -283,6 +228,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -340,6 +286,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -371,6 +318,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -388,6 +336,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -407,6 +356,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down
46 changes: 6 additions & 40 deletions examples/notebooks/chained-hydro-reservoirs.ipynb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -23,56 +24,18 @@
"import matplotlib.pyplot as plt"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"First tell PyPSA that links will have a 2nd bus by overriding the component_attrs. This is needed so that water can both go through a turbine AND feed the next reservoir"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"override_component_attrs = pypsa.descriptors.Dict(\n",
" {k: v.copy() for k, v in pypsa.components.component_attrs.items()}\n",
")\n",
"override_component_attrs[\"Link\"].loc[\"bus2\"] = [\n",
" \"string\",\n",
" np.nan,\n",
" np.nan,\n",
" \"2nd bus\",\n",
" \"Input (optional)\",\n",
"]\n",
"override_component_attrs[\"Link\"].loc[\"efficiency2\"] = [\n",
" \"static or series\",\n",
" \"per unit\",\n",
" 1.0,\n",
" \"2nd bus efficiency\",\n",
" \"Input (optional)\",\n",
"]\n",
"override_component_attrs[\"Link\"].loc[\"p2\"] = [\n",
" \"series\",\n",
" \"MW\",\n",
" 0.0,\n",
" \"2nd bus output\",\n",
" \"Output\",\n",
"]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"network = pypsa.Network(override_component_attrs=override_component_attrs)\n",
"network = pypsa.Network()\n",
"network.set_snapshots(pd.date_range(\"2016-01-01 00:00\", \"2016-01-01 03:00\", freq=\"H\"))"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -111,6 +74,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -187,6 +151,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -226,6 +191,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down
42 changes: 2 additions & 40 deletions examples/notebooks/chp-fixed-heat-power-ratio.ipynb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -24,52 +25,13 @@
"import pypsa, numpy as np"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"First tell PyPSA that links will have a 2nd bus by overriding the component_attrs. This can be done for as many buses as you need with format busi for i = 2,3,4,5,...."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"override_component_attrs = pypsa.descriptors.Dict(\n",
" {k: v.copy() for k, v in pypsa.components.component_attrs.items()}\n",
")\n",
"override_component_attrs[\"Link\"].loc[\"bus2\"] = [\n",
" \"string\",\n",
" np.nan,\n",
" np.nan,\n",
" \"2nd bus\",\n",
" \"Input (optional)\",\n",
"]\n",
"override_component_attrs[\"Link\"].loc[\"efficiency2\"] = [\n",
" \"static or series\",\n",
" \"per unit\",\n",
" 1.0,\n",
" \"2nd bus efficiency\",\n",
" \"Input (optional)\",\n",
"]\n",
"override_component_attrs[\"Link\"].loc[\"p2\"] = [\n",
" \"series\",\n",
" \"MW\",\n",
" 0.0,\n",
" \"2nd bus output\",\n",
" \"Output\",\n",
"]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"network = pypsa.Network(override_component_attrs=override_component_attrs)\n",
"network = pypsa.Network()\n",
"\n",
"network.add(\"Bus\", \"Frankfurt\", carrier=\"AC\")\n",
"network.add(\"Load\", \"Frankfurt\", bus=\"Frankfurt\", p_set=5)\n",
Expand Down
Loading