Это старая версия документа!


Пересчет на кислород

Наиболее примитивный метод расчета на заданное число атомов кислорода.

Подробнее

Информация о публикации
Ссылка
Учитываемые компоненты Все
Рассчитываемые компоненты Нет

Исходный код

  1. elements <- read.csv("constants_elements.csv",stringsAsFactors=F)
  2. oxides <- read.csv("constants_oxides.csv",stringsAsFactors=F)
  3.  
  4.  
  5. recalc.common_oxygen <- function (wtp_data, count=12, ...)
  6. {
  7. oxy_data = wtp_data[,grep("_wtp", names(wtp_data))];
  8. ds = data.frame();
  9. for (j in 1:nrow(oxy_data))
  10. {
  11. row <- oxy_data[j,];
  12.  
  13. names(row) <- gsub('_wtp', "", names(oxy_data));
  14. for ( i in 1:length(row))
  15. {
  16. ox= names(row)[i]
  17. oxconst = subset(oxides,oxide==ox)
  18. catconst = subset(elements,element==oxconst$cation)
  19. anconst = subset(elements,element==oxconst$anion)
  20. row[[ox]] = (row[[ox]]/(catconst$weight*oxconst$cation_count+anconst$weight*oxconst$anion_count));
  21.  
  22. if (oxconst$anion == 'O' && oxconst$anion_count > 0)
  23. {
  24. row[[ox]] = row[[ox]] * oxconst$anion_count;
  25. }
  26. }
  27. csum = count/sum(row);
  28. for ( i in 1:length(row))
  29. {
  30. ox= names(row)[i]
  31. oxconst = subset(oxides,oxide==ox);
  32. catconst = subset(elements,element==oxconst$cation) ;
  33. anconst = subset(elements,element==oxconst$anion) ;
  34. row[[paste0(oxconst$cation,'_pfu')]] = row[[ox]] * csum / oxconst$anion_count*oxconst$cation_count;
  35. }
  36. ds = rbind(ds,row)
  37. names(ds) <- names(row)
  38. }
  39. return(cbind(Name=wtp_data$Name,ds[,grep("_pfu", names(ds))]));
  40. }
  41.  
  42.  
  43. recalc.common_oxygen.test <- function () {
  44. src <- data.frame(Name='test',SiO2_wtp=37.50,TiO2_wtp=0.3,Al2O3_wtp=20.21,FeO_wtp=26.30,MnO_wtp=2.94,MgO_wtp=3.25,CaO_wtp=9.94);
  45.  
  46. result <- recalc.common_oxygen (src, count = 12);
  47.  
  48. expect_equal(object = result$Si_pfu, 2.978, tolerance = 0.001);
  49. expect_equal(object = result$Ti_pfu, 0.018, tolerance = 0.001);
  50. expect_equal(object = result$Al_pfu, 1.891, tolerance = 0.001);
  51. expect_equal(object = result$Fe_pfu, 1.746, tolerance = 0.001);
  52. expect_equal(object = result$Mn_pfu, 0.195, tolerance = 0.001);
  53. expect_equal(object = result$Mg_pfu, 0.385, tolerance = 0.001);
  54. expect_equal(object = result$Ca_pfu, 0.846, tolerance = 0.001);
  55. }
  • recalc/common_oxygen.1443019065.txt.gz
  • Последние изменения: 2018/11/12 15:08
  • (внешнее изменение)