Spaces:
Sleeping
Sleeping
Update nutri_call.html
Browse files- nutri_call.html +46 -38
nutri_call.html
CHANGED
|
@@ -1179,49 +1179,57 @@ function calculateOxidePercentages(data) {
|
|
| 1179 |
|
| 1180 |
|
| 1181 |
function calculateCationsAndAnions(data) {
|
| 1182 |
-
console.log("=== РАСЧЕТ КАТИОНОВ И АНИОНОВ ===");
|
| 1183 |
-
|
| 1184 |
-
//
|
| 1185 |
-
const
|
| 1186 |
-
|
| 1187 |
-
|
| 1188 |
-
|
| 1189 |
-
|
| 1190 |
-
|
| 1191 |
-
|
| 1192 |
-
|
| 1193 |
-
|
| 1194 |
-
|
| 1195 |
-
|
| 1196 |
-
const sMass = actualProfile["S"] || 0; // SO₄²⁻
|
| 1197 |
-
const pMass = actualProfile["P"] || 0; // H₂PO₄⁻
|
| 1198 |
-
|
| 1199 |
-
// Общая масса катионов
|
| 1200 |
-
const totalCations = caMass + mgMass + kMass + nh4Mass;
|
| 1201 |
-
|
| 1202 |
-
// Общая масса анионов
|
| 1203 |
-
const totalAnions = no3Mass + sMass + pMass;
|
| 1204 |
-
|
| 1205 |
-
console.log(`Общая масса катионов: ${totalCations}`);
|
| 1206 |
-
console.log(`Общая масса анионов: ${totalAnions}`);
|
| 1207 |
-
|
| 1208 |
-
// Обновляем заголовок N1
|
| 1209 |
-
document.getElementById("n1-value").textContent = `Катионы:${totalCations.toFixed(2)}: Анионы:${totalAnions.toFixed(2)} PPM=${data.total_ppm}`;
|
| 1210 |
|
| 1211 |
-
//
|
| 1212 |
-
const
|
| 1213 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1214 |
|
| 1215 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1216 |
const total = totalCations + totalAnions;
|
| 1217 |
-
const
|
| 1218 |
-
const
|
| 1219 |
|
| 1220 |
-
|
| 1221 |
-
|
| 1222 |
-
|
| 1223 |
|
| 1224 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1225 |
}
|
| 1226 |
|
| 1227 |
|
|
|
|
| 1179 |
|
| 1180 |
|
| 1181 |
function calculateCationsAndAnions(data) {
|
| 1182 |
+
console.log("=== ТОЧНЫЙ РАСЧЕТ КАТИОНОВ И АНИОНОВ ===");
|
| 1183 |
+
|
| 1184 |
+
// Молярные массы и валентности элементов
|
| 1185 |
+
const ION_DATA = {
|
| 1186 |
+
// Катионы
|
| 1187 |
+
'Ca': { mass: 40.08, charge: 2 },
|
| 1188 |
+
'Mg': { mass: 24.305, charge: 2 },
|
| 1189 |
+
'K': { mass: 39.098, charge: 1 },
|
| 1190 |
+
'NH4': { mass: 18.038, charge: 1 },
|
| 1191 |
+
// Анионы
|
| 1192 |
+
'NO3': { mass: 62.004, charge: 1 },
|
| 1193 |
+
'SO4': { mass: 96.06, charge: 2 },
|
| 1194 |
+
'H2PO4': { mass: 96.99, charge: 1 }
|
| 1195 |
+
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1196 |
|
| 1197 |
+
// Получаем данные профиля
|
| 1198 |
+
const profile = data.actual_profile;
|
| 1199 |
+
|
| 1200 |
+
// Рассчитываем миллиэквиваленты (meq/L) для каждого иона
|
| 1201 |
+
const ions = {
|
| 1202 |
+
// Катионы
|
| 1203 |
+
'Ca': (profile['Ca'] || 0) * 2 / 40.08,
|
| 1204 |
+
'Mg': (profile['Mg'] || 0) * 2 / 24.305,
|
| 1205 |
+
'K': (profile['K'] || 0) * 1 / 39.098,
|
| 1206 |
+
'NH4': (profile['N (NH4+)'] || 0) * 1 / 18.038,
|
| 1207 |
+
// Анионы
|
| 1208 |
+
'NO3': (profile['N (NO3-)'] || 0) * 1 / 62.004,
|
| 1209 |
+
'SO4': (profile['S'] || 0) * 2 / 96.06,
|
| 1210 |
+
'H2PO4': (profile['P'] || 0) * 1 / 96.99
|
| 1211 |
+
};
|
| 1212 |
|
| 1213 |
+
// Суммируем катионы и анионы
|
| 1214 |
+
const totalCations = ions['Ca'] + ions['Mg'] + ions['K'] + ions['NH4'];
|
| 1215 |
+
const totalAnions = ions['NO3'] + ions['SO4'] + ions['H2PO4'];
|
| 1216 |
+
|
| 1217 |
+
// Рассчитываем процентное соотношение
|
| 1218 |
const total = totalCations + totalAnions;
|
| 1219 |
+
const cationPercent = (totalCations / total * 100).toFixed(1);
|
| 1220 |
+
const anionPercent = (totalAnions / total * 100).toFixed(1);
|
| 1221 |
|
| 1222 |
+
console.log(`Катионы: ${totalCations.toFixed(2)} meq/L (${cationPercent}%)`);
|
| 1223 |
+
console.log(`Анионы: ${totalAnions.toFixed(2)} meq/L (${anionPercent}%)`);
|
| 1224 |
+
console.log(`Дисбаланс: ${(totalCations - totalAnions).toFixed(2)} meq/L`);
|
| 1225 |
|
| 1226 |
+
// Обновляем UI
|
| 1227 |
+
document.getElementById("n1-value").textContent =
|
| 1228 |
+
`Катионы: ${totalCations.toFixed(2)} meq/L | Анионы: ${totalAnions.toFixed(2)} meq/L`;
|
| 1229 |
+
|
| 1230 |
+
// Обновляем индикаторы
|
| 1231 |
+
document.getElementById("cation-indicator").style.width = `${cationPercent}%`;
|
| 1232 |
+
document.getElementById("anion-indicator").style.width = `${anionPercent}%`;
|
| 1233 |
}
|
| 1234 |
|
| 1235 |
|