DmitrMakeev commited on
Commit
efef438
·
verified ·
1 Parent(s): 80fa53f

Update nutri_call.html

Browse files
Files changed (1) hide show
  1. nutri_call.html +22 -27
nutri_call.html CHANGED
@@ -1208,8 +1208,8 @@ function calculateOxidePercentages(data) {
1208
 
1209
  function calculateCationsAndAnions(data) {
1210
  console.log("=== ТОЧНЫЙ РАСЧЕТ КАТИОНОВ И АНИОНОВ ===");
1211
-
1212
- // Молярные массы и валентности ионов
1213
  const ION_DATA = {
1214
  // Катионы
1215
  'Ca': { mass: 40.08, charge: 2 },
@@ -1222,27 +1222,27 @@ function calculateCationsAndAnions(data) {
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,23 +1251,18 @@ function calculateCationsAndAnions(data) {
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
 
 
1208
 
1209
  function calculateCationsAndAnions(data) {
1210
  console.log("=== ТОЧНЫЙ РАСЧЕТ КАТИОНОВ И АНИОНОВ ===");
1211
+
1212
+ // Молярные массы и валентности элементов
1213
  const ION_DATA = {
1214
  // Катионы
1215
  'Ca': { mass: 40.08, 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) * 2 / 40.08,
1232
+ 'Mg': (profile['Mg'] || 0) * 2 / 24.305,
1233
+ 'K': (profile['K'] || 0) * 1 / 39.098,
1234
+ 'NH4': (profile['N (NH4+)'] || 0) * 1 / 18.038,
1235
  // Анионы
1236
+ 'NO3': (profile['N (NO3-)'] || 0) * 1 / 62.004,
1237
+ 'SO4': (profile['S'] || 0) * 2 / 96.06,
1238
+ 'H2PO4': (profile['P'] || 0) * 1 / 96.99
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
+ document.getElementById("n1-value").textContent =
1256
+ `Катионы: ${totalCations.toFixed(2)} mEq/L | Анионы: ${totalAnions.toFixed(2)} mEq/L`;
1257
+
1258
+ // Обновляем индикаторы
1259
+ document.getElementById("cation-indicator").style.width = `${cationPercent}%`;
1260
+ document.getElementById("anion-indicator").style.width = `${anionPercent}%`;
 
 
 
 
1261
  }
1262
 
1263
 
1264
 
1265
 
 
1266
 
1267
 
1268