Spaces:
Sleeping
Sleeping
File size: 9,730 Bytes
2737675 f2890ea 2737675 f2890ea 2737675 f2890ea 2737675 93a28dc f2890ea 73faeec f2890ea 73faeec f2890ea 2737675 93a28dc 944b3f0 f2890ea 73faeec f2890ea 73faeec f2890ea 944b3f0 f2890ea 944b3f0 f2890ea 944b3f0 45b020d f2890ea 45b020d 73faeec f2890ea 73faeec 45b020d f2890ea 45b020d f2890ea 45b020d f2890ea 45b020d 73faeec f2890ea 73faeec 45b020d 73faeec 45b020d 73faeec 45b020d f2890ea 73faeec f2890ea 45b020d f2890ea 73faeec 45b020d f2890ea 944b3f0 45b020d 73faeec 45b020d f2890ea 944b3f0 f2890ea 944b3f0 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 |
<!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: 200px; }
button { padding: 8px 12px; cursor: pointer; margin-top: 10px; }
.result { margin-top: 20px; }
</style>
</head>
<body>
<h1>Расчёт необходимого количества удобрений с учётом состава</h1>
<div>
<h3>Введите состав удобрений (%):</h3>
<label for="ca_content_ca">Ca в Ca(NO₃)₂·4H₂O:</label>
<input type="number" id="ca_content_ca" value="19" step="0.1"><br>
<label for="ca_content_n">N в Ca(NO₃)₂·4H₂O:</label>
<input type="number" id="ca_content_n" value="14.9" step="0.1"><br>
<label for="p_content">P в KH₂PO₄:</label>
<input type="number" id="p_content" value="22" step="0.1"><br>
<label for="k_content_kh2po4">K в KH₂PO₄:</label>
<input type="number" id="k_content_kh2po4" value="28" step="0.1"><br>
<label for="k_content_kno3">K в KNO₃:</label>
<input type="number" id="k_content_kno3" value="46" step="0.1"><br>
<label for="n_content_kno3">N в KNO₃:</label>
<input type="number" id="n_content_kno3" value="13.5" step="0.1"><br>
<label for="mg_content_mgso4">Mg в MgSO₄·7H₂O:</label>
<input type="number" id="mg_content_mgso4" value="16" step="0.1"><br>
<label for="s_content_mgso4">S в MgSO₄·7H₂O:</label>
<input type="number" id="s_content_mgso4" value="13.5" step="0.1"><br>
<label for="mg_content_mgno3">Mg в Mg(NO₃)₂:</label>
<input type="number" id="mg_content_mgno3" value="9.8" step="0.1"><br>
<label for="n_content_mgno3">N в Mg(NO₃)₂:</label>
<input type="number" id="n_content_mgno3" value="11" step="0.1"><br>
<label for="k_content_k2so4">K в K₂SO₄:</label>
<input type="number" id="k_content_k2so4" value="41.5" step="0.1"><br>
<label for="s_content_k2so4">S в K₂SO₄:</label>
<input type="number" id="s_content_k2so4" value="18" step="0.1"><br>
<label for="n_content_nh4no3">N в NH₄NO₃:</label>
<input type="number" id="n_content_nh4no3" value="34" step="0.1"><br>
<h3>Введите требуемые концентрации элементов (мг/л):</h3>
<label for="ca">Кальций (Ca):</label>
<input type="number" id="ca" placeholder="например, 115"><br>
<label for="p">Фосфор (P):</label>
<input type="number" id="p" placeholder="например, 60"><br>
<label for="k">Калий (K):</label>
<input type="number" id="k" placeholder="например, 149.5"><br>
<label for="mg">Магний (Mg):</label>
<input type="number" id="mg" placeholder="например, 42.71"><br>
<label for="s">Сера (S):</label>
<input type="number" id="s" placeholder="например, 74.691"><br>
<label for="n">Азот (N):</label>
<input type="number" id="n" placeholder="например, 110.74"><br>
<button onclick="calculate()">Рассчитать количество удобрений</button>
</div>
<div class="result" id="result"></div>
<script>
function calculate() {
// Состав удобрений (% → доли)
const caContentCa = parseFloat(document.getElementById("ca_content_ca").value) / 100;
const caContentN = parseFloat(document.getElementById("ca_content_n").value) / 100;
const pContent = parseFloat(document.getElementById("p_content").value) / 100;
const kContentKH2PO4 = parseFloat(document.getElementById("k_content_kh2po4").value) / 100;
const kContentKNO3 = parseFloat(document.getElementById("k_content_kno3").value) / 100;
const nContentKNO3 = parseFloat(document.getElementById("n_content_kno3").value) / 100;
const mgContentMgSO4 = parseFloat(document.getElementById("mg_content_mgso4").value) / 100;
const sContentMgSO4 = parseFloat(document.getElementById("s_content_mgso4").value) / 100;
const mgContentMgNO3 = parseFloat(document.getElementById("mg_content_mgno3").value) / 100;
const nContentMgNO3 = parseFloat(document.getElementById("n_content_mgno3").value) / 100;
const kContentK2SO4 = parseFloat(document.getElementById("k_content_k2so4").value) / 100;
const sContentK2SO4 = parseFloat(document.getElementById("s_content_k2so4").value) / 100;
const nContentNH4NO3 = parseFloat(document.getElementById("n_content_nh4no3").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 n = parseFloat(document.getElementById("n").value) || 0;
// Проверка ввода
if ([ca, p, k, mg, s, n].some(v => isNaN(v))) {
document.getElementById("result").innerHTML = "Введите все значения!";
return;
}
// 1. Ca(NO₃)₂·4H₂O от Ca
let caNO3 = ca / caContentCa;
let nFromCaNO3 = caNO3 * caContentN;
// 2. KH₂PO₄ от P
let kh2po4 = p / pContent;
let kFromKH2PO4 = kh2po4 * kContentKH2PO4;
// 3. MgSO₄·7H₂O и Mg(NO₃)₂ для Mg и S
let mgso4 = s / sContentMgSO4; // Сначала максимум S
let mgFromMgSO4 = mgso4 * mgContentMgSO4;
let sFromMgSO4 = mgso4 * sContentMgSO4;
let mgRemaining = mg - mgFromMgSO4;
let mgno3 = mgRemaining > 0 ? mgRemaining / mgContentMgNO3 : 0;
let nFromMgNO3 = mgno3 * nContentMgNO3;
if (mgFromMgSO4 > mg) {
mgso4 = mg / mgContentMgSO4;
sFromMgSO4 = mgso4 * sContentMgSO4;
mgno3 = 0;
nFromMgNO3 = 0;
}
// 4. KNO₃ для остатка N
let nRemaining = n - nFromCaNO3 - nFromMgNO3;
let kno3FromN = nRemaining > 0 ? nRemaining / nContentKNO3 : 0;
let kFromKNO3FromN = kno3FromN * kContentKNO3;
let kRemaining = k - kFromKH2PO4;
let kno3FromK = kRemaining > 0 ? kRemaining / kContentKNO3 : 0;
let nFromKNO3FromK = kno3FromK * nContentKNO3;
let kno3 = Math.min(kno3FromN, kno3FromK);
let nFromKNO3 = kno3 * nContentKNO3;
let kFromKNO3 = kno3 * kContentKNO3;
// 5. NH₄NO₃ для остатка N
nRemaining = n - nFromCaNO3 - nFromMgNO3 - nFromKNO3;
let nh4no3 = nRemaining > 0 ? nRemaining / nContentNH4NO3 : 0;
// 6. K₂SO₄ для остатка S и K
let sRemaining = s - sFromMgSO4;
let k2so4FromS = sRemaining > 0 ? sRemaining / sContentK2SO4 : 0;
let kFromK2SO4FromS = k2so4FromS * kContentK2SO4;
kRemaining = k - kFromKH2PO4 - kFromKNO3;
let k2so4FromK = kRemaining > 0 ? kRemaining / kContentK2SO4 : 0;
let k2so4 = Math.min(k2so4FromS, k2so4FromK);
let sFromK2SO4 = k2so4 * sContentK2SO4;
let kFromK2SO4 = k2so4 * kContentK2SO4;
// Итоговые концентрации
let totalN = (nFromCaNO3 + nFromKNO3 + nFromMgNO3 + nh4no3 * nContentNH4NO3).toFixed(2);
let totalP = (kh2po4 * pContent).toFixed(2);
let totalK = (kFromKH2PO4 + kFromKNO3 + kFromK2SO4).toFixed(2);
let totalCa = (caNO3 * caContentCa).toFixed(2);
let totalMg = (mgso4 * mgContentMgSO4 + mgno3 * mgContentMgNO3).toFixed(2);
let totalS = (sFromMgSO4 + sFromK2SO4).toFixed(2);
// Результаты
let resultText = `
<h3>Результаты расчёта (г/1000 л):</h3>
<p>Ca(NO₃)₂·4H₂O: ${caNO3.toFixed(2)} (Ca: ${totalCa}, N: ${nFromCaNO3.toFixed(2)})</p>
<p>KH₂PO₄: ${kh2po4.toFixed(2)} (P: ${totalP}, K: ${kFromKH2PO4.toFixed(2)})</p>
<p>KNO₃: ${kno3.toFixed(2)} (K: ${kFromKNO3.toFixed(2)}, N: ${nFromKNO3.toFixed(2)})</p>
<p>MgSO₄·7H₂O: ${mgso4.toFixed(2)} (Mg: ${(mgso4 * mgContentMgSO4).toFixed(2)}, S: ${sFromMgSO4.toFixed(2)})</p>
<p>Mg(NO₃)₂: ${mgno3.toFixed(2)} (Mg: ${(mgno3 * mgContentMgNO3).toFixed(2)}, N: ${nFromMgNO3.toFixed(2)})</p>
<p>K₂SO₄: ${k2so4.toFixed(2)} (S: ${sFromK2SO4.toFixed(2)}, K: ${kFromK2SO4.toFixed(2)})</p>
<p>NH₄NO₃: ${nh4no3.toFixed(2)} (N: ${(nh4no3 * nContentNH4NO3).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> |