Skip to content

Commit

Permalink
Update transformer catalogue and parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
alihamdan committed Nov 29, 2024
1 parent 2ed5d23 commit 3c36c5a
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 782 deletions.
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ dev = [
[tool.uv]
managed = true

[tool.uv.sources]
roseau-load-flow = { git = "https://github.com/RoseauTechnologies/Roseau_Load_Flow.git", branch = "tr-catalogue" }

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
Expand Down
11 changes: 6 additions & 5 deletions roseau/load_flow_single/models/tests/test_buses.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ def test_voltage_limits():
assert bus.max_voltage == Q_(434.6, "V")

# Can be reset to None
bus.nominal_voltage = None
bus.min_voltage_level = None
bus.max_voltage_level = None
bus.nominal_voltage = None
assert bus.min_voltage_level is None
assert bus.max_voltage_level is None
assert bus.min_voltage is None
Expand All @@ -60,19 +60,19 @@ def test_voltage_limits():

# NaNs are converted to None
for na in (np.nan, float("nan"), pd.NA):
bus.nominal_voltage = na
bus.min_voltage_level = na
bus.max_voltage_level = na
bus.nominal_voltage = na
assert bus.nominal_voltage is None
assert bus.min_voltage_level is None
assert bus.max_voltage_level is None
assert bus.min_voltage is None
assert bus.max_voltage is None

# Min/Max voltage values defined without nominal voltage are useless
bus.nominal_voltage = None
bus.min_voltage_level = None
bus.max_voltage_level = None
bus.nominal_voltage = None
with pytest.warns(
UserWarning,
match=r"The min voltage level of the bus 'bus' is useless without a nominal voltage. Please define a nominal "
Expand Down Expand Up @@ -105,6 +105,7 @@ def test_voltage_limits():
bus.nominal_voltage = 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 @@ -186,7 +187,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 @@ -342,7 +343,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 @@ -940,8 +940,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,
"ampacities": lp.ampacities.m + 1,
"line_type": LineType.OVERHEAD,
"materials": Material.CU,
Expand Down
Loading

0 comments on commit 3c36c5a

Please sign in to comment.