###########################################################################################
###########################################################################################
# Function to calculate Surface tension of water from temperature
###########################################################################################
###########################################################################################
## created by Marcus Klaus, Swedish University of Agricultural Sciences (SLU), Umeå, Sweden
## contact: marcus.klaus@slu.se
## last update: 2026/04/30
###########################################################################################

## INPUTS:
# T...water temperature (°C)

## OUTPUTS:
# sigma...surface tension (N/m=Kg/s2) 

## References
# fitted to data in Table 86 in  
# Jasper (1972): The Surface Tension of Pure Liquid Compounds. Journal of Physical and Chemical Reference Data 1,
# 841; https://doi.org/10.1063/1.3253106

## Note:
# - parameterization was derived for temperature from 10 to 40 °C
# - surface tension of natural water also depends on water chemistry, besides temperature, which is neglected here
###########################################################################################

Temp2SurfTension <- function(T){
  
  visTable <- c(74.36,73.62,72.88,72.14,71.40,70.66,69.92)
  tempTable <- c(10,15,20,25,30,35,40)
  sigmamodel <- lm(visTable~tempTable)
  sigma <- as.numeric(predict(sigmamodel,newdata=data.frame(tempTable=T))/1000)
  
  return(sigma)
}
