Skip to content

Getting Started ​

Installation ​

bash
uv add pyptp
bash
pip install pyptp

PyPtP requires Python 3.11 or higher.

Quick Start ​

Load an Existing Network ​

python
from pyptp import NetworkLV, NetworkMV, configure_logging
from pyptp.ptp_log import logger

# Enable logging to see output
configure_logging(level="INFO")

# Load unbalanced network (nine-conductor modeling, GNF/Gaia format)
lv_network = NetworkLV.from_file("path/to/network.gnf")
logger.info("Unbalanced network: %s nodes, %s cables", len(lv_network.nodes), len(lv_network.cables))

# Load balanced network (three-phase modeling, VNF/Vision format)
mv_network = NetworkMV.from_file("path/to/network.vnf")
logger.info("Balanced network: %s nodes, %s lines", len(mv_network.nodes), len(mv_network.lines))

# Access network elements
for node in list(mv_network.nodes.values())[:5]:
    logger.info("Node: %s at %skV", node.general.name, node.general.unom)

# Save modified network
mv_network.save("output.vnf")

Network Types

  • NetworkLV: Unbalanced network model for GNF files (Gaia format)
  • NetworkMV: Balanced network model for VNF files (Vision format)

See Overview for details on balanced vs unbalanced modeling.