# ### initialize the lognormal mass and number distributions for 30 bins # In[40]: # #set the edges of the mass bins #31 edges means we have 30 droplet bins # numrads = 30 mass_vals = np.linspace(-20,-16,numrads+1) mass_vals = 10**mass_vals #aerosol mass in kg mu=input_dict['aerosol']['themean'] sigma = input_dict['aerosol']['sd'] totmass = input_dict['aerosol']['totmass'] mdist = totmass*lognormal(mass_vals,np.log(mu),np.log(sigma)) mdist = find_centers(mdist)*np.diff(mass_vals) #kg/m^3 of aerosol in each bin center_mass = find_centers(mass_vals) ndist = mdist/center_mass #number/m^3 of aerosol in each bin #save these in an ordered dictionary to pass to functions cloud_vars = od() cloud_vars['mdist'] = mdist cloud_vars['ndist'] = ndist cloud_vars['center_mass'] = center_mass cloud_vars['koehler_fun'] = koehler_fun # ### find the equilibrium radius for each bin at saturation Sinit # In[41]: S_target = parcel.Sinit
pp.pprint(input_dict) # ### Calculate the lognormal aerosol mass distribution and get the number concentration in each of 30 bins # # (code borrowed from aero.ipynb) # In[53]: mass_vals = np.linspace(-20,-16,30) mass_vals = 10**mass_vals mu=input_dict['aerosol']['themean'] sigma = input_dict['aerosol']['sd'] totmass = input_dict['aerosol']['totmass'] mdist = totmass*lognormal(mass_vals,np.log(mu),np.log(sigma)) mdist = find_centers(mdist)*np.diff(mass_vals) center_mass = find_centers(mass_vals) ndist = mdist/center_mass # ### Find the equilibrium radius for each of the 30 aerosol masses # # (code borrowed from koehler.ipynb) # ### Python note -- using function factories ("closures") # # A closure is a function object that remembers values in its "enclosing scope" # (see e.g [this article](http://www.shutupandship.com/2012/01/python-closures-explained.html)). For example, instead of # writing: # # ```python