Skip to content

Comments

Version 0.13.0#406

Merged
benoit9126 merged 71 commits intomainfrom
develop
Sep 1, 2025
Merged

Version 0.13.0#406
benoit9126 merged 71 commits intomainfrom
develop

Conversation

@benoit9126
Copy link
Member

A very long list of changes for this new version. 🌟

alihamdan and others added 30 commits March 14, 2025 15:37
BUG: ground not added by `add_short_circuit`
- Fix the constant-impedance equation to become V²/Z instead of V².Z
- Fix the constant-current equation to become V.I* instead of V.I
- Mention the constant variable in each equation
Detect duplicate IDs for line and transformer parameters and raise an
error if they are found.

The duplicate ID checks in `to_dict` are no longer needed.
The equality comparisons using the fields of the parameters are replaced
by identity comparisons.

Resolves #300
- Add nominal frequency (`fn`), cooling class (`cooling`) and insulation
type (`insulation`) to the `TransformerParameters` class.
- The transformers catalogue has been updated accordingly.
- The manufacturer names in the catalogue have been expanded to better
accomodate new transformers (`SE` -> `Schneider Electric`, `FT` ->
`France Transfo`, ...).
  - More HV/MV transformers have been added to the catalogue.
- The cooling and insulation are described in the new enumeration types
`TransformerCooling` and `TransformerInsulation` respectively.
This is a purely cosmetic change to improve the readability of the
results so that when we introspect the results in an interactive console
like a notebook cell we see something like `(-43.17581696+81.68999335j)`
instead of `np.complex128(-43.17581696+81.68999335j)` which is even more
annoying when seen in the dict of a network. Performance is not affected
by this change.
This PR has no user facing changes.

---------

Co-authored-by: Saelyos <seb.vallet@gmail.com>
Co-authored-by: Ali Hamdan <ali.hamdan@roseautechnologies.com>
This uses the newly added C++ branch methods to access the potential of
the ground port of a line with shunt componenets. This makes the line
results accessible independent of the Python ground element. No breaking
changes are made to the line results interface but the network JSON
format needed to be updated to store the new results.

This work will be essential later when we simplify ground handling in
RLF.
Use faster methods to get scalar C++ results and a few minor
improvements. This makes hosting capacity calculation from 25% faster
for small networks to 300% faster for larger networks.
Bumps [astral-sh/setup-uv](https://github.com/astral-sh/setup-uv) from 5
to 6.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/astral-sh/setup-uv/releases">astral-sh/setup-uv's
releases</a>.</em></p>
<blockquote>
<h2>v6.0.0 🌈 activate-environment and working-directory</h2>
<h2>Changes</h2>
<p>This version contains some breaking changes which have been gathering
up for a while. Lets dive into them:</p>
<ul>
<li><a
href="https://github.com/astral-sh/setup-uv/blob/HEAD/#activate-environment">Activate
environment</a></li>
<li><a
href="https://github.com/astral-sh/setup-uv/blob/HEAD/#working-directory">Working
Directory</a></li>
<li><a
href="https://github.com/astral-sh/setup-uv/blob/HEAD/#default-cache-dependency-glob">Default
<code>cache-dependency-glob</code></a></li>
<li><a
href="https://github.com/astral-sh/setup-uv/blob/HEAD/#use-default-cache-dir-on-self-hosted-runners">Use
default cache dir on self hosted runners</a></li>
</ul>
<h3>Activate environment</h3>
<p>In previous versions using the input <code>python-version</code>
automatically activated a venv at the repository root.
This led to some unwanted side-effects, was sometimes unexpected and not
flexible enough.</p>
<p>The venv activation is now explicitly controlled with the new input
<code>activate-environment</code> (false by default):</p>
<pre lang="yaml"><code>- name: Install the latest version of uv and
activate the environment
  uses: astral-sh/setup-uv@v6
  with:
    activate-environment: true
- run: uv pip install pip
</code></pre>
<p>The venv gets created by the <a
href="https://docs.astral.sh/uv/pip/environments/"><code>uv
venv</code></a> command so the python version is controlled by the
<code>python-version</code> input or the files
<code>pyproject.toml</code>, <code>uv.toml</code>,
<code>.python-version</code> in the <code>working-directory</code>.</p>
<h3>Working Directory</h3>
<p>The new input <code>working-directory</code> controls where we look
for <code>pyproject.toml</code>, <code>uv.toml</code> and
<code>.python-version</code> files
which are used to determine the version of uv and python to install.</p>
<p>It can also be used to control where the venv gets created.</p>
<pre lang="yaml"><code>- name: Install uv based on the config files in
the working-directory
  uses: astral-sh/setup-uv@v6
  with:
    working-directory: my/subproject/dir
</code></pre>
<blockquote>
<p>[!CAUTION]</p>
<p>The inputs <code>pyproject-file</code> and <code>uv-file</code> have
been removed.</p>
</blockquote>
<h3>Default <code>cache-dependency-glob</code></h3>
<p><a href="https://github.com/ssbarnea"><code>@​ssbarnea</code></a>
found out that the default <code>cache-dependency-glob</code> was not
suitable for a lot of users.</p>
<p>The old default</p>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/astral-sh/setup-uv/commit/6b9c6063abd6010835644d4c2e1bef4cf5cd0fca"><code>6b9c606</code></a>
Bump dependencies (<a
href="https://redirect.github.com/astral-sh/setup-uv/issues/389">#389</a>)</li>
<li><a
href="https://github.com/astral-sh/setup-uv/commit/ef6bcdff59f18584d3ff2d6733fe1ffb9b7545c1"><code>ef6bcdf</code></a>
Fix default cache dependency glob (<a
href="https://redirect.github.com/astral-sh/setup-uv/issues/388">#388</a>)</li>
<li><a
href="https://github.com/astral-sh/setup-uv/commit/9a311713f4acad0acceb25fb016307e47c3887b6"><code>9a31171</code></a>
chore: update known checksums for 0.6.17 (<a
href="https://redirect.github.com/astral-sh/setup-uv/issues/384">#384</a>)</li>
<li><a
href="https://github.com/astral-sh/setup-uv/commit/c7f87aa956e4c323abf06d5dec078e358f6b4d04"><code>c7f87aa</code></a>
bump to v6 in README (<a
href="https://redirect.github.com/astral-sh/setup-uv/issues/382">#382</a>)</li>
<li><a
href="https://github.com/astral-sh/setup-uv/commit/aadfaf08d64f83cdd98eea14fdab8eb08f73656c"><code>aadfaf0</code></a>
Change default cache-dependency-glob (<a
href="https://redirect.github.com/astral-sh/setup-uv/issues/352">#352</a>)</li>
<li><a
href="https://github.com/astral-sh/setup-uv/commit/a0f9da6273a171f2d94cce2036eaf5a07fefa23c"><code>a0f9da6</code></a>
No default UV_CACHE_DIR on selfhosted runners (<a
href="https://redirect.github.com/astral-sh/setup-uv/issues/380">#380</a>)</li>
<li><a
href="https://github.com/astral-sh/setup-uv/commit/ec4c6916287cf1471f9f803d79ef6a0a04520e81"><code>ec4c691</code></a>
new inputs activate-environment and working-directory (<a
href="https://redirect.github.com/astral-sh/setup-uv/issues/381">#381</a>)</li>
<li><a
href="https://github.com/astral-sh/setup-uv/commit/aa1290542ebcd3b6932d825ed2b40807f82b2fdd"><code>aa12905</code></a>
chore: update known checksums for 0.6.16 (<a
href="https://redirect.github.com/astral-sh/setup-uv/issues/378">#378</a>)</li>
<li><a
href="https://github.com/astral-sh/setup-uv/commit/fcaddda076a8158a712b6d64986baf606c446694"><code>fcaddda</code></a>
chore: update known checksums for 0.6.15 (<a
href="https://redirect.github.com/astral-sh/setup-uv/issues/377">#377</a>)</li>
<li><a
href="https://github.com/astral-sh/setup-uv/commit/fb3a0a97fac846cb3395265a3087ab94ad3ca2a0"><code>fb3a0a9</code></a>
log info on venv activation (<a
href="https://redirect.github.com/astral-sh/setup-uv/issues/375">#375</a>)</li>
<li>See full diff in <a
href="https://github.com/astral-sh/setup-uv/compare/v5...v6">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=astral-sh/setup-uv&package-manager=github_actions&previous-version=5&new-version=6)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
- User facing changes:
- Rename `ElectricalNetwork.from_dgs` to `from_dgs_file` and add
`ElectricalNetwork.from_dgs_dict`. The old method is deprecated.
- Internal changes:
- Refactor common parts of electrical network classes into an abstract
base class.
- Refactor common parts of element classes into an abstract base class.
  - Streamline abstract classes handling
- Avoid setting `_cy_element` to `None` and prefer deleting the
disconnected object to avoid segfaults similar to #346
  - Emit a clear error when mixing rlf and rlfs objects
Internal changes only:
- Simplify warnings filtering by applying `action` directly in
`catch_warnings`
- Simplify `ImportError` traceback with exception notes instead of
chaining exceptions
benoit9126 and others added 20 commits July 23, 2025 16:10
Also add preliminary support for python 3.14 development version and for
free-threaded python 3.13t. Full support is waiting on our dependencies
to release relevant wheels.
- Fix an error when plotting a network with all its geometries on the
same longitude or latitude and `zoom_start` is not provided
- Add more information to the hover over lines and buses
- Emit a clear error if an rlfs element was passed to plotting functions
that accept rlf elements only
- [single] Support plotting rlfs networks and add `rlfs.plotting` module
This makes the common case much more ergonomic.
- Add `rlfs.ElectricalNetwork.from_rlf`
- Add `rlfs.ElectricalNetwork` catalogue methods that reuse
`rlfs.ElectricalNetwork.from_rlf`
- Add conversion of transformer and flexible params from rlf to rlfs
similar to line params
…398)

This PR brings many performance improvements for results access on the
network and for network serialization. The optimization is mainly based
on looping over lists instead of numpy arrays which is much more
performant for small sized arrays like in our case.

Iterating over a small list, of say voltages, is 4X faster than
iterating over an array:

```ipy
[In]:  %%timeit
       [[v.real, v.imag] for v in voltages]
[Out]: 1.62 μs ± 32 ns per loop (mean ± std. dev. of 7 runs, 1,000,000 loops each)
```
vs
```ipy
[In]:  %%timeit
       [[v.real, v.imag] for v in voltages.tolist()]
[Out]: 429 ns ± 6.77 ns per loop (mean ± std. dev. of 7 runs, 1,000,000 loops each)
```

Similarly, computing the complex power in a list is 2X faster than using
array multiplication.

This resulted in a measured speedup of 20% when accessing
`en.res_buses`, `en.res_buses_voltages`, `en.res_lines`,
`en.res_transformers` and `en.res_loads` in an MV feeder with 351 buses,
318 lines, 31 transformers and 498 loads. The same network showed a 15%
speedup when serialized to a dict with the results.
Similar structure to rlfs.
The nesting is no longer needed as we don't have the C++ code anymore.
Added `rlfs.plotting.plot_results_interactive_map` which plots a network
colored by its results.

I had this function lying around in my local repo and thought it makes
sense to share it. This function shares a lot of code with
`plot_interactive_map` so I factorized the common parts into a helper
function. After the factorization, it became easy to separate
`plot_interactive_map` for rlfs from rlf so I separated them.
I am getting a `TypeError: Object of type Point is not JSON serializable`
when trying to plot the graph of the network with pyviz.
This is because we store the geometries as shapely objects in the graph.
This PR changes the geometries to geojson-like format so that they are
JSON serializable for better compatibility with the networkx ecosystem.
I also noticed that the buses were missing some data so I added them.
Fix ValueError: cannot process flags argument with a compiled pattern
@benoit9126 benoit9126 self-assigned this Aug 29, 2025
@benoit9126 benoit9126 added the enhancement New feature or request label Aug 29, 2025
@alihamdan
Copy link
Member

Maybe add the "Programming Language :: Python :: 3.14" and "Programming Language :: Python :: Free Threading :: 2 - Beta" classifiers?

@alihamdan
Copy link
Member

@benoit9126 I wrote blog-style release notes that better organize the changes and highlight important ones. Please use it in the GitHub release when it is out.


This is the release notes for Roseau Load Flow version 0.13.0. This version introduces several new
features, improvements, and bug fixes.

Support for Open Switches

Pass closed=False to the Switch constructor to create an open switch. Call switch.open() to open an existing switch and switch.close() to close it. switch.closed tells if the switch is closed or not. The switch is closed by default.

Contributed in PR 389.

Sides Accessors for Branches

Access to parameters and results of branch sides has been improved by adding side accessors to branch elements.

  • Transformer.side_hv and Transformer.side_lv return the high-voltage and low-voltage sides of a transformer.
  • Line.side1 and Line.side2 return the from and to sides of a line.
  • Switch.side1 and Switch.side2 return the from and to sides of a switch.

A side is a bus connectable element that has all common attributes of bus connectables. For example, Transformer.side_hv has the attributes bus, phases, res_currents, res_powers, res_voltages, etc.

Functions that used to accept a separate branch element and a side argument now accept a branch side element instead. Passing a branch element and a separate side argument to these functions is deprecated. These functions are rlf.GroundConnection, rlf.plotting.plot_voltage_phasors and rlf.plotting.plot_symmetrical_voltages. For example, replace rlf.GroundConnection(ground=ground, element=transformer, side="HV") by rlf.GroundConnection(ground=ground, element=transformer.side_hv) to avoid the deprecation warning.

Contributed in PR 385.

Plotting Improvements

  • Add popup and search functionality to the interactive map plot and improve hover tooltips.

    The rlf.plotting.plot_interactive_map function now accepts add_tooltips, add_popups and add_search arguments to control the display of tooltips, popups and search features. These features are enabled by default.

  • Fix an error in automatic zoom calculation when the whole network is on the same longitude or latitude.

Contributed in PR 395, PR 399.

Better Graph Support

In this release, the en.to_graph method has been revamped to fix several issues and improve usability.

  • The method now returns a multi-graph to preserve parallel edges like two or more lines, transformers or switches between the same two buses.
  • The geom attribute of nodes and edges is now a GeoJSON-like dictionary instead of a shapely geometry object. This makes the graph data JSON-serializable and compatible with pyviz plotting tools.
  • The graph now includes nominal voltage and min/max voltage levels as node attributes.
  • A new respect_switches parameter allows including open switches in the graph when set to False. By default, open switches are not included.

Contributed in PR 391.

External Tool Data in JSON Files

When writing an electrical network to a JSON file, it is now possible to include data specific to your tool or application. This data is stored in the tool_data attribute of the ElectricalNetwork class, which is a dictionary-like object. Any key-value pairs added to this dictionary will be saved in the JSON file when the network is saved and will be loaded back when the network is read from the file.

Contributed in PR 388.

Improved Unbalance Calculations

In earlier versions, the voltage unbalance calculation was limited to the IEC definition (Voltage Unbalance Factor, VUF). This release adds support for IEEE (Percentage Voltage Unbalance Ratio, PVUR) and NEMA (Load Voltage Unbalance Ratio, LVUR) definitions. The res_voltage_unbalance method now accepts a definition parameter which can be set to 'VUF', 'PVUR' or 'LVUR'.

Additionally, current unbalance calculations have been added for loads and sources through the res_current_unbalance method.

Contributed in PR 357.

Transformers Improvements

This release includes several improvements and bug fixes related to transformers and the transformers catalogue.

  • Add HV/MV transformer models to the catalogue.

    The manufacturer names in the catalogue have been expanded to better accommodate new transformers (SESchneider Electric, FTFrance Transfo, ...). Please update any references to the old manufacturer names in your code to use the new names.

  • Add nominal frequency (fn), cooling class (cooling) and insulation type (insulation) to the TransformerParameters class.

    The cooling and insulation are described in the new enumeration types TransformerCooling and TransformerInsulation respectively. The transformers catalogue has been updated to include these new attributes.

  • Improve load flow convergence for networks with step-up transformers.

    A bug that cause wrong source voltage propagation when the network contained step-up transformer has been fixed. This yields better initial guesses for the voltages of the buses and improves load flow convergence.

  • Fix missing floating neutral of three-phase transformers when the bus does not have a neutral.

    When connecting a three-phase transformer with a neutral wire to a bus without a neutral, the neutral of the transformer was incorrectly removed. This has been fixed and the neutral of the transformer is now preserved and becomes floating.

  • Fix minor inconsistency in transformer short-circuit parameters calculation.

    Iron losses are now ignored during the calculation of the short-circuit parameters of transformers with no open and short circuit tests data. This is consistent with the model we use if the open and short circuit tests data were available.

  • Deprecate Transformer.res_voltage_hv and Transformer.res_voltage_lv properties added in the last release by mistake. The recommended way to access the voltages of transformer sides is now through the new side accessors: Transformer.side_hv.res_voltages and Transformer.side_lv.res_voltages.

Contributed in PR 355, PR 366, PR 382, PR 364, PR 371, PR 365.

Python Support and Build System Changes

This release drops support for Python 3.10 and older versions. Roseau Load Flow now requires Python 3.11 or newer.

This release also adds support for musl linux distributions and preliminary support for python 3.14 development version and for free-threaded python 3.13t and 3.14t. Full support is waiting on our dependencies to release relevant wheels.

We also switched from hatchling to uv_build as the build backend, this should not impact users following standard installation procedures.

Contributed in PR 362, PR 394, PR 393.

Other Notable Improvements and New Features

  • Improve the performance of accessing network results as dataframes by up to 20% and serializing a network to a dictionary by up to 15%.

    The improvements are mostly noticeable with large networks or when performing many simulations like in a time series analysis.

    Contributed in PR 398.

  • Add LineParameters.to_sym method to convert three-phase line parameters to symmetrical components. The method returns the symmetrical components: z0, z1, y0, y1, and for lines with a neutral wire: zn, zpn, yn, ypn.

    Contributed in PR 400.

  • Detect and raise an error when duplicate line or transformer parameters IDs are used in the same network.

    This prevents unexpected behavior and prevents hard-to-debug issues and fixes an inconsistency in the handling of duplicate IDs as previously networks could be created with duplicate line or transformer parameters IDs but could not be saved to a JSON file.

    Contributed in PR 361.

  • Rework the DGS conversion methods of the electrical network.

    Rename the from_dgs method of rlf.ElectricalNetwork to from_dgs_file and add a new from_dgs_dict method to load a network from a DGS-formatted dictionary. The old method is deprecated and will be removed in a future release. The from_dgs_file method accepts an optional encoding parameter to specify the encoding of the DGS file.

    Contributed in PR 374.

Other Notable Bug Fixes

  • Fix lingering ground connections of disconnected loads and sources.

    Disconnect a ground connection of a load or source when the load or source is disconnected from the network. Add is_disconnected property to loads, sources and ground connections to check if the element is disconnected. In the future, accessing the bus of a disconnected load or source will return the original bus instead of None, use is_disconnected to check if the load or source is disconnected.

    Contributed in PR 392.

  • Fix a regression since version 0.11.0 where max_voltage_level for buses was missing in the catalogue networks.

    Contributed in PR 356.

Miscellaneous Changes

  • Allow passing a single FlexibleParameter object to a constant-power load to be used for all phases.

    Contributed in PR 396.

  • Add a Line.res_ground_potential property to access the potential of the ground port of lines with shunt components.

    Contributed in PR 369.

  • Fix an error when neutral ampacity is not passed to LineParameters.from_geometry.

    The neutral ampacity now defaults to the phase conductor ampacity if not provided.

    Contributed in PR 380.

  • Update JSON file format to version 5 to store this information. Files created with previous versions of Roseau Load Flow will still be readable and will warn on loading.

  • Fix a bug caused by a short circuits to a newely created ground.

    Contributed in PR 360.

  • Fix a division by zero error during DGS export.

    Contributed in PR 358.

  • Rename some internal models modules. The models classes are always available as rlf.<model_name>.

    Contributed in PR 401.

  • Stop reformatting arrays in json output.

    Contributed in PR 387.

@benoit9126 benoit9126 merged commit 291cdf6 into main Sep 1, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants