def make_ammonium_sulfate(epsilon=0.3, N=200.): ammonium_sulfate = { 'Ms': 0.13214, # Molecular weight, kg/mol 'rho_s': 1.769*1e-3*1e6, 'rho_u': 1.769*1e-3*1e6, 'nu': 3.0, # number of ions into which a solute dissolve 'epsilon': epsilon # mass fraction of soluble material in the dry particle } ammonium_sulfate['rho_p'] = 1.769*1e-3*1e6 mu, sigma, bins, N = 0.05, 2.0, 50, N l = 0 r = bins aerosol_dist = Lognorm(mu=mu, sigma=sigma, N=N) rs = np.logspace(np.log10(mu/(sigma*10.)), np.log10(mu*sigma*10), num=bins+1)[:] mids = np.array([np.sqrt(a*b) for a, b in zip(rs[:-1], rs[1:])])[l:r] Nis = np.array([0.5*(b-a)*(aerosol_dist.pdf(a) + aerosol_dist.pdf(b)) for a, b in zip(rs[:-1], rs[1:])])[l:r] r_drys = mids*1e-6 ammonium_sulfate['distribution'] = aerosol_dist ammonium_sulfate['r_drys'] = r_drys ammonium_sulfate['rs'] = rs ammonium_sulfate['Nis'] = Nis*1e6 ammonium_sulfate['species'] = '(NH4)2SO4' ammonium_sulfate['nr'] = len(r_drys) return AerosolSpecies(**ammonium_sulfate)
from chi_square import Chi_square from exponential import Exponential from f_dist import F_dist from gamma import Gamma from inv_gamma import Inverse_gamma from student_t import Student_t from uniform import Uniform from numpy import array x = array([1.2, 1.5, 2.1, 5.4]) x2 = array([.1, .3, .4, .7]) mu, sigma, alpha, beta, k, gamma, d1, d2, kk, theta = [1.2, 2.3, .4, .5, 4, 3, 4, 6, 1.6, .7] lnorm = Lognorm(mu, sigma) norm = Normal(mu, sigma) beta = Beta(alpha, beta) chi = Chi(k) chi2 = Chi_square(k) exp = Exponential(gamma) f = F_dist(d1, d2) gamma = Gamma(kk, theta) invgamma = Inverse_gamma(mu, sigma) t = Student_t(d2) uniform = Uniform(alpha, d2) print 'lnorm.cdf(x): ', lnorm.cdf(x) print 'norm.cdf(x): ', norm.cdf(x) print 'beta.cdf(x2): ', beta.cdf(x2) print 'chi.cdf(x): ', chi.cdf(x)
from exponential import Exponential from f_dist import F_dist from gamma import Gamma from inv_gamma import Inverse_gamma from student_t import Student_t from uniform import Uniform from numpy import array x = array([1.2, 1.5, 2.1, 5.4]) x2 = array([.1, .3, .4, .7]) mu, sigma, alpha, beta, k, gamma, d1, d2, kk, theta = [ 1.2, 2.3, .4, .5, 4, 3, 4, 6, 1.6, .7 ] lnorm = Lognorm(mu, sigma) norm = Normal(mu, sigma) beta = Beta(alpha, beta) chi = Chi(k) chi2 = Chi_square(k) exp = Exponential(gamma) f = F_dist(d1, d2) gamma = Gamma(kk, theta) invgamma = Inverse_gamma(mu, sigma) t = Student_t(d2) uniform = Uniform(alpha, d2) print 'lnorm.cdf(x): ', lnorm.cdf(x) print 'norm.cdf(x): ', norm.cdf(x) print 'beta.cdf(x2): ', beta.cdf(x2) print 'chi.cdf(x): ', chi.cdf(x)