예제 #1
0
def test_subgraph(plan):
    a = Generator(name="A", type="135kVA")
    a1 = Distro(name="A1", type="SPEC-7")
    plan.add_connection(a, a1, 400, 3, length=10)

    b = Generator(name="B", type="135kVA")
    b1 = Distro(name="B1", type="SPEC-7")
    plan.add_connection(b, b1, 400, 3, length=10)
    plan.generate()

    grids = list(plan.grids())

    assert len(grids) == 2

    for grid in grids:
        assert grid.parent == plan
예제 #2
0
def test_port_assignment(plan):
    gen = Generator(name="A", type="135kVA")
    a1 = Distro(name="A1", type="SPEC-7")
    plan.add_connection(gen, a1, 400, 3)

    a2 = Distro(name="A2", type="EPS/63-4")
    plan.add_connection(a1, a2, 63, 3)

    a3 = Distro(name="A3", type="EPS/63-3")
    plan.add_connection(a1, a3, 63, 3)

    a4 = Distro(name="A4", type="TOB-32")
    plan.add_connection(a3, a4, 32, 1)

    assert len(plan.validate()) == 0
    plan.assign_ports()
    assert plan.graph[a1][a2]["out_port"] == 0
    assert plan.graph[a1][a2]["in_port"] == 0
    assert plan.graph[a1][a3]["out_port"] == 1
    assert plan.graph[a1][a3]["in_port"] == 0

    plan.assign_cables()

    assert plan.graph[a1][a2]["csa"] == 16
    assert a4.source() == gen
예제 #3
0
def test_duplicate_node_name(plan):
    gen = Generator(name="A", type="135kVA")
    a1 = Distro(name="A1", type="SPEC-7")
    plan.add_connection(gen, a1, 400, 3)

    a2 = Distro(name="A1", type="EPS/63-4")
    plan.add_connection(a1, a2, 63, 3)

    assert len(plan.validate()) == 2
예제 #4
0
def test_zs(plan):
    gen = Generator(name="A", type="135kVA")
    plan.add_node(gen)

    # Arrive at the result by an independent route...
    spec = gen.get_spec()
    Ibase = spec["power"] / (sqrt(3) * spec["voltage"])
    Ifault = (100 / spec["transient_reactance"]) * Ibase
    Z = spec["voltage"] / (sqrt(3) * Ifault)
    assert Z == gen.z_e()
예제 #5
0
def test_create_graph():
    plan = Plan()
    gen = Generator(name="A")
    dist = Distro(name="A1")
    plan.add_node(gen)
    plan.add_connection(gen, dist, 400, 3)

    assert plan.graph.number_of_nodes() == 2
    assert plan.graph.number_of_edges() == 1
    assert len(plan.validate()) == 0
    assert plan.num_generators() == 1
    assert plan.num_distros() == 1
예제 #6
0
def test_graph_incomplete_spec(plan):
    gen = Generator(name="A", type="135kVA")
    a1 = Distro(name="A1", type="SPEC-7")
    plan.add_connection(gen, a1, 400, 3, length=10)

    a2 = Distro(name="A2", type="EPS/63-4")
    plan.add_connection(a1, a2, 63, 3, length=52)

    a3 = Distro(name="A3", type="EPS/63-3")
    plan.add_connection(a1, a3, 63, 3, length=54)

    a4 = Distro(name="A4", type="TOB-32")
    plan.add_connection(a3, a4, 32, 1, length=25)

    plan.generate()

    assert len(generate_bom_html(plan)) > 0
예제 #7
0
def test_fault_current(plan):
    gen = Generator(name="A", type="135kVA")
    a1 = Distro(name="A1", type="SPEC-7")
    plan.add_connection(gen, a1, 400, 3, length=10)

    a2 = Distro(name="A2", type="EPS/63-4")
    plan.add_connection(a1, a2, 63, 3, length=52)

    a3 = Distro(name="A3", type="EPS/63-3")
    plan.add_connection(a1, a3, 63, 3, length=54)

    a4 = Distro(name="A4", type="TOB-32")
    plan.add_connection(a3, a4, 32, 1, length=25)

    assert len(plan.validate()) == 0
    plan.generate()

    a4.i_pf()
예제 #8
0
def test_spec(spec, plan):
    assert len(spec.generator) == 1
    assert len(spec.distro) == 23

    gen = Generator(name="A", type="135kVA")
    dist = Distro(name="A1", type="SPEC-7")
    plan.add_connection(gen, dist, 400, 3)
    assert len(plan.validate()) == 0

    # Add another distro connected to a generator with only one output
    dist2 = Distro(name="A2", type="SPEC-7")
    plan.add_connection(gen, dist2, 400, 3)
    assert len(plan.validate()) == 1

    # Add a distro connected with an incorrect cable rating
    dist3 = Distro(name="A3", type="EPS/32")
    plan.add_connection(dist, dist3, 32, 3)
    assert len(plan.validate()) == 2