Skip to content
This repository was archived by the owner on Jul 1, 2026. It is now read-only.

Repository files navigation

PlatformPythonLicenseCode style: BlackTestsCoverage Status

wntr_quantum

wntr_quantum builds on the python package WNTR to leverage quantum computing for the simulation and optimization of water networks. The main capablities of the software are:

1. Quantum Enhanced Newton-Raphson Algorithm

The QuantumEpanetSimulator of wntr_quantum use quantum solvers to solve the linear systems required as part of the Newon-Raphson GGA algorithm. Several quantum linear solvers are available:

  • Harrow–Hassidim–Lloyd (HHL) : Gate based quantum solution. See example for Net0
  • Variational Quantum Linear Solver (VQLS) : hybrid quantum-classical gate based solution. See example for Net0 and on Net2loops
  • QUBO Linear Solver (QUBOLS) : Quantum Annealing solution. See example for Net0 and on Net2loops

2. Quantum Hydraulics Simulations

The FullQuboPolynomialSimulator recast the hydraulics equation as a Quadratic Unconstrained Binary Optimization (QUBO) problem, that can be solved using quantum annealers. An example of use on Net0can be found here

3. Quantum Optimization of Water Networks

The QUBODesignPipeDiameter recast the hydraulics equation and the pipe-diameter optimization as a Quadratic Unconstrained Binary Optimization problem, that can be solved using quantum annealers. An example of use on Net0can be found here

Installation

To install wntr_quantum from GitHub repository, do:

git clone git@github.com:QuantumApplicationLab/wntr-quantum.gitcd wntr-quantumpython -m pip install .

Installation of EPANET Quantum

WNTR Quantum can use a dedicated EPANET solver that allows to offload calculation to quantum linear solvers. This custom EPANET code can be found at : https://github.com/QuantumApplicationLab/EPANET. To install this sover follow the instructions below:

# clone EPANET
git clone https://github.com/QuantumApplicationLab/EPANET
# build EPANET
cd EPANET
mkdir build
cd build cmake .. cmake --build . --config Release
# copy the shared lib
cp lib/libepanet2.so <path to wntr-quantum>/wntr-quantum/wntr_quantum/epanet/Linux/libepanet22_amd64.so
# export environment variable
export EPANET_TMP=<path to tmp dir>/.epanet_quantum export EPANET_QUANTUM = <path to EPANET_QUANTUM>

Example

The example below shows how to use the Variational Quantum Linear Solver to solve the linear systems required in the Newton-Raphson-GGA algorithm.

importwntrimportwntr_quantumfromqiskit.circuit.libraryimportRealAmplitudesfromqiskit.primitivesimportEstimatorfromqiskit_algorithmsimportoptimizersasoptfromquantum_newton_raphson.vqls_solverimportVQLS_SOLVER# define the water network inp_file='Net2Loops.inp'wn=wntr.network.WaterNetworkModel(inp_file)
# define the vqls ansatzn_qubits=3qc=RealAmplitudes(n_qubits, reps=3, entanglement="full")
estimator=Estimator()
# define the VQLS solverlinear_solver=VQLS_SOLVER(
estimator=estimator,
ansatz=qc,
optimizer=[opt.COBYLA(maxiter=1000, disp=True), opt.CG(maxiter=500, disp=True)],
matrix_decomposition="symmetric",
verbose=True,
preconditioner="diagonal_scaling",
reorder=True,
)
# use wntr-quantum to solve the networksim=wntr_quantum.sim.QuantumEpanetSimulator(wn, linear_solver=linear_solver)
results_vqls=sim.run_sim(linear_solver=linear_solver)

Contributing

If you want to contribute to the development of wntr_quantum, have a look at the contribution guidelines.

Credits

This package was created with Cookiecutter and the NLeSC/python-template.

About

A quantum enabled water network tool

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages