#################################################################################################################
## Function to calculate rise velocity of dirty bubbles in quiescent liquid
#################################################################################################################

###########################################################################################
## created by Marcus Klaus, Swedish University of Agricultural Sciences (SLU), Umeå, Sweden
## contact: marcus.klaus@slu.se
## last update: 2026/04/30
###########################################################################################

## INPUTS:
# r_m... bubble radius (m)
# g... gravity acceleration (m/s2)
# p... Water density (kg/m3)
# v... kinemtic viscosity (m2/s)

## OUTPUT:
# Vb... bubble rise velocity (m/s)

## Using different equations depending on bubble size

## References
# Thorpe (1982): On the clouds of bubbles formed by breaking wind-waves in deep water, and their role in air-sea gas transfer. 
# Phil. Trans. R. Soc. Lond. A 304, 155-210

# Leifer et al. (2002): The bubble mechanism for methane transport from the shallow
# sea bed to the surface: A review and sensitivity study. Continental Shelf Research 22 (2002) 2409–2428
###########################################################################################

calcBubbleRiseVelocity <- function(r_m,g,p,v){

if(r_m<600*10^-6){
  # r<600 micron (Thorpe 1982, Eq. 13)
  # m/s2 * m3 /(m2/s)^2 = unitless
  X=g*r_m^3/(v^2) 
  y=10.82/X # shape correction factor (unitless)
  # unit: m2 * Kg/m3 * m/s2 / (m2/s) 
  Vb=2/9*(r_m^2*p/1000*g/v)*((y^2+2*y)^(1/2)-y)
}else{
  # dirty bubble for 600<r<10000 microns (Leifer et al. 2002, Eq. 16, original in Clift et al. (1978))
  Vb=(276*(r_m*100) - 1648*(r_m*100)^2 + 4882*(r_m*100)^3 - 7429*(r_m*100)^4 + 5618*(r_m*100)^5 - 1670*(r_m*100)^6)/100
}
  
  return(Vb)
  
}
