Pipe network analysis of hydraulics network.
According to given property of pipes and boundary conditions, hydra can solve the flowrate (steady state) on each pipe in a hydraulic network.
Currently, only CPU version has the function to obtain equations from graph automatically.
The GPU version for the course project is in cuda folder.
-
Linux
make cpu ./test_cpu.exe ./data/network1.dat
-
Windows (MinGW-win64)
mingw32-make ./test_cpu.exe ./data/network1.dat
- Use cuSolverSP to solve for large scale network. (As we test, bicg is difficult to converge in large scale case, though it is suitable to be parallelized.)
- Use to +-1RMQ to solve LCA
Based on conservation of flow rate, summation of flow rate on a node should be zero. Thus, we can obtain node equations for every node (if boundary condition is pressure, then source nodes are excluded.).
To satisfy Kirshoff's second law, total presure drop (head loss) of any loop should be zero. Thus, we can obtain loop equations for every loop (we only include independent loops to solve unknowns.).
The pressure drop of a pipe can be calculated according to
or
-
More general form
(r is combination of the coefficients, n is usually between 1.5 to 2)
(p.s. n = 1 => Hagen-Poiseuille Equation; n = 1.85 => Hazen-Williams equation; n = 2.0 => Darcy-Weisbach equation)
-
Actual equation used
Becaues the sign of each term should correspond to the direction of flow, the head loss and its derivative become
- Construct BFS spanning tree
- For every pipe that is not included in the spanning tree, use the two endpoints of that pipe as starting point and end point.
- Then find lowest common ancestor of the starting point and end point, the travelled path is the loop we want to find. (connect the endpoints also)
We have to solve system of non-linear equations.
We use incidence matrix to store coefficients (+r, -r, +1, -1) and a vector to store constants (bounary conditions) in node equations and loop equations.
We compute residual matrix R and its jacobian J at every x.
We implement Gaussian ellimination (with partial pivoting) and Biconjugate gradient method to solve.
For large scale network (number of pipe > 300), we thus suggest to use Gaussian ellimination.
We support two kind of boundary conditions:
- Flowrate at node
nNeq = nN - 1
nLeq = nE - nNeq
(nN: #nodes, nE: #edges (unknows), nNeq: #node_eq, nLeq: #loop_eq)
- One node equation should be excluded because it is dependent to the others.
- Pressure at node
nNeq = nN - nN0
nLeq = nL + nN0 - 1
- Additional (number of sources - 1) loops pass through different sources should be included.
- Node equation on source nodes should be excluded.
Currently, we have support the function for converting following conditions into equivalent network, so you have to convert these conditions by yourself.
- parallel pipes between two nodes
We only support single pipe between two nodes. But you still can convert it to equivalent structure and retrive the actual results based on it.
- long serial pipes between two nodes
- multiple sources on one node
Just sum them up.
- multiple separated networks
Just put them into different network.dat.