Breakpoint Chlorination Calculator
function updateStrength() {
var type = document.getElementById("productType").value;
var strengthInput = document.getElementById("strengthPct");
if (type !== "custom") {
strengthInput.value = type;
strengthInput.readOnly = true;
strengthInput.style.backgroundColor = "#eee";
} else {
strengthInput.readOnly = false;
strengthInput.style.backgroundColor = "white";
}
}
function calculateBreakpoint() {
var vol = parseFloat(document.getElementById("waterVolume").value);
var cc = parseFloat(document.getElementById("combinedChlorine").value);
var fc = parseFloat(document.getElementById("currentFree").value);
var target = parseFloat(document.getElementById("targetFree").value);
var strength = parseFloat(document.getElementById("strengthPct").value);
if (isNaN(vol) || isNaN(cc) || isNaN(fc) || isNaN(target) || isNaN(strength) || vol <= 0 || strength <= 0) {
alert("Please enter valid positive numbers for all fields.");
return;
}
// 1. Calculate the Breakpoint Threshold (10x Combined Chlorine)
var threshold = cc * 10;
// 2. Calculate the total ppm dosage needed
// Logic: We must reach the threshold first.
// If current Free Chlorine is already above 0, it contributes, but the breakpoint reaction consumes chlorine.
var dosageNeeded = threshold – fc + target;
// Ensure we don't have a negative dosage
if (dosageNeeded < 0) dosageNeeded = 0;
// 3. Convert ppm dosage to actual product weight/volume
// Rule: 1 lb of 100% chlorine in 1,000,000 lbs of water (approx 120,000 gallons) is 1 ppm.
// Standard pool formula: (Vol * 8.34 * Dosage) / (1,000,000 * (Strength/100))
var pounds100Pct = (vol * 8.34 * dosageNeeded) / 1000000;
var actualWeightLbs = pounds100Pct / (strength / 100);
// Display Results
document.getElementById("resultsArea").style.display = "block";
document.getElementById("resThreshold").innerText = threshold.toFixed(2);
document.getElementById("resDosage").innerText = dosageNeeded.toFixed(2);
var finalDisplay = "";
var altDisplay = "";
// Formatting based on product type
if (strength = 128) {
var gallons = fluidOunces / 128;
finalDisplay = gallons.toFixed(2) + " Gallons";
altDisplay = "(" + fluidOunces.toFixed(1) + " fl oz)";
} else {
finalDisplay = fluidOunces.toFixed(1) + " Fluid Ounces";
}
} else { // Likely Dry (Cal-Hypo or Trichlor)
var ounces = actualWeightLbs * 16;
if (ounces >= 32) {
finalDisplay = actualWeightLbs.toFixed(2) + " lbs";
altDisplay = "(" + ounces.toFixed(1) + " oz)";
} else {
finalDisplay = ounces.toFixed(1) + " Ounces";
}
}
document.getElementById("resFinalAmount").innerText = finalDisplay;
document.getElementById("resFinalAmountAlt").innerText = altDisplay;
// Scroll to results
document.getElementById("resultsArea").scrollIntoView({ behavior: 'smooth', block: 'nearest' });
}
// Initialize readOnly state
updateStrength();