Skip to content

Parallel Cable ​

An old cable in the Lindelaan feeds four connections, on both sides of the street, and is overloaded. A heavier cable is laid along the south side and takes over at the corner. The connections on the south side then move onto the new cable, each at a new joint of its own.

This page also describes the two helpers behind it, move_connections_to_cable() and split_cable(), from pyptp.helpers.lv.

Full Example

View the complete code: 18_lv_parallel_cable.py

The New Cable ​

The old cable is five sections, from the substation rail through four joints to the corner. The new cable is an ordinary CableLV of 38 m from the rail to the corner. between() draws it with one extra corner below the corner node, so it runs along the south side of the street and turns up into the joint. The old cable is opened at the corner:

python
from pyptp.elements.element_utils import SIDE_NODE2
from pyptp.elements.lv.cable import CableLV
from pyptp.elements.lv.presentations import BranchPresentation

old_type = "4* 50 VMvK/Alk"
add_cable("Lindelaan", old_type, CL_BLUE, rail, joint_1, 10)
add_cable("Lindelaan", old_type, CL_BLUE, joint_1, joint_2, 6)
add_cable("Lindelaan", old_type, CL_BLUE, joint_2, joint_3, 6)
add_cable("Lindelaan", old_type, CL_BLUE, joint_3, joint_4, 6)
last_old_section = add_cable("Lindelaan", old_type, CL_BLUE, joint_4, corner, 6)

# The old cable is overloaded. A heavier cable is laid along the south side, from the
# substation to the corner, and the old cable is opened at the corner.
new_cable = CableLV(
    CableLV.General(node1=rail.general.guid, node2=corner.general.guid, name="Lindelaan nieuw"),
    presentations=[BranchPresentation.between(rail, corner, sheet, via=[(880, 440)])],
    cable_part=CableLV.CablePart(length=38),
)
new_cable.presentations[0].color = CL_RED
new_cable.set_cable_type(types, "4*150 VVMvKsas/Alk")
network.add(new_cable)

last_old_section.general.set_switches(SIDE_NODE2, closed=False)

The rail is a vertical line symbol, so the new cable leaves it at the height of its first corner and runs straight to the corner, where it turns up into the joint: [(200, 440), (880, 440), (880, 360)]. The length of 38 m is the length of the cable in the street, not of its drawing.

Here the last old section runs from the last joint to the corner, so the corner is its node 2. In a network read from a file, a section is often stored the other way round. There, open the side whose node is the corner:

python
from pyptp.elements.element_utils import SIDE_NODE1, SIDE_NODE2

if last_old_section.general.node2 == corner.general.guid:
    last_old_section.general.set_switches(SIDE_NODE2, closed=False)
else:
    last_old_section.general.set_switches(SIDE_NODE1, closed=False)

Moving the Connections ​

python
from pyptp.helpers.lv import move_connections_to_cable

# Lindelaan 2 and 4 are on the side of the new cable, so they move onto it
result = move_connections_to_cable(network, new_cable, [lindelaan_2, lindelaan_4])

# one section per stretch between joints
for section in result.sections:
    logger.info("Section of the new cable: %.1f m", section.cable_part.length)
Section of the new cable: 16.0 m
Section of the new cable: 12.0 m
Section of the new cable: 10.0 m

Lindelaan 2 is drawn below the second joint of the old cable, so its new joint lands where the new cable passes nearest, at (520, 440). Lindelaan 4 gets its joint at (760, 440). The three sections keep the new cable's type, and their lengths add up to its 38 m.

move_connections_to_cable() ​

python
move_connections_to_cable(network, cable, connections, *, symbol=NodePresentationSymbol.CLOSED_TRIANGLE) -> CableSections

Moves each connection onto cable, at a new joint where the cable passes nearest to it. The cable is cut at the joints as by split_cable().

  • N and PE are joined at each new joint (s_N_PE = True).
  • Every section is at least 0.5 m. A connection nearer than that to a cable end gets its joint 0.5 m from the end, and connections less than 0.5 m apart share a joint.
  • Each connection keeps its drawing and length. Its cable route on the map is redrawn straight from the joint, or dropped when the joint or the connection has no map position.
  • symbol is the node symbol of the new joints on every sheet.

It raises ValueError when the cable is not in the network, has connections on the cable itself or is shorter than 1 m, when a connection is not in the network, or when a connection is drawn on a sheet without the cable or shares neither the map nor a sheet with it.

split_cable() ​

python
split_cable(network, cable, at, *, symbol=NodePresentationSymbol.CLOSED_CIRCLE) -> CableSections

Cuts cable at new joints, at metres from node 1:

python
from pyptp.helpers.lv import split_cable

result = split_cable(network, cable, [12.5, 30])
  • at must be ascending and every position must lie strictly between 0 and the cable's length. Positions are rounded to centimetres.
  • Every section must be at least 0.5 m, and the sections add up to the cable's length.
  • The first section keeps the cable's GUID. The others get new GUIDs and the same name.
  • Fuses, switches and measure fields at node 2 move to the last section. The new inner ends are closed and without protection.
  • On the map and on every sheet, a joint sits at the same share of the route as its position is of the cable's length. A cable without a route on the map gets its joints on the straight line between its end nodes, when both have a map position.

It raises ValueError when the cable is not in the network or has connections on the cable itself, when at is not ascending or not inside the cable, or when a section would be shorter than 0.5 m. An empty at returns the cable as it is.

CableSections ​

split_cable() and move_connections_to_cable() return a CableSections:

FieldContent
sectionsThe cables, in order from node 1 to node 2 of the original cable
jointsThe new nodes, one between each pair of consecutive sections

Next Steps ​