Desktop view | Switch to Mobile

Query Logic.

COMPLETE QUERY LOGIC EXPLANATION

The pump selection query process is a multi-stage filtering and ranking system that identifies the best matching pumps for given operating conditions. The system uses a combination of database queries, fluid dynamics calculations, and scoring algorithms to find optimal pump matches.

QUERY INITIATION

When a query is submitted, the system receives the following parameters:

  • Head (ft): Required total dynamic head at the operating point
  • Flow (USgpm): Required flow rate at the operating point
  • Temperature (°F): Fluid temperature (default: 68°F if not specified)
  • Glycol Percentage (%): Glycol concentration in the fluid (0% = pure water)
  • Number of Results: How many top matches to return (default: 5)
  • Armstrong Part Number (optional): If provided, searches for pumps with matching Armstrong equivalence

STEP 1: INITIAL DATABASE FILTERING (DatabaseService.FindPumpsByFlowAndHead)

The query process begins with a database-level filter to quickly eliminate pumps that cannot 
possibly meet the requirements. This is the most restrictive filter and dramatically reduces 
the number of pumps that need detailed analysis.

For each pump in the database:
  ✓ PRIMARY FILTER: QMin ≤ Required Flow ≤ QMax
     - This ensures the pump can operate at the required flow rate
     - Pumps outside this range are immediately excluded
     - This is the FIRST and most important filter
  
  ✓ SECONDARY FILTER: Has performance point within 0.1 ft of required head
     - Checks if the pump has any performance data point where head is within 0.1 ft of required head
     - This is a preliminary check before detailed interpolation
     - Pumps without nearby head values are excluded

The sub-query logic works as follows:
  - For each pump's performance points, the system calculates: |Pump Flow - Required Flow|
  - It then filters to points where: Pump Head ≥ Required Head
  - Among these points, it finds the one with minimum flow difference
  - This identifies the closest performance point that can achieve the required head
  - If no such point exists, the pump is rejected

This initial filtering typically reduces the candidate pool from thousands of pumps to 
dozens or hundreds, making subsequent calculations much more efficient.
        

STEP 2: OPERATING CONDITIONS VALIDATION (FluidDynamicsService.CanHandleOperatingConditions)

For each pump that passed Step 1, the system performs detailed validation:

  ✓ RE-VERIFY FLOW RANGE: Required flow within pump's QMin to QMax range
     - Double-checks the flow range (redundant but ensures consistency)
  
  ✓ CALCULATE OPERATING POINT: Using linear interpolation
     - Finds the two performance points that bracket the required flow
     - Interpolates to find the exact head, efficiency, power, NPSH, and RPM at required flow
     - This gives us the predicted operating point on the pump curve
  
  ✓ HEAD TOLERANCE CHECK: Operating head ≥ (Required head - 5% tolerance)
     - Calculates: Minimum acceptable head = Required head × 0.95
     - Checks if interpolated operating head meets or exceeds this minimum
     - Allows 5% tolerance below required head (pump can slightly underperform)
     - If operating head is too low, pump is rejected

  If ANY check fails → Pump is REJECTED and removed from consideration

This step ensures that only pumps capable of meeting the actual operating requirements 
proceed to scoring and ranking.
        

STEP 3: OPERATING POINT CALCULATION (FluidDynamicsService.CalculateOperatingPoint)

For each pump that passed Step 2, the system calculates the precise operating point:

  ✓ LOCATE BRACKETING POINTS: Find two performance points that bracket the required flow
     - Lower point: Highest flow point ≤ Required flow
     - Upper point: Lowest flow point ≥ Required flow
     - If exact match exists, uses that point directly
  
  ✓ INTERPOLATION CALCULATION:
     - Calculates interpolation ratio: (Required Flow - Lower Flow) / (Upper Flow - Lower Flow)
     - Applies this ratio to interpolate all parameters:
       • Head (ft)
       • Efficiency (%)
       • Power (HP)
       • NPSH (ft)
       • RPM
  
  ✓ RETURN OPERATING POINT: Complete PerformancePoint object with:
     - Flow = Required flow (exact)
     - Head = Interpolated head
     - Efficiency = Interpolated efficiency
     - Power = Interpolated power
     - NPSH = Interpolated NPSH
     - RPM = Interpolated RPM

This operating point represents where the pump will actually operate on its performance curve 
when delivering the required flow rate.
        

STEP 4: EFFICIENCY EXTRACTION (FluidDynamicsService.CalculateOperatingEfficiency)

For each pump, the system extracts the operating efficiency:

  ✓ EFFICIENCY VALUE: Extract efficiency from the calculated operating point
     - Efficiency is already calculated during interpolation in Step 3
     - This step simply extracts and returns the efficiency percentage
     - Efficiency is stored as a decimal (0.68 = 68%) and converted to percentage

The efficiency value is critical for the match score calculation in the next step, as 
higher efficiency pumps are generally preferred.
        

STEP 5: MATCH SCORE CALCULATION (FluidDynamicsService.CalculateMatchScore)

For each pump, a comprehensive match score is calculated (out of 100 points maximum).
The score is the sum of multiple weighted factors:

  ✓ EFFICIENCY SCORE (up to 10 points):
     - Formula: Operating Efficiency × 10
     - Example: 68% efficiency = 6.8 points
     - Higher efficiency = higher score
     - Rewards pumps that operate efficiently at the required point

  ✓ FLOW RATIO SCORE (up to 20 points):
     - Measures how close the required flow is to the pump's Best Efficiency Point (BEP)
     - Formula: Based on proximity to BEP × 20
     - Pumps operating near their BEP score higher
     - Rewards pumps operating in their optimal range

  ✓ HEAD MATCH SCORE (up to 20 points):
     - Measures how well the pump matches the required head
     - Formula: Penalty for head difference (maximum 20 points)
     - Perfect head match = 20 points
     - Head too high or too low = reduced score
     - Rewards pumps that closely match required head

  ✓ POWER EFFICIENCY SCORE (up to 5 points):
     - Measures power efficiency: (Flow × Head) / Power
     - Formula: Power efficiency metric × 5
     - Higher power efficiency = higher score
     - Rewards pumps that deliver more work per unit of power

  ✓ NPSH MARGIN SCORE (up to 10 points):
     - Measures available NPSH margin
     - Formula: Operating NPSH × 2 (capped at 10 points)
     - Higher NPSH margin = higher score
     - Rewards pumps with better cavitation resistance

  TOTAL SCORE = Sum of all above components (maximum 100 points)

The match score provides a quantitative way to rank pumps, with higher scores indicating 
better overall matches for the specified operating conditions.
        

STEP 6: RESULT RANKING AND LIMITING

After all pumps have been scored, the system ranks and limits results:

  ✓ SORT BY SCORE: Pumps sorted by match score (highest first)
     - Best matches appear first
     - Pumps with identical scores maintain database order
  
  ✓ LIMIT RESULTS: Take top N results (default: 5)
     - Returns only the best matching pumps
     - User can specify how many results to return
     - Prevents overwhelming output with too many options
  
  ✓ GENERATE PERFORMANCE CHARTS: For each result
     - Creates visual performance curve chart
     - Marks the operating point on the curve
     - Shows head, efficiency, and power curves
     - Chart style can be Grundfos or DST format

  ✓ ARMSTRONG EQUIVALENCE HANDLING:
     - If Armstrong part number is provided, only pumps with matching equivalence are returned
     - This allows direct lookup of Grundfos equivalents for Armstrong pumps
     - Overrides normal flow/head search when Armstrong number is specified
        

FINAL OUTPUT: PumpResult Objects

Each result contains a complete PumpResult object with:

  ✓ PUMP DATA (PumpData):
     - Product name and part number
     - Impeller size and curve information
     - Variable speed capability
     - Phase and step information
     - QMin and QMax flow range
     - Weight and physical specifications
     - Armstrong equivalents (if any)
     - Complete list of performance points

  ✓ OPERATING POINT (PerformancePoint):
     - Flow (USgpm)
     - Head (ft)
     - Efficiency (%)
     - Power (HP and kW)
     - NPSH (ft)
     - RPM

  ✓ MATCH SCORE: Numerical score (0-100) indicating match quality

  ✓ PERFORMANCE CHART: Base64-encoded PNG image of the performance curve

This comprehensive output allows users to evaluate and compare pump options with all 
necessary technical information.
        

KEY FILTERING POINTS

The query uses a cascading filter approach for efficiency:

1. QMin/QMax RANGE CHECK (FIRST FILTER - most restrictive)
   - Eliminates pumps that cannot handle the required flow
   - This is the primary database-level filter
   - Typically eliminates 80-90% of pumps immediately

2. HEAD TOLERANCE CHECK (5% tolerance)
   - Ensures pump can achieve required head (within 5% tolerance)
   - Uses interpolated operating point for accuracy
   - Eliminates pumps that cannot meet head requirements

3. PERFORMANCE CURVE INTERPOLATION
   - Calculates exact operating point on pump curve
   - Provides accurate head, efficiency, and power values
   - Enables precise match scoring

4. MATCH SCORE RANKING
   - Quantifies how well each pump matches requirements
   - Enables objective comparison of multiple options
   - Identifies truly optimal pump selections
        

COMMON REJECTION REASONS

Pumps are rejected for the following reasons:

  ✗ REQUIRED FLOW > QMax
     - Pump cannot deliver the required flow rate
     - Most common rejection reason for high-flow applications

  ✗ REQUIRED FLOW < QMin
     - Pump cannot operate efficiently at such low flow
     - Common for oversized pump selections

  ✗ CANNOT ACHIEVE REQUIRED HEAD (within 5% tolerance)
     - Interpolated operating head is too low
     - Pump curve does not reach required head at required flow
     - May indicate need for different impeller size or model

  ✗ NO PERFORMANCE POINTS NEAR REQUIRED HEAD
     - Initial database filter found no points within 0.1 ft
     - Pump curve does not cover the required operating range
     - May indicate wrong pump type or size

  ✗ INSUFFICIENT DATA
     - Pump lacks complete performance point data
     - Cannot perform accurate interpolation
     - Data quality issue in database
        

SPECIAL QUERY MODES

ARMSTRONG EQUIVALENCE LOOKUP:
  - When Armstrong part number is provided, the query bypasses normal flow/head filtering
  - Searches directly for pumps with matching Armstrong equivalence
  - Returns the Grundfos pump(s) that are equivalent to the specified Armstrong pump
  - Useful for cross-referencing between pump manufacturers

This mode allows users to find Grundfos alternatives for existing Armstrong installations.
        

 

                

WHAT IS INTERPOLATION?

---------------------- Interpolation = Estimating a value between two known data points Example: If you know it's 60°F at 2pm and 70°F at 4pm, you can estimate it's about 65°F at 3pm. WHY DO WE NEED IT FOR PUMP SELECTION? -------------------------------------- Pump performance curves have DISCRETE data points: Point A: Q=1000 GPM, H=35 ft Point B: Q=1200 GPM, H=32 ft Point C: Q=1400 GPM, H=28 ft But you need: Q=1210 GPM, H=30.67 ft This point is NOT in the data - it's BETWEEN points B and C... We need to INTERPOLATE to find what the head and efficiency will be at exactly 1210 GPM. HOW THE ALGORITHM WORKS --------------------------------------- STEP 1: Find the Two Bounding Points Given: Required Flow = 1210 GPM Look through performance points: Point B: Q=1200 GPM, H=32 ft ← Lower bound Point C: Q=1400 GPM, H=28 ft ← Upper bound 1200 ≤ 1210 ≤ 1400 ✓ Found the bracket! STEP 2: Calculate the Ratio ratio = (Required Flow - Lower Flow) / (Upper Flow - Lower Flow) ratio = (1210 - 1200) / (1400 - 1200) ratio = 10 / 200 ratio = 0.05 (or 5%) This means: 1210 is 5% of the way from 1200 to 1400 STEP 3: Interpolate Each Parameter For HEAD: Interpolated Head = Lower Head + ratio × (Upper Head - Lower Head) Interpolated Head = 32 + 0.05 × (28 - 32) Interpolated Head = 32 + 0.05 × (-4) Interpolated Head = 32 - 0.2 Interpolated Head = 31.8 ft For EFFICIENCY: Lower Eff = 68%, Upper Eff = 70% Interpolated Eff = 68 + 0.05 × (70 - 68) Interpolated Eff = 68 + 0.1 Interpolated Eff = 68.1% For POWER: Lower Power = 15.2 HP, Upper Power = 15.8 HP Interpolated Power = 15.2 + 0.05 × (15.8 - 15.2) Interpolated Power = 15.2 + 0.03 Interpolated Power = 15.23 HP STEP 4: Return the Interpolated Operating Point Operating Point: Q=1210 GPM, H=31.8 ft, Eff=68.1%, Power=15.23 HP VISUAL REPRESENTATION --------------------- Performance Curve: Head (ft) 35 | A | \ 32 | B | \ 30 | \ ← Required point (1210, 30.67) | \ 28 | C |________________ 1000 1200 1400 Flow (GPM) ↑ ↑ Lower Upper Bound Bound The interpolated point is on the line between B and C, proportional to how far 1210 is between 1200 and 1400. WHAT IF NO BRACKETING POINTS EXIST? ------------------------------------ If your required flow is: - Below all data points → Use first point - Above all data points → Use last point - Exactly on a data point → Use that point directly WHY LINEAR INTERPOLATION? ------------------------- ✓ Simple and fast ✓ Reasonably accurate for most pump curves ✓ Good enough for preliminary selection For more accuracy, we could use: - Polynomial interpolation (curved fit) - Spline interpolation (smooth curves) - But these are more complex and may overfit THE CODE IN ACTION ------------------ From FluidDynamicsService.cs: 1. Sort points by flow 2. Find lowerPoint and upperPoint that bracket required flow 3. Calculate ratio 4. Return new PerformancePoint with interpolated values: - flow = required flow (1210) - head = interpolated head (31.8) - efficiency = interpolated efficiency (68.1) - power = interpolated power (15.23) - NPSH = interpolated NPSH - RPM = interpolated RPM
REAL EXAMPLE WITH PUMP 92559971 -------------------------------- Looking at pump 92559971's actual data: Point 10: Q=1006 GPM, H=33.99 ft, Eff=60.78% Point 11: Q=1132 GPM, H=31.78 ft, Eff=64.50% Point 12: Q=1258 GPM, H=30.18 ft, Eff=67.23% For your required Q=1210 GPM: ratio = (1210 - 1132) / (1258 - 1132) ratio = 78 / 126 ratio = 0.619 Interpolated Head = 31.78 + 0.619 × (30.18 - 31.78) = 31.78 + 0.619 × (-1.60) = 31.78 - 0.99 = 30.79 ft This is VERY CLOSE to your required 30.67 ft! ✓ Interpolated Efficiency = 64.50 + 0.619 × (67.23 - 64.50) = 64.50 + 0.619 × 2.73 = 64.50 + 1.69 = 66.19%