Modeling Boyle's Law using Computational Thinking

 ECT Demo: Modeling Boyle’s Law using Computational Thinking


Demonstration at a glance...

Core subject(s)

Science

Subject area(s)

Chemistry

Suggested age

14 to 18 years old

Prerequisites

Some familiarity with concepts like particles and velocity.

Time

Preparation: 14 to 30 minutes

Instruction: 30 to 55 minutes

Standards

Core Subject: CCSS Math; NGSS

CS: Australia, CSTA, UK

In this demonstration...

Demonstration Overview

In this demonstration the teacher describes how computational thinking is used to understand the relationship between pressure and volume in a container of gas as described by Boyle’s Law[1]. Students will begin to see how decomposition, pattern recognition, abstraction and algorithm design can be used to understand natural phenomena. At the end of this demonstration students should be able to describe how velocity affects the position of a particle and how collisions of the molecules in a gas exert pressure on the inside of a container holding a gas and how the size of the container affects the rate of collisions.

Materials and Equipment

  • For the teacher:
  • Required: Internet-connected computer, projector and projector screen or other flat projection surface
  • Required: Whiteboard and dry-erase markers or equivalent
  • Required: Software

Preparation Tasks

Confirm that your computer is on and logged-in

1 to 3 minutes

Confirm that your projector is turned on and is projecting properly

1 to 3 minutes

Confirm required software is installed or install software as described below

1 to 3 minutes

This demo uses VPython. We recommend you use the latest version of VPython (6.x) which requires an older version of Python (2.x). If you have a 64-bit version of Windows you should use a 64-bit version of both Python and VPython.

Steps:

And then

5 to 10 minutes

5 to 10 minutes

Open the ECT Pseudocode Guide

1 minute

The Demonstration

Part 1: Using Computational Thinking to analyze gas pressure & volume

10 to 15 minutes

Part 2: Using pseudocode and VPython to simulate a gas contained in a cube

20 to 40 minutes

Part 1: Using Computational Thinking to analyze gas pressure & volume (10 to 15 minutes)

Notes to the Teacher:

Chemistry often involves processes that cannot be observed directly. Computational thinking becomes all the more critical in this field where observations and data must be analyzed for patterns to develop laws and theories.

Use the information below to give your students an overview of four Computational Thinking connections and the concepts of Boyle’s Law.

Computational Thinking Connections:

Decomposition

The pressure of a gas in a container results of rate and velocity that particles of the gas collide with the container.

Pattern Recognition

For a particular number of particles of gas at a particular temperature, the larger the volume of the container the less likely that gas particles will collide with the sides of the container.  Likewise, as the volume of the container decreases, the rate of collisions with the sides of the container increases.  In other words, pressure varies as the inverse of the volume.

Abstraction

A change in the rate of collisions of particles at a fixed average velocity represents a change in the pressure that the gas produces against the walls.


Part 2: Using pseudocode and VPython to simulate a gas contained in a cube (20 to 40 minutes)

Notes to the Teacher:

Walk through the following pseudocode example below with your students to show them how algorithmic thinking can help us understand how the motions of molecules in a gas explains the pressure it exerts on its container.

Computational Thinking Connections:

Algorithm Design

This model is designed to show the relationship between the rate of collisions with the walls of a container and its volume.  As the pressure exerted by the gas in the container is based on the rate of collisions students can begin to understand why increasing the volume of the container decreases the pressure of the gas. For simplicity, only one particle is modeled but additional particles could be added as an additional challenge.

Activity:

Pseudocode

  1. Create a particle with a constant velocity and a container of a certain volume.
  2. Change the particle’s position.
  3. Change the particle’s direction if it collides with the container and add 1 to the number of collisions.
  4. Calculate the rate of collisions by dividing the number of collisions by the elapsed time.
  5. Update the elapsed time by adding Δtime
  6. Repeat steps 2 - 5 indefinitely

This pseudocode can be used with various container sizes to calculate the associated rate of collisions.

VPython Code

  • In the following VPython code the variables cannot include greek characters, so Δtime is represented as deltat.
  • x position is represented as pos.x and y position is represented as pos.y

Invoke your VPython environment called VIdle and copy/paste the following code into it:

from visual import *

# Code modified from VPython 5.x Tutorial -->

# http://vpython.org/contents/docs/VPython_Intro.pdf

# Pseudocode line 1 (the next 9 lines)

length=20 # Length of each side of cube. Change to adjust the volume of the cube

# Note: Simulation works best when the length of each side is greater than 5

# Set size of display to be proportionate to the size of the cube

scene2 = display(width=length*50, height=length*50)

midpoint = length / 2.0

# Create cube by creating its walls

# For simplicity we’ll leave out the front and back walls

RightWall = box(pos = (midpoint, 0, 0), size = (0.2, length, length))

LeftWall = box(pos = (-midpoint, 0, 0), size = (0.2, length, length))

TopWall = box(pos = (0, midpoint, 0), size = (length, 0.2, length))

BottomWall = box(pos = (0, -midpoint, 0), size = (length, 0.2, length))

atom = sphere(pos = (midpoint, 0, 0), radius = 0.5, color = color.red)

atom.velocity = vector(20, 10, 0) # give particle initial x & y velocity

time = 0 # start with time = 0

deltat = 0.005  # Length of each time period of simulation

collisions = 0  # Number of bounces off a wall (so far none)

rate_label = label(pos = (0, midpoint, 0),

                   text = 'rate = 0', border = 15, box = False)

while true :  # Pseudocode line 6

    rate(100) # Slow down the rate of the program so we can see the particle move

    atom.pos = atom.pos + atom.velocity * deltat  # Pseudocode line 2 -- change the particle’s position

    # Pseudocode line 3 -- Change the particle’s direction if it collides with the walls (the next 8 lines)

    # If it bounces off the left or right wall change its x direction

    if (atom.pos.x > RightWall.pos.x) or (atom.pos.x < LeftWall.pos.x) :

        collisions += 1

        atom.velocity.x = -atom.velocity.x

    # If it bounces off the top or bottom wall change its y direction

    if (atom.pos.y > TopWall.pos.y) or (atom.pos.y < BottomWall.pos.y) :

        collisions += 1

        atom.velocity.y = -atom.velocity.y

    # Pseudocode line 4 -- increase total elapsed time by deltat

    time += deltat

    # Pseudocode line 5 -- Calculate the rate of collisions with walls

    rate_label.text = 'rate = ' + str(round(collisions / time, 1))

Run the VPython code using Run → Run Module. The code will produce an animation of a single particle of gas inside a cube with sides equal to the value of length in the VPython code. The larger the size of the cube, the less often the particle collides with the sides of the cube, or, the rate of collisions is inversely proportional to the size of the cube.

Output

(length = 10 and 20 respectively)

Learning Objectives and Standards

Learning Objectives

Standards

LO1: Student should be able to describe how velocity affects the position of a particle.

Core Subject

CCSS MATH.HSN.VM.A.3. Solve problems involving velocity and other quantities that can be represented by vectors.

Computer Science

AUSTRALIA 8.4 (Collecting, managing and analyzing data): Analyse and visualise data using a range of software to create information; and use structured data to model objects or events.

CSTA L3A.CT.8: Use modeling and simulation to represent and understand natural phenomena.

UK 4.2: Develop and apply their analytic, problem-solving, design, and computational thinking skills.

LO2: Student should be able to describe how collisions of the molecules in a gas exert pressure on the inside of a container holding a gas and how the size of the container affects the rate of collisions.

Core Subject

NGSS PS1.A: Gases and liquids are made of molecules or inert atoms that are moving about relative to each other. In a gas, they are widely spaced except when they happen to collide.

Computer Science

AUSTRALIA 8.4 (Collecting, managing and analyzing data)

CSTA L3A.CT.8

UK 4.2

Additional Information and Resources

Lesson Vocabulary

Term

Definition

For Additional Information

Volume

A unit of three-dimensional measure of space that comprises a length, a width and a height. It is measured in units of cubic centimeters in metric, cubic inches or cubic feet in English measurement.

http://en.wiktionary.org/wiki/volume

Pressure

The amount of force that is applied over a given area divided by the size of this area.

http://en.wiktionary.org/wiki/pressure

Position

Coordinates of an object, often expressed as x, y, and/or z. Position is sometimes referred to an displacement to emphasize how far the object has traveled or how far it is from position (0,0) or (0,0.0)

http://en.wikipedia.org/wiki/Cartesian_coordinate_system

Velocity

Rate of change of the position of an object

http://en.wikipedia.org/wiki/Velocity

Computational Thinking Concepts

Concept

Definition

Decomposition

Breaking down data, processes or problems into smaller, manageable parts

Pattern Recognition

Observing patterns and regularities in data

Abstraction

Identifying and extracting relevant information to define main idea(s)

Algorithm Design

Creating an ordered series of instructions for solving similar problems

Additional Resource Links

Administrative Details

Contact info

For more info about Exploring Computational Thinking (ECT), visit the ECT website (g.co/exploringCT)

Credits

Developed by the Exploring Computational Thinking team at Google and reviewed by K-12 educators from around the world.

Last updated on

06/26/2015

Copyright info

Except as otherwise noted, the content of this document is licensed under the Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache 2.0 License.


 ECT: Modeling Boyle’s Law using Computational Thinking                                                            of


[1] Boyle’s Law states that the pressure of a gas is inversely proportional to volume if the temperature of the gas is held constant.  Because the Ideal Gas Law is a composite of gas laws, it can be interpreted in a way that is equivalent to Boyle’s Law.  When we consider pV=nRT we can say that if the number of gas molecules and the temperature remain constant, then the pressure is inversely proportional to the volume.