H2SO4_titrat <-
function(conc_SO4, pH_target, class_anim){
if (class_anim == "pig"){
td <- data.frame(cSO4 = c(0, 0.237188238, 0.474376476, 0.711564714, 0.948752952,
1.18594119, 1.423129427, 1.660317665, 1.897505903,
2.134694141, 2.371882379, 2.609070617, 2.846258855,
3.083447093),
pH = c(6.9, 6.6375, 6.435, 6.2925, 6.1475, 5.9975, 5.845,
5.67, 5.495, 5.325, 5.1575, 5, 4.875, 4.755))
} else if (class_anim == "cattle"){
td <- data.frame(cSO4 = c(0,0.237946483, 0.475892965, 0.713839448, 0.951785931,
1.189732413, 1.427678896, 1.665625378, 1.903571861,
2.141518344, 2.379464826, 2.617411309, 2.855357792,
3.093304274, 3.331250757),
pH = c(6.71, 6.5875, 6.47, 6.3625, 6.265, 6.155, 6.0575,
5.945, 5.8275, 5.6875, 5.525, 5.37, 5.18, 4.9875,
4.81))
} else if (class_anim == "degassed"){
td <- data.frame(cSO4 = c(0,0.237946483, 0.475892965, 0.713839448, 0.951785931,
1.189732413, 1.427678896, 1.665625378, 1.903571861,
2.141518344, 2.379464826, 2.617411309, 2.855357792,
3.093304274, 3.331250757),
pH = c(6.71, 6.5875, 6.47, 6.3625, 6.265, 6.155, 6.0575,
5.945, 5.8275, 5.6875, 5.525, 5.37, 5.18, 4.9875,
4.81))
}
pH <- approx(td$cSO4, td$pH, xout = conc_SO4, rule = 2)$y
cSO4 <- approx(td$pH, td$cSO4, xout = pH_target, rule = 2)$y
return(list(pH = pH, cSO4 = cSO4))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.