Skip to main content

EPANET Input File Parsing Analysis

Overview

This document analyzes the EpanetConsoleCore/NetworkManager project to understand how EPANET input files are parsed and mapped to database models. The analysis identifies which EPANET sections are currently processed and which are missing.

Current EPANET Input File Processing

Processed Sections (Currently Implemented)

1. Network Topology Sections

  • [JUNCTIONS]FULLY PROCESSED

    • Model: EN2Models.Junction
    • Parser: EN2NodeBuilder.GetJunctionByIndex()
    • Properties Mapped:
      • Id - Junction ID
      • Elevation - Junction elevation
      • BaseDemand - Base demand value
      • Pattern - Demand pattern ID
      • XCoord, YCoord - Coordinates
  • [RESERVOIRS]FULLY PROCESSED

    • Model: EN2Models.Reservoir
    • Parser: EN2NodeBuilder.GetReservoirByIndex()
    • Properties Mapped:
      • Id - Reservoir ID
      • InitalHead - Initial head (elevation)
      • Pattern - Head pattern ID
      • XCoord, YCoord - Coordinates
  • [TANKS]FULLY PROCESSED

    • Model: EN2Models.Tank
    • Parser: EN2NodeBuilder.GetTankByIndex()
    • Properties Mapped:
      • Id - Tank ID
      • InitVolume - Initial volume
      • InitQual - Initial quality
      • MinLevel, MaxLevel - Level limits
      • Diameter - Tank diameter
      • Elevation - Tank elevation
      • MinVolume, MaxVolume - Volume limits
      • BulkCoeff - Bulk reaction coefficient
      • VolCurve - Volume curve ID
      • MixingModel - Mixing model type
      • XCoord, YCoord - Coordinates
  • [PIPES]FULLY PROCESSED

    • Model: EN2Models.Pipe
    • Parser: EN2LinkBuilder.GetPipeByIndex()
    • Properties Mapped:
      • Id - Pipe ID
      • Diameter - Pipe diameter
      • Length - Pipe length
      • Roughness - Roughness coefficient
      • MinorLoss - Minor loss coefficient
      • KWall - Wall reaction coefficient
      • FromNode, ToNode - Node connections
  • [PUMPS]FULLY PROCESSED

    • Model: EN2Models.Pump
    • Parser: EN2LinkBuilder.GetPumpByIndex()
    • Properties Mapped:
      • Id - Pump ID
      • InitStatus - Initial status
      • InitSetting - Initial setting
      • Pattern - Speed pattern ID
      • HCurve - Head curve ID
      • ECurve - Efficiency curve ID
      • ECost - Energy cost
      • EPattern - Energy pattern ID
      • FromNode, ToNode - Node connections
  • [VALVES]FULLY PROCESSED

    • Model: EN2Models.Valve
    • Parser: EN2LinkBuilder.GetValveByIndex()
    • Properties Mapped:
      • Id - Valve ID
      • Diameter - Valve diameter
      • MinorLoss - Minor loss coefficient
      • Setting - Valve setting
      • Status - Valve status
      • ValveType - Valve type (CVPIPE, PRV, PSV, PBV, FCV, TCV, GPV)
      • FromNode, ToNode - Node connections

2. Geometry Sections

  • [COORDINATES]FULLY PROCESSED

    • Model: EN2Models.Node (XCoord, YCoord properties)
    • Parser: wrapper.GetNodeCoords(i) in node builders
    • Properties Mapped:
      • XCoord, YCoord - Node coordinates
  • [VERTICES]FULLY PROCESSED

    • Model: EN2Models.LinkVertex
    • Parser: EN2LinkBuilder.GetVertex()
    • Properties Mapped:
      • LinkId - Link ID
      • Sequence - Vertex sequence number
      • XCoord, YCoord - Vertex coordinates

3. Configuration Sections

  • [OPTIONS] ⚠️ PARTIALLY PROCESSED
    • Model: EN2Models.Options (exists but not parsed)
    • Current Processing: Only flow units extracted via epanetWrapper.GetFlowUnitsString()
    • Missing: All other options (pressure units, head loss formula, etc.)

Additional Processing

  • Measurement Units: Populated from JSON seed files based on detected flow units
  • Network Configuration: Seeded from JSON files (entity types, metrics, visualization configs)
  • Link Geometries: Calculated and stored in LinkGeoms table

Missing EPANET Sections (NOT Processed)

Critical Missing Sections

1. Time and Pattern Sections

  • [PATTERNS]NOT PROCESSED

    • Model: EN2Models.Pattern (exists but not parsed)
    • Impact: No time-varying data support
    • Missing Data: Pattern multipliers, pattern descriptions
  • [CURVES]NOT PROCESSED

    • Model: EN2Models.DataCurve (exists but not parsed)
    • Impact: No pump curves, tank curves, or valve curves
    • Missing Data: X,Y coordinate pairs for curves
  • [TIMES]NOT PROCESSED

    • Model: EN2Models.TimeParameters (exists but not parsed)
    • Impact: No simulation timing configuration
    • Missing Data: Duration, time steps, report settings

2. Demand and Quality Sections

  • [DEMANDS]NOT PROCESSED

    • Model: EN2Models.Demand (exists but not parsed)
    • Impact: Only base demands from junctions, no multiple demand categories
    • Missing Data: Demand categories, demand patterns per category
  • [SOURCES]NOT PROCESSED

    • Model: EN2Models.Source (exists but not parsed)
    • Impact: No water quality sources
    • Missing Data: Source types, strengths, patterns
  • [REACTIONS]NOT PROCESSED

    • Model: EN2Models.Reaction (exists but not parsed)
    • Impact: No chemical reaction modeling
    • Missing Data: Reaction types, coefficients, orders
  • [QUALITY]NOT PROCESSED

    • Model: EN2Models.Quality (exists but not parsed)
    • Impact: No initial water quality values
    • Missing Data: Initial quality concentrations at nodes

3. Advanced Modeling Sections

  • [MIXING]NOT PROCESSED

    • Model: EN2Models.TankMixing (exists but not parsed)
    • Impact: No tank mixing model configuration
    • Missing Data: Mixing models, compartment volumes
  • [ENERGY]NOT PROCESSED

    • Model: EN2Models.Energy (exists but not parsed)
    • Impact: No energy analysis configuration
    • Missing Data: Energy prices, efficiency settings, demand charges
  • [EMITTERS]NOT PROCESSED

    • Model: EN2Models.Emitter (exists but not parsed)
    • Impact: No pressure-dependent demand modeling
    • Missing Data: Emitter coefficients
  • [LEAKAGE]NOT PROCESSED

    • Model: EN2Models.Leakage (exists but not parsed)
    • Impact: No pipe leakage modeling
    • Missing Data: Leakage coefficients, exponents

4. Control and Status Sections

  • [STATUS]NOT PROCESSED

    • Model: EN2Models.Status (exists but not parsed)
    • Impact: No link status configuration
    • Missing Data: Link status settings, status patterns
  • [CONTROLS]NOT PROCESSED

    • Model: EN2Models.SimpleControl (exists but not parsed)
    • Impact: No simple control rules
    • Missing Data: Control rules, control actions
  • [RULES]NOT PROCESSED

    • Model: EN2Models.RuleBasedControl (exists but not parsed)
    • Impact: No rule-based control systems
    • Missing Data: Rule conditions, rule actions

5. Reporting Section

  • [REPORT]NOT PROCESSED
    • Model: EN2Models.Report (exists but not parsed)
    • Impact: No output reporting configuration
    • Missing Data: Report options, output settings

Display and GUI Sections (Lower Priority)

  • [TITLE]NOT PROCESSED

    • Impact: No project title storage
    • Missing Data: Project title, description
  • [LABELS]NOT PROCESSED

    • Impact: No map labels
    • Missing Data: Label text, positions
  • [BACKDROP]NOT PROCESSED

    • Impact: No backdrop image configuration
    • Missing Data: Backdrop file, dimensions, offsets
  • [TAGS]NOT PROCESSED

    • Impact: No node/link tagging system
    • Missing Data: Tag assignments

Processing Architecture

Current Processing Flow

  1. NetworkBuilder.Main() - Entry point
  2. BuildNetwork() - Main processing method
  3. BuildAndProcessNodes() - Process all node types
  4. BuildAndProcessLinks() - Process all link types
  5. PopulateLinkGeoms() - Calculate link geometries
  6. PopulateMeasurementUnits() - Seed measurement units
  7. PopulateNetworkConfiguration() - Seed configuration data

Parser Classes

  • EN2NodeBuilder - Handles node parsing (Junctions, Tanks, Reservoirs)
  • EN2LinkBuilder - Handles link parsing (Pipes, Pumps, Valves)
  • NetworkConfigurationSeedingService - Handles JSON-based configuration seeding

EpanetWrapper Integration

  • Uses EPANET Toolkit API via EpanetWrapper
  • Calls EN_open() to load input file
  • Uses property getters to extract data
  • No direct section-by-section parsing

Gap Analysis Summary

Coverage Statistics

  • Total EPANET Sections: ~30 sections
  • Currently Processed: ~8 sections (27%)
  • Missing Critical Sections: ~14 sections (47%)
  • Missing Display Sections: ~8 sections (27%)

Impact Assessment

High Impact Missing Sections

  1. [PATTERNS] - Essential for time-varying simulations
  2. [CURVES] - Required for pump and tank modeling
  3. [TIMES] - Critical for simulation configuration
  4. [OPTIONS] - Essential for analysis setup
  5. [DEMANDS] - Important for demand modeling
  6. [SOURCES] - Required for water quality analysis
  7. [REACTIONS] - Needed for chemical modeling
  8. [ENERGY] - Important for energy analysis

Medium Impact Missing Sections

  1. [MIXING] - Tank mixing models
  2. [EMITTERS] - Pressure-dependent demands
  3. [LEAKAGE] - Pipe leakage modeling
  4. [QUALITY] - Initial quality values
  5. [STATUS] - Link status configuration
  6. [CONTROLS] - Simple control rules
  7. [RULES] - Rule-based controls
  8. [REPORT] - Output reporting options

Low Impact Missing Sections

  1. [TITLE] - Project title
  2. [LABELS] - Map labels
  3. [BACKDROP] - Backdrop images
  4. [TAGS] - Node/link tags

Recommendations

Immediate Priority (Phase 1)

  1. Implement [PATTERNS] parsing - Critical for time-varying data
  2. Implement [CURVES] parsing - Required for pump/tank curves
  3. Implement [LEAKAGE] parsing - Pipe leakage
  4. Implement [CONTROLS] parsing - Simple controls
  5. Implement [RULES] parsing - Rule-based controls
  6. Implement [TIMES] parsing - Essential for simulation timing
  7. Complete [OPTIONS] parsing - Critical for analysis configuration

Medium Priority (Phase 2)

  1. Implement [DEMANDS] parsing - Multiple demand categories
  2. Implement [SOURCES] parsing - Water quality sources
  3. Implement [REACTIONS] parsing - Chemical reactions
  4. Implement [ENERGY] parsing - Energy analysis

Lower Priority (Phase 3)

  1. Implement [MIXING] parsing - Tank mixing models
  2. Implement [EMITTERS] parsing - Pressure-dependent demands
  3. Implement [QUALITY] parsing - Initial quality
  4. Implement [STATUS] parsing - Link status
  5. Implement [REPORT] parsing - Output reporting

Implementation Strategy

  1. Extend EpanetWrapper - Add methods to extract missing section data
  2. Create new builder classes - PatternBuilder, CurveBuilder, etc.
  3. Update NetworkBuilder - Add calls to new parsing methods
  4. Add validation - Ensure data integrity during parsing
  5. Update seeding - Create default records for scenario-based models

Conclusion

The NetworkManager currently processes only the basic network topology sections of EPANET input files. While this provides a solid foundation for network modeling, significant functionality is missing, particularly around time-varying data, water quality analysis, and advanced modeling features.

The 14 new models that were recently implemented represent the missing EPANET sections, but they are not yet being parsed from input files. Implementing the parsing for these sections would significantly enhance the system's capability to handle complete EPANET models and provide full feature parity with EPANET desktop software.