Skip to content

Hardy Cross Looped Network Solver & O&G Review Update#1849

Merged
EvenSol merged 3 commits intomasterfrom
looped-pipeline-network
Jan 31, 2026
Merged

Hardy Cross Looped Network Solver & O&G Review Update#1849
EvenSol merged 3 commits intomasterfrom
looped-pipeline-network

Conversation

@EvenSol
Copy link
Copy Markdown
Collaborator

@EvenSol EvenSol commented Jan 31, 2026

Summary

This PR introduces a new Hardy Cross looped pipeline network solver for handling ring mains, parallel pipelines, and complex gathering systems. It also includes a comprehensive update to the Oil & Gas Design Operations Review document with improved documentation of existing functionality.


New Features

1. Hardy Cross Looped Pipeline Network Solver

A complete implementation of the classic Hardy Cross iterative method for solving looped pipe networks.

New Classes

File Description
NetworkLoop.java Represents an independent loop with pipe members and flow directions
LoopDetector.java DFS spanning tree algorithm for detecting independent loops
LoopedPipeNetwork.java Main network class with Hardy Cross solver
LoopedPipeNetworkTest.java Unit tests for loop detection and solver

Key Features

  • Automatic Loop Detection: Uses graph theory (DFS spanning tree) to find all independent loops
  • Hardy Cross Iteration: Classic iterative solver for balancing pressure drops
  • Multiple Node Types: Source, sink, and junction nodes
  • Solver Types: HARDY_CROSS, SEQUENTIAL, NEWTON_RAPHSON (future)
  • JSON Export: Integration-ready output format
  • Configurable Parameters: Tolerance, max iterations, relaxation factor

Algorithm

The Hardy Cross method calculates flow corrections for each loop:

$$\Delta Q = -\frac{\sum_i H_i}{2 \sum_i \left|\frac{H_i}{Q_i}\right|}$$

Where:

  • $H_i$ = head loss in pipe $i$
  • $Q_i$ = flow rate in pipe $i$

Usage Example

LoopedPipeNetwork network = new LoopedPipeNetwork("Distribution Ring");
network.setFluidTemplate(gas);

// Add nodes
network.addSourceNode("supply", 50.0, 2000.0);  // 50 bar, 2000 kg/hr
network.addJunctionNode("A");
network.addJunctionNode("B");
network.addSinkNode("customer", 2000.0);

// Add pipes forming a ring
network.addPipe("supply", "A", "inlet", 1000.0, 0.3);
network.addPipe("A", "B", "ring1", 500.0, 0.2);
network.addPipe("B", "supply", "ring2", 500.0, 0.2);  // Creates loop
network.addPipe("A", "customer", "outlet", 200.0, 0.15);

network.run();  // Solves using Hardy Cross

Applications

  • Gas distribution networks with ring mains
  • Offshore pipeline networks with redundant paths
  • Water/steam distribution systems
  • Any pipe network with multiple flow paths

2. Example Notebook

File Description
LoopedPipelineNetworkExample.ipynb Interactive Jupyter notebook with examples

Notebook Contents:

  • Triangle loop detection
  • Distribution ring main
  • Offshore subsea ring network
  • Figure-8 network (two loops)
  • NetworkLoop API demonstration
  • JSON output for integration

Documentation Updates

3. Oil & Gas Design Operations Review

Major update to NEQSIM_OIL_GAS_DESIGN_OPERATIONS_REVIEW.md:

Updated Sections

Section Changes
2.1 Flow Assurance Added erosion-corrosion modeling with API RP 14E
2.4 Field Development Documented WellFlow IPR models and ReservoirCouplingExporter
3.2 Rotating Equipment Upgraded to "Good" with driver framework documentation
3.3 Utilities Upgraded to "Moderate Coverage" with flare stack details
4.1 High Priority Updated status of implemented features
5.1 Onshore Apps Updated pipeline network rating
7. Roadmap Added completion status indicators
Appendix B Reorganized and expanded documentation links
Appendix C NEW - New Functionality Reference

New Documentation of Existing Features

Well Performance (IPR) - WellFlow.java:

  • Production Index model
  • Vogel correlation for oil wells
  • Fetkovich correlation for gas wells
  • Backpressure equation with non-Darcy term
  • Table-driven IPR from well tests
  • Multi-layer commingled wells

Reservoir Coupling - ReservoirCouplingExporter.java:

  • VFP table generation (VFPPROD/VFPINJ)
  • Eclipse 100/E300/Intersect formats
  • Separator efficiency curves
  • Compression curves
  • Network deliverability constraints

Erosion-Corrosion - ManifoldMechanicalDesignCalculator.java:

  • API RP 14E erosional velocity: Ve = C/√ρ
  • Configurable C-factor (100-150)
  • Gas, liquid, multiphase velocity limits

Compressor Drivers:

  • GasTurbineDriver: Ambient derating, part-load efficiency, fuel consumption
  • ElectricMotorDriver: VFD speed control, efficiency curves
  • SteamTurbineDriver: Extraction/condensing modes

Condition Monitoring:

  • FlowInducedVibrationAnalyser: LOF/FRMS methods
  • ConditionBasedReliability: Health index, RUL estimation
  • DegradationModel: Linear, Exponential, Weibull, ML-based

Flare System - FlareStack.java:

  • Radiation models: Point Source, Chamberlain line-source
  • Emissions tracking: CO₂, H₂O, NOx, SO₂, THC, CO
  • Tip backpressure calculation
  • Air/steam assist modeling

4. Reference Manual Index Update

Updated REFERENCE_MANUAL_INDEX.md:

Addition Description
O&G Design Review Added to Chapter 1: Introduction
Looped Network Solver Added link to enhancement proposal
Looped Network Tutorial Added link to example notebook

5. Pipeline Network Enhancement Proposal

Updated PIPELINE_NETWORK_SOLVER_ENHANCEMENT.md:

  • Added "Implementation Status: ✅ COMPLETE" header
  • Listed implemented classes with links
  • Added key features summary

Test Results

All 12 unit tests pass:

Tests run: 12, Failures: 0, Errors: 0, Skipped: 0

Test Coverage:

  • testTriangleLoopDetection - Basic loop detection
  • testTwoLoopDetection - Multiple independent loops
  • testTreeNetworkNoLoops - Tree topology (no loops)
  • testRingMainNetworkCreation - Ring main topology
  • testHardyCrossConvergence - Solver convergence
  • testNetworkLoopClass - Loop member management
  • testSolutionSummary - Output format
  • testJsonOutput - JSON serialization
  • testParallelPipes - Parallel pipe loop detection
  • testSolverTypeSelection - Solver configuration
  • testRelaxationFactor - Parameter setting
  • testOffshoreRingNetwork - Realistic offshore topology

Files Changed

New Files (5)

src/main/java/neqsim/process/equipment/network/
├── NetworkLoop.java
├── LoopDetector.java
└── LoopedPipeNetwork.java

src/test/java/neqsim/process/equipment/network/
└── LoopedPipeNetworkTest.java

docs/examples/
└── LoopedPipelineNetworkExample.ipynb

Modified Files (3)

docs/
├── NEQSIM_OIL_GAS_DESIGN_OPERATIONS_REVIEW.md
├── REFERENCE_MANUAL_INDEX.md
└── process/PIPELINE_NETWORK_SOLVER_ENHANCEMENT.md

Breaking Changes

None. This PR adds new functionality without modifying existing APIs.


Migration Guide

No migration required. Existing code continues to work unchanged.


Future Work

  1. Newton-Raphson Solver: Implement simultaneous solution for large networks
  2. Transient Looped Networks: Extend TwoFluidPipe for looped transient simulation
  3. OPC-UA Connector: Real-time data integration
  4. MEG/TEG Tracking: System-wide inhibitor tracking

Related Issues

  • Enhancement request for looped network solver
  • Documentation review for O&G design capabilities

Reviewers

Please review:

  1. Loop detection algorithm correctness
  2. Hardy Cross convergence behavior
  3. Documentation accuracy for existing features
  4. Example notebook clarity

Checklist

  • Code compiles without errors
  • All unit tests pass
  • JavaDoc added to new classes
  • Example notebook created
  • Documentation updated
  • Reference manual index updated
  • No breaking changes to existing APIs

@EvenSol EvenSol merged commit 13995f6 into master Jan 31, 2026
7 checks passed
@EvenSol EvenSol deleted the looped-pipeline-network branch January 31, 2026 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant