def calc_enthalpy(point_dict): """ Calculate the enthalpy and total water mixing ratio for an air parcel, given a dictionary or parameters Parameters ---------- point_dict: dictionary dictionary with the following keys ['id','temp','rv','rl','press'] units: point letter, K kg/kg kg/kg Pa Returns ------- vals: named tuple tuple with dictionary values plus rt (kg/kg) and enthalpy (J/kg) """ point_dict['rt'] = point_dict['rv'] + point_dict['rl'] vals = make_tuple(point_dict) cp = c.cpd + vals.rt*c.cl point_dict['enthalpy'] = cp*vals.temp + find_lv(vals.temp)*vals.rv vals = make_tuple(point_dict) return vals
def find_derivs(var_vec, the_time, cloud_tup): """ calcuate derivatives of var_vec Parameters ---------- var_vec: vector(float) vector of values to be integrated the_time: float timestep cloud_tup: namedtuple tuple of necessary coefficients Returns ------- deriv_vec: vector(float) derivatives of each of var_vec """ # print('inside: ',var_vec) temp, press, height = var_vec[-3:] numrads = len(var_vec) - 3 dry_radius = cloud_tup.dry_radius rho = press / (c.Rd * temp) # # find the evironmental S by water balance # S = Scalc(var_vec, cloud_tup) deriv_vec = np.zeros_like(var_vec) # dropgrow notes equaton 18 (W&H p. 170) for i in range(numrads): m = cloud_tup.masses[i] if var_vec[i] < dry_radius[i]: var_vec[i] = dry_radius[i] Seq = cloud_tup.koehler_fun(var_vec[i], m) rhovr = (Seq * find_esat(temp)) / (c.Rv * temp) rhovinf = S * find_esat(temp) / (c.Rv * temp) # day 25 drop_grow.pdf eqn. 18 deriv_vec[i] = (c.D / (var_vec[i] * c.rhol)) * (rhovinf - rhovr) # # moist adiabat day 25 equation 21a # deriv_vec[-3] = find_lv(temp) / c.cpd * wlderiv(var_vec, deriv_vec, cloud_tup) - c.g0 / c.cpd * cloud_tup.wvel # # hydrostatic balance dp/dt = -rho g dz/dt # deriv_vec[-2] = -1.0 * rho * c.g0 * cloud_tup.wvel # # how far up have we traveled? # deriv_vec[-1] = cloud_tup.wvel return deriv_vec
def therm_calc(the_row): rT = cloud_vars['wt'] S = the_row[-1] temp, press,height = the_row[-4:-1] esat = find_esat(temp) e = S*esat rv = c.eps*e/(press - e) #Thompkins eqn 2.20 Td = find_Td(rv,press) thetae = find_thetaet(Td,rT,temp,press) hm = c.cpd*temp + find_lv(temp)*rv + c.g0*height return (thetae, hm)