Ejemplo n.º 1
0
def test_tp_dict_methods():
    """Test the to/from dict methods."""
    tp = TransformerProperties('Transformer--25KVA CT', 25)

    tp_dict = tp.to_dict()
    new_tp = TransformerProperties.from_dict(tp_dict)
    assert new_tp == tp
    assert tp_dict == new_tp.to_dict()
Ejemplo n.º 2
0
def test_tp_equality():
    """Test the equality of Wire objects."""
    tp = TransformerProperties('Transformer--25KVA CT', 25)
    tp_dup = tp.duplicate()
    tp_alt = TransformerProperties('Transformer--50KVA CT', 50)

    assert tp is tp
    assert tp is not tp_dup
    assert tp == tp_dup
    tp_dup.kva = 100
    assert tp != tp_dup
    assert tp != tp_alt
Ejemplo n.º 3
0
def test_tp_electrical_database_dict_methods():
    """Test the to/from electrical_database_dict methods."""
    tp = transformer_prop_by_identifier(TRANSFORMER_PROPERTIES[0])

    tp_dict = tp.to_electrical_database_dict()
    new_tp = TransformerProperties.from_electrical_database_dict(tp_dict)
    assert new_tp == tp
    assert tp_dict == new_tp.to_electrical_database_dict()
Ejemplo n.º 4
0
def test_transformer_dict_methods():
    """Test the Transformer to/from dict methods."""
    pts = (Point2D(0, 0), Point2D(2, 0), Point2D(2, 2), Point2D(0, 2))
    polygon = Polygon2D(pts)
    tp = TransformerProperties('Transformer--25KVA CT', 25)
    transformer = Transformer('Transformer_1', polygon, tp)

    transformer_dict = transformer.to_dict()
    new_transformer = Transformer.from_dict(transformer_dict)
    assert transformer_dict == new_transformer.to_dict()
Ejemplo n.º 5
0
def test_transformer_init():
    """Test the initialization of Transformer and basic properties."""
    pts = (Point2D(0, 0), Point2D(2, 0), Point2D(2, 2), Point2D(0, 2))
    polygon = Polygon2D(pts)
    tp = TransformerProperties('Transformer--25KVA CT', 25)
    transformer = Transformer('Transformer_1', polygon, tp)
    str(transformer)  # test the string representation

    assert transformer.identifier == 'Transformer_1'
    assert transformer.geometry == polygon
    assert transformer.properties == tp
Ejemplo n.º 6
0
def test_tp_init():
    """Test the initialization of TransformerProperties and basic properties."""
    tp = TransformerProperties('Transformer--25KVA CT', 25)
    str(tp)  # test the string representation

    assert tp.identifier == 'Transformer--25KVA CT'
    assert tp.kva == 25
    assert tp.resistance == 0.1
    assert tp.reactance == 0.1
    assert tp.phases == ('A', 'B', 'C')
    assert tp.high_voltage == 13.2
    assert tp.low_voltage == 0.48
    assert not tp.is_center_tap
    assert tp.connection == 'Wye-Wye'
Ejemplo n.º 7
0
def test_transformer_transform():
    """Test the Transformer transform methods."""
    pts = (Point2D(0, 0), Point2D(2, 0), Point2D(2, 2), Point2D(0, 2))
    polygon = Polygon2D(pts)
    tp = TransformerProperties('Transformer--25KVA CT', 25)
    transformer = Transformer('Transformer_1', polygon, tp)

    new_transformer = transformer.duplicate()
    new_transformer.move(Vector3D(100, 0))
    assert new_transformer.geometry[0] == Point2D(100, 0)

    new_transformer = transformer.duplicate()
    new_transformer.rotate_xy(90, Point3D())
    assert new_transformer.geometry[1].y == pytest.approx(2, rel=1e-3)

    new_transformer = transformer.duplicate()
    new_transformer.reflect(Plane(n=Vector3D(1, 0)))
    assert new_transformer.geometry[1].x == pytest.approx(-2, rel=1e-3)

    new_transformer = transformer.duplicate()
    new_transformer.scale(0.5)
    assert new_transformer.geometry[1].x == pytest.approx(1, rel=1e-3)
Ejemplo n.º 8
0
def test_tp_setability():
    """Test the setting of properties of TransformerProperties."""
    tp = TransformerProperties('Transformer--25KVA CT', 25)

    tp.identifier = 'Transformer--50KVA PM'
    assert tp.identifier == 'Transformer--50KVA PM'
    tp.kva = 50
    assert tp.kva == 50
    tp.resistance = 0.15
    assert tp.resistance == 0.15
    tp.reactance = 0.15
    assert tp.reactance == 0.15
    tp.phases = ('A',)
    assert tp.phases == ('A',)
    tp.high_voltage = 20
    assert tp.high_voltage == 20
    tp.low_voltage = 0.5
    assert tp.low_voltage == 0.5
    tp.is_center_tap = True
    assert tp.is_center_tap
    tp.connection = 'Delta-Delta'
    assert tp.connection == 'Delta-Delta'