Spaces:
Sleeping
Sleeping
Update calculate.html
Browse files- calculate.html +94 -49
calculate.html
CHANGED
@@ -9,6 +9,7 @@
|
|
9 |
input { padding: 8px; margin: 5px; width: 200px; }
|
10 |
button { padding: 8px 12px; cursor: pointer; margin-top: 10px; }
|
11 |
.result { margin-top: 20px; }
|
|
|
12 |
</style>
|
13 |
</head>
|
14 |
<body>
|
@@ -16,18 +17,40 @@
|
|
16 |
|
17 |
<div>
|
18 |
<h3>Введите состав удобрений (%):</h3>
|
19 |
-
<
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
<
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
<h3>Требуемые концентрации (мг/л):</h3>
|
33 |
<label>Ca:</label><input type="number" id="ca" placeholder="50" step="0.1"><br>
|
@@ -38,9 +61,9 @@
|
|
38 |
<label>N:</label><input type="number" id="nitrogen" value="50" step="0.1"><br>
|
39 |
|
40 |
<h3>Соотношение N (NH₄NO₃):</h3>
|
41 |
-
<label>NH₄NO₃ (
|
42 |
-
<input type="range" id="n_ratio" min="0" max="
|
43 |
-
<span id="n_ratio_value">
|
44 |
|
45 |
<button onclick="calculate()">Рассчитать</button>
|
46 |
</div>
|
@@ -49,20 +72,23 @@
|
|
49 |
|
50 |
<script>
|
51 |
document.getElementById('n_ratio').addEventListener('input', function() {
|
52 |
-
|
|
|
53 |
});
|
54 |
|
55 |
function calculate() {
|
56 |
// Состав удобрений (% → доли)
|
57 |
-
const
|
58 |
-
const
|
59 |
-
const
|
60 |
-
const
|
61 |
-
const
|
62 |
-
const
|
63 |
-
const
|
64 |
-
const
|
65 |
-
const
|
|
|
|
|
66 |
|
67 |
// Требуемые концентрации (мг/л)
|
68 |
const ca = parseFloat(document.getElementById("ca").value) || 0;
|
@@ -71,7 +97,7 @@
|
|
71 |
const mg = parseFloat(document.getElementById("mg").value) || 0;
|
72 |
const s = parseFloat(document.getElementById("s").value) || 0;
|
73 |
const nitrogen = parseFloat(document.getElementById("nitrogen").value) || 0;
|
74 |
-
const nRatio = parseFloat(document.getElementById("n_ratio").value) /
|
75 |
|
76 |
// Проверка ввода
|
77 |
if ([ca, p, k, mg, s, nitrogen].some(v => isNaN(v))) {
|
@@ -80,36 +106,55 @@
|
|
80 |
}
|
81 |
|
82 |
// Расчёт массы удобрений (г/1000 л)
|
83 |
-
|
84 |
-
const
|
85 |
-
const
|
86 |
-
|
87 |
-
|
88 |
-
const
|
89 |
-
const
|
90 |
-
const
|
91 |
-
|
92 |
-
|
93 |
-
const
|
94 |
-
const
|
95 |
-
|
96 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
|
98 |
// Итоговые концентрации для проверки
|
99 |
-
const totalN = (caNO3Total *
|
100 |
-
const
|
|
|
|
|
|
|
|
|
101 |
|
102 |
// Вывод результата
|
103 |
const resultText = `
|
104 |
<h3>Необходимые удобрения (г/1000 л):</h3>
|
105 |
-
<p>Ca(NO₃)₂·4H₂O: ${caNO3Total.toFixed(2)} (N: ${(caNO3Total *
|
106 |
-
<p>NH₄NO₃: ${nh4no3.toFixed(2)} (N: ${(nh4no3 *
|
107 |
-
<p>KH₂PO₄: ${kh2po4.toFixed(2)} (P: ${
|
108 |
-
<p>KNO₃: ${kno3.toFixed(2)} (N: ${nFromKNO3.toFixed(2)}, K: ${(kno3 *
|
109 |
-
<p>MgSO₄·7H₂O: ${mgso4.toFixed(2)} (Mg: ${
|
110 |
-
<p>K₂SO₄: ${k2so4.toFixed(2)} (S: ${
|
111 |
<h3>Итоговые концентрации (мг/л):</h3>
|
112 |
-
<p>N: ${totalN}, P: ${
|
113 |
`;
|
114 |
document.getElementById("result").innerHTML = resultText;
|
115 |
}
|
|
|
9 |
input { padding: 8px; margin: 5px; width: 200px; }
|
10 |
button { padding: 8px 12px; cursor: pointer; margin-top: 10px; }
|
11 |
.result { margin-top: 20px; }
|
12 |
+
.fertilizer-group { margin-bottom: 15px; }
|
13 |
</style>
|
14 |
</head>
|
15 |
<body>
|
|
|
17 |
|
18 |
<div>
|
19 |
<h3>Введите состав удобрений (%):</h3>
|
20 |
+
<div class="fertilizer-group">
|
21 |
+
<label>Ca в Ca(NO₃)₂·4H₂O:</label>
|
22 |
+
<input type="number" id="ca_content_ca" value="19.3" step="0.1"><br>
|
23 |
+
<label>N в Ca(NO₃)₂·4H₂O:</label>
|
24 |
+
<input type="number" id="ca_content_n" value="14.9" step="0.1">
|
25 |
+
</div>
|
26 |
+
<div class="fertilizer-group">
|
27 |
+
<label>P в KH₂PO₄:</label>
|
28 |
+
<input type="number" id="kh2po4_content_p" value="21.8" step="0.1"><br>
|
29 |
+
<label>K в KH₂PO₄:</label>
|
30 |
+
<input type="number" id="kh2po4_content_k" value="27.4" step="0.1">
|
31 |
+
</div>
|
32 |
+
<div class="fertilizer-group">
|
33 |
+
<label>K в KNO₃:</label>
|
34 |
+
<input type="number" id="kno3_content_k" value="38" step="0.1"><br>
|
35 |
+
<label>N в KNO₃:</label>
|
36 |
+
<input type="number" id="kno3_content_n" value="13.5" step="0.1">
|
37 |
+
</div>
|
38 |
+
<div class="fertilizer-group">
|
39 |
+
<label>Mg в MgSO₄·7H₂O:</label>
|
40 |
+
<input type="number" id="mgso4_content_mg" value="10.14" step="0.1"><br>
|
41 |
+
<label>S в MgSO₄·7H₂O:</label>
|
42 |
+
<input type="number" id="mgso4_content_s" value="13.5" step="0.1">
|
43 |
+
</div>
|
44 |
+
<div class="fertilizer-group">
|
45 |
+
<label>K в K₂SO₄:</label>
|
46 |
+
<input type="number" id="k2so4_content_k" value="41.5" step="0.1"><br>
|
47 |
+
<label>S в K₂SO₄:</label>
|
48 |
+
<input type="number" id="k2so4_content_s" value="18" step="0.1">
|
49 |
+
</div>
|
50 |
+
<div class="fertilizer-group">
|
51 |
+
<label>N в NH₄NO₃:</label>
|
52 |
+
<input type="number" id="nh4no3_content_n" value="34" step="0.1">
|
53 |
+
</div>
|
54 |
|
55 |
<h3>Требуемые концентрации (мг/л):</h3>
|
56 |
<label>Ca:</label><input type="number" id="ca" placeholder="50" step="0.1"><br>
|
|
|
61 |
<label>N:</label><input type="number" id="nitrogen" value="50" step="0.1"><br>
|
62 |
|
63 |
<h3>Соотношение N (NH₄NO₃):</h3>
|
64 |
+
<label>NH₄NO₃ (0-1):</label>
|
65 |
+
<input type="range" id="n_ratio" min="0" max="10" value="5">
|
66 |
+
<span id="n_ratio_value">0.5</span><br>
|
67 |
|
68 |
<button onclick="calculate()">Рассчитать</button>
|
69 |
</div>
|
|
|
72 |
|
73 |
<script>
|
74 |
document.getElementById('n_ratio').addEventListener('input', function() {
|
75 |
+
const ratio = (this.value / 10).toFixed(1);
|
76 |
+
document.getElementById('n_ratio_value').textContent = ratio;
|
77 |
});
|
78 |
|
79 |
function calculate() {
|
80 |
// Состав удобрений (% → доли)
|
81 |
+
const caContentCa = parseFloat(document.getElementById("ca_content_ca").value) / 100;
|
82 |
+
const caContentN = parseFloat(document.getElementById("ca_content_n").value) / 100;
|
83 |
+
const kh2po4ContentP = parseFloat(document.getElementById("kh2po4_content_p").value) / 100;
|
84 |
+
const kh2po4ContentK = parseFloat(document.getElementById("kh2po4_content_k").value) / 100;
|
85 |
+
const kno3ContentK = parseFloat(document.getElementById("kno3_content_k").value) / 100;
|
86 |
+
const kno3ContentN = parseFloat(document.getElementById("kno3_content_n").value) / 100;
|
87 |
+
const mgso4ContentMg = parseFloat(document.getElementById("mgso4_content_mg").value) / 100;
|
88 |
+
const mgso4ContentS = parseFloat(document.getElementById("mgso4_content_s").value) / 100;
|
89 |
+
const k2so4ContentK = parseFloat(document.getElementById("k2so4_content_k").value) / 100;
|
90 |
+
const k2so4ContentS = parseFloat(document.getElementById("k2so4_content_s").value) / 100;
|
91 |
+
const nh4no3ContentN = parseFloat(document.getElementById("nh4no3_content_n").value) / 100;
|
92 |
|
93 |
// Требуемые концентрации (мг/л)
|
94 |
const ca = parseFloat(document.getElementById("ca").value) || 0;
|
|
|
97 |
const mg = parseFloat(document.getElementById("mg").value) || 0;
|
98 |
const s = parseFloat(document.getElementById("s").value) || 0;
|
99 |
const nitrogen = parseFloat(document.getElementById("nitrogen").value) || 0;
|
100 |
+
const nRatio = parseFloat(document.getElementById("n_ratio").value) / 10;
|
101 |
|
102 |
// Проверка ввода
|
103 |
if ([ca, p, k, mg, s, nitrogen].some(v => isNaN(v))) {
|
|
|
106 |
}
|
107 |
|
108 |
// Расчёт массы удобрений (г/1000 л)
|
109 |
+
// 1. MgSO₄·7H₂O от Mg
|
110 |
+
const mgso4 = mg / mgso4ContentMg;
|
111 |
+
const sFromMgSO4 = mgso4 * mgso4ContentS;
|
112 |
+
|
113 |
+
// 2. K₂SO₄ от остатка S
|
114 |
+
const sRemaining = s - sFromMgSO4;
|
115 |
+
const k2so4 = sRemaining > 0 ? sRemaining / k2so4ContentS : 0;
|
116 |
+
const kFromK2SO4 = k2so4 * k2so4ContentK;
|
117 |
+
|
118 |
+
// 3. KH₂PO₄ от P
|
119 |
+
const kh2po4 = p / kh2po4ContentP;
|
120 |
+
const kFromKH2PO4 = kh2po4 * kh2po4ContentK;
|
121 |
+
|
122 |
+
// 4. KNO₃ от остатка K
|
123 |
+
const kRemaining = k - kFromKH2PO4 - kFromK2SO4;
|
124 |
+
const kno3 = kRemaining > 0 ? kRemaining / kno3ContentK : 0;
|
125 |
+
const nFromKNO3 = kno3 * kno3ContentN;
|
126 |
+
|
127 |
+
// 5. Ca(NO₃)₂·4H₂O от Ca
|
128 |
+
const caNO3FromCa = ca / caContentCa;
|
129 |
+
const nFromCaNO3Min = caNO3FromCa * caContentN;
|
130 |
+
|
131 |
+
// 6. NH₄NO₃ и дополнительный Ca(NO₃)₂ для N
|
132 |
+
const nRemaining = nitrogen - nFromKNO3 - nFromCaNO3Min;
|
133 |
+
const nFromNH4NO3 = nRemaining * nRatio;
|
134 |
+
const nFromCaNO3Extra = nRemaining * (1 - nRatio);
|
135 |
+
const nh4no3 = nFromNH4NO3 > 0 ? nFromNH4NO3 / nh4no3ContentN : 0;
|
136 |
+
const caNO3Extra = nFromCaNO3Extra > 0 ? nFromCaNO3Extra / caContentN : 0;
|
137 |
+
const caNO3Total = caNO3FromCa + caNO3Extra;
|
138 |
|
139 |
// Итоговые концентрации для проверки
|
140 |
+
const totalN = (caNO3Total * caContentN + nh4no3 * nh4no3ContentN + kno3 * kno3ContentN).toFixed(2);
|
141 |
+
const totalP = (kh2po4 * kh2po4ContentP).toFixed(2);
|
142 |
+
const totalK = (kh2po4 * kh2po4ContentK + kno3 * kno3ContentK + k2so4 * k2so4ContentK).toFixed(2);
|
143 |
+
const totalCa = (caNO3Total * caContentCa).toFixed(2);
|
144 |
+
const totalMg = (mgso4 * mgso4ContentMg).toFixed(2);
|
145 |
+
const totalS = (mgso4 * mgso4ContentS + k2so4 * k2so4ContentS).toFixed(2);
|
146 |
|
147 |
// Вывод результата
|
148 |
const resultText = `
|
149 |
<h3>Необходимые удобрения (г/1000 л):</h3>
|
150 |
+
<p>Ca(NO₃)₂·4H₂O: ${caNO3Total.toFixed(2)} (N: ${(caNO3Total * caContentN).toFixed(2)}, Ca: ${totalCa})</p>
|
151 |
+
<p>NH₄NO₃: ${nh4no3.toFixed(2)} (N: ${(nh4no3 * nh4no3ContentN).toFixed(2)})</p>
|
152 |
+
<p>KH₂PO₄: ${kh2po4.toFixed(2)} (P: ${totalP}, K: ${kFromKH2PO4.toFixed(2)})</p>
|
153 |
+
<p>KNO₃: ${kno3.toFixed(2)} (N: ${nFromKNO3.toFixed(2)}, K: ${(kno3 * kno3ContentK).toFixed(2)})</p>
|
154 |
+
<p>MgSO₄·7H₂O: ${mgso4.toFixed(2)} (Mg: ${totalMg}, S: ${sFromMgSO4.toFixed(2)})</p>
|
155 |
+
<p>K₂SO₄: ${k2so4.toFixed(2)} (K: ${kFromK2SO4.toFixed(2)}, S: ${(k2so4 * k2so4ContentS).toFixed(2)})</p>
|
156 |
<h3>Итоговые концентрации (мг/л):</h3>
|
157 |
+
<p>N: ${totalN}, P: ${totalP}, K: ${totalK}, Ca: ${totalCa}, Mg: ${totalMg}, S: ${totalS}</p>
|
158 |
`;
|
159 |
document.getElementById("result").innerHTML = resultText;
|
160 |
}
|