Hydraulic analysis and optimization for branched water distribution systems
Project description
Branch Network Hydraulic Analyzer (BNHA)
A Python package for hydraulic analysis and optimization of branched water distribution networks. Supports pressure, head loss, velocity, and economic assessments for branched systems defined via CSV input.
🚀 Features
-
Analyze multi-branch pipe networks from simple
.csvfiles -
Compute:
- Head losses (Hazen-Williams)
- Pressure and total head at all nodes
- Flow velocities and Reynolds numbers
-
Visualize:
- Hydraulic profiles per branch (HGL, EGL, static head)
- Pipe performance metrics
-
Run pipe diameter sensitivity analysis
📦 Installation
From Local .whl File
- Copy the generated
.whlfile to your working directory (e.g.dist/branch_network_hydraulics-0.1.0-py3-none-any.whl) - In terminal or Jupyter Notebook:
pip install ./branch_network_hydraulics-0.1.0-py3-none-any.whl
🛠 Usage
1. Prepare Your Network CSV
Use the template format:
pipe,diameter_m,start_junc,end_junc,length_m,flow_cmh,end_junc_elevation,static_head,hwc,branch_end,end_junc_path
p1,0.5,source,a,900,140,250,300,140,0,p1
p2,0.5,a,b,700,140,270,300,140,0,p1,p2
p3,0.5,b,v1,5000,100,240,300,140,1,p1,p2,p3
p4,0.5,b,v2,100,40,230,300,140,1,p1,p2,p4
Save it as network.csv
2. Example Script
import pandas as pd
from branch_optimizer.network import BranchNetwork
from branch_optimizer.analysis import analyze_network
from branch_optimizer.plots import plot_hydraulic_profile
# Load network from CSV
df = pd.read_csv("network.csv")
# Initialize the network
net = BranchNetwork()
net.set_system_data(reservoir_elevation=300, reservoir_total_head=320)
net.load_from_dataframe(df)
# Inject paths to each pipe (for branch recognition)
for pid, path in net.get_branch_paths().items():
net.pipes[pid]['path'] = path
# Analyze
df_results, summary = analyze_network(*net.to_dict())
# Plot
figs = plot_hydraulic_profile(df_results, net.system_data)
for fig in figs:
fig.show()
📊 Sensitivity Optimization
from branch_optimizer.optimizer import diameter_sensitivity_analysis
# Run sensitivity on all pipes between 100mm and 600mm
df_test = diameter_sensitivity_analysis(net.pipes, net.system_data, diameter_range=(0.1, 0.6, 0.1))
print(df_test)
📁 Directory Layout (When Cloned)
branch_optimizer/
├── hydraulics.py # Core fluid equations
├── network.py # Data model for network
├── analysis.py # Node-by-node head + velocity calcs
├── plots.py # Visualization tools
├── optimizer.py # Sensitivity analysis
📜 License
MIT License (c) 2025 Your Name
🌐 Future Plans
- Pipe cost optimization
- Automated diameter selection
- Integration with EPANET or pressure zone mapping
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file branch_network_hydraulics-0.1.0.tar.gz.
File metadata
- Download URL: branch_network_hydraulics-0.1.0.tar.gz
- Upload date:
- Size: 15.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27683d79dc245998ba033eed765310fc105c058f6dd41bffb24f4bb956933f59
|
|
| MD5 |
a157ac8fffeda71a77383f895bea2c3c
|
|
| BLAKE2b-256 |
85c788f3298ebb6b4c54c479ddbead353f30ccc89ceb933c2e84d7b0ed8db351
|
File details
Details for the file branch_network_hydraulics-0.1.0-py3-none-any.whl.
File metadata
- Download URL: branch_network_hydraulics-0.1.0-py3-none-any.whl
- Upload date:
- Size: 16.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f4b565a667aac9d4eda4c720987841bba773967732ddd5185e2bc643b9205cf9
|
|
| MD5 |
1bef80cd637d7987ef75dc6348648da6
|
|
| BLAKE2b-256 |
406b51e3c907b553e9a28a05952904640a1656bb71a97af3e7d0bb62c7d027a6
|