h1

Notebook 2.0: Introducing integration with Maxima

January 16, 2010

This very simple Euler notebook introduces integration with Maxima by asking students to set up simple integrals for calculating expansion work.

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 2.0 - Integration with Maxima
% 
% When we're finding derivatives, we are finding the instantaneous rate
% of change for a function. For example, we can see how P changes with 
% V for an ideal gas by calculating the derivative dP/dV at constant T:
 
>: Pideal : R*T/V
>: dPdV_ideal : diff(Pideal,V)
 
                                        R T
                                      - ---
                                         2
                                        V
 
>: Pvdw : R*T/(V-b)-a/V^2
>: dPdV_vdw : diff(Pvdw, V)
 
                                 2 a     R T
                                 --- - --------
                                  3           2
                                 V     (V - b)
 
% 
% Often we want to calculate the change in a variable from its rate
% of change. For example, if we have dP/dV, we can reverse the process
% above to find P, by integrating the derivative with respect to
% V:
% 
>: Pideal : integrate(dPdV_ideal,V)
 
                                       R T
                                       ---
                                        V
 
>: Pvdw : integrate(dPdV_vdw,V)
 
                                    R T    a
                                   ----- - --
                                   V - b    2
                                           V
 
% 
% Integration undoes differentiation, and vice versa:
% 
>: integrate(diff(Pideal,V),V)
 
                                       R T
                                       ---
                                        V
 
>: diff(integrate(Pideal, V),V)
 
                                       R T
                                       ---
                                        V
 
% -------------------------------------------------------------------------------------
% In the space below, calculate the derivative of P for a Dieterici gas with respect
% to V (with T held constant. Call it dPdV_Dieterici.
% 
 
>: P_Dieterici : R*T*exp(-a/(R*T*V))/(V-b)
>: dPdV_Dieterici : diff(P_Dieterici,V)
 
% -------------------------------------------------------------------------------------
% In the space below, show that integrating dPdV_Dieterici gives back
% P for a Dieterici gas..
% 
>: integrate(dPdV_Dieterici,V)
% -------------------------------------------------------------------------------------
% We can use integration to calculate the work done during gas expansions, or the work
% required to compress a gas. This is done by integrating the external pressure (NOT the
% gas pressure) with respect to volume, over some volume range. 
% 
% In Maxima, you can integrate over a range by adding the beginning and end of the range as 
% third and fourth arguments for the integrate() function. For example, the work done to compress a gas from 4 m^3 to 2 m^3 under an external
% pressure of 101000 Pa is
 
>: work: -integrate(101000,V,4,2)
 
% When Pext is constant, the work is simply -Pext times the volume change, so we could have
% calculated the work more simply as
% 
>: work: -101000*(2-4)
% 
% Both calculations give work in joules, because we've used SI units (pascals and cubic meters)
% throughout the calculation. 
% 
% In the space below, calculate the work done (in joules) when a sample of 1.70 mol of argon gas
% expands from 20 L to 50 L against a constant external pressure equal to the final
% pressure of the gas. The temperature of the gas is 25 degrees C.
% 
>: n: 1.70
>: R: 8.314
>: T: 25+273.15
>: V2: 50*1e-3
>: V1: 20*1e-3
>: Pext: n*R*T/V2
>: work: -integrate(Pext,V,V1,V2)
% or, more simply,
>: work: -Pext*(V2-V1)
% -------------------------------------------------------------------------------------
% In the space below, calculate the expansion work done when 1 mole of water is electrolysed
% under a constant 1 atm external pressure at 298 K. Hint: Study example 2.1 in the text!
% 
% Solution: The work is equal to -Pext times the volume change. The initial volume of the water
% is 1 mol * 18 g/mol * 1 mL / 1 g * 1e-3 L/ 1 mL * 1 dm^3 / 1 L * 1e-3 m^3 / 1 dm^3
>:  V1: 1*18*1*1e-3*1*1e-3
% 1/2 mol of O2 and 1 mole of H2 is produced by the reaction. The final pressure of the gases
% will be equal to the external pressure. If the gases are assumed to be ideal, the final volume is
% n*R*T/Pext.
>: n: 1.5
>: R: 8.314
>: T: 298
>: Pext: 1 * 101325
>: V2: n*R*T/Pext
% and the work is
>: work: -integrate(Pext,V,V1,V2)
% or, equivalently, 
>: work: -Pext*(V2-V1)
% We could have simplified the solution by neglecting V1, since gases have about 1000 times
% the molar volume of liquids around room temperature and pressure. Then the work is 
% approximately
>: work: -Pext*V2
------------------------------------snip here------------------------------------
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: