Superheat and Subcooling Calculator

Superheat and Subcooling Calculator: HVAC Performance Analysis :root { –primary-color: #004a99; –success-color: #28a745; –background-color: #f8f9fa; –text-color: #333; –border-color: #ddd; –card-background: #fff; –shadow: 0 2px 5px 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; display: flex; justify-content: center; padding-top: 20px; padding-bottom: 40px; } .container { max-width: 1000px; width: 95%; background-color: var(–card-background); padding: 25px; border-radius: 8px; box-shadow: var(–shadow); box-sizing: border-box; } h1, h2, h3 { color: var(–primary-color); text-align: center; margin-bottom: 20px; } h1 { font-size: 2.2em; } h2 { font-size: 1.8em; margin-top: 30px; border-bottom: 2px solid var(–primary-color); padding-bottom: 5px; } h3 { font-size: 1.4em; margin-top: 25px; } .calculator-section, .article-section { background-color: var(–card-background); padding: 25px; border-radius: 8px; box-shadow: var(–shadow); margin-bottom: 25px; } .input-group { margin-bottom: 18px; text-align: left; } .input-group label { display: block; margin-bottom: 7px; font-weight: bold; color: var(–primary-color); } .input-group input, .input-group select { width: calc(100% – 22px); /* Account for padding and border */ padding: 10px; border: 1px solid var(–border-color); border-radius: 5px; font-size: 1em; box-sizing: border-box; } .input-group input[type="number"] { -moz-appearance: textfield; /* Firefox */ } .input-group input[type="number"]::-webkit-outer-spin-button, .input-group input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; } .input-group small { display: block; margin-top: 5px; color: #666; font-size: 0.9em; } .error-message { color: #dc3545; font-size: 0.9em; margin-top: 5px; display: none; /* Hidden by default */ } .button-group { display: flex; justify-content: center; gap: 10px; margin-top: 20px; flex-wrap: wrap; } button { padding: 12px 25px; border: none; border-radius: 5px; font-size: 1em; cursor: pointer; transition: background-color 0.3s ease; font-weight: bold; } #calculateBtn, #copyResultsBtn { background-color: var(–primary-color); color: white; } #calculateBtn:hover, #copyResultsBtn:hover { background-color: #003366; } #resetBtn { background-color: #6c757d; color: white; } #resetBtn:hover { background-color: #5a6268; } #result { background-color: var(–primary-color); color: white; padding: 20px; text-align: center; border-radius: 5px; margin-top: 25px; box-shadow: var(–shadow); font-size: 1.8em; font-weight: bold; display: none; /* Hidden by default */ word-wrap: break-word; } .result-container { margin-top: 25px; padding: 20px; border: 1px solid var(–border-color); border-radius: 5px; background-color: #e9ecef; display: none; /* Hidden by default */ } .result-item { margin-bottom: 10px; font-size: 1.1em; } .result-item strong { color: var(–primary-color); } .formula-explanation { margin-top: 15px; font-size: 0.95em; font-style: italic; color: #555; text-align: left; } table { width: 100%; border-collapse: collapse; margin-top: 20px; overflow-x: auto; /* Enable horizontal scrolling */ display: block; /* Needed for overflow-x to work */ white-space: nowrap; /* Prevent wrapping within cells */ } th, td { padding: 10px 15px; border: 1px solid var(–border-color); text-align: left; } thead { background-color: var(–primary-color); color: white; } tbody tr:nth-child(even) { background-color: #f2f2f2; } caption { caption-side: bottom; font-size: 0.9em; color: #666; margin-top: 10px; text-align: left; } canvas { max-width: 100%; height: auto; display: block; margin: 20px auto; border: 1px solid var(–border-color); border-radius: 5px; background-color: var(–card-background); } .article-section p, .article-section ul, .article-section ol { margin-bottom: 15px; padding-left: 20px; } .article-section ul li, .article-section ol li { margin-bottom: 8px; } .article-section ul.no-padding, .article-section ol.no-padding { padding-left: 0; } .article-section a { color: var(–primary-color); text-decoration: none; } .article-section a:hover { text-decoration: underline; } .faq-item { margin-bottom: 15px; } .faq-item strong { display: block; color: var(–primary-color); cursor: pointer; margin-bottom: 5px; } .faq-item p { margin-left: 15px; display: none; /* Hidden by default */ font-size: 0.95em; } .related-links ul { list-style: none; padding: 0; } .related-links li { margin-bottom: 10px; } .related-links a { font-weight: bold; } .related-links span { font-size: 0.9em; color: #555; margin-left: 10px; } @media (max-width: 768px) { .container { width: 95%; padding: 15px; } h1 { font-size: 1.8em; } h2 { font-size: 1.5em; } h3 { font-size: 1.2em; } button { width: 100%; margin-bottom: 10px; } .button-group { flex-direction: column; } #result { font-size: 1.5em; } }

Superheat and Subcooling Calculator

Analyze HVAC system performance and efficiency by calculating superheat and subcooling.

HVAC Performance Calculator

R-410A R-22 R-134a R-404A Select the type of refrigerant used in the system.
Measured at the suction line near the compressor.
Please enter a valid positive number for suction pressure.
Measured at the suction line, typically 6 inches from the evaporator outlet.
Please enter a valid positive number for suction line temperature.
Measured on the liquid line, typically 6 inches from the condenser outlet.
Please enter a valid positive number for liquid line temperature.
Measured at the discharge line near the compressor.
Please enter a valid positive number for discharge pressure.

Intermediate Values & Analysis

Saturation Temperature (Suction): °F
Saturation Temperature (Discharge): °F
Superheat: °F
Subcooling: °F
Formula Explanation:
Superheat = Suction Line Temperature – Saturation Temperature (at Suction Pressure)
Subcooling = Saturation Temperature (at Discharge Pressure) – Liquid Line Temperature

System Performance Chart

HVAC Operating Temperatures vs. Refrigerant Saturation Points

What is Superheat and Subcooling?

Superheat and subcooling are critical metrics used in the HVAC (Heating, Ventilation, and Air Conditioning) industry to diagnose and assess the performance and efficiency of refrigeration and air conditioning systems. They are not direct measures of energy consumption, but rather indicators of how well the refrigerant is transitioning between its liquid and vapor states within the system. Understanding these values helps technicians fine-tune systems, identify potential problems like refrigerant charge issues, airflow restrictions, or component malfunctions, and ensure optimal cooling or heating delivery.

Who should use this superheat and subcooling calculator?

  • HVAC technicians and service professionals
  • Refrigeration engineers
  • Building maintenance personnel
  • Appliance repair specialists
  • Anyone responsible for maintaining or troubleshooting HVAC equipment.

Common Misconceptions:

  • Misconception: Higher superheat/subcooling is always better. Reality: Both superheat and subcooling need to be within specific target ranges for optimal performance. Deviations indicate problems.
  • Misconception: Superheat and subcooling are the same as temperature difference. Reality: While calculated using temperature differences, they specifically relate to the refrigerant's phase change points (saturation temperatures).
  • Misconception: These calculations are only for cooling mode. Reality: While primarily discussed in cooling, similar principles apply to heat pumps in heating mode, though the target values and measurements might differ.

Superheat and Subcooling Formula and Mathematical Explanation

The calculations for superheat and subcooling are straightforward but rely on accurate pressure and temperature measurements. They help determine if the refrigerant is absorbing the correct amount of heat in the evaporator (superheat) and if it's fully condensed before reaching the expansion device (subcooling).

Superheat Calculation

Superheat is the temperature difference between the actual suction line temperature and the saturation temperature of the refrigerant at the evaporator's pressure (suction pressure).

Formula:

Superheat = Suction Line Temperature - Saturation Temperature (at Suction Pressure)

This calculation verifies that all the liquid refrigerant has boiled off into a vapor by the time it leaves the evaporator, preventing liquid floodback to the compressor.

Subcooling Calculation

Subcooling is the temperature difference between the saturation temperature of the refrigerant at the condenser's pressure (discharge pressure) and the actual liquid line temperature.

Formula:

Subcooling = Saturation Temperature (at Discharge Pressure) - Liquid Line Temperature

This calculation confirms that all the refrigerant vapor has condensed back into a liquid in the condenser, ensuring the expansion device receives only liquid refrigerant.

Variable Explanations

Variable Meaning Unit Typical Range (Approximate)
Suction Line Temperature Actual temperature measured on the suction line. °F (°C) Varies widely with load and ambient conditions.
Suction Pressure Pressure of the refrigerant in the low-pressure side (evaporator/suction line). PSIG (kPa gauge) Typically 50-80 PSIG for R-410A in cooling.
Saturation Temperature (Suction) The boiling/condensing temperature of the refrigerant at a given pressure. °F (°C) Derived from pressure-temperature chart/data for the specific refrigerant.
Liquid Line Temperature Actual temperature measured on the liquid line leaving the condenser. °F (°C) Varies widely with load and ambient conditions.
Discharge Pressure Pressure of the refrigerant in the high-pressure side (condenser/discharge line). PSIG (kPa gauge) Typically 200-300 PSIG for R-410A in cooling.
Saturation Temperature (Discharge) The condensing temperature of the refrigerant at a given pressure. °F (°C) Derived from pressure-temperature chart/data for the specific refrigerant.
Superheat Amount the vapor temperature is above its saturation temperature. °F (°C) Typically 10-20°F for residential AC.
Subcooling Amount the liquid temperature is below its saturation temperature. °F (°C) Typically 10-20°F for residential AC.

Practical Examples (Real-World Use Cases)

Example 1: Residential Air Conditioner – Normal Operation

A technician is servicing a home's central air conditioner using R-410A refrigerant. The system is running in cooling mode.

  • Inputs:
    • Refrigerant Type: R-410A
    • Suction Pressure: 72 PSIG
    • Suction Line Temp: 52°F
    • Liquid Line Temp: 98°F
    • Discharge Pressure: 260 PSIG
  • Calculation:
    • Saturation Temp (Suction for R-410A @ 72 PSIG): Approx. 40°F
    • Saturation Temp (Discharge for R-410A @ 260 PSIG): Approx. 110°F
    • Superheat: 52°F – 40°F = 12°F
    • Subcooling: 110°F – 98°F = 12°F
  • Results: Superheat = 12°F, Subcooling = 12°F.
  • Interpretation: These values are within the typical target range for a residential R-410A system, indicating that the refrigerant charge is likely correct, airflow is adequate, and the system is operating efficiently.

Example 2: Commercial Refrigeration Unit – Low Refrigerant Charge

A service call is made for a walk-in freezer that is not cooling properly. The technician suspects a low refrigerant charge.

  • Inputs:
    • Refrigerant Type: R-404A
    • Suction Pressure: 10 PSIG
    • Suction Line Temp: 15°F
    • Liquid Line Temp: 60°F
    • Discharge Pressure: 180 PSIG
  • Calculation:
    • Saturation Temp (Suction for R-404A @ 10 PSIG): Approx. -8°F
    • Saturation Temp (Discharge for R-404A @ 180 PSIG): Approx. 45°F
    • Superheat: 15°F – (-8°F) = 23°F
    • Subcooling: 45°F – 60°F = -15°F (This indicates subcooling cannot be calculated as temp is higher than saturation)
  • Results: Superheat = 23°F, Subcooling = N/A (or negative, indicating no subcooling).
  • Interpretation: The high superheat (23°F) suggests that not all the refrigerant is boiling off in the evaporator, which might seem counterintuitive. However, combined with the lack of subcooling (liquid line temperature is higher than the condensing saturation temperature), it strongly indicates a low refrigerant charge. There isn't enough refrigerant to fully condense in the condenser (zero subcooling) and is boiling off too early in the evaporator (high superheat). The system needs a leak check and recharge.

How to Use This Superheat and Subcooling Calculator

Our superheat and subcooling calculator is designed for ease of use, providing quick insights into your HVAC system's performance. Follow these simple steps:

  1. Select Refrigerant Type: Choose the specific refrigerant your system uses from the dropdown menu. This is crucial as saturation temperatures vary significantly between different refrigerants.
  2. Measure Pressures: Using appropriate gauges, measure the suction pressure (low side) and discharge pressure (high side) at the service ports. Enter these values in PSIG (pounds per square inch gauge).
  3. Measure Temperatures: Use a reliable thermometer (digital clamp-on thermometers are ideal) to measure:
    • Suction Line Temperature: Typically taken 6 inches downstream from the evaporator outlet.
    • Liquid Line Temperature: Typically taken 6 inches downstream from the condenser outlet.
    Enter these temperatures in Fahrenheit (°F).
  4. Click Calculate: Press the "Calculate" button.

How to Read Results:

  • Saturation Temperatures: The calculator first determines the theoretical boiling (suction) and condensing (discharge) temperatures based on the measured pressures and selected refrigerant.
  • Superheat: This is the difference between the actual suction line temperature and its corresponding saturation temperature. A target range (e.g., 10-20°F for many residential systems) indicates proper evaporator function and refrigerant vaporization. Too low suggests possible liquid floodback; too high suggests potential undercharge or airflow issues.
  • Subcooling: This is the difference between the discharge saturation temperature and the actual liquid line temperature. A target range (e.g., 10-20°F) suggests the refrigerant is fully condensing. Too low (or negative) suggests an undercharge or overcharge issue leading to insufficient condensation; too high might indicate restricted airflow or overcharge.

Decision-Making Guidance:

Use the calculated superheat and subcooling values, along with manufacturer specifications for the specific equipment, to diagnose system issues. For example:

  • Low Superheat, Normal Subcooling: Might indicate high refrigerant charge.
  • High Superheat, Normal Subcooling: Might indicate low refrigerant charge or low airflow over the evaporator.
  • Normal Superheat, Low Subcooling: Might indicate low refrigerant charge or high airflow over the condenser.
  • Low Superheat, Low Subcooling: Often indicates a significant overcharge.
  • High Superheat, High Subcooling: Can indicate low airflow over the evaporator and low airflow over the condenser, possibly due to dirty coils or fan issues.

Always refer to the specific equipment manufacturer's installation and service manual for precise operating parameters.

Key Factors That Affect Superheat and Subcooling Results

Several environmental and operational factors can influence the measured superheat and subcooling values, making it essential to consider them during analysis.

  1. Refrigerant Charge Level: This is arguably the most significant factor. An undercharged system typically results in high superheat and low (or no) subcooling. An overcharged system can lead to low superheat and high subcooling. Proper refrigerant recovery and charging are critical.
  2. Airflow (Evaporator & Condenser): Insufficient airflow across the evaporator coil (due to dirty filters, blocked vents, or slow fan) reduces heat absorption, leading to higher suction temperatures and thus higher superheat. Similarly, restricted airflow over the condenser coil (dirty coils, blocked fan) hinders heat rejection, causing higher discharge pressures and saturation temperatures, which can affect subcooling.
  3. System Load: The amount of heat the system is trying to remove (cooling load) directly impacts pressures and temperatures. On very hot days or with high internal heat loads, pressures will be higher, affecting both superheat and subcooling targets. Performance testing should ideally occur under normal operating conditions.
  4. Ambient Temperature: The outdoor temperature significantly affects the condenser's ability to reject heat. Higher ambient temperatures lead to higher discharge pressures and saturation temperatures, impacting subcooling calculations.
  5. Component Efficiency & Condition: The performance of the compressor, metering device (TXV or piston), evaporator, and condenser coils all play a role. A failing compressor, a restricted expansion valve, or dirty/damaged coils will alter the system's thermodynamics and affect readings. Regular HVAC maintenance is key.
  6. Metering Device Operation: The expansion device (like a TXV – Thermostatic Expansion Valve) is designed to regulate refrigerant flow based on superheat. If it's malfunctioning (e.g., stuck open or closed, sensing bulb issue), it will directly impact superheat and subcooling readings.
  7. System Leaks: Refrigerant leaks are a primary cause of undercharging, leading to the characteristic high superheat and low subcooling issues. Prompt leak detection and repair are vital for system longevity and efficiency.

Frequently Asked Questions (FAQ)

Q1: What is the ideal superheat and subcooling value?

A: There isn't one single ideal value. The target range varies significantly by manufacturer, system type (AC, heat pump, refrigerator), refrigerant, and operating conditions (load, ambient temperature). Typically, for residential AC systems, technicians aim for superheat between 10-20°F and subcooling between 10-20°F, but always consult the equipment's service manual.

Q2: Can I calculate superheat and subcooling in heating mode?

A: Yes, but the process is different for heat pumps. In heating mode, the indoor coil becomes the condenser and the outdoor coil becomes the evaporator. Superheat is measured at the *outdoor* unit's suction line, and subcooling is measured at the *indoor* unit's liquid line. The target values and interpretation also differ.

Q3: What does it mean if my subcooling is negative?

A: Negative subcooling means the liquid line temperature is *higher* than the saturation temperature at the discharge pressure. This typically indicates a lack of subcooling, often caused by an overcharged system, a non-condensable, or severe issues with the condenser's ability to reject heat (e.g., extremely dirty coil or fan failure).

Q4: How do I interpret high superheat and low subcooling together?

A: This combination is a classic symptom of a low refrigerant charge. There isn't enough refrigerant to satisfy the system's demand, leading to excessive vaporization (high superheat) and incomplete condensation (low/no subcooling).

Q5: What if my superheat is too low?

A: Low superheat (approaching 0°F) means the refrigerant is not fully vaporizing in the evaporator. This can lead to liquid refrigerant returning to the compressor ("liquid floodback"), which can damage the compressor seals and internal components. It might indicate an overcharge, a restriction in the system before the evaporator, or high evaporator airflow.

Q6: Does system size affect the target superheat/subcooling?

A: While the fundamental principles remain the same, the target values might be adjusted by manufacturers based on system size and design. Larger commercial systems or specialized equipment might have different recommended ranges than standard residential units.

Q7: Why is precise measurement important for this calculator?

A: The calculations are highly sensitive to accurate pressure and temperature readings. Small errors in measurement can lead to significantly incorrect superheat and subcooling values, resulting in misdiagnosis and improper service actions. Using calibrated tools is essential.

Q8: Can this calculator be used for R-22 systems?

A: Yes, as long as you select R-22 as the refrigerant type. However, keep in mind that R-22 is being phased out due to environmental regulations, and most new installations use alternative refrigerants like R-410A.

Related Tools and Internal Resources

© 2023 Your Company Name. All rights reserved.

// Refrigerant data: Saturation temps based on pressure (PSIG) // Data simplified for common ranges. For exact values, refer to refrigerant PT charts. var refrigerantData = { "R-410A": { "name": "R-410A", "saturationTemps": { // temp_F: psig 30: 21.8, 35: 27.3, 40: 33.1, 45: 39.2, 50: 45.7, 55: 52.5, 60: 59.7, 65: 67.3, 70: 75.3, 75: 83.7, 80: 92.5, 85: 101.7, 90: 111.3, 95: 121.3, 100: 131.7, 105: 142.5, 110: 153.7, 115: 165.3, 120: 177.3, 125: 189.7, 130: 202.5, 200: 134.8, 210: 147.6, 220: 160.9, 230: 174.7, 240: 189.0, 250: 203.8, 260: 219.1, 270: 234.9, 280: 251.2, 290: 268.0, 300: 285.3 } }, "R-22": { "name": "R-22", "saturationTemps": { // temp_F: psig 0: -28.7, 5: -23.6, 10: -18.6, 15: -13.7, 20: -8.9, 25: -4.2, 30: 0.4, 35: 4.9, 40: 9.4, 45: 14.0, 50: 18.6, 55: 23.3, 60: 28.1, 65: 33.0, 70: 37.9, 75: 42.9, 80: 48.0, 85: 53.2, 90: 58.4, 95: 63.8, 100: 69.2, 150: 105.5, 160: 115.9, 170: 126.8, 180: 138.1, 190: 150.0, 200: 162.3, 210: 175.1, 220: 188.3, 230: 201.9, 240: 215.9, 250: 230.4 } }, "R-134a": { "name": "R-134a", "saturationTemps": { // temp_F: psig 0: -11.3, 5: -6.6, 10: -2.0, 15: 2.5, 20: 7.0, 25: 11.4, 30: 15.9, 35: 20.4, 40: 24.9, 45: 29.5, 50: 34.1, 55: 38.8, 60: 43.5, 65: 48.3, 70: 53.1, 75: 58.0, 80: 62.9, 85: 67.9, 90: 73.0, 95: 78.1, 100: 83.3, 150: 128.3, 160: 139.4, 170: 150.9, 180: 162.8, 190: 175.0, 200: 187.7, 210: 200.7, 220: 214.1, 230: 227.9, 240: 242.1, 250: 256.7 } }, "R-404A": { "name": "R-404A", "saturationTemps": { // temp_F: psig -20: -11.0, -10: -2.5, 0: 6.5, 10: 15.8, 20: 25.8, 30: 36.5, 40: 47.9, 50: 60.1, 60: 73.0, 70: 86.8, 80: 101.3, 90: 116.7, 100: 132.9, 110: 149.9, 120: 167.7, 130: 186.4, 140: 205.9, 150: 226.3, 160: 247.6, 170: 270.0, 180: 293.2, 190: 317.4, 200: 342.5 } } }; var chart = null; var chartCtx = null; function getSaturationTemp(pressure, refrigerantType) { var data = refrigerantData[refrigerantType]; if (!data) return null; var temps = Object.keys(data.saturationTemps).map(Number).sort(function(a, b){ return a – b; }); var psig = parseFloat(pressure); if (isNaN(psig)) return null; // Find the closest higher pressure and its temp var closestHigherTemp = null; for (var i = 0; i = psig) { closestHigherTemp = temps[i]; break; } } if (closestHigherTemp !== null) { return data.saturationTemps[closestHigherTemp]; } // If pressure is higher than any value in the table, use the last one return data.saturationTemps[temps[temps.length – 1]]; } function validateInput(id, minValue, maxValue) { var input = document.getElementById(id); var errorElement = document.getElementById(id + "Error"); var value = parseFloat(input.value); if (isNaN(value) || value <= 0) { errorElement.style.display = 'block'; input.style.borderColor = '#dc3545'; return false; } else if (minValue !== null && value maxValue) { errorElement.textContent = "Value cannot be greater than " + maxValue + "."; errorElement.style.display = 'block'; input.style.borderColor = '#dc3545'; return false; } else { errorElement.style.display = 'none'; input.style.borderColor = '#ced4da'; return true; } } function performCalculation() { var inputsValid = true; inputsValid &= validateInput("suctionPressure", null, null); inputsValid &= validateInput("suctionTemp", null, null); inputsValid &= validateInput("liquidLineTemp", null, null); inputsValid &= validateInput("dischargePressure", null, null); if (!inputsValid) { document.getElementById("result").style.display = 'none'; document.getElementById("intermediateResultsContainer").style.display = 'none'; return; } var refrigerantType = document.getElementById("refrigerantType").value; var suctionPressure = parseFloat(document.getElementById("suctionPressure").value); var suctionTemp = parseFloat(document.getElementById("suctionTemp").value); var liquidLineTemp = parseFloat(document.getElementById("liquidLineTemp").value); var dischargePressure = parseFloat(document.getElementById("dischargePressure").value); var saturationTempSuction = getSaturationTemp(suctionPressure, refrigerantType); var saturationTempDischarge = getSaturationTemp(dischargePressure, refrigerantType); if (saturationTempSuction === null || saturationTempDischarge === null) { document.getElementById("result").style.display = 'none'; document.getElementById("intermediateResultsContainer").style.display = 'none'; alert("Could not retrieve saturation temperatures for the selected refrigerant and pressures. Please check your inputs."); return; } var calculatedSuperheat = suctionTemp – saturationTempSuction; var calculatedSubcooling = saturationTempDischarge – liquidLineTemp; document.getElementById("saturationTempSuction").textContent = saturationTempSuction.toFixed(1); document.getElementById("saturationTempDischarge").textContent = saturationTempDischarge.toFixed(1); document.getElementById("calculatedSuperheat").textContent = calculatedSuperheat.toFixed(1); document.getElementById("calculatedSubcooling").textContent = calculatedSubcooling.toFixed(1); var analysis = ""; if (calculatedSuperheat 20) analysis += "High Superheat: Potential low charge or airflow issue. "; else analysis += "Superheat: Normal range. "; if (calculatedSubcooling 20) analysis += "High Subcooling: Potential overcharge or condenser restriction. "; else analysis += "Subcooling: Normal range. "; var mainResultText = "Superheat: " + calculatedSuperheat.toFixed(1) + "°F | Subcooling: " + calculatedSubcooling.toFixed(1) + "°F"; document.getElementById("result").textContent = mainResultText; document.getElementById("result").style.display = 'block'; document.getElementById("intermediateResultsContainer").style.display = 'block'; updateChartData(); return { superheat: calculatedSuperheat.toFixed(1), subcooling: calculatedSubcooling.toFixed(1), saturationSuction: saturationTempSuction.toFixed(1), saturationDischarge: saturationTempDischarge.toFixed(1), analysis: analysis.trim() }; } function calculateValues() { // Update chart data in real-time updateChartData(); // Optionally, you can trigger calculation visually without button press // performCalculation(); } function resetCalculator() { document.getElementById("suctionPressure").value = "70"; document.getElementById("suctionTemp").value = "50"; document.getElementById("liquidLineTemp").value = "95"; document.getElementById("dischargePressure").value = "250"; document.getElementById("refrigerantType").value = "R-410A"; // Clear error messages var errorElements = document.querySelectorAll('.error-message'); for (var i = 0; i < errorElements.length; i++) { errorElements[i].style.display = 'none'; } // Reset input borders var inputs = document.querySelectorAll('.loan-calc-container input'); for (var i = 0; i < inputs.length; i++) { inputs[i].style.borderColor = '#ced4da'; } document.getElementById("result").style.display = 'none'; document.getElementById("intermediateResultsContainer").style.display = 'none'; performCalculation(); // Recalculate with default values } function copyResults() { var resultDiv = document.getElementById("result"); var intermediateResultsContainer = document.getElementById("intermediateResultsContainer"); if (resultDiv.style.display === 'none' || intermediateResultsContainer.style.display === 'none') { alert("Please calculate the results first."); return; } var mainResult = resultDiv.innerText; var intermediateData = intermediateResultsContainer.innerText.replace('Intermediate Values & Analysis', ''); // Remove header for clean copy var copyText = "HVAC Performance Results:\n\n" + mainResult + "\n\n" + intermediateData + "\n\nAssumptions:\n"; copyText += "- Refrigerant Type: " + document.getElementById("refrigerantType").value + "\n"; copyText += "- Suction Pressure: " + document.getElementById("suctionPressure").value + " PSIG\n"; copyText += "- Suction Line Temp: " + document.getElementById("suctionTemp").value + " °F\n"; copyText += "- Liquid Line Temp: " + document.getElementById("liquidLineTemp").value + " °F\n"; copyText += "- Discharge Pressure: " + document.getElementById("dischargePressure").value + " PSIG\n"; navigator.clipboard.writeText(copyText).then(function() { alert("Results copied to clipboard!"); }, function(err) { console.error('Async: Could not copy text: ', err); prompt("Copy these values manually:", copyText); }); } // Charting Logic function initChart() { chartCtx = document.getElementById("performanceChart").getContext("2d"); chart = new Chart(chartCtx, { type: 'scatter', // Use scatter for plotting specific points data: { datasets: [{ label: 'Suction Line Measurement', data: [], // Will be populated by updateChartData backgroundColor: 'rgba(255, 99, 132, 0.8)', // Reddish borderColor: 'rgba(255, 99, 132, 1)', borderWidth: 1, pointRadius: 6, pointHoverRadius: 9, showLine: false // We are plotting individual points }, { label: 'Liquid Line Measurement', data: [], // Will be populated by updateChartData backgroundColor: 'rgba(54, 162, 235, 0.8)', // Bluish borderColor: 'rgba(54, 162, 235, 1)', borderWidth: 1, pointRadius: 6, pointHoverRadius: 9, showLine: false }, { label: 'Saturation Temp (Suction)', data: [], // Will be populated by updateChartData backgroundColor: 'rgba(255, 206, 86, 0.6)', // Yellowish borderColor: 'rgba(255, 206, 86, 1)', borderWidth: 1, pointRadius: 5, pointHoverRadius: 8, showLine: false }, { label: 'Saturation Temp (Discharge)', data: [], // Will be populated by updateChartData backgroundColor: 'rgba(75, 192, 192, 0.6)', // Greenish borderColor: 'rgba(75, 192, 192, 1)', borderWidth: 1, pointRadius: 5, pointHoverRadius: 8, showLine: false }] }, options: { responsive: true, maintainAspectRatio: false, // Allow custom height/width scales: { x: { // Pressure Axis type: 'linear', position: 'bottom', title: { display: true, text: 'Pressure (PSIG)' }, ticks: { callback: function(value, index, values) { // Custom tick formatting if needed, here just show value return value; } } }, y: { // Temperature Axis type: 'linear', title: { display: true, text: 'Temperature (°F)' }, ticks: { callback: function(value, index, values) { // Custom tick formatting if needed return value + '°F'; } } } }, plugins: { tooltip: { callbacks: { label: function(context) { var label = context.dataset.label || ''; if (label) { label += ': '; } if (context.parsed.x !== null) { label += 'Pressure: ' + context.parsed.x.toFixed(1) + ' PSIG, '; } if (context.parsed.y !== null) { label += 'Temp: ' + context.parsed.y.toFixed(1) + ' °F'; } return label; } } }, legend: { position: 'top', } } } }); } function updateChartData() { if (!chart) initChart(); var refrigerantType = document.getElementById("refrigerantType").value; var suctionPressure = parseFloat(document.getElementById("suctionPressure").value); var suctionTemp = parseFloat(document.getElementById("suctionTemp").value); var liquidLineTemp = parseFloat(document.getElementById("liquidLineTemp").value); var dischargePressure = parseFloat(document.getElementById("dischargePressure").value); var saturationTempSuction = getSaturationTemp(suctionPressure, refrigerantType); var saturationTempDischarge = getSaturationTemp(dischargePressure, refrigerantType); // Clear previous data chart.data.datasets[0].data = []; // Suction Line Measurement chart.data.datasets[1].data = []; // Liquid Line Measurement chart.data.datasets[2].data = []; // Saturation Temp Suction chart.data.datasets[3].data = []; // Saturation Temp Discharge // Add valid data points if (!isNaN(suctionPressure) && !isNaN(suctionTemp)) { chart.data.datasets[0].data.push({ x: suctionPressure, y: suctionTemp }); } if (!isNaN(liquidLineTemp)) { // Assuming liquid line temp is measured at the component/line, not tied to a specific pressure reading on the chart directly in this scatter plot context for simplicity // For simplicity in this scatter plot, we'll plot liquid line temp against discharge pressure, though typically it's just a point. // A more complex chart might show this differently. Here, we plot it against discharge pressure for relation. if (!isNaN(dischargePressure)) { chart.data.datasets[1].data.push({ x: dischargePressure, y: liquidLineTemp }); } } if (saturationTempSuction !== null && !isNaN(suctionPressure)) { chart.data.datasets[2].data.push({ x: suctionPressure, y: saturationTempSuction }); } if (saturationTempDischarge !== null && !isNaN(dischargePressure)) { chart.data.datasets[3].data.push({ x: dischargePressure, y: saturationTempDischarge }); } chart.update(); } // Initialize chart on load window.onload = function() { initChart(); // Perform initial calculation with default values performCalculation(); }; // Add event listener for Enter key to trigger calculation document.addEventListener('keypress', function(e) { if (e.key === 'Enter' && document.activeElement.id !== 'copyResultsBtn') { e.preventDefault(); // Prevent default form submission behavior performCalculation(); } }); // Need to include Chart.js library for the canvas chart // This code assumes Chart.js is available globally. // In a real WordPress environment, you'd enqueue this script. // For a self-contained HTML file, you'd typically embed it like this: // // Since this is a direct output, I cannot include external scripts. // Therefore, this script will NOT run without Chart.js being loaded separately. // *** IMPORTANT NOTE FOR EXECUTION *** // The Chart.js library needs to be included in your HTML file for the canvas chart to work. // Add this line within the or before the closing tag: //

Leave a Comment