Skip to content

Commit

Permalink
Use pint
Browse files Browse the repository at this point in the history
  • Loading branch information
alihamdan committed Oct 30, 2023
1 parent a0167b4 commit 1d9ab02
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion roseau/load_flow/models/buses.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,8 @@ def get_connected_buses(self) -> Iterator[Id]:
to_add = set(element._connected_elements).difference(visited)
remaining.update(to_add)

def res_voltage_unbalance(self) -> float:
@ureg_wraps("percent", (None,), strict=False)
def res_voltage_unbalance(self) -> Q_[float]:
"""Calculate the voltage unbalance on this bus according to the IEC definition.
Voltage Unbalance Factor:
Expand Down
8 changes: 4 additions & 4 deletions roseau/load_flow/models/tests/test_buses.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,18 +335,18 @@ def test_res_voltage_unbalance():

# Balanced system
bus._res_potentials = np.array([va, vb, vc])
assert np.isclose(bus.res_voltage_unbalance(), 0)
assert np.isclose(bus.res_voltage_unbalance().m_as("percent"), 0)

# Unbalanced system
bus._res_potentials = np.array([va, vb, vb])
assert np.isclose(bus.res_voltage_unbalance(), 100)
assert np.isclose(bus.res_voltage_unbalance().m_as("percent"), 100)

# With neutral
bus = Bus("b3n", phases="abcn")
bus._res_potentials = np.array([va, vb, vc, 0])
assert np.isclose(bus.res_voltage_unbalance(), 0)
assert np.isclose(bus.res_voltage_unbalance().m_as("percent"), 0)
bus._res_potentials = np.array([va, vb, vb, 0])
assert np.isclose(bus.res_voltage_unbalance(), 100)
assert np.isclose(bus.res_voltage_unbalance().m_as("percent"), 100)

# Non 3-phase bus
bus = Bus("b1", phases="an")
Expand Down

0 comments on commit 1d9ab02

Please sign in to comment.