#chem-calc-container h2 { color: #2c3e50; text-align: center; margin-bottom: 25px; border-bottom: 2px solid #3498db; padding-bottom: 10px; }
#chem-calc-container .input-group { margin-bottom: 20px; }
#chem-calc-container label { display: block; font-weight: 600; margin-bottom: 8px; color: #34495e; }
#chem-calc-container input[type="number"] { width: 100%; padding: 12px; border: 2px solid #bdc3c7; border-radius: 5px; box-sizing: border-box; font-size: 16px; }
#chem-calc-container input:focus { border-color: #3498db; outline: none; }
#chem-calc-container .calc-btn { width: 100%; background-color: #3498db; color: white; padding: 15px; border: none; border-radius: 5px; font-size: 18px; font-weight: bold; cursor: pointer; transition: background-color 0.3s; margin-top: 10px; }
#chem-calc-container .calc-btn:hover { background-color: #2980b9; }
#chem-calc-container #chem-result { margin-top: 25px; padding: 20px; border-radius: 5px; background-color: #f8f9fa; border-left: 5px solid #3498db; display: none; }
#chem-calc-container .result-val { font-weight: bold; color: #e67e22; font-size: 1.2em; }
#chem-calc-container .formula-display { background: #eee; padding: 10px; border-radius: 4px; font-family: 'Courier New', Courier, monospace; margin: 10px 0; font-size: 0.9em; }
#chem-calc-container .grid-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 600px) { #chem-calc-container .grid-layout { grid-template-columns: 1fr; } }
function calculateStoichiometry() {
var mK = parseFloat(document.getElementById("massKnown").value);
var mmK = parseFloat(document.getElementById("molarMassKnown").value);
var cK = parseFloat(document.getElementById("coeffKnown").value);
var cT = parseFloat(document.getElementById("coeffTarget").value);
var mmT = parseFloat(document.getElementById("molarMassTarget").value);
var resultDiv = document.getElementById("chem-result");
if (isNaN(mK) || isNaN(mmK) || isNaN(cK) || isNaN(cT) || isNaN(mmT) || mmK <= 0 || cK <= 0 || cT <= 0 || mmT <= 0) {
alert("Please enter valid positive numerical values for all fields.");
resultDiv.style.display = "none";
return;
}
// Step 1: Moles of Known
var molesKnown = mK / mmK;
// Step 2: Molar Ratio (Moles of Target)
var molesTarget = (molesKnown * cT) / cK;
// Step 3: Mass of Target
var massTarget = molesTarget * mmT;
// Display Results
document.getElementById("resMolesKnown").innerText = molesKnown.toFixed(4);
document.getElementById("resMolesTarget").innerText = molesTarget.toFixed(4);
document.getElementById("resMassTarget").innerText = massTarget.toFixed(4);
document.getElementById("logicSummary").innerHTML = "Path: " + mK + "g ÷ " + mmK + "g/mol × (" + cT + "/" + cK + ") × " + mmT + "g/mol = " + massTarget.toFixed(4) + "g";
resultDiv.style.display = "block";
resultDiv.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
}
Stoichiometry & Equation Calculator
Calculation Results:
Moles of Known Substance: 0 mol
Moles of Target Substance: 0 mol
Theoretical Yield of Target: 0 grams
How to Use the Chemistry Equation Calculator
This stoichiometry calculator helps you determine the amount of a target product or reactant needed based on a balanced chemical equation. To get accurate results, you must first have your chemical equation balanced to find the stoichiometric coefficients.
Step-by-Step Calculation Guide:
- Balance the Equation: For example, in 2H₂ + O₂ → 2H₂O, the coefficient for H₂ is 2 and O₂ is 1.
- Find Molar Masses: Use a periodic table to sum the atomic masses (e.g., H₂O = 1.008*2 + 15.999 = 18.015 g/mol).
- Input Your Mass: Enter the weight in grams of the substance you are starting with.
- Ratio Conversion: The calculator uses the molar ratio (Target Coefficient / Known Coefficient) to bridge the gap between substances.
The Math Behind Stoichiometry
The calculation follows the standard "Mass-to-Mass" pathway in chemistry:
Mass(A) ÷ Molar Mass(A) × (Coefficient B / Coefficient A) × Molar Mass(B) = Mass(B)
Practical Example: Combustion of Methane
If you have 16 grams of Methane (CH₄) and want to find how much Oxygen (O₂) is required for complete combustion:
- Equation: CH₄ + 2O₂ → CO₂ + 2H₂O
- Mass of Known: 16g
- Molar Mass CH₄: 16.04 g/mol
- Coefficient Known (CH₄): 1
- Coefficient Target (O₂): 2
- Molar Mass Target (O₂): 32.00 g/mol
By entering these values, the calculator will show you that 64 grams of Oxygen are required to react completely with 16 grams of Methane.