Boyle s Law: A Multivariable Model and Interactive Animated Simulation Using tools available in Excel, we will turn a multivariable model into an interactive animated simulation. Projectile motion, Boyle's Law, nuclear decay, and population growth are just a few examples of the types of models for which a simulation can be useful to deepen a student's understanding. Knowledge of the basic aspects of Excel is required. We are going to build an interactive simulation of Boyle s Law in Excel. Boyle s Law relates how volume influences the pressure of a trapped amount of gas at constant temperature. Boyle s Law is the basis of air exchange from your lungs. Materials needed Computers with Excel and Internet access Excel files: Boyle s_law.xls Building a Multivariable Simulation Let s investigate how pressure and volume are related for a gas. If we trap a constant amount of air in a cylinder at constant temperature, how will the pressure behave if the gas is compressed by shrinking the volume? Can you sketch and label a graph? What is the dependent variable? 2YC3 Conference, Rockville, MD/Sinex 1
Open the Excel file: Boyle s_law.xls and click once on the up arrow of the spinner. spinner Click on the add arrow and compress the gas by lowering the piston. Did your prediction match the graph of the experiment? You can connect the points with a smooth curve or add an equation to the fit the data by selecting the check boxes. How well does the equation fit the data? Now this was ideal data (no experimental error) from a simple simulation using Boyle s Law. From the equation on the graph: P = 50V -1 or P = 50/V or PV = 50. Complete the task outlined on the data tab (see screenshot on next page). 2YC3 Conference, Rockville, MD/Sinex 2
From the data and graph you may see that the relationship is PV = constant. So let s see what constitutes the constant and play with some error as well. Boyle s Law holds if temperature (T) and the amount of trapped gas (n) are constant or considering the Ideal gas law: PV = nrt where R is the gas constant (0.0821 L-atm/mole-K). We want to create a column of volume data for a syringe and then we will calculate the pressure as: PV = k k nrt P = = V V Now we have two more variables to change to see how they influence the pressure and change the graph. When you do this experiment it can be difficult to hold the syringe at constant volume especially at high pressures. So let s add some random error to the volume measurement. This will be done by the equation below, where noise is the noise in the volume data: ' V = V + noise*(randbetween(-10,10)/10) where noise varies from 0 (no error) to some positive value that is multiplied by a random number between -10 to +10 using the RANDBETWEEN function in Excel. Another error in this experiment is due to the tubing connecting the syringe to the pressure gauge or other measuring device. The tubing adds some extra volume 2YC3 Conference, Rockville, MD/Sinex 3
that is not accounted for without applying a correction. So let s add this in to the equation for volume above and convert it to liters. To get: ' V = (V + noise*(randbetween(-10,10)/10) + V tubing )/1000 The final calculation of pressure then becomes: nrt P = ((V + noise*(randbetween(-10,10)/10) + V )/1000) tubing Now we have four variables to adjust in this simulation. Okay to the spreadsheet Set up the worksheet to look like the screen shot below. If you use the same cells as illustrated here, all the formulas will be the same as what we get as a group. Now we need to place a formula to calculate in cell B5. To make the formula look more like a real formula and not spreadsheet notation, let s name the variable. Go to the Formula tab and select Define Name and then Define Name again. This will open the New Name pop-up menu. Click on D2 and the n will appear in the name box as seen below. 2YC3 Conference, Rockville, MD/Sinex 4
Repeat this process for the other variables. Click on F2, I2, and then K2 to get the four variables named. A named variable is automatically made an absolute reference. It will keep its cell reference on dragging down a formula. See absolute reference for more information. Now if you click on B5 to compose the formula to calculate the pressure. In B5 start the formula with an equal sign and type this (you can get the variable by clicking on the appropriate cells): =n*0.0821*t/((a5+noise*(randbetween(-10,10)/10)+vtubing)/1000) After typing the formula in, click on B5 and then the formula bar (see below). Here is another way of showing how the calculation is done using the variables. This uses the Formula Auditing tools on the Formula tab. 2YC3 Conference, Rockville, MD/Sinex 5
Now drag the formula down the column to complete the calculation of pressures. Set up a graph by highlighting the data to plot, go to the Insert tab and select Scatter. This is the only plot in Excel where the x-variable is a numerical scale, all others are categories. 2YC3 Conference, Rockville, MD/Sinex 6
Now select the points only plot type from the menu as seen to the right. Your graph should appear. If you click on the graph, it will highlight the data as shown below. Note the colors of the highlighted for the x and y variables. With the graph highlighted, you will see the chart tools as new three tabs appear. You can add a trendline (power regression) form the Layout tab. This tab also allows you to label axes, title, etc. 2YC3 Conference, Rockville, MD/Sinex 7
If you select trendlines (really regressions) and go to the bottom and click on More Trendline Option the Format Trendline menu seen to the right appears. Select Power as the trendline option and select the display equation on chart and display R-square value on chart too. If you move the Format Trendline menu from on top the graph, you can select through the various trendline to explore fits. Now if you change one of the variables on row 2, the data recalculates, the graph adjusts, and the regression recalculates as well. Wow, you built a simulation! Now let s play (do a little learning) with the simulation. Here is where you need to ask the what if questions to drive students to use the simulation to get answers. When inducing errors, students need to watch how the model parameters and goodness-of-fit can vary. Address the following questions: How does increasing the temperature influence the curve? 2YC3 Conference, Rockville, MD/Sinex 8
How does adding random noise (scatter) or error to the data influence the curve and regression? How does the tubing error influence the results? Build a Simulation on Your Own See if you can construct the following spreadsheet. We want to look at the cooling of a cup of coffee. The temperature, T, of the coffee as a function of time, t, is given by: T (t) = T surroundings + (T initial cup T surroundings )e -kt where t is time in minutes, k is the rate constant for the cooling process, and T surroundings = 25 o C T initial cup = 90 o C k = 0.3 minute -1 First set up the two columns for time, t and T(t) in cells A3 and B3. We will calculate the temperature over the time range of 0 to 20 minutes. Plug the numbers into the formula above before you put this into the spreadsheet to generate T(t). Remember to use EXP(-kt) to represent e -kt. So your equation would look like: in cell B4 in cell A4 0 = 25+(90-25)*EXP(-0.3*A4) and copy the formula down column B. Generate and label a graph of the data generated. Try a regression fit too. How well does an exponential regression fit? How would you describe the plot of the data? 2YC3 Conference, Rockville, MD/Sinex 9
Now suppose you wanted to see how the curve responds if you changed the rate constant. What would you do? Now let s take the coffee cooling example above and make it an interactive spreadsheet where we can adjust variables and see what happens. To start, set up the following in a new worksheet. To subscript and superscript, highlight the text, right click, select Format Cells, and you will see subscript and superscript on the menu that pops up. To turn the cell lines off, go to the Page Layout ribbon and deselect the Gridlines View checkbox. Now we are going to name variables in Excel. This makes the formulas easier to follow and more like algebraic equations. We will use the names that have the blank yellow cells associated with them. To name variables click on the yellow cell E2 and then go to the Formulas ribbon and select Define Name. The New Name pop-up menu will appear and it will contain the name from the cell to the left. 2YC3 Conference, Rockville, MD/Sinex 10
Do this for the other to variables with yellow cells. The named variables are absolute cell references (they will not change cell reference on dragging) and will use the number that we place in the various yellow cells in calculations. Note that absolute cell references use a $ sign in front of the letter and number of the cell. Now in the column labeled T(t) (cell C5) add the formula by clicking on the various cells. = T surroundings + (T initial cup T surroundings )*EXP(-k*B5) where cell B5 contains the time. Set up the T(t) - T surroundings column as well. Then produce a graph showing how T(t) and T(t) - T surroundings vary with respect to time, t. Once you have done this, change the values in the various yellow cells. What happens? You may want to add an exponential regression to the T (t) - T surroundings data. How well does it fit? Compose some what if or predict-test-analyze questions for this simulation. For even more interactivity see the Cooling Coffee Excelet at: http://academic.pgcc.edu/~ssinex/excelets/cooling_coffee.xls. This interactive Excel spreadsheet or Excelet (Java-less applet like) uses items from the Forms Toolbar to enhance the level of interactivity. 2YC3 Conference, Rockville, MD/Sinex 11
More Resources For further materials on mathematical modeling and developing interactive Excel spreadsheets, see the Developer s Guide to Excelets at http://academic.pgcc.edu/~ssinex/excelets. For more information on the Boyle s Law simulation, see The Boyle s Law Simulator: A Dynamic Interactive Visualization for Discovery Learning of Experimental Error Analysis, which appeared in Spreadsheets in Education 3 (1) 20-26 (http://epublications.bond.edu.au/ejsie/vol3/iss1/2/). Alternate data collection can be done by experimentation (pressure probe and computer) or See the following Flash animation at: http://www.chem.iastate.edu/group/greenbowe/sections/projectfolder/flashfiles /gaslaw/boyles_law_graph.html This work was developed as part of the Computation and Science for School teachers (CAST) Workshop at the Pittsburgh Supercomputing Center. See http://www.psc.edu/eot/k12/2011yr.php for more information. 2YC3 Conference, Rockville, MD/Sinex 12