Skip to content

Instantly share code, notes, and snippets.

@RyanHope
Created June 24, 2013 16:48
Show Gist options
  • Save RyanHope/5851550 to your computer and use it in GitHub Desktop.
Save RyanHope/5851550 to your computer and use it in GitHub Desktop.
Slow Force Carbonation Functions for R
bars <- function(temp, psi) {
(psi+14.695)*(0.01821+0.090115*exp(-(temp-32)/43.11))-0.003342
}
psi <- function(bars, temp) {
((bars+0.003342)/(0.01821+0.090115*exp(-(temp-32)/43.11)))-14.695
}
temp <- function(bars, psi) {
-log(((bars+0.003342)/(psi+14.695)-0.01821)/0.090115)*43.11+32
}
# > bars(49, 12)
# [1] 2.104462
# > psi(2.104462, 49)
# [1] 12
# > temp(2.104462, 12)
# [1] 49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment