Наиболее примитивный метод расчета на заданное число атомов кислорода.
Reference | |
---|---|
Input | wtp |
Results | pfu |
elements <- read.csv("constants_elements.csv",stringsAsFactors=F) oxides <- read.csv("constants_oxides.csv",stringsAsFactors=F) recalc.common_oxygen <- function (wtp_data, count=12, ...) { oxy_data = wtp_data[,grep("_wtp", names(wtp_data))]; ds = data.frame(); for (j in 1:nrow(oxy_data)) { row <- oxy_data[j,]; names(row) <- gsub('_wtp', "", names(oxy_data)); for ( i in 1:length(row)) { ox= names(row)[i] oxconst = subset(oxides,oxide==ox) catconst = subset(elements,element==oxconst$cation) anconst = subset(elements,element==oxconst$anion) row[[ox]] = (row[[ox]]/(catconst$weight*oxconst$cation_count+anconst$weight*oxconst$anion_count)); if (oxconst$anion == 'O' && oxconst$anion_count > 0) { row[[ox]] = row[[ox]] * oxconst$anion_count; } } csum = count/sum(row); for ( i in 1:length(row)) { ox= names(row)[i] oxconst = subset(oxides,oxide==ox); catconst = subset(elements,element==oxconst$cation) ; anconst = subset(elements,element==oxconst$anion) ; row[[paste0(oxconst$cation,'_pfu')]] = row[[ox]] * csum / oxconst$anion_count*oxconst$cation_count; } ds = rbind(ds,row) names(ds) <- names(row) } return(cbind(Name=wtp_data$Name,ds[,grep("_pfu", names(ds))])); } recalc.common_oxygen.test <- function () { 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); result <- recalc.common_oxygen (src, count = 12); expect_equal(object = result$Si_pfu, 2.978, tolerance = 0.001); expect_equal(object = result$Ti_pfu, 0.018, tolerance = 0.001); expect_equal(object = result$Al_pfu, 1.891, tolerance = 0.001); expect_equal(object = result$Fe_pfu, 1.746, tolerance = 0.001); expect_equal(object = result$Mn_pfu, 0.195, tolerance = 0.001); expect_equal(object = result$Mg_pfu, 0.385, tolerance = 0.001); expect_equal(object = result$Ca_pfu, 0.846, tolerance = 0.001); }