Spaces:
Sleeping
Sleeping
Update nutri_call.html
Browse files- nutri_call.html +31 -29
nutri_call.html
CHANGED
@@ -1207,9 +1207,9 @@ function calculateOxidePercentages(data) {
|
|
1207 |
|
1208 |
|
1209 |
function calculateCationsAndAnions(data) {
|
1210 |
-
console.log("===
|
1211 |
-
|
1212 |
-
// Молярные массы и валентности
|
1213 |
const ION_DATA = {
|
1214 |
// Катионы
|
1215 |
'Ca': { mass: 40.08, charge: 2 },
|
@@ -1219,33 +1219,30 @@ function calculateCationsAndAnions(data) {
|
|
1219 |
// Анионы
|
1220 |
'NO3': { mass: 62.004, charge: 1 },
|
1221 |
'SO4': { mass: 96.06, charge: 2 },
|
1222 |
-
'
|
1223 |
};
|
1224 |
|
|
|
1225 |
const profile = data.actual_profile;
|
1226 |
-
|
1227 |
-
//
|
1228 |
-
const NH4_actual = profile['N (NH4+)'] * (18.038/14);
|
1229 |
-
const HPO4_actual = profile['P'] * (95.97/30.97);
|
1230 |
-
|
1231 |
const ions = {
|
1232 |
-
// Катионы
|
1233 |
-
'Ca': (profile['Ca'] || 0) *
|
1234 |
-
'Mg': (profile['Mg'] || 0) *
|
1235 |
-
'K': (profile['K'] || 0) /
|
1236 |
-
'NH4':
|
1237 |
-
|
1238 |
-
|
1239 |
-
'
|
1240 |
-
'
|
1241 |
-
'HPO4': HPO4_actual * 2 / 95.97
|
1242 |
};
|
1243 |
|
1244 |
-
//
|
1245 |
const totalCations = ions['Ca'] + ions['Mg'] + ions['K'] + ions['NH4'];
|
1246 |
const totalAnions = ions['NO3'] + ions['SO4'] + ions['H2PO4'];
|
1247 |
-
|
1248 |
-
//
|
1249 |
const total = totalCations + totalAnions;
|
1250 |
const cationPercent = (totalCations / total * 100).toFixed(1);
|
1251 |
const anionPercent = (totalAnions / total * 100).toFixed(1);
|
@@ -1254,18 +1251,23 @@ function calculateCationsAndAnions(data) {
|
|
1254 |
console.log(`Анионы: ${totalAnions.toFixed(2)} mEq/L (${anionPercent}%)`);
|
1255 |
console.log(`Дисбаланс: ${(totalCations - totalAnions).toFixed(2)} mEq/L`);
|
1256 |
|
1257 |
-
//
|
1258 |
-
document.getElementById("n1-value")
|
1259 |
-
|
1260 |
-
|
1261 |
-
|
1262 |
-
|
1263 |
-
|
|
|
|
|
|
|
|
|
1264 |
}
|
1265 |
|
1266 |
|
1267 |
|
1268 |
|
|
|
1269 |
|
1270 |
|
1271 |
|
|
|
1207 |
|
1208 |
|
1209 |
function calculateCationsAndAnions(data) {
|
1210 |
+
console.log("=== ТОЧНЫЙ РАСЧЕТ КАТИОНОВ И АНИОНОВ ===");
|
1211 |
+
|
1212 |
+
// Молярные массы и валентности ионов
|
1213 |
const ION_DATA = {
|
1214 |
// Катионы
|
1215 |
'Ca': { mass: 40.08, charge: 2 },
|
|
|
1219 |
// Анионы
|
1220 |
'NO3': { mass: 62.004, charge: 1 },
|
1221 |
'SO4': { mass: 96.06, charge: 2 },
|
1222 |
+
'H2PO4': { mass: 96.99, charge: 1 }
|
1223 |
};
|
1224 |
|
1225 |
+
// Профиль ионов из данных
|
1226 |
const profile = data.actual_profile;
|
1227 |
+
|
1228 |
+
// Расчет миллиэквивалентов (mEq/L)
|
|
|
|
|
|
|
1229 |
const ions = {
|
1230 |
+
// Катионы
|
1231 |
+
'Ca': (profile['Ca'] || 0) * ION_DATA['Ca'].charge / ION_DATA['Ca'].mass,
|
1232 |
+
'Mg': (profile['Mg'] || 0) * ION_DATA['Mg'].charge / ION_DATA['Mg'].mass,
|
1233 |
+
'K': (profile['K'] || 0) * ION_DATA['K'].charge / ION_DATA['K'].mass,
|
1234 |
+
'NH4': (profile['N (NH4+)'] || 0) * ION_DATA['NH4'].charge / ION_DATA['NH4'].mass,
|
1235 |
+
// Анионы
|
1236 |
+
'NO3': (profile['N (NO3-)'] || 0) * ION_DATA['NO3'].charge / ION_DATA['NO3'].mass,
|
1237 |
+
'SO4': (profile['S'] || 0) * ION_DATA['SO4'].charge / ION_DATA['SO4'].mass,
|
1238 |
+
'H2PO4': (profile['P'] || 0) * ION_DATA['H2PO4'].charge / ION_DATA['H2PO4'].mass
|
|
|
1239 |
};
|
1240 |
|
1241 |
+
// Суммы катионов и анионов
|
1242 |
const totalCations = ions['Ca'] + ions['Mg'] + ions['K'] + ions['NH4'];
|
1243 |
const totalAnions = ions['NO3'] + ions['SO4'] + ions['H2PO4'];
|
1244 |
+
|
1245 |
+
// Общая сумма
|
1246 |
const total = totalCations + totalAnions;
|
1247 |
const cationPercent = (totalCations / total * 100).toFixed(1);
|
1248 |
const anionPercent = (totalAnions / total * 100).toFixed(1);
|
|
|
1251 |
console.log(`Анионы: ${totalAnions.toFixed(2)} mEq/L (${anionPercent}%)`);
|
1252 |
console.log(`Дисбаланс: ${(totalCations - totalAnions).toFixed(2)} mEq/L`);
|
1253 |
|
1254 |
+
// Обновление UI
|
1255 |
+
const n1Element = document.getElementById("n1-value");
|
1256 |
+
if (n1Element) {
|
1257 |
+
n1Element.textContent =
|
1258 |
+
`Катионы: ${totalCations.toFixed(2)} mEq/L | Анионы: ${totalAnions.toFixed(2)} mEq/L`;
|
1259 |
+
}
|
1260 |
+
|
1261 |
+
const cationBar = document.getElementById("cation-indicator");
|
1262 |
+
const anionBar = document.getElementById("anion-indicator");
|
1263 |
+
if (cationBar) cationBar.style.width = `${cationPercent}%`;
|
1264 |
+
if (anionBar) anionBar.style.width = `${anionPercent}%`;
|
1265 |
}
|
1266 |
|
1267 |
|
1268 |
|
1269 |
|
1270 |
+
|
1271 |
|
1272 |
|
1273 |
|