barakuda_thermo.py 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. # Misc :
  2. import sys
  3. import numpy as nmp
  4. import math
  5. rt0 = 273.16
  6. grav = 9.8 # gravity
  7. Rgas = 287.04
  8. Patm = 101000.
  9. ctv = 0.608 # for virtual temperature
  10. R_dry = 287.05 # Specific gas constant for dry air [J/K/kg]
  11. R_vap = 461.495 # Specific gas constant for water vapor [J/K/kg]
  12. reps0 = R_dry/R_vap # ratio of gas constant for dry air and water vapor => ~ 0.622
  13. cte = 0.622
  14. kappa = 0.4 # Von Karman's constant
  15. Cp = 1000.5
  16. Pi = 3.141592654
  17. eps_w = 0.987 # emissivity of water
  18. sigma = 5.67E-8 # Stefan Boltzman constamt
  19. alfa = 0.066 # Surface albedo over ocean
  20. rtt0 = 273.16 # triple point of temperature [K]
  21. sensit = 0.1
  22. def Lvap(zsst):
  23. #
  24. # INPUT : zsst => water temperature in [K]
  25. # OUTPUT : Lvap => Latent Heat of Vaporization [J/Kg]
  26. return ( 2.501 - 0.00237*(zsst - rt0) )*1.E6
  27. def e_air(q_air, zslp):
  28. #
  29. #--------------------------------------------------------------------
  30. # **** Function e_air ****
  31. #
  32. # Gives vapour pressure of air from pressure and specific humidity
  33. #
  34. #--------------------------------------------------------------------
  35. #
  36. diff = 1.E8
  37. e_old = q_air*zslp/reps0
  38. while diff > 1.:
  39. #print "Again... diff = ", diff
  40. ee = q_air/reps0*(zslp - (1. - reps0)*e_old)
  41. diff = nmp.sum(abs( ee - e_old ))
  42. e_old = ee
  43. return ee
  44. ### Update: June 2019, LB:
  45. def e_sat(rT):
  46. #
  47. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  48. # rT: air temperature [K]
  49. # e_sat: water vapor at saturation [Pa]
  50. #
  51. # Recommended by WMO
  52. #
  53. # Goff, J. A., 1957: Saturation pressure of water on the new kelvin
  54. # temperature scale. Transactions of the American society of heating
  55. # and ventilating engineers, 347.
  56. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  57. #
  58. ztmp1 = nmp.zeros(nmp.shape(rT))
  59. ztmp2 = nmp.zeros(nmp.shape(rT))
  60. ztmp2 = rT/rtt0
  61. ztmp1 = 1./ztmp2
  62. #
  63. #e_sat = 100.*( 10.^(10.79574*(1. - ztmp) - 5.028*LOG10(rT/rtt0) \
  64. # + 1.50475*10.^(-4)*(1. - 10.^(-8.2969*(rT/rtt0 - 1.)) ) \
  65. # + 0.42873*10.^(-3)*(10.^(4.76955*(1. - ztmp)) - 1.) + 0.78614) )
  66. #
  67. e_sat = 100.*( nmp.power(10.,(10.79574*(1. - ztmp1) - 5.028*nmp.log10(ztmp2) \
  68. + 1.50475*0.0001*(1. - nmp.power(10.,(-8.2969*(ztmp2 - 1.))) ) \
  69. + 0.42873*0.001 *(nmp.power(10.,(4.76955*(1. - ztmp1))) - 1.) + 0.78614 ) ) )
  70. #
  71. del ztmp1, ztmp2
  72. #
  73. return e_sat
  74. def q_air_dp(da, slp):
  75. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  76. # Air specific humidity from dew point temperature
  77. # da !: dew-point temperature [K]
  78. # slp !: atmospheric pressure [Pa]
  79. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  80. #
  81. es = e_sat(da)
  82. q_air_dp = es*reps0/(slp - (1. - reps0)*es)
  83. return q_air_dp