Spaces:
Sleeping
Sleeping
<html lang="ru"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Расчёт удобрений с азотом</title> | |
<style> | |
body { font-family: Arial, sans-serif; margin: 20px; } | |
input { padding: 8px; margin: 5px; width: 200px; } | |
button { padding: 8px 12px; cursor: pointer; margin-top: 10px; } | |
.result { margin-top: 20px; } | |
.fertilizer-group { margin-bottom: 15px; } | |
</style> | |
</head> | |
<body> | |
<h1>Расчёт удобрений для смешивания с азотом</h1> | |
<div> | |
<h3>Введите состав удобрений (%):</h3> | |
<div class="fertilizer-group"> | |
<label>Ca в Ca(NO₃)₂·4H₂O:</label> | |
<input type="number" id="ca_content_ca" value="19.3" step="0.1"><br> | |
<label>N в Ca(NO₃)₂·4H₂O:</label> | |
<input type="number" id="ca_content_n" value="14.9" step="0.1"> | |
</div> | |
<div class="fertilizer-group"> | |
<label>P в KH₂PO₄:</label> | |
<input type="number" id="kh2po4_content_p" value="21.8" step="0.1"><br> | |
<label>K в KH₂PO₄:</label> | |
<input type="number" id="kh2po4_content_k" value="27.4" step="0.1"> | |
</div> | |
<div class="fertilizer-group"> | |
<label>K в KNO₃:</label> | |
<input type="number" id="kno3_content_k" value="38" step="0.1"><br> | |
<label>N в KNO₃:</label> | |
<input type="number" id="kno3_content_n" value="13.5" step="0.1"> | |
</div> | |
<div class="fertilizer-group"> | |
<label>Mg в MgSO₄·7H₂O:</label> | |
<input type="number" id="mgso4_content_mg" value="10.14" step="0.1"><br> | |
<label>S в MgSO₄·7H₂O:</label> | |
<input type="number" id="mgso4_content_s" value="13.5" step="0.1"> | |
</div> | |
<div class="fertilizer-group"> | |
<label>K в K₂SO₄:</label> | |
<input type="number" id="k2so4_content_k" value="41.5" step="0.1"><br> | |
<label>S в K₂SO₄:</label> | |
<input type="number" id="k2so4_content_s" value="18" step="0.1"> | |
</div> | |
<div class="fertilizer-group"> | |
<label>N в NH₄NO₃:</label> | |
<input type="number" id="nh4no3_content_n" value="34" step="0.1"> | |
</div> | |
<h3>Требуемые концентрации (мг/л):</h3> | |
<label>Ca:</label><input type="number" id="ca" placeholder="50" step="0.1"><br> | |
<label>P:</label><input type="number" id="p" placeholder="50" step="0.1"><br> | |
<label>K:</label><input type="number" id="k" placeholder="100" step="0.1"><br> | |
<label>Mg:</label><input type="number" id="mg" placeholder="25" step="0.1"><br> | |
<label>S:</label><input type="number" id="s" placeholder="20" step="0.1"><br> | |
<label>N:</label><input type="number" id="nitrogen" value="50" step="0.1"><br> | |
<h3>Соотношение N (NH₄NO₃):</h3> | |
<label>NH₄NO₃ (0-1):</label> | |
<input type="range" id="n_ratio" min="0" max="10" value="5"> | |
<span id="n_ratio_value">0.5</span><br> | |
<button onclick="calculate()">Рассчитать</button> | |
</div> | |
<div class="result" id="result"></div> | |
<script> | |
document.getElementById('n_ratio').addEventListener('input', function() { | |
const ratio = (this.value / 10).toFixed(1); | |
document.getElementById('n_ratio_value').textContent = ratio; | |
}); | |
function calculate() { | |
// Состав удобрений (% → доли) | |
const caContentCa = parseFloat(document.getElementById("ca_content_ca").value) / 100; | |
const caContentN = parseFloat(document.getElementById("ca_content_n").value) / 100; | |
const kh2po4ContentP = parseFloat(document.getElementById("kh2po4_content_p").value) / 100; | |
const kh2po4ContentK = parseFloat(document.getElementById("kh2po4_content_k").value) / 100; | |
const kno3ContentK = parseFloat(document.getElementById("kno3_content_k").value) / 100; | |
const kno3ContentN = parseFloat(document.getElementById("kno3_content_n").value) / 100; | |
const mgso4ContentMg = parseFloat(document.getElementById("mgso4_content_mg").value) / 100; | |
const mgso4ContentS = parseFloat(document.getElementById("mgso4_content_s").value) / 100; | |
const k2so4ContentK = parseFloat(document.getElementById("k2so4_content_k").value) / 100; | |
const k2so4ContentS = parseFloat(document.getElementById("k2so4_content_s").value) / 100; | |
const nh4no3ContentN = parseFloat(document.getElementById("nh4no3_content_n").value) / 100; | |
// Требуемые концентрации (мг/л) | |
const ca = parseFloat(document.getElementById("ca").value) || 0; | |
const p = parseFloat(document.getElementById("p").value) || 0; | |
const k = parseFloat(document.getElementById("k").value) || 0; | |
const mg = parseFloat(document.getElementById("mg").value) || 0; | |
const s = parseFloat(document.getElementById("s").value) || 0; | |
const nitrogen = parseFloat(document.getElementById("nitrogen").value) || 0; | |
const nRatio = parseFloat(document.getElementById("n_ratio").value) / 10; | |
// Проверка ввода | |
if ([ca, p, k, mg, s, nitrogen].some(v => isNaN(v))) { | |
document.getElementById("result").innerHTML = "Введите все значения!"; | |
return; | |
} | |
// Расчёт массы удобрений (г/1000 л) | |
// 1. MgSO₄·7H₂O от Mg | |
const mgso4 = mg / mgso4ContentMg; | |
const sFromMgSO4 = mgso4 * mgso4ContentS; | |
// 2. K₂SO₄ от остатка S | |
const sRemaining = s - sFromMgSO4; | |
const k2so4 = sRemaining > 0 ? sRemaining / k2so4ContentS : 0; | |
const kFromK2SO4 = k2so4 * k2so4ContentK; | |
// 3. KH₂PO₄ от P | |
const kh2po4 = p / kh2po4ContentP; | |
const kFromKH2PO4 = kh2po4 * kh2po4ContentK; | |
// 4. KNO₃ от остатка K | |
const kRemaining = k - kFromKH2PO4 - kFromK2SO4; | |
const kno3 = kRemaining > 0 ? kRemaining / kno3ContentK : 0; | |
const nFromKNO3 = kno3 * kno3ContentN; | |
// 5. Ca(NO₃)₂·4H₂O от Ca | |
const caNO3FromCa = ca / caContentCa; | |
const nFromCaNO3Min = caNO3FromCa * caContentN; | |
// 6. NH₄NO₃ и дополнительный Ca(NO₃)₂ для N | |
const nRemaining = nitrogen - nFromKNO3 - nFromCaNO3Min; | |
const nFromNH4NO3 = nRemaining * nRatio; | |
const nFromCaNO3Extra = nRemaining * (1 - nRatio); | |
const nh4no3 = nFromNH4NO3 > 0 ? nFromNH4NO3 / nh4no3ContentN : 0; | |
const caNO3Extra = nFromCaNO3Extra > 0 ? nFromCaNO3Extra / caContentN : 0; | |
const caNO3Total = caNO3FromCa + caNO3Extra; | |
// Итоговые концентрации для проверки | |
const totalN = (caNO3Total * caContentN + nh4no3 * nh4no3ContentN + kno3 * kno3ContentN).toFixed(2); | |
const totalP = (kh2po4 * kh2po4ContentP).toFixed(2); | |
const totalK = (kh2po4 * kh2po4ContentK + kno3 * kno3ContentK + k2so4 * k2so4ContentK).toFixed(2); | |
const totalCa = (caNO3Total * caContentCa).toFixed(2); | |
const totalMg = (mgso4 * mgso4ContentMg).toFixed(2); | |
const totalS = (mgso4 * mgso4ContentS + k2so4 * k2so4ContentS).toFixed(2); | |
// Вывод результата | |
const resultText = ` | |
<h3>Необходимые удобрения (г/1000 л):</h3> | |
<p>Ca(NO₃)₂·4H₂O: ${caNO3Total.toFixed(2)} (N: ${(caNO3Total * caContentN).toFixed(2)}, Ca: ${totalCa})</p> | |
<p>NH₄NO₃: ${nh4no3.toFixed(2)} (N: ${(nh4no3 * nh4no3ContentN).toFixed(2)})</p> | |
<p>KH₂PO₄: ${kh2po4.toFixed(2)} (P: ${totalP}, K: ${kFromKH2PO4.toFixed(2)})</p> | |
<p>KNO₃: ${kno3.toFixed(2)} (N: ${nFromKNO3.toFixed(2)}, K: ${(kno3 * kno3ContentK).toFixed(2)})</p> | |
<p>MgSO₄·7H₂O: ${mgso4.toFixed(2)} (Mg: ${totalMg}, S: ${sFromMgSO4.toFixed(2)})</p> | |
<p>K₂SO₄: ${k2so4.toFixed(2)} (K: ${kFromK2SO4.toFixed(2)}, S: ${(k2so4 * k2so4ContentS).toFixed(2)})</p> | |
<h3>Итоговые концентрации (мг/л):</h3> | |
<p>N: ${totalN}, P: ${totalP}, K: ${totalK}, Ca: ${totalCa}, Mg: ${totalMg}, S: ${totalS}</p> | |
`; | |
document.getElementById("result").innerHTML = resultText; | |
} | |
</script> | |
</body> | |
</html> |