"""This script makes a plot of the constant-L approximation for the saturation vapor pressure for water, switching from sublimation to vaporization latent heat at the triple point """ #Updated 10/31/2011. # Eliminated unneeded import of Numeric # Added comments related to using a gas object as an argument # Added axis labels #Updates 11/12/2013: Shortened Labels of ice vs. liquid curves #Data on section of text which this script is associated with #**ToDo: Chapter and Figure references can be given in terms of #LaTeX labels, which can then be turned into numbers using #information in the .aux files LaTeX produces. This isn't so #necessary for the Chapter refs, which won't change much, but #it would be useful for the Figure refs. Chapter = '2.**' Figure = '**' # import phys from ClimateUtilities import * # stuff = phys.water # Put your favorite substance here #Set up a list of temperatures Tlist = [200. + i for i in range(121)] #Make empty lists to hold results of the three calculations psatw = [] psati = [] #Compute the three saturation vapor pressures by looping #over the temperatures in the list. Append the results #to the appropriate lists. # #Note that instead of passing #the thermodynamic properties as three separate arguments #to phys.satvps_function, you could instead just use the #gas object as the argument, as in #satvps = phys.satvps_function(stuff) #However, by default this uses the sublimation latent heat #for temperature below the triple point and the vaporization #latent heat above the triple point (which is usually what you #want). Here, we want to illustrate the difference between vapor #pressure over ice and over liquid, so we set the latent heat #explicitly to the one we want in each case. An alternate #way to do this is to use a gas object as argument, but to specify #which latent heat you want with the optional second argument, e.g. #satvps_w = phys.satvps_function(stuff,'liquid') #satvps_i = phys.satvps_function(stuff,'ice') # satvps_w = phys.satvps_function( stuff.TriplePointT,stuff.TriplePointP,stuff.MolecularWeight,stuff.L_vaporization) satvps_i = phys.satvps_function( stuff.TriplePointT,stuff.TriplePointP,stuff.MolecularWeight,stuff.L_sublimation) for T in Tlist: psatw.append(satvps_w(T)) #Exponential form based on L for water psati.append(satvps_i(T)) #Exponential form based on L for ice #Put the results in a data structure for plotting c = Curve() c.addCurve(Tlist,'T','Temperature') c.addCurve(psatw,'ps_w','Const L (liquid)') c.addCurve(psati,'ps_i','Const. L (ice)') # # Set the plotting options. We use a logarithmic axis because the saturation # vapor pressure varies over such a great range c.YlogAxis = True c.Xlabel = 'Temperature (K)' c.Ylabel = 'Pressure (Pa)' c.PlotTitle = 'Saturation Vapor Pressure for '+stuff.name #Do the plot. plot(c) # #Write out to file c.dump()