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

Update transformer catalogue and parameters #2

Merged
merged 3 commits into from
Nov 29, 2024
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
94 changes: 94 additions & 0 deletions .vscode/cspell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
{
// Version of the setting file. Always 0.2
"version": "0.2",
// language - current active spelling language
"language": "en,fr",
// words - list of words to be always considered correct
"words": [
"abcn",
"absolufy",
"acsr",
"aldrey",
"asarray",
"astype",
"bline",
"bnline",
"bnpline",
"bysource",
"cohl",
"cosgini",
"cterm",
"curmg",
"cython",
"direc",
"dline",
"dropna",
"dtype",
"elmlodmv",
"elmpvsys",
"furo",
"gpslat",
"gpslon",
"gscale",
"htmlcov",
"ilini",
"imiso",
"inom",
"isort",
"mathjax",
"mathrm",
"mlei",
"nbsphinx",
"ndarray",
"nlnph",
"nneutral",
"noloadloss",
"normhkva",
"nphase",
"nphases",
"nplin",
"opendss",
"pcutr",
"pgini",
"phasor",
"phasors",
"phtech",
"pipx",
"plini",
"pmatrix",
"pmax",
"pyproj",
"pyproject",
"pytest",
"pyupgrade",
"qgini",
"qlini",
"qurs",
"raphson",
"rline",
"rnline",
"rnpline",
"rtol",
"sgini",
"slini",
"strn",
"susceptance",
"transfo",
"uknom",
"uktr",
"ureg",
"utrn",
"xline",
"xlpe",
"xnet",
"xnline",
"xnpline",
"yesqa"
],
// flagWords - list of words to be always considered incorrect
// This is useful for offensive words and common spelling errors.
// For example "hte" should be "the"
"flagWords": [
"hte"
]
}
8 changes: 8 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"recommendations": [
"charliermarsh.ruff",
"esbenp.prettier-vscode",
"ms-python.python",
"ms-python.vscode-pylance",
],
}
33 changes: 33 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
// Jupyter Notebook
"jupyter.notebookFileRoot": "${workspaceFolder}",
"notebook.formatOnSave.enabled": true,
"notebook.codeActionsOnSave": {
"source.organizeImports.ruff": "explicit",
},

// Python
"python.analysis.diagnosticSeverityOverrides": {
"reportInvalidStringEscapeSequence": "warning",
"reportImportCycles": "warning",
"reportUnusedImport": "warning",
},
"python.testing.pytestEnabled": true,
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports.ruff": "explicit",
},
},
// Prettier
"prettier.printWidth": 120,
"[markdown][yaml][html][css]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
},
// Json
"[json]": {
"editor.indentSize": 2,
},
}
44 changes: 44 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"options": { "cwd": "${workspaceFolder}" },
"presentation": {
"showReuseMessage": true,
"clear": true,
},
"tasks": [
{
"label": "Build docs",
"detail": "Build the docs using Sphinx.",
"type": "shell",
"command": "make -C doc html",
"group": {
"kind": "build",
"isDefault": true,
},
"problemMatcher": [],
"presentation": {
"reveal": "silent",
"focus": true,
},
},
{
"label": "Open docs",
"detail": "Open the docs in the browser.",
"type": "shell",
"command": "open build/html/index.html",
"presentation": {
"reveal": "never",
"close": true,
"focus": false,
"panel": "dedicated",
},
"group": {
"kind": "build",
"isDefault": true,
},
"isBackground": true,
},
],
}
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ dependencies = [
"pandas>=1.4.0",
"geopandas>=1.0.0",
"shapely>=2.0.0",
"regex>=2022.1.18",
"pint>=0.21.0",
"typing-extensions>=4.6.2",
"pyproj>=3.3.0",
Expand All @@ -57,6 +56,8 @@ dev = [
"pytest-cov>=5.0.0",
"pytest-xdist>=3.1.0",
"coverage[toml]>=7.0.5",
"networkx>=3.4.2",
"matplotlib>=3.9.2",
]

[tool.uv]
Expand Down
18 changes: 10 additions & 8 deletions roseau/load_flow_single/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,24 @@
__status__,
__url__,
)
from roseau.load_flow_single.models.branches import AbstractBranch
from roseau.load_flow_single.models.buses import Bus
from roseau.load_flow_single.models.core import Element
from roseau.load_flow_single.models.lines import Line, LineParameters
from roseau.load_flow_single.models.loads import (
from roseau.load_flow_single.models import (
AbstractBranch,
AbstractLoad,
Bus,
Control,
CurrentLoad,
Element,
FlexibleParameter,
ImpedanceLoad,
Line,
LineParameters,
PowerLoad,
Projection,
Switch,
Transformer,
TransformerParameters,
VoltageSource,
)
from roseau.load_flow_single.models.sources import VoltageSource
from roseau.load_flow_single.models.switches import Switch
from roseau.load_flow_single.models.transformers import Transformer, TransformerParameters
from roseau.load_flow_single.network import ElectricalNetwork

__version__ = importlib.metadata.version("roseau-load-flow-single")
Expand Down
17 changes: 6 additions & 11 deletions roseau/load_flow_single/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
from roseau.load_flow import Projection, TransformerParameters
from roseau.load_flow_single.models.branches import AbstractBranch
from roseau.load_flow_single.models.buses import Bus
from roseau.load_flow_single.models.core import Element
from roseau.load_flow_single.models.lines import Line, LineParameters
from roseau.load_flow_single.models.loads import (
AbstractLoad,
Control,
CurrentLoad,
FlexibleParameter,
ImpedanceLoad,
PowerLoad,
Projection,
)
from roseau.load_flow_single.models.flexible_parameters import Control, FlexibleParameter
from roseau.load_flow_single.models.line_parameters import LineParameters
from roseau.load_flow_single.models.lines import Line
from roseau.load_flow_single.models.loads import AbstractLoad, CurrentLoad, ImpedanceLoad, PowerLoad
from roseau.load_flow_single.models.sources import VoltageSource
from roseau.load_flow_single.models.switches import Switch
from roseau.load_flow_single.models.transformers import Transformer, TransformerParameters
from roseau.load_flow_single.models.transformers import Transformer

__all__ = [
"Element",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from roseau.load_flow_engine.cy_engine import CyShuntLine, CySimplifiedLine
from roseau.load_flow_single.models.branches import AbstractBranch
from roseau.load_flow_single.models.buses import Bus
from roseau.load_flow_single.models.lines.parameters import LineParameters
from roseau.load_flow_single.models.line_parameters import LineParameters

logger = logging.getLogger(__name__)

Expand Down
4 changes: 0 additions & 4 deletions roseau/load_flow_single/models/lines/__init__.py

This file was deleted.

5 changes: 0 additions & 5 deletions roseau/load_flow_single/models/loads/__init__.py

This file was deleted.

5 changes: 3 additions & 2 deletions roseau/load_flow_single/models/tests/test_buses.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def test_voltage_limits():
bus.max_voltage_level = None

# Bad values
bus.nominal_voltage = 400
bus.min_voltage_level = 0.95
with pytest.raises(RoseauLoadFlowException) as e:
bus.max_voltage_level = 0.92
Expand Down Expand Up @@ -185,7 +186,7 @@ def test_propagate_limits(): # noqa: C901

lp_mv = LineParameters(id="lp_mv", z_line=1.0, y_shunt=0.1)
lp_lv = LineParameters(id="lp_lv", z_line=1.0)
tp = TransformerParameters.from_catalogue(name="SE_Minera_A0Ak_100kVA", manufacturer="SE")
tp = TransformerParameters.from_catalogue(name="SE Minera A0Ak 100kVA 15/20kV(20) 410V Dyn11")

Line(id="l1_mv", bus1=b1_mv, bus2=b2_mv, length=1.5, parameters=lp_mv)
Line(id="l2_mv", bus1=b2_mv, bus2=b3_mv, length=2, parameters=lp_mv)
Expand Down Expand Up @@ -341,7 +342,7 @@ def test_get_connected_buses():

lp_mv = LineParameters(id="lp_mv", z_line=1.0, y_shunt=0.1)
lp_lv = LineParameters(id="lp_lv", z_line=1.0)
tp = TransformerParameters.from_catalogue(name="SE_Minera_A0Ak_100kVA", manufacturer="SE")
tp = TransformerParameters.from_catalogue(name="SE Minera A0Ak 100kVA 15/20kV(20) 410V Dyn11")

Line(id="l1_mv", bus1=b1_mv, bus2=b2_mv, length=1.5, parameters=lp_mv)
Line(id="l2_mv", bus1=b2_mv, bus2=b3_mv, length=2, parameters=lp_mv)
Expand Down
31 changes: 14 additions & 17 deletions roseau/load_flow_single/models/tests/test_flexible_parameters.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import warnings

import numpy as np
import pytest

Expand Down Expand Up @@ -56,14 +54,14 @@ def test_control():
assert e.value.code == RoseauLoadFlowExceptionCode.BAD_CONTROL_VALUE

# Warning if values provided to useless values
with warnings.catch_warnings(record=True) as records:
with pytest.warns(
UserWarning,
match=(
r"Some voltage norm value\(s\) will not be used by the 'p_max_u_production' control. "
r"Nevertheless, values different from 0 were given: 'u_min' \(2.0 V\), 'u_down' \(1.0 V\)"
),
):
Control(type="p_max_u_production", u_min=2, u_down=1, u_up=240, u_max=250)
assert len(records) == 1
assert (
records[0].message.args[0] == "Some voltage norm value(s) will not be used by the 'p_max_u_production' "
"control. Nevertheless, values different from 0 were given: 'u_min' (2.0 V), 'u_down' (1.0 V)"
)
assert records[0].category is UserWarning

# Bad control value for p_max_u_consumption
with pytest.raises(RoseauLoadFlowException) as e:
Expand Down Expand Up @@ -102,15 +100,14 @@ def test_control():
assert e.value.code == RoseauLoadFlowExceptionCode.BAD_CONTROL_VALUE

# Warning if values provided to useless values
with warnings.catch_warnings(record=True) as records:
with pytest.warns(
UserWarning,
match=(
r"Some voltage norm value\(s\) will not be used by the 'p_max_u_consumption' control. "
r"Nevertheless, values different from 0 were given: 'u_max' \(-1.0 V\), 'u_up' \(2.3 V\)"
),
):
Control(type="p_max_u_consumption", u_min=210, u_down=220, u_up=2.3, u_max=-1)
assert len(records) == 1
assert (
records[0].message.args[0] == "Some voltage norm value(s) will not be used by the 'p_max_u_consumption' "
"control. Nevertheless, values different from 0 were given: 'u_max' (-1.0 "
"V), 'u_up' (2.3 V)"
)
assert records[0].category is UserWarning

# Bad control value for q_u
with pytest.raises(RoseauLoadFlowException) as e:
Expand Down
4 changes: 2 additions & 2 deletions roseau/load_flow_single/models/tests/test_line_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,8 +691,8 @@ def test_equality():

other_data = {
"id": lp.id + " other",
"z_line": lp.z_line.m + 1,
"y_shunt": lp.y_shunt.m + 1,
"z_line": lp.z_line.m + 1j,
"y_shunt": lp.y_shunt.m + 1j,
"ampacity": lp.ampacity.m + 1,
"line_type": LineType.OVERHEAD,
"material": Material.CU,
Expand Down
Loading
Loading