Archive for the ‘course management systems’ Category

h1

Notebook 1.4: Trends in Boyle temperatures

January 15, 2010

All of those ugly, clunky-looking equations of state for real gases have to simplify to PV = nRT at very low pressure. It’s tempting to say that real gases behave like ideal gases under those conditions, but that isn’t quite right.

Even at pressures near zero, all of the properties of real gases won’t become ideal. In particular, any property that depends on the second (and higher) virial coefficient won’t necessarily converge to its ideal gas value as pressure drops. That convergence occurs only at the Boyle temperature, where the second virial coefficient is zero …as long as we assume all the higher order virial coefficients are zero, too. Usually that isn’t a bad assumption.

The Euler notebook posted below asks students to find the Boyle temperatures of noble gases from the van der Waals equation of state. They then critically examine trends in their calculated Boyle temperatures. The notebook introduces algebraic calculations with Maxima, including limits, differentiation, and equation solving.

To use the notebook:

  • Download and install the Euler Math Toolbox.
  • Cut and paste the code below into a plain text file.
  • Save the file with an .en file extension.
  • Double-click the file. It should open up in the Toolbox.

All of the notebooks in this series are specifically keyed to Atkins’ Physical Chemistry, 8th edition. Italics mark the items students had to fill in themselves.

—————————-snip here———————————————
 Notebook 1.4: Boyle Temperatures of Noble Gases
% 
% In this notebook, we'll use Euler's symbolic math capabilities to
% derive an expression for the Boyle temperature in terms of the 
% van der Waals constants a and b. You'll then use this expression
% to try to discover periodic trends in the Boyle temperature.
% 
% We can derive algebraic expressions in a notebook using Euler.
% Symbolic algebra and calculus can be done with a software package 
% called Maxima which is built into Euler. We can talk to Maxima
% directly by typing a colon (':') after the '>' prompt.
% For example, here is the van der Waals equation in Maxima:
% 
>: (P+a/V^2)*(V-b)=R*T
 
                              a
                             (-- + P) (V - b) = R T
                               2
                              V
 
% 
% If you forget to type : after the > prompt, the command gets
% sent to Euler, not to Maxima. Euler will give you an error 
% message (because it can't compute a result unless you assign numbers
% to each variable). 
% 
% It's useful to name equations, variables, and expressions so
% we don't have to type them over and over again. Maxima lets us
% type a name (say, 'vdw') followed by a colon to name an 
% expression: 
% 
>: vdw : (P+a/V^2)*(V-b)=R*T
 
                              a
                             (-- + P) (V - b) = R T
                               2
                              V
 
% 
% Use a colon to set a name, not an equal sign- you can see 
% from the previous line that '=' means equality, not assignment!
% 
% Now we can just type vdw when we want the van der Waals equation:
% 
>: vdw
 
                              a
                             (-- + P) (V - b) = R T
                               2
                              V
 
% 
% We can make substitutions in the equation using the at() function,
% which looks like at(expression,[conditions]). For example, to see
% that the van der Waals equation is the ideal gas 
% equation when a and b are zero, we could type
% 
>: at(vdw,[a=0,b=0])
 
                                    P V = R T
 
% 
% To solve an equation in Maxima, type solve(equation,x), where
% equation is the equation you want to solve and x is the variable
% to solve for. For example, to solve the equation 
% 2*x^2 + 3*x + 1 = 0 for x, you could type 
% 
>: solve(2*x^2 + 3*x + 1 = 0, x)
 
                                      1
                               [x = - -, x = - 1]
                                      2
 
% 
% Notice that the result is an array; there are two 
% solutions to this quadratic equation.  
% 
% To solve the van der Waals equation for P, you could type
% 
>: solve(vdw,P)
 
                                      2
                                 R T V  - a V + a b
                            [P = ------------------]
                                      3      2
                                     V  - b V
 
% 
% Notice that solve returns an array of solutions - even when 
% there is only one solution, as is the case here. We can 
% extract the % solution from the array by putting a subscript
% 1 (which is written as [1]) after solve:
% 
>: solve(vdw,P)[1]
 
                                      2
                                 R T V  - a V + a b
                             P = ------------------
                                      3      2
                                     V  - b V
 
% 
% The square brackets are gone. Suppose we're just interested
% in the right hand side of this equation. We can use 
% Maxima's rhs function to extract the right hand side:
% 
>: Pvdw : rhs(solve(vdw,P)[1])
 
                                    2
                               R T V  - a V + a b
                               ------------------
                                    3      2
                                   V  - b V
 
% 
% This doesn't look like equation 1.21a from the textbook-
% but it is! You can check to see that Pvdw really is 
% equivalent to R*T/(V-b) - a/V^2 by typing
% 
>: is(equal(Pvdw, R*T/(V-b) - a/V^2))
 
                                      true
 
% 
% Maxima reports and uses expressions in the form of rational polynomials
% (ratios of polynomials). As physical chemists, we would rather
% write expressions broken into separate terms that have some physical
% meaning.
% 
% Maxima can rearrange or simplify the expression, but we have to
% tell it what we want. Here, the partfrac() function can be used.
% The call looks like partfrac(expression,x) where the expression
% is expanded into fractions with powers of x in the denominator.
% Here we can use
% 
>: partfrac(Pvdw,V)
 
                                    R T    a
                                   ----- - --
                                   V - b    2
                                           V
 
% 
% which is exactly how the textbook writes the van der Waals
% equation.
% 
% We can also check to see if Pvdw is correct by seeing that Pvdw
% becomes equal to Pideal as V approaches infinity (which is typed
% as 'inf' in Maxima). To calculate the limit of y as x approaches
% a, type limit(y,x,a). If you enter
>: limit(Pvdw,V,inf)
 
 Is  R T  positive, negative, or zero?
 
>: positive
 
                                        0
 
% Maxima asks whether RT is positive, negative, or zero, and
% you must answer to get the limit. (When you answer, type : after
% the prompt, or the answer goes to Euler, not to Maxima) 
% Maxima then tells us that 
% Pvdw approaches 0 as V approaches infinity, which isn't the same
% as saying it approaches Pideal. Instead, we can define Pideal
% and see whether Pideal/Pvdw approaches 1 as V approaches infinity:
% 
>: Pideal : R*T/V
 
                                       R T
                                       ---
                                        V
 
>: limit(Pideal/Pvdw,V,inf)
 
                                        1
 
% We can also check derivatives of Pvdw this way. As Pvdw approaches
% Pideal, all of the derivatives of Pvdw should approach corresponding
% derivatives of Pideal. 
% 
% It's easy to calculate derivatives in Maxima. The derivative of
%%y with respect to x would be typed diff(y,x). To calculate the
% derivative of Pvdw with respect to V, we can type
>: dPdV_vdw : diff(Pvdw,V)
 
                                  2                2
                2 R T V - a   (3 V  - 2 b V) (R T V  - a V + a b)
                ----------- - -----------------------------------
                  3      2                 3      2 2
                 V  - b V                (V  - b V )
 
% In the space below, calculate the derivative of Pideal with respect
% to V and name it dPdV_ideal.
% 
>: dPdV_ideal : diff(Pideal,V)
 
                                        R T
                                      - ---
                                         2
                                        V
 
% In the space below, show that dP/dV for a van der Waals gas approaches
% dP/dV for an ideal gas as V approaches infinity.
% 
>: limit(dPdV_ideal/dPdV_vdw,V,inf)
 
                                        1
 
% 
% ----------------------------------------------------------------
% 
% Now let's derive an exptression for the Boyle temperature of a
% van der Waals gas. Our approach will be to:
%%1. Calculate dZ/d(1/V) for a van der Waals gas.
%%2. Calculate B as the limit of dZ/d(1/V) as V approaches
%%infinity.
%%3. Find the Boyle temperature as the the temperature where
%%B = 0.
% 
% In the space below, calculate the compressibility factor for a
% van der Waals gas and call it Z_vdw.
% 
>: Z_vdw : Pvdw*V/(R*T)
 
                                     2
                             V (R T V  - a V + a b)
                             ----------------------
                                      3      2
                                R T (V  - b V )
 
% In the space below, calculate the derivative of Z with respect
% to V, and call it dZdV.
% 
>: dZdV : diff(Z_vdw,V)
 
             2
        R T V  - a V + a b   V (2 R T V - a)
        ------------------ + ---------------
               3      2            3      2
         R T (V  - b V )     R T (V  - b V )
                                                 2                2
                                           V (3 V  - 2 b V) (R T V  - a V + a b)
                                         - -------------------------------------
                                                           3      2 2
                                                     R T (V  - b V )
 
% In the space below, calculate the derivative dZ/d(1/V) and call
% it dZd1V. HINT: dy/dx = -(dy/dz)/(dx/dz). 
% 
>: dZd1V : -dZdV/diff(1/V,V)
 
                     2
           2    R T V  - a V + a b   V (2 R T V - a)
        - V  (- ------------------ - ---------------
                       3      2            3      2
                 R T (V  - b V )     R T (V  - b V )
                                                2                2
                                          V (3 V  - 2 b V) (R T V  - a V + a b)
                                        + -------------------------------------)
                                                          3      2 2
                                                    R T (V  - b V )
 
% In the space below, calculate B as the limit of dZ/d(1/V) as V
% approaches infinity. Name it B.
% 
>: B : limit(dZd1V,V,inf)
 
                                     b R T - a
                                   - ---------
                                        R T
 
% In the space below, calculate the Boyle temperature as the temperature
% where B = 0. Call the Boyle temperature TB.
% 
>: TB: rhs(solve(B=0,T)[1])
 
                                        a
                                       ---
                                       b R
 
% Now let's see how well this equation works by looking at trends
% in Boyle temperature for the noble gases. Because we'll be calculating
% numbers and making graphs, we'll switch from Maxima back to Euler.
% 
% In the space below, define arrays a and b that contain the van
% der Waals constants for the noble gases He, Ne, Ar, Kr, and Xe,
% in that order. Take the numbers from Atkins Table 1.6 in the Data
% Section at the end of the book.
% 
>a = [0.0341,0.205,1.337,5.125,4.137]; 
>b = [2.38e-2,1.67e-2,3.20e-2,1.06e-2,5.16e-2];
% In the space below, assign R in units consistent with the units
% for a and b.
% 
>R = 0.082059;
% Next we will calculate an array of predicted Boyle temperatures
% for the noble gases, using the formula we derived in Maxima. Although
% the formula is so simple that it's easy to just retype it in Euler,
% let's see how you would move equations and expressions from Maxima
% into Euler.
% 
% The Euler function mxm() returns a named object in Maxima as a
% text string:
% 
>mxm("TB")
 a/(b*R)
% 
% To evaluate a text string in Euler, use the evaluate() function:
% 
>TB = evaluate(mxm("TB"))
      17.46027991133      149.5929648399      509.1610914098      5891.987058552      977.0338245001 
% 
% In the space below, plot the Boyle temperatures on the y axis
% with atomic number on the x axis. Insert the plot into this notebook.
% As always, title the plot and label the axes.
>atomicnumber = [2,10,18,36,54];
>plot2d(atomicnumber,TB);
>title("Boyle Temperature Trend for the Noble Gases");
>xlabel("Atomic Number");
>ylabel("Boyle Temperature (K)");
>insimg;

% 
% We'd expect the Boyle temperature to increase with increasing
% intermolecular attraction (a) and with decreasing molecular volume
% (b), so it's conceivable that the Boyle temperature might gradually
% rise and then fall going from He to Xe- but the huge spike in
% Boyle temperature at Kr is hard to miss. Either something is wrong
% with the data or calculations, or we have discovered something
% interesting about Kr.
% 
% In the space below, draw the plot again, but this time use van
% der Waals parameters from some other source (such as the CRC handbook).
>a = [0.03412,0.2107,1.345,2.318,4.194];
>b = [2.37e-2,1.709e-2,3.219e-2,3.78e-2,5.105e-2];
>TB = a/(b*R);
>plot2d(atomicnumber,TB);
>title("Boyle Temperature Trend for the Noble Gases");
>xlabel("Atomic Number");
>ylabel("Boyle Temperature (K)");
>insimg;

% 
% The moral of this last plot is: always double-check data points
% that don't fit the pattern implied by the rest of the data. Discordant
% points indicate either an error or an interesting discovery. 
% 
% The little cusp at Ar is interesting. To see if it's real, add
% a curve that shows the true Boyle temperatures as a thicker line
% on the plot. Insert the plot into this notebook again in the space
% below.
% 
>TB = [22.64,122.1,411.5,575,768];
>plot2d(atomicnumber,TB,add=1,thickness=2); insimg;

% 
% Explain the deviation between the true and van der Waals Boyle
% temperatures in terms of intermolecular forces. Does the van der
% Waals equation overestimate or underestimate the strength of intermolecular
% attractions?
% 
% ANSWER: The equation for the Boyle temperature we derived above
% shows that the larger a is, the higher the Boyle temperature will
% be. This suggests that the that the stronger intermolecular attractions
% are, the higher the Boyle temperature must be.
% 
% However the van der Waals predictions of the Boyle temperature
% are too high. That suggests that the van der Waals equation overestimates
% the strength of intermolecular attractions.
% 
—————————-snip here———————————————
Advertisements
h1

Moodle vs. Blackboard: Equation Input & Graphing

September 10, 2009

Moodle’s equation input and interactive graphing facilities make it a better choice than Blackboard for teaching chemistry or math online. Jacek Polewczak and Carol Shubin at CSU Northridge compare the two:

Scientific input in Moodle and WebCT8/Blackboard9 (April 6, 2009)