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:
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
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 Net0
can be found here
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 Net0
can be found here
To install wntr_quantum from GitHub repository, do:
git clone [email protected]:QuantumApplicationLab/wntr-quantum.git
cd wntr-quantum
python -m pip install .
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>
The example below shows how to use the Variational Quantum Linear Solver to solve the linear systems required in the Newton-Raphson-GGA algorithm.
import wntr
import wntr_quantum
from qiskit.circuit.library import RealAmplitudes
from qiskit.primitives import Estimator
from qiskit_algorithms import optimizers as opt
from quantum_newton_raphson.vqls_solver import VQLS_SOLVER
# define the water network
inp_file = 'Net2Loops.inp'
wn = wntr.network.WaterNetworkModel(inp_file)
# define the vqls ansatz
n_qubits = 3
qc = RealAmplitudes(n_qubits, reps=3, entanglement="full")
estimator = Estimator()
# define the VQLS solver
linear_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 network
sim = wntr_quantum.sim.QuantumEpanetSimulator(wn, linear_solver=linear_solver)
results_vqls = sim.run_sim(linear_solver=linear_solver)
If you want to contribute to the development of wntr_quantum, have a look at the contribution guidelines.
This package was created with Cookiecutter and the NLeSC/python-template.