<s> """<STR_LIT>""" <EOL> from math import * <EOL> def AirDensity ( RH , Tc , P = <NUM_LIT> ) : <EOL> Rd = <NUM_LIT> <EOL> q = <NUM_LIT> * ( RH * SatVapor ( Tc ) ) / P <EOL> Tv = ( Tc + <NUM_LIT> ) * ( <NUM_LIT:1.0> + <NUM_LIT> * q ) <EOL> P *= <NUM_LIT> <EOL> rho_a = P / ( Rd * Tv ) <EOL> return rho_a <EOL> def PsychConst ( P , cP = <NUM_LIT> , lambda_v = <NUM_LIT> ) : <EOL> gamma = ( cP * P / ( <NUM_LIT> * lambda_v ) ) <EOL> return gamma <EOL> def SatVaporPress ( Tc ) : <EOL> eSat = <NUM_LIT> * exp ( <NUM_LIT> * Tc / ( <NUM_LIT> + Tc ) ) <EOL> return eSat <EOL> def SlopeSatVaporPress ( Tc ) : <EOL> delta = <NUM_LIT> * SatVaporPress ( Tc ) / ( <NUM_LIT> + Tc ) ** <NUM_LIT:2> <EOL> return delta <EOL> def AeroReist ( um , zm , z0 , d , zmp = zm ) : <EOL> k = <NUM_LIT> <EOL> r_a = <NUM_LIT:1.0> / ( k ** <NUM_LIT:2> * um ) * log ( ( zm - d ) / z0 ) * log ( ( zmp - d ) / ( z0 / <NUM_LIT> ) ) <EOL> return r_a <EOL> def SurfResist ( g0 , S , D , Tc , SM , SM0 ) : <EOL> g_c = Gee_C ( ) <EOL> g_R = Gee_R ( S ) <EOL> g_D = Gee_D ( D ) <EOL> g_T = Gee_T ( Tc + <NUM_LIT> ) <EOL> g_M = Gee_M ( SM , SM0 ) <EOL> g_s = g0 * g_c * g_R * g_D * g_T * g_M <EOL> r_s = <NUM_LIT:1.0> / g_s <EOL> return r_s <EOL> def Gee_c ( ) : <EOL> g_c = <NUM_LIT:1.0> <EOL> return g_c <EOL> def Gee_R ( S , K_R = <NUM_LIT> ) : <EOL> g_R = ( S * ( <NUM_LIT> + K_R ) ) / ( <NUM_LIT> * ( S + K_R ) ) <EOL> return g_R <EOL> def Gee_D ( D , K_D1 = - <NUM_LIT> , K_D2 = <NUM_LIT> ) : <EOL> g_D = <NUM_LIT:1.0> + K_D1 * D + K_D2 * D ** <NUM_LIT:2> <EOL> return g_D <EOL> def Gee_T ( TK , TL = <NUM_LIT> , TH = <NUM_LIT> , T0 = <NUM_LIT> ) : <EOL> alpha_T = ( TH - T0 ) / ( T0 - TL ) <EOL> g_T = ( ( TK - TL ) * ( TH - TK ) ** alpha_T ) / ( ( T0 - TL ) * ( TH - T0 ) ** alpha_T ) <EOL> return g_T <EOL> def Gee_M ( SM , SM0 , K_M1 , K_M2 ) : <EOL> g_SM = <NUM_LIT:1.0> - K_M1 * exp ( K_M2 * ( SM - SM0 ) ) <EOL> return g_SM <EOL> def PenmanMonteithPET ( Tc , RH , Rn , S , SM , um , z0 , d , g0 , SM0 , P = <NUM_LIT> , zm = <NUM_LIT> ) : <EOL> cP = <NUM_LIT> <EOL> rho_a = AirDensity ( RH , Tc , P ) <EOL> D = ( <NUM_LIT:1.0> - RH ) * SatVaporPress ( Tc ) <EOL> delta = SlopeSatVaporPress ( Tc ) <EOL> gamma = PsychConst ( P ) <EOL> r_a = AeroReist ( um , zm , z0 , d ) <EOL> r_s = SurfResist ( g0 , S , D , Tc , SM , SM0 ) <EOL> LE = ( delta * Rn + ( rho_a * cP * D ) / r_a ) / ( delta + gamma * ( <NUM_LIT:1.0> + r_s / r_a ) ) <EOL> return LE </s>
