-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from opusonesolutions/support-multiple-neutrals
Test support for multiple neutrals, get rid of dict of 'A' -> 'A'
- Loading branch information
Showing
8 changed files
with
169 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
class LineModel: | ||
def __init__(self, conductors): | ||
self._resistance = {} | ||
self._geometric_mean_radius = {} | ||
self._wire_positions = {} | ||
self._phases = {} | ||
|
||
for phase, (r, gmr, (x, y)) in conductors.items(): | ||
self._resistance[phase] = r | ||
self._geometric_mean_radius[phase] = gmr | ||
self._wire_positions[phase] = (x, y) | ||
self._phases = sorted(list(conductors.keys())) | ||
|
||
@property | ||
def resistance(self): | ||
return self._resistance | ||
|
||
@property | ||
def geometric_mean_radius(self): | ||
return self._geometric_mean_radius | ||
|
||
@property | ||
def wire_positions(self): | ||
return self._wire_positions | ||
|
||
@property | ||
def phases(self): | ||
return self._phases |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
from numpy.testing import assert_array_almost_equal | ||
|
||
from .test_carsons import ABCN_line_z_primitive | ||
from carsons.carsons import CarsonsEquations | ||
|
||
|
||
def test_compatibility_with_dict_of_phases(): | ||
class BackwardsCompatibleModel(): | ||
def __init__(self): | ||
self.resistance = { | ||
"A": 0.000115575, | ||
"B": 0.000115575, | ||
"C": 0.000115575, | ||
"N": 0.000367852, | ||
} | ||
|
||
self.geometric_mean_radius = { | ||
"A": 0.00947938, | ||
"B": 0.00947938, | ||
"C": 0.00947938, | ||
"N": 0.00248107, | ||
} | ||
|
||
self.wire_positions = { | ||
"A": (0.762, 8.5344), | ||
"B": (2.1336, 8.5344), | ||
"C": (0, 8.5344), | ||
"N": (1.2192, 7.3152), | ||
} | ||
self.phases = { | ||
"A": "A", | ||
"B": "B", | ||
"C": "C", | ||
"N": "N", | ||
} | ||
# we are compatible models that provide 'phases' | ||
# as a dictionary | ||
|
||
model = BackwardsCompatibleModel() | ||
|
||
z_primative = CarsonsEquations(model).build_z_primitive() | ||
assert_array_almost_equal( | ||
z_primative, | ||
ABCN_line_z_primitive(), | ||
decimal=4 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import numpy | ||
from numpy.testing import assert_array_almost_equal | ||
|
||
from carsons.carsons import CarsonsEquations | ||
from tests.helpers import LineModel | ||
from tests.test_carsons import ABCN_line_z_primitive | ||
|
||
|
||
def test_dual_neutral_model(): | ||
|
||
model = CarsonsEquations(LineModel({ | ||
# resistance gmr (x, y) | ||
# ========================================== | ||
"A": (0.000115575, 0.00947938, (0.762, 8.5344)), | ||
"B": (0.000115575, 0.00947938, (2.1336, 8.5344)), | ||
"N1": (0.000115575, 0.00947938, (0.0, 8.5344)), | ||
"N2": (0.000367852, 0.00248107, (0.0, 7.3152)), | ||
})) | ||
z_primitive = model.build_z_primitive() | ||
|
||
# dimensions should include A, B, C and as many neutrals as are described | ||
assert z_primitive.shape == (5, 5) | ||
|
||
# because there's no C conductor in the model, expect a row/column of zeros | ||
assert_array_almost_equal(z_primitive[2, 0:], [0+0j]*5) | ||
assert_array_almost_equal(z_primitive[0:, 2], [0+0j]*5) | ||
|
||
# if we delete the C row/column, we should get a z_primitive that looks | ||
# like Configuration 601, since the geometry of A/B/C/N is mapped to | ||
# A/B/N1/N2 | ||
z_equivalent = z_primitive.copy() | ||
z_equivalent = numpy.delete(z_equivalent, 2, 0) | ||
z_equivalent = numpy.delete(z_equivalent, 2, 1) | ||
z_expected = ABCN_line_z_primitive() | ||
assert_array_almost_equal(z_equivalent, z_expected, decimal=4) | ||
|
||
|
||
def test_malformed_neutrals_are_ignored(): | ||
LINE_WITH_BAD_NEUTRAL_LABEL = LineModel({ | ||
# resistance gmr (x, y) | ||
# ========================================== | ||
"A": (0.000115575, 0.00947938, (0.762, 8.5344)), | ||
"B": (0.000115575, 0.00947938, (2.1336, 8.5344)), | ||
"C": (0.000115575, 0.00947938, (0.0, 8.5344)), | ||
"N1": (0.000367852, 0.00248107, (0.0, 7.3152)), | ||
"pN2": (0.000367852, 0.00248107, (1.2192, 7.3152)), | ||
}) | ||
model = CarsonsEquations(LINE_WITH_BAD_NEUTRAL_LABEL) | ||
z_primitive = model.build_z_primitive() | ||
|
||
assert z_primitive.shape == (4, 4) | ||
|
||
z_expected = ABCN_line_z_primitive() | ||
assert_array_almost_equal(z_primitive, z_expected, decimal=4) |