Spaces:
Sleeping
Sleeping
File size: 8,142 Bytes
2737675 bf9b840 2737675 bf9b840 2737675 93a28dc 1c86ac2 bf9b840 1c86ac2 bf9b840 1c86ac2 bf9b840 1c86ac2 bf9b840 1c86ac2 bf9b840 1c86ac2 93a28dc 1c86ac2 2737675 93a28dc 2737675 93a28dc 1c86ac2 93a28dc 3eae11a 95a95fd 3eae11a 95a95fd 3eae11a 95a95fd 3eae11a 95a95fd 3eae11a 95a95fd 3eae11a 95a95fd 3eae11a 95a95fd 3eae11a 95a95fd 3eae11a 95a95fd 3eae11a 95a95fd 3eae11a 95a95fd 93a28dc 2737675 93a28dc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
<!DOCTYPE html>
<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: 100px; }
button { padding: 8px 12px; cursor: pointer; margin-top: 10px; }
.result { margin-top: 20px; }
.fertilizer-group { margin-bottom: 15px; display: flex; align-items: center; }
.fertilizer-group label { margin-right: 10px; }
.fertilizer-group input { margin-right: 20px; }
</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">
<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">
<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">
<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">
<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">
<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() {
// Функция для безопасного получения числового значения
function getValue(id) {
const value = parseFloat(document.getElementById(id).value);
return isNaN(value) ? 0 : value;
}
// Состав удобрений (% → доли)
const caContentCa = getValue("ca_content_ca") / 100;
const caContentN = getValue("ca_content_n") / 100;
const kh2po4ContentP = getValue("kh2po4_content_p") / 100;
const kh2po4ContentK = getValue("kh2po4_content_k") / 100;
const kno3ContentK = getValue("kno3_content_k") / 100;
const kno3ContentN = getValue("kno3_content_n") / 100;
const mgso4ContentMg = getValue("mgso4_content_mg") / 100;
const mgso4ContentS = getValue("mgso4_content_s") / 100;
const k2so4ContentK = getValue("k2so4_content_k") / 100;
const k2so4ContentS = getValue("k2so4_content_s") / 100;
const nh4no3ContentN = getValue("nh4no3_content_n") / 100;
// Требуемые концентрации (мг/л)
const ca = getValue("ca");
const p = getValue("p");
const k = getValue("k");
const mg = getValue("mg");
const s = getValue("s");
const nitrogen = getValue("nitrogen");
const nRatio = getValue("n_ratio") / 10;
// Проверка ввода
if ([ca, p, k, mg, s, nitrogen].some(v => isNaN(v))) {
document.getElementById("result").innerHTML = "Введите все значения!";
return;
}
// Расчёт
let kh2po4 = p / kh2po4ContentP;
let kFromKH2PO4 = kh2po4 * kh2po4ContentK;
let caNO3FromCa = ca / caContentCa;
let nFromCaNO3Min = caNO3FromCa * caContentN;
let nFromNH4NO3 = nitrogen * nRatio;
let nh4no3 = nFromNH4NO3 / nh4no3ContentN;
let mgso4 = s / mgso4ContentS;
let mgFromMgSO4 = mgso4 * mgso4ContentMg;
let sFromMgSO4 = mgso4 * mgso4ContentS;
let sRemaining = s - sFromMgSO4;
let k2so4 = sRemaining > 0 ? sRemaining / k2so4ContentS : 0;
let kFromK2SO4 = k2so4 * k2so4ContentK;
let kRemaining = k - kFromKH2PO4 - kFromK2SO4;
let kno3 = kRemaining > 0 ? kRemaining / kno3ContentK : 0;
let nFromKNO3 = kno3 * kno3ContentN;
let totalN = nFromCaNO3Min + nFromNH4NO3 + nFromKNO3;
let nDelta = nitrogen - totalN;
let caNO3Extra = 0;
if (nDelta > 0) {
caNO3Extra = nDelta / caContentN;
} else if (nDelta < 0) {
let nExcess = -nDelta;
let kno3Reduction = nExcess / kno3ContentN;
kno3 = Math.max(0, kno3 - kno3Reduction);
nFromKNO3 = kno3 * kno3ContentN;
nExcess = nitrogen - (nFromNH4NO3 + nFromKNO3 + nFromCaNO3Min);
if (nExcess > 0) {
caNO3Extra = nExcess / caContentN;
}
}
let caNO3Total = caNO3FromCa + caNO3Extra;
let totalMg = mgso4 * mgso4ContentMg;
let mgDelta = mg - totalMg;
if (mgDelta > 0) {
mgso4 += mgDelta / mgso4ContentMg;
sFromMgSO4 = mgso4 * mgso4ContentS;
}
totalN = (caNO3Total * caContentN + nh4no3 * nh4no3ContentN + kno3 * kno3ContentN).toFixed(2);
let totalP = (kh2po4 * kh2po4ContentP).toFixed(2);
let totalK = (kh2po4 * kh2po4ContentK + kno3 * kno3ContentK + k2so4 * k2so4ContentK).toFixed(2);
let totalCa = (caNO3Total * caContentCa).toFixed(2);
totalMg = (mgso4 * mgso4ContentMg).toFixed(2);
let totalS = (mgso4 * mgso4ContentS + k2so4 * k2so4ContentS).toFixed(2);
const result = `
<h3>Результат расчёта (г/1000 л):</h3>
<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>
<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>Ca(NO₃)₂·4H₂O: ${caNO3Total.toFixed(2)} (N: ${(caNO3Total * caContentN).toFixed(2)}, Ca: ${totalCa})</p>
<p>NH₄NO₃: ${nh4no3.toFixed(2)} (N: ${nFromNH4NO3.toFixed(2)})</p>
<h3>Итоговые концентрации (мг/л):</h3>
<p>N: ${totalN}, P: ${totalP}, K: ${totalK}, Ca: ${totalCa}, Mg: ${totalMg}, S: ${totalS}</p>
`;
document.getElementById("result").innerHTML = result;
}
</script>
</body>
</html> |