File size: 12,156 Bytes
2737675
 
 
 
 
9b65f68
2737675
 
f2890ea
2737675
 
 
 
 
9b65f68
2737675
 
93a28dc
f2890ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73faeec
 
f2890ea
 
 
a84c006
73faeec
a84c006
73faeec
 
f2890ea
 
 
 
 
 
 
 
 
 
9b65f68
f2890ea
9b65f68
f2890ea
9b65f68
f2890ea
9b65f68
f2890ea
9b65f68
f2890ea
9b65f68
f2890ea
 
2737675
 
93a28dc
 
944b3f0
9b65f68
a84c006
 
 
 
 
 
 
 
9b65f68
 
 
 
 
 
 
 
 
 
 
 
 
 
944b3f0
 
 
 
f2890ea
 
 
 
73faeec
f2890ea
73faeec
 
f2890ea
 
 
944b3f0
 
 
 
 
 
 
f2890ea
944b3f0
f2890ea
944b3f0
 
 
 
a84c006
f2890ea
45b020d
a84c006
9b65f68
a84c006
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f2890ea
a84c006
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45b020d
9b65f68
45b020d
73faeec
a84c006
45b020d
9b65f68
 
 
 
 
a84c006
9b65f68
 
a84c006
9b65f68
a84c006
9b65f68
 
 
a84c006
9b65f68
f2890ea
 
 
9b65f68
 
45b020d
a84c006
 
45b020d
a84c006
 
9b65f68
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
<!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₃)₂·6H₂O:</label>
        <input type="number" id="mg_content_mgno3" value="9.8" step="0.1"><br>
        <label for="n_content_mgno3">N в Mg(NO₃)₂·6H₂O:</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" value="115"><br>
        <label for="p">Фосфор (P):</label>
        <input type="number" id="p" value="60"><br>
        <label for="k">Калий (K):</label>
        <input type="number" id="k" value="149.5"><br>
        <label for="mg">Магний (Mg):</label>
        <input type="number" id="mg" value="42.71"><br>
        <label for="s">Сера (S):</label>
        <input type="number" id="s" value="74.691"><br>
        <label for="n">Азот (N):</label>
        <input type="number" id="n" value="110.74"><br>

        <button onclick="calculate()">Рассчитать количество удобрений</button>
    </div>

    <div class="result" id="result"></div>

    <script>
        const DENSITY_DATA = {
            "NH4NO3": [[5, 1.001], [10, 1.003], /* ... */ [690, 1.2528]],
            "Ca(NO3)2*4H2O": [[5, 1.0015], [10, 1.0041], /* ... */ [755, 1.3519], [920, 1.4208]],
            "MgSO4*7H2O": [[5, 1.0014], [10, 1.0037], /* ... */ [695, 1.2974]],
            "Mg(NO3)2*6H2O": [[5, 1.0001], [10, 1.0023], /* ... */ [500, 1.2007]],
            "KNO3": [[5, 1.0011], [10, 1.0042], /* ... */ [280, 1.1627]],
            "K2SO4": [[5, 1.002], [10, 1.006], /* ... */ [110, 1.0825]],
            "KH2PO4": [[5, 1.0016], [10, 1.0051], /* ... */ [110, 1.0719]]
        };

        function getDensity(fertilizer, mass) {
            const data = DENSITY_DATA[fertilizer];
            if (!data || mass <= 0) return 1;
            for (let i = 0; i < data.length - 1; i++) {
                if (mass >= data[i][0] && mass <= data[i + 1][0]) {
                    const [x1, y1] = data[i];
                    const [x2, y2] = data[i + 1];
                    return y1 + (mass - x1) * (y2 - y1) / (x2 - x1);
                }
            }
            return data[data.length - 1][1]; // Последнее значение
        }

        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;
            }

            // Инициализация масс (г/1000 л)
            let caNO3 = ca / caContentCa;
            let kh2po4 = p / pContent;
            let mgso4 = 0;
            let mgno3 = 0;
            let kno3 = 0;
            let k2so4 = 0;
            let nh4no3 = 0;

            // Итеративный расчёт
            for (let i = 0; i < 10; i++) {
                let nFromCaNO3 = caNO3 * caContentN;
                let kFromKH2PO4 = kh2po4 * kContentKH2PO4;

                // MgSO₄·7H₂O и Mg(NO₃)₂·6H₂O
                mgso4 = mg / mgContentMgSO4;
                let sFromMgSO4 = mgso4 * sContentMgSO4;
                let mgFromMgSO4 = mgso4 * mgContentMgSO4;
                mgno3 = 0;
                let nFromMgNO3 = 0;

                if (sFromMgSO4 > s) {
                    mgso4 = s / sContentMgSO4;
                    sFromMgSO4 = mgso4 * sContentMgSO4;
                    mgFromMgSO4 = mgso4 * mgContentMgSO4;
                    mgno3 = (mg - mgFromMgSO4) / mgContentMgNO3;
                    nFromMgNO3 = mgno3 * nContentMgNO3;
                }

                // KNO₃
                let nRemaining = n - nFromCaNO3 - nFromMgNO3;
                kno3 = nRemaining > 0 ? nRemaining / nContentKNO3 : 0;
                let kFromKNO3 = kno3 * kContentKNO3;
                let nFromKNO3 = kno3 * nContentKNO3;

                // K₂SO₄
                let kRemaining = k - kFromKH2PO4 - kFromKNO3;
                let sRemaining = s - sFromMgSO4;
                k2so4 = Math.min(kRemaining / kContentK2SO4, sRemaining / sContentK2SO4);
                if (k2so4 < 0) k2so4 = 0;
                let sFromK2SO4 = k2so4 * sContentK2SO4;
                let kFromK2SO4 = k2so4 * kContentK2SO4;

                // NH₄NO₃
                nRemaining = n - nFromCaNO3 - nFromMgNO3 - nFromKNO3;
                nh4no3 = nRemaining > 0 ? nRemaining / nContentNH4NO3 : 0;

                // Плотность
                let density = (
                    getDensity("Ca(NO3)2*4H2O", caNO3) +
                    getDensity("KH2PO4", kh2po4) +
                    getDensity("KNO3", kno3) +
                    getDensity("MgSO4*7H2O", mgso4) +
                    getDensity("Mg(NO3)2*6H2O", mgno3) +
                    getDensity("K2SO4", k2so4) +
                    getDensity("NH4NO3", nh4no3)
                ) / 7;

                // Корректировка масс
                caNO3 *= density;
                kh2po4 *= density;
                mgso4 *= density;
                mgno3 *= density;
                kno3 *= density;
                k2so4 *= density;
                nh4no3 *= density;
            }

            // Финальные значения
            let nFromCaNO3 = caNO3 * caContentN;
            let kFromKH2PO4 = kh2po4 * kContentKH2PO4;
            let sFromMgSO4 = mgso4 * sContentMgSO4;
            let mgFromMgSO4 = mgso4 * mgContentMgSO4;
            let nFromMgNO3 = mgno3 * nContentMgNO3;
            let mgFromMgNO3 = mgno3 * mgContentMgNO3;
            let kFromKNO3 = kno3 * kContentKNO3;
            let nFromKNO3 = kno3 * nContentKNO3;
            let sFromK2SO4 = k2so4 * sContentK2SO4;
            let kFromK2SO4 = k2so4 * kContentK2SO4;
            let nFromNH4NO3 = nh4no3 * nContentNH4NO3;

            let density = (
                getDensity("Ca(NO3)2*4H2O", caNO3) +
                getDensity("KH2PO4", kh2po4) +
                getDensity("KNO3", kno3) +
                getDensity("MgSO4*7H2O", mgso4) +
                getDensity("Mg(NO3)2*6H2O", mgno3) +
                getDensity("K2SO4", k2so4) +
                getDensity("NH4NO3", nh4no3)
            ) / 7;

            let totalN = (nFromCaNO3 + nFromKNO3 + nFromMgNO3 + nFromNH4NO3) / density;
            let totalP = (kh2po4 * pContent) / density;
            let totalK = (kFromKH2PO4 + kFromKNO3 + kFromK2SO4) / density;
            let totalCa = (caNO3 * caContentCa) / density;
            let totalMg = (mgFromMgSO4 + mgFromMgNO3) / density;
            let totalS = (sFromMgSO4 + sFromK2SO4) / density;

            let resultText = `
                <h3>Результаты расчёта (г/1000 л):</h3>
                <p>Ca(NO₃)₂·4H₂O: ${caNO3.toFixed(2)} (Ca: ${totalCa.toFixed(2)}, N: ${nFromCaNO3.toFixed(2)})</p>
                <p>KH₂PO₄: ${kh2po4.toFixed(2)} (P: ${totalP.toFixed(2)}, 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: ${mgFromMgSO4.toFixed(2)}, S: ${sFromMgSO4.toFixed(2)})</p>
                <p>Mg(NO₃)₂·6H₂O: ${mgno3.toFixed(2)} (Mg: ${mgFromMgNO3.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: ${nFromNH4NO3.toFixed(2)})</p>
                <h3>Итоговые концентрации (мг/л, плотность ${density.toFixed(4)}):</h3>
                <p>N: ${totalN.toFixed(2)}, P: ${totalP.toFixed(2)}, K: ${totalK.toFixed(2)}, Ca: ${totalCa.toFixed(2)}, Mg: ${totalMg.toFixed(2)}, S: ${totalS.toFixed(2)}</p>
            `;
            document.getElementById("result").innerHTML = resultText;
        }
    </script>
</body>
</html>