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


Пересчет весовых процентов оксидов на атомные проценты

Пересчет весовых процентов оксидов на атомные проценты.

Подробнее

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

Код

  1. elements <- read.csv("constants_elements.csv",stringsAsFactors=F);
  2. oxides <- read.csv("constants_oxides.csv",stringsAsFactors=F);
  3.  
  4. recalc.wtp_comp_to_atp <- function (wtp_data, cat_only = T, ...)
  5. {
  6. data <- wtp_data[,grep("_wtp", names(wtp_data))];
  7. data_atp = data.frame(Name=wtp_data$Name);
  8. cF = rep(0, nrow(data));
  9. cCl = rep(0, nrow(data));
  10. cO = rep(0, nrow(data));
  11.  
  12.  
  13. for (wtname in names(data))
  14. {
  15. oxname <- gsub('_wtp', "", wtname);
  16.  
  17. oxconst = subset(oxides,oxide==oxname)
  18. catconst = subset(elements,element==oxconst$cation)
  19. anconst = subset(elements,element==oxconst$anion)
  20.  
  21. ddf = data.frame(data[,wtname]/(catconst$weight*oxconst$cation_count+anconst$weight*oxconst$anion_count)*oxconst$cation_count);
  22. names(ddf) <- c(oxconst$cation);
  23. data_atp = cbind(data_atp, ddf);
  24.  
  25. anc = data[,wtname]/(catconst$weight*oxconst$cation_count+anconst$weight*oxconst$anion_count)*oxconst$anion_count;
  26. if(oxconst$anion=="F") {cF = cF + anc}
  27. if(oxconst$anion=="Cl") {cCl = cCl + anc}
  28. if(oxconst$anion=="O") {cO = cO + anc}
  29. }
  30. data_atp$Name <- NULL;
  31.  
  32. if(!cat_only)
  33. {
  34. data_atp$F <- cF;
  35. data_atp$Cl <- cCl;
  36. data_atp$O <- cO;
  37. }
  38. else
  39. {
  40. data_atp$F <- NULL;
  41. data_atp$Cl <- NULL;
  42. data_atp$O <- NULL;
  43. }
  44.  
  45. names(data_atp) <- paste0(names(data_atp),'_atp');
  46. return(cbind(Name=wtp_data$Name,data_atp));
  47. }
  • recalc/wtp_comp_to_atp.1452609532.txt.gz
  • Последние изменения: 2018/11/12 15:08
  • (внешнее изменение)