Pump Size Calculator

Pump Size Calculator: Determine Optimal Pump Capacity :root { –primary-color: #004a99; –success-color: #28a745; –background-color: #f8f9fa; –text-color: #333; –border-color: #ddd; –card-background: #fff; –shadow-color: rgba(0, 0, 0, 0.1); } body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background-color: var(–background-color); color: var(–text-color); line-height: 1.6; margin: 0; padding: 0; } .container { max-width: 1000px; margin: 20px auto; padding: 20px; background-color: var(–card-background); border-radius: 8px; box-shadow: 0 4px 15px var(–shadow-color); } header { text-align: center; margin-bottom: 30px; padding-bottom: 20px; border-bottom: 1px solid var(–border-color); } header h1 { color: var(–primary-color); margin-bottom: 10px; } .calculator-section { margin-bottom: 40px; padding: 30px; background-color: var(–card-background); border-radius: 8px; box-shadow: 0 2px 10px var(–shadow-color); } .calculator-section h2 { color: var(–primary-color); text-align: center; margin-bottom: 25px; } .input-group { margin-bottom: 20px; text-align: left; } .input-group label { display: block; margin-bottom: 8px; font-weight: bold; color: var(–primary-color); } .input-group input[type="number"], .input-group select { width: calc(100% – 22px); padding: 10px; border: 1px solid var(–border-color); border-radius: 4px; font-size: 1rem; box-sizing: border-box; } .input-group .helper-text { font-size: 0.85em; color: #666; margin-top: 5px; display: block; } .error-message { color: #dc3545; font-size: 0.85em; margin-top: 5px; display: none; /* Hidden by default */ } .button-group { text-align: center; margin-top: 30px; } .button-group button { padding: 12px 25px; margin: 0 10px; border: none; border-radius: 5px; cursor: pointer; font-size: 1rem; font-weight: bold; transition: background-color 0.3s ease; } .btn-calculate { background-color: var(–primary-color); color: white; } .btn-calculate:hover { background-color: #003366; } .btn-reset { background-color: #6c757d; color: white; } .btn-reset:hover { background-color: #5a6268; } .btn-copy { background-color: var(–success-color); color: white; } .btn-copy:hover { background-color: #218838; } .results-container { margin-top: 30px; padding: 25px; background-color: #e9ecef; border-radius: 8px; border: 1px solid #ced4da; } .results-container h3 { color: var(–primary-color); text-align: center; margin-bottom: 20px; } .primary-result { font-size: 2.2em; font-weight: bold; color: var(–success-color); text-align: center; margin-bottom: 20px; padding: 15px; background-color: #d4edda; border: 1px solid var(–success-color); border-radius: 5px; } .intermediate-results div, .formula-explanation { margin-bottom: 15px; font-size: 1.1em; } .intermediate-results span, .formula-explanation span { font-weight: bold; color: var(–primary-color); } .formula-explanation { font-style: italic; color: #555; margin-top: 20px; padding-top: 15px; border-top: 1px dashed #ccc; } table { width: 100%; border-collapse: collapse; margin-top: 20px; } th, td { padding: 10px; text-align: left; border: 1px solid var(–border-color); } th { background-color: var(–primary-color); color: white; font-weight: bold; } td { background-color: var(–card-background); } caption { font-size: 1.1em; font-weight: bold; color: var(–primary-color); margin-bottom: 10px; caption-side: top; text-align: left; } canvas { display: block; margin: 20px auto; max-width: 100%; background-color: var(–card-background); border-radius: 5px; box-shadow: 0 2px 8px var(–shadow-color); } .article-section { margin-top: 40px; padding: 30px; background-color: var(–card-background); border-radius: 8px; box-shadow: 0 2px 10px var(–shadow-color); } .article-section h2, .article-section h3 { color: var(–primary-color); margin-bottom: 15px; } .article-section h2 { text-align: center; margin-bottom: 30px; } .article-section p, .article-section ul, .article-section ol { margin-bottom: 15px; } .article-section li { margin-bottom: 8px; } .faq-item { margin-bottom: 15px; padding: 10px; border-left: 3px solid var(–primary-color); background-color: #f0f8ff; } .faq-item strong { color: var(–primary-color); } .internal-links-section { margin-top: 40px; padding: 30px; background-color: var(–card-background); border-radius: 8px; box-shadow: 0 2px 10px var(–shadow-color); } .internal-links-section h3 { color: var(–primary-color); text-align: center; margin-bottom: 20px; } .internal-links-section ul { list-style: none; padding: 0; } .internal-links-section li { margin-bottom: 10px; } .internal-links-section a { color: var(–primary-color); text-decoration: none; font-weight: bold; } .internal-links-section a:hover { text-decoration: underline; } .internal-links-section p { font-size: 0.9em; color: #555; margin-top: 5px; } .highlight { background-color: var(–primary-color); color: white; padding: 2px 5px; border-radius: 3px; } .error-border { border-color: #dc3545 !important; }

Pump Size Calculator

Accurately determine the optimal pump size for your fluid transfer needs.

Pump Sizing Calculator

Enter the desired volume of fluid per unit of time (e.g., GPM, LPM, m³/h).
Gallons Per Minute (GPM) Liters Per Minute (LPM) Cubic Meters Per Hour (m³/h) Select the unit for your flow rate.
Enter the total equivalent height the pump must lift the fluid (in feet or meters).
Feet (ft) Meters (m) Select the unit for your total dynamic head.
Ratio of fluid density to water density (1.0 for water).
Enter the pump's operating efficiency as a percentage.
Enter the motor's operating efficiency as a percentage.
A safety factor, typically 1.15 or higher.

Calculation Results

Hydraulic Power:
Brake Horsepower (BHP):
Electrical Input Power:
Formula Used:

Hydraulic Power (HP) = (Flow Rate [GPM] * Total Head [ft] * Specific Gravity) / 3960
Brake Horsepower (BHP) = Hydraulic Power / Pump Efficiency
Electrical Input Power (kW) = (BHP * 0.746) / Motor Efficiency
(Conversions applied based on selected units and standard constants)

Key Assumptions & Units
Parameter Value Unit
Required Flow Rate
Total Dynamic Head
Fluid Specific Gravity
Pump Efficiency%
Motor Efficiency%
Service Factor

Understanding Pump Sizing

Selecting the correct pump size is a critical step in any fluid transfer system. An undersized pump will struggle to meet demand, leading to inefficiency and potential system failure. Conversely, an oversized pump can be unnecessarily expensive to purchase and operate, and may even cause damage to the system due to excessive pressure or flow. This pump size calculator is designed to help engineers, technicians, and system designers accurately determine the required pump capacity based on key operational parameters.

What is Pump Sizing?

Pump sizing is the process of determining the appropriate pump model and specifications (like flow rate, head, and power) needed to effectively move a specific fluid from one point to another within a system. It involves analyzing the system's requirements, the fluid's properties, and the pump's performance characteristics to ensure optimal operation. A well-sized pump ensures reliability, efficiency, and longevity of the entire fluid handling system.

Who Should Use a Pump Size Calculator?

  • Engineers: Mechanical, process, and civil engineers designing new fluid systems or upgrading existing ones.
  • System Designers: Professionals responsible for specifying equipment for HVAC, water supply, wastewater treatment, irrigation, and industrial processes.
  • Maintenance Technicians: Individuals troubleshooting pump performance issues or replacing existing units.
  • Contractors: Those installing and commissioning pump systems.
  • Students and Educators: Learning about fluid dynamics and pump applications.

Common Misconceptions about Pump Sizing

  • "Bigger is always better": Oversizing leads to inefficiency and potential damage.
  • Ignoring system friction: Only considering static lift (elevation change) is insufficient; friction losses in pipes and fittings are crucial.
  • Assuming 100% efficiency: Pumps and motors have inherent inefficiencies that must be accounted for.
  • Not considering fluid properties: Viscosity and specific gravity significantly impact pump performance and power requirements.
  • Forgetting the service factor: This safety margin accounts for variations in load and operating conditions.

Pump Sizing Formula and Mathematical Explanation

The core of pump sizing involves calculating the power required to move a fluid against a certain resistance. This is primarily determined by the flow rate, the total dynamic head (TDH), and the fluid's properties. The calculations typically proceed in stages:

Step-by-Step Derivation

  1. Calculate Hydraulic Power (Water Horsepower): This is the theoretical power required to move the fluid itself, without considering any inefficiencies. It's directly proportional to the volume of fluid moved per unit time (flow rate) and the height it's lifted (head), adjusted for the fluid's density (specific gravity).
  2. Calculate Brake Horsepower (BHP): This accounts for the pump's mechanical and volumetric inefficiencies. The hydraulic power is divided by the pump's efficiency rating. This gives the actual power the pump shaft must deliver.
  3. Calculate Electrical Input Power: This accounts for the motor's efficiency. The BHP is divided by the motor's efficiency rating to determine the electrical power the motor consumes. This is often expressed in kilowatts (kW) for electrical calculations.
  4. Apply Service Factor: The calculated power requirements are often multiplied by a service factor to provide a safety margin, ensuring the pump and motor operate within their rated limits under varying conditions.

Variable Explanations

Understanding the variables used in the pump size calculator is key to accurate input:

Pump Sizing Variables
Variable Meaning Unit Typical Range
Flow Rate (Q) The volume of fluid the pump needs to deliver per unit of time. GPM, LPM, m³/h Varies widely based on application (e.g., 1 to 10,000+ GPM)
Total Dynamic Head (TDH) The total equivalent height the pump must overcome. Includes static lift, static head, friction losses, and pressure head. Feet (ft), Meters (m) Varies widely (e.g., 10 to 500+ ft)
Fluid Specific Gravity (SG) The ratio of the fluid's density to the density of water at a standard temperature. Affects the weight of the fluid being moved. Unitless ~0.7 (oils) to 1.0 (water) to >1.0 (slurries, brines)
Pump Efficiency (ηpump) The ratio of hydraulic power output to the mechanical power input at the pump shaft. % 50% – 85% (typical for centrifugal pumps)
Motor Efficiency (ηmotor) The ratio of mechanical power output from the motor shaft to the electrical power input. % 80% – 95% (for standard electric motors)
Service Factor (SF) A multiplier applied to the rated horsepower to indicate the allowable overload capability of the motor under specific conditions. Unitless 1.0 to 1.25 (commonly 1.15)

Practical Examples (Real-World Use Cases)

Example 1: Residential Water Supply

A homeowner needs to pump water from a well to their house. The well is 30 feet deep (static lift), and the water needs to reach a storage tank 20 feet higher than the ground level (static head). The piping system and fittings create an estimated 10 feet of friction loss. The required flow rate for the household is 15 GPM. The fluid is water (SG = 1.0). A typical centrifugal pump might have 65% efficiency, and the motor 90% efficiency. A service factor of 1.15 is desired.

  • Inputs:
  • Flow Rate: 15 GPM
  • Total Head: 30 ft (lift) + 20 ft (head) + 10 ft (friction) = 60 ft
  • Fluid SG: 1.0
  • Pump Efficiency: 65%
  • Motor Efficiency: 90%
  • Service Factor: 1.15

Using the calculator:

  • Hydraulic Power ≈ 0.91 HP
  • Brake Horsepower (BHP) ≈ 1.40 HP
  • Electrical Input Power ≈ 1.04 kW

Interpretation: The system requires approximately 1.4 HP at the pump shaft. Considering the service factor, a motor rated around 1.5 HP or 2 HP would be suitable to ensure reliable operation. The calculator helps confirm that a standard residential well pump is likely appropriate.

Example 2: Industrial Cooling System

An industrial facility needs to circulate cooling water through a heat exchanger. The system requires a flow rate of 500 LPM. The total head the pump must overcome, including static elevation changes and significant friction losses in the large pipes, is 25 meters. The fluid is treated water (SG = 1.0). The selected pump has an efficiency of 75%, and the motor has an efficiency of 92%. A service factor of 1.2 is applied.

  • Inputs:
  • Flow Rate: 500 LPM
  • Total Head: 25 m
  • Fluid SG: 1.0
  • Pump Efficiency: 75%
  • Motor Efficiency: 92%
  • Service Factor: 1.2

Using the calculator (after converting LPM to GPM and m to ft if necessary, or using internal logic):

  • Hydraulic Power ≈ 10.5 HP (equivalent)
  • Brake Horsepower (BHP) ≈ 14.0 HP
  • Electrical Input Power ≈ 11.4 kW

Interpretation: This industrial application requires a substantial amount of power. The pump needs to deliver 14 HP. With the service factor, a motor rated around 15 HP to 20 HP would be necessary. This calculation guides the selection of a robust industrial pump and motor combination.

How to Use This Pump Size Calculator

Our pump size calculator simplifies the complex process of pump selection. Follow these steps for accurate results:

  1. Determine Required Flow Rate: Identify the maximum volume of fluid you need to move per unit of time. Consider your application's peak demand. Select the appropriate unit (GPM, LPM, m³/h).
  2. Calculate Total Dynamic Head (TDH): This is the most crucial input. It includes:
    • Static Lift: Vertical distance from the fluid source's surface to the pump's discharge point.
    • Static Head: Vertical distance from the pump to the final discharge point if it's higher than the pump.
    • Friction Head Loss: Resistance from pipes, valves, elbows, and other fittings. This can be estimated using friction loss charts or software.
    • Pressure Head: If the discharge point is pressurized (e.g., into a pressure vessel), add the equivalent head of that pressure.
    Sum these components and select the correct unit (feet or meters).
  3. Input Fluid Properties: Enter the Specific Gravity (SG) of the fluid. For water, SG is 1.0. For other fluids, consult their properties.
  4. Enter Efficiencies: Input the estimated or rated efficiency for both the pump and the motor. These are usually expressed as percentages. If unsure, use typical values (e.g., 65-75% for pump, 90-92% for motor).
  5. Set Service Factor: Enter a service factor, typically 1.15 or higher, for a safety margin.
  6. Click Calculate: The calculator will instantly display the required Hydraulic Power, Brake Horsepower (BHP), and Electrical Input Power.

How to Read Results

  • Primary Result (BHP): This is the most direct indicator of the pump's required shaft power. You'll typically select a pump and motor combination where the motor's rated horsepower meets or exceeds this BHP value, often considering the service factor.
  • Hydraulic Power: The theoretical power needed to move the fluid. Useful for understanding the baseline energy requirement.
  • Electrical Input Power: The actual power the motor will draw from the electrical supply. Important for electrical system design and energy cost estimation.
  • Assumptions Table: Review the table to ensure your inputs were correctly entered and to understand the basis of the calculation.
  • Chart: Visualize the relationship between power components.

Decision-Making Guidance

Use the calculated BHP and Electrical Input Power to select a pump and motor. Ensure the motor's horsepower rating is sufficient, considering the service factor. For example, if the calculated BHP is 14 HP and the service factor is 1.15, you need a motor capable of delivering at least 14 * 1.15 = 16.1 HP. You would typically choose the next standard motor size up (e.g., 20 HP).

Key Factors That Affect Pump Sizing Results

Several factors influence the accuracy of pump sizing calculations and the final pump selection:

  1. System Curve Complexity: TDH is not static. It changes with flow rate due to friction losses, which increase non-linearly. A detailed system curve analysis is often needed for critical applications. Our calculator uses a single TDH value for simplicity.
  2. Fluid Viscosity: Highly viscous fluids require more power to pump and can significantly reduce pump efficiency. The standard formulas assume water-like viscosity. Adjustments are needed for oils, slurries, or other viscous liquids.
  3. Temperature Effects: Fluid density (SG) and viscosity can change with temperature, affecting power requirements. Also, high temperatures can affect pump materials and seals.
  4. Pump Type and Curve: Different pump types (centrifugal, positive displacement) have distinct performance curves. Centrifugal pumps are best suited for low-viscosity fluids and variable head/flow conditions, while positive displacement pumps excel at high viscosity and constant flow regardless of head. The calculator assumes a centrifugal pump performance model.
  5. NPSH Available vs. Required: Net Positive Suction Head (NPSH) is critical to prevent cavitation. While not directly part of power calculation, it heavily influences pump selection and installation design. Insufficient NPSH can lead to pump damage and reduced performance.
  6. Operating Point Stability: Pumps perform most efficiently at their Best Efficiency Point (BEP) on the performance curve. Sizing should aim to keep the operating point close to the BEP for optimal energy use and longevity. Operating too far from the BEP can lead to inefficiency, vibration, and premature wear.
  7. Future System Changes: Consider potential future modifications to the system, such as increased flow demand or changes in elevation, when sizing the pump. It might be prudent to select a pump that can handle slightly higher demands than currently required.
  8. Environmental Factors: Ambient temperature, altitude, and potential for corrosive or abrasive elements in the fluid can impact material selection, motor cooling, and overall system reliability, indirectly affecting sizing decisions.

Frequently Asked Questions (FAQ)

Q1: What is the difference between Flow Rate and Total Dynamic Head (TDH)?

Flow Rate (Q) is the volume of fluid moved per unit time (e.g., GPM). TDH is the total equivalent height the pump must lift the fluid, accounting for elevation changes, friction in pipes/fittings, and system pressure. Both are essential for sizing.

Q2: Can I use this calculator for any type of fluid?

The calculator is primarily designed for fluids with properties similar to water (SG ≈ 1.0). For highly viscous fluids (like heavy oils or slurries), you'll need to consult pump manufacturer data for specific viscosity corrections and efficiency adjustments, as standard formulas may not apply accurately.

Q3: What happens if I choose a pump that is too small?

An undersized pump will likely fail to meet the required flow rate or head. This can lead to system underperformance, increased energy consumption (as the pump runs constantly at its limit), premature wear, and potential damage.

Q4: What happens if I choose a pump that is too large?

An oversized pump can be inefficient, leading to higher energy costs. It may also cause issues like cavitation (if flow is throttled excessively), excessive system pressure, vibration, and accelerated wear on components like seals and impellers.

Q5: How do I calculate friction loss for TDH?

Friction loss depends on pipe diameter, length, material, flow rate, and the number/type of fittings (elbows, valves). You can use online calculators, friction loss tables (like the Hazen-Williams or Darcy-Weisbach equations), or engineering software. It's a critical component of TDH.

Q6: What is a "Service Factor" in motor sizing?

The service factor (SF) on a motor nameplate indicates how much overload the motor can handle for short periods without damage. A common SF is 1.15, meaning the motor can safely deliver 1.15 times its rated horsepower. It's used as a safety margin in calculations.

Q7: Does pump efficiency change with flow rate?

Yes, pump efficiency varies across its operating range. Pumps have a Best Efficiency Point (BEP). The efficiency value you input should ideally be the pump's efficiency at your specific operating point (flow rate and head). If unknown, use the rated efficiency at BEP or a typical average.

Q8: Can this calculator determine the physical pump model?

No, this calculator provides the key performance parameters (required horsepower, flow, head) needed to select a pump model. You will still need to consult pump manufacturer catalogs and performance curves to find a specific model that meets these calculated requirements and other system constraints (like NPSH).

© 2023 Your Company Name. All rights reserved.
var flowRateInput = document.getElementById('flowRate'); var flowUnitSelect = document.getElementById('flowUnit'); var totalHeadInput = document.getElementById('totalHead'); var headUnitSelect = document.getElementById('headUnit'); var fluidSpecificGravityInput = document.getElementById('fluidSpecificGravity'); var efficiencyInput = document.getElementById('efficiency'); var motorEfficiencyInput = document.getElementById('motorEfficiency'); var serviceFactorInput = document.getElementById('serviceFactor'); var primaryResultDiv = document.getElementById('primaryResult'); var hydraulicPowerDiv = document.getElementById('hydraulicPower'); var brakeHorsepowerDiv = document.getElementById('brakeHorsepower'); var electricalInputPowerDiv = document.getElementById('electricalInputPower'); var tableFlowRate = document.getElementById('tableFlowRate'); var tableFlowUnit = document.getElementById('tableFlowUnit'); var tableTotalHead = document.getElementById('tableTotalHead'); var tableHeadUnit = document.getElementById('tableHeadUnit'); var tableSG = document.getElementById('tableSG'); var tablePumpEff = document.getElementById('tablePumpEff'); var tableMotorEff = document.getElementById('tableMotorEff'); var tableSF = document.getElementById('tableSF'); var flowRateError = document.getElementById('flowRateError'); var totalHeadError = document.getElementById('totalHeadError'); var fluidSpecificGravityError = document.getElementById('fluidSpecificGravityError'); var efficiencyError = document.getElementById('efficiencyError'); var motorEfficiencyError = document.getElementById('motorEfficiencyError'); var serviceFactorError = document.getElementById('serviceFactorError'); var chart = null; var chartContext = null; function convertToGPM(value, unit) { if (unit === 'LPM') { return value * 0.264172; } else if (unit === 'm3h') { return value * 4.40288; } return value; // Assume GPM } function convertToFt(value, unit) { if (unit === 'm') { return value * 3.28084; } return value; // Assume Feet } function validateInput(inputElement, errorElement, min, max, fieldName) { var value = parseFloat(inputElement.value); var isValid = true; errorElement.style.display = 'none'; inputElement.classList.remove('error-border'); if (isNaN(value)) { errorElement.textContent = fieldName + ' is required.'; errorElement.style.display = 'block'; inputElement.classList.add('error-border'); isValid = false; } else if (value max) { errorElement.textContent = fieldName + ' cannot be greater than ' + max + '.'; errorElement.style.display = 'block'; inputElement.classList.add('error-border'); isValid = false; } return isValid; } function calculatePumpSize() { var isValid = true; // Reset errors flowRateError.style.display = 'none'; flowRateInput.classList.remove('error-border'); totalHeadError.style.display = 'none'; totalHeadInput.classList.remove('error-border'); fluidSpecificGravityError.style.display = 'none'; fluidSpecificGravityInput.classList.remove('error-border'); efficiencyError.style.display = 'none'; efficiencyInput.classList.remove('error-border'); motorEfficiencyError.style.display = 'none'; motorEfficiencyInput.classList.remove('error-border'); serviceFactorError.style.display = 'none'; serviceFactorInput.classList.remove('error-border'); // Validate inputs if (!validateInput(flowRateInput, flowRateError, 0.1, 100000, 'Flow Rate')) isValid = false; if (!validateInput(totalHeadInput, totalHeadError, 1, 10000, 'Total Dynamic Head')) isValid = false; if (!validateInput(fluidSpecificGravityInput, fluidSpecificGravityError, 0.1, 5, 'Fluid Specific Gravity')) isValid = false; if (!validateInput(efficiencyInput, efficiencyError, 1, 100, 'Pump Efficiency')) isValid = false; if (!validateInput(motorEfficiencyInput, motorEfficiencyError, 1, 100, 'Motor Efficiency')) isValid = false; if (!validateInput(serviceFactorInput, serviceFactorError, 1, 2, 'Service Factor')) isValid = false; if (!isValid) { primaryResultDiv.textContent = 'Invalid Input'; return; } var flowRate = parseFloat(flowRateInput.value); var flowUnit = flowUnitSelect.value; var totalHead = parseFloat(totalHeadInput.value); var headUnit = headUnitSelect.value; var sg = parseFloat(fluidSpecificGravityInput.value); var pumpEffPercent = parseFloat(efficiencyInput.value); var motorEffPercent = parseFloat(motorEfficiencyInput.value); var sf = parseFloat(serviceFactorInput.value); var flowRateGPM = convertToGPM(flowRate, flowUnit); var totalHeadFt = convertToFt(totalHead, headUnit); var pumpEff = pumpEffPercent / 100; var motorEff = motorEffPercent / 100; // Calculations var hydraulicPowerHP = (flowRateGPM * totalHeadFt * sg) / 3960; var brakeHorsepower = hydraulicPowerHP / pumpEff; var electricalInputPowerKW = (brakeHorsepower * 0.746) / motorEff; var requiredMotorHP = brakeHorsepower * sf; // Display Results primaryResultDiv.textContent = requiredMotorHP.toFixed(2) + ' HP'; hydraulicPowerDiv.innerHTML = 'Hydraulic Power: ' + hydraulicPowerHP.toFixed(2) + ' HP'; brakeHorsepowerDiv.innerHTML = 'Brake Horsepower (BHP): ' + brakeHorsepower.toFixed(2) + ' HP'; electricalInputPowerDiv.innerHTML = 'Electrical Input Power: ' + electricalInputPowerKW.toFixed(2) + ' kW'; // Update table tableFlowRate.textContent = flowRate.toFixed(2); tableFlowUnit.textContent = flowUnit; tableTotalHead.textContent = totalHead.toFixed(2); tableHeadUnit.textContent = headUnit; tableSG.textContent = sg.toFixed(2); tablePumpEff.textContent = pumpEffPercent.toFixed(1); tableMotorEff.textContent = motorEffPercent.toFixed(1); tableSF.textContent = sf.toFixed(2); updateChart(hydraulicPowerHP, brakeHorsepower, electricalInputPowerKW, requiredMotorHP); } function resetCalculator() { flowRateInput.value = 100; flowUnitSelect.value = 'GPM'; totalHeadInput.value = 50; headUnitSelect.value = 'ft'; fluidSpecificGravityInput.value = 1.0; efficiencyInput.value = 70; motorEfficiencyInput.value = 90; serviceFactorInput.value = 1.15; // Clear errors flowRateError.style.display = 'none'; flowRateInput.classList.remove('error-border'); totalHeadError.style.display = 'none'; totalHeadInput.classList.remove('error-border'); fluidSpecificGravityError.style.display = 'none'; fluidSpecificGravityInput.classList.remove('error-border'); efficiencyError.style.display = 'none'; efficiencyInput.classList.remove('error-border'); motorEfficiencyError.style.display = 'none'; motorEfficiencyInput.classList.remove('error-border'); serviceFactorError.style.display = 'none'; serviceFactorInput.classList.remove('error-border'); calculatePumpSize(); // Recalculate with default values } function copyResults() { var resultsText = "Pump Size Calculation Results:\n\n"; resultsText += "Required Motor HP: " + primaryResultDiv.textContent + "\n"; resultsText += document.getElementById('hydraulicPower').textContent + "\n"; resultsText += document.getElementById('brakeHorsepower').textContent + "\n"; resultsText += document.getElementById('electricalInputPower').textContent + "\n\n"; resultsText += "Key Assumptions & Units:\n"; var rows = document.getElementById('assumptionsTableBody').getElementsByTagName('tr'); for (var i = 0; i < rows.length; i++) { var cells = rows[i].getElementsByTagName('td'); if (cells.length === 3) { resultsText += cells[0].textContent + ": " + cells[1].textContent + " " + cells[2].textContent + "\n"; } } // Use a temporary textarea to copy var textArea = document.createElement("textarea"); textArea.value = resultsText; textArea.style.position = "fixed"; textArea.style.left = "-9999px"; document.body.appendChild(textArea); textArea.focus(); textArea.select(); try { var successful = document.execCommand('copy'); var msg = successful ? 'Results copied!' : 'Copy failed!'; console.log(msg); // Optionally show a temporary message to the user var copyButton = document.querySelector('.btn-copy'); var originalText = copyButton.textContent; copyButton.textContent = 'Copied!'; setTimeout(function() { copyButton.textContent = originalText; }, 2000); } catch (err) { console.error('Fallback: Oops, unable to copy', err); } document.body.removeChild(textArea); } function updateChart(hp, bhp, kw, reqHP) { var canvas = document.getElementById('pumpChart'); if (!canvas) return; chartContext = canvas.getContext('2d'); // Destroy previous chart instance if it exists if (chart) { chart.destroy(); } chart = new Chart(chartContext, { type: 'bar', data: { labels: ['Hydraulic Power', 'Brake Horsepower (BHP)', 'Electrical Input (kW)', 'Required Motor HP'], datasets: [{ label: 'Power (HP/kW)', data: [hp, bhp, kw, reqHP], backgroundColor: [ 'rgba(0, 74, 153, 0.6)', // Primary Blue 'rgba(40, 167, 69, 0.6)', // Success Green 'rgba(255, 193, 7, 0.6)', // Warning Yellow (for kW) 'rgba(108, 117, 125, 0.6)' // Secondary Gray (for Required HP) ], borderColor: [ 'rgba(0, 74, 153, 1)', 'rgba(40, 167, 69, 1)', 'rgba(255, 193, 7, 1)', 'rgba(108, 117, 125, 1)' ], borderWidth: 1 }] }, options: { responsive: true, maintainAspectRatio: false, scales: { y: { beginAtZero: true, title: { display: true, text: 'Power Units (HP for first 3, kW for Electrical Input)' } } }, plugins: { legend: { display: false // Hide legend as labels are clear }, title: { display: true, text: 'Power Component Breakdown' } } } }); } // Initial calculation on page load document.addEventListener('DOMContentLoaded', function() { // Check if Chart.js is available before trying to use it if (typeof Chart !== 'undefined') { // Initialize chart with placeholder data or call calculatePumpSize() calculatePumpSize(); } else { console.error("Chart.js library not found. Please include it in your HTML."); // Optionally disable chart-related elements or show a message var canvas = document.getElementById('pumpChart'); if (canvas) canvas.style.display = 'none'; var chartCaption = canvas.previousElementSibling; // Assuming caption is right before canvas if (chartCaption) chartCaption.style.display = 'none'; } // Add event listeners for real-time updates (optional, but good UX) var inputs = document.querySelectorAll('.loan-calc-container input, .loan-calc-container select'); inputs.forEach(function(input) { input.addEventListener('input', calculatePumpSize); input.addEventListener('change', calculatePumpSize); }); });

Leave a Comment