University of Kentucky
6-25-2020
On a sunny day in April, my 11-year old daughter Amy came to me.
"Mom, I want to make a model", she said.
What a surprise! Delighted by her request, I asked, "What do you want to model?"
"Solid, liquid, and gas. The three states of matter", Amy said, "my science teacher wants us to make a model project for our NTI science class. I want to make a computer model."
"Sure!"
This was the onset of this model. It took us nearly two hours to make the model from scratch. Over the process, I was surprised how vividly the modeling process revealed the underlying ideas behind the states of matter to my daughter, and me.
I searched for the standards in the NTI assignment: Develop a model to describe that matter is made of particles too small to be seen (5-PS1-1). I showed it to Amy, "Is this the standard for your model?"
"Ye...ah, maybe", she sounded so unsure. My bad! It just showed how unfruitful to start science learning with a statement of standards.
"OK, then just tell me what you want to make in the model?"
"I want to make some little water change but the amount stays the same," she said.
"What do you want the 'small water' look like?" I asked.
"Just some balls."
I wrote three questions on a sheet of print paper and let Amy answer them.
Question 1: How many turtles do you need? (Amy knew that turtles meant the agents in a model.)
Amy's answer: 16
Question 2: How do the turtles move? Amy drew a diagram (Figure 1)
Question 3: How does it look like after you ask turtles to keep moving?
Amy's answer: A clump of balls labeled with W for water moving and changing, but the amount still stays the same.
Then, we went to make the model.
Dear readers, although Amy made the model from scratch, you may save some time by using an existing basic model. Download the existing basic model or see here to make the basic model yourself. This model, made in NetLogo, shows a butterfly wandering on a green lawn (Figure 2). You will see how it is turned into a model for states of matter.
Amy wanted to have 16 particles at the beginning, but she quickly realized she could have way more particles than that. She envisioned that a number of small balls, i.e., particles, jiggle in the model. So we asked NetLogo to create a number of small circles that randomly jiggle.
Setting up the number of particles
First , we went to the “code” tab. In the "setup-turtles" procedure, we created a variable “number-of-particles” after the "create-turtles" command. Then, we went to the interface tab and made a slider for this variable, and then set the min and max bounds of the slider to 0 and 200 (Figure 3).
Setting up the properties of particles
Next, to get the small particles, we changed the agent shape from “butterfly” to “circle”, the size from 1.75 to 1, and the color from light green (number 68) to blue. After that, we added a new line of code to place these particles within a 5X5 area in the simulation window (Figure 4). Why did we put the particles in a square? Amy insisted they should look like an "ice cube" at the beginning.
Setting up the background color
You don't like the blue color in a dark green background? We didn't look it either. In the "setup-patches" procedure, we changed the background patch color from dark green (number 52) to white (Figure 5) If you get it done, go to the inteface tab and press on the "setup" button. It wasn't too bad, was it?
The basic model contains a "move" procedure that makes the agents randomly move around. It simulates kinetic motion to some extent.
However, Amy wanted to "heat up" and "cool down" the particles. "The particles will move all over the place when heat up and not move very much when cooled down", she said.
Well , this meant we needed to control the speed of the particles. One way to code the speed was to define how far an agent could move in each tick. So, in the code tab, we first defined a variable owned by agents, called "step". Once it was defined, every agent had the variable as one of their properties. Then in the "setup-turtles" procedure, we set the initial value of "step" as 0.2 for a moderate speed. Finally, in the "move" procedure, we replaced the number "1" with "step" (Figure 6). Now, in each tick, each individual agent moved towards a random direction at a step of 0.2. Run the model in the interface tab. We saw a window of jiggling particles (Figure 7).
Then we only needed to change the speed of the particles to simulate the effects of heating up and cooling down. We created a button in the interface tab named "Heat up". Put the following code into the button:
ask turtles [set step step + 0.05]
In English, the code means, "Hi turtles, increase your step by 0.05." Therefore, every time you press on the button, the speed of all agents increases 0.05. i.e., they get faster. Note here you don't need the "to-end" procedure structure as you put code directly into a button (Figure 8).
In the same way, we created a button in the interface tab named "Cool down". Put the following code into the button:
ask turtles [set step step - 0.05]
You probably can tell what the code means. Yes, every time you press on the button, the speed of all agents decreases 0.05, i.e, they get slower.
So far so good. All ideas seemed to be pretty straightforward. Dear readers, soon you will see how things could go off track.
Amy was very excited that she was able to "heat up" and "cool down" the particles. She clicked on the "heat up" button again and again. As expected, particles moved faster and spead over the entire window. Great! Then, she pressed the "cool down" button again and again. Yes, the particles got slower and slower. Oh, they even stopped. Wait, what! they moved again and got faster and faster?!
Yikes! How can particles move faster when they were cooled down?
We paused the model to check the particles. We randomly right clicked on one particle in the simulation window, and chose to inspect it. In the pop-up window, we saw the step had a negative value (Figure 9) . Ahha, of course, when you kept subtracting the value of the step, it eventually became negative. In NetLogo, moving forward a negative value means moving backward the absolute value of the negative value. So the agents started to move backward at some point and they moved backward faster and faster when Amy kept pressing the "cool down" button.
We had two things in the cooling-down procedure that are inconsistant with the reality. First, particles cannot have a "negative" speed. Second, particles only stop when the temperature gets to the absolute zero, theoretically.
We revised the code in the "cool down" button to the following to better simulate the authentic process,
ask turtles [ifelse step > 0.1
[set step step - 0.05] [set step step * 0.5]]
The code means, "Hi turtles, if your speed is greater than 0.1, descrease it by 0.05; if your speed is no more than 0.1, decrease it by half."
Since a number never becomes zero by dividing two. This code can slow down particles but never generate a zero or negative value. Yes, you could argue this is not the exact formula of cooling geneated by scientists. You are very much welcome to try the formula here and see what happens. My goal at the moment was to simulate a close cooling pattern using a code that is accessible for a 11-year old. I tried to explain to her this is only a close simulation. But she did not seem to understand and ever care the formula. She was more interested by if this looked "real". To a large extent, I think she had the point.
We ran the model again. Yes, problem solved. Cooling only slowed down the particles in the simulation (Figure 10).
Something in the simulation is still inconsistent with the reality. The particles did slow down, but they stayed where they were. Remember we started with an "ice cube". Shouldn't the particles get closer when they are cooled down? In a general condition on the Earth, water molecules will aggregate to form water droplets when temperatures go down, known as "condensation". We did not see these particles condense in the simulation. Without condensation, how could we represent different states of matter?
When we found out this, Amy concluded, "Oh well, I just did it wrong."
I explained to her that her ideas of kinetic motion had no problems. The model just demonstrated to us that kinetic motion alone cannot account for the state changes. What was missing here?
There must be something holding particles together when their speeds are low. Attractive force! How about we included attractive forces in the model? This is not hard. Head and Wilensky (2013) had simulated intermolecular forces in a NetLogo membrane formation model. Let's try it here.
We first created an "attraction" procedure in the code tab.
to attraction
ask turtles [
let a-close-molecule one-of other turtles in-radius 5
if a-close-molecule != nobody [face a-close-molecule fd attractive-force rt random-float 360]
]
end
The code means, " Hi turtles, are there any particles within a radius of 5? If so, choose one of them as an 'a-close-molecule'. Face towards this particle and move towards it at the value defined by the 'attractive-force'. Then turn by a random degree value. " We included the procedure name in the "go" procedure to run with the kinetic motion procedure.
As usual, NetLogo warned us there was no such thing called "attractive-force". Then in the interface tab, we made a "attractive-force" slider, set the min, increment, max, and value as 0, 0.01, 0.1, and 0.02, respectively (Figure 11).
When running the model, the particles became cohesive. They tended to stick to each other, even they were able to move away when heat up. When cooled down, they gradually adhered to each other (Figure 12).
This was so much fun to see the vivid change in particle behaviors. But this was not the end of the story. Do you notice the particles got so close that they completely overlapped? Particles cannot get infinitely close in reality. Why? There are repulsive forces keeping them away. We needed to include the repulsive forces in the model as well. Using the similar ideas in Head and Wilensky (2013), we coded repulsion as below.
We created an "repulsion" procedure in code tab.
to repulsion
ask turtles [
let a-close-molecule one-of other turtles in-radius 1
if a-close-molecule != nobody [face a-close-molecule bk repulsive-force rt random-float 360]
]
end
The code means, " Hi turtles, are there any particles within a radius of 1? If so, choose one of them as an 'a-close-molecule'. Face towards this particle and move away from it at the value defined by the 'repulsive-force'. Then turn by a random degree value. " We included the procedure name in the "go" procedure to run with procedures of kinetic motion and attraction .
Then we went to the interface tab, made a "repulsive-force" slider, set the min, increment, max, and value as 0, 0.01, 0.1, and 0.04, respectively (Figure 13).
Finally, we were there. By including kinetic motion, attraction and repulsion in this model, we enable the particles in the model to transform among three different states of matter over and over (Figure 14).
Amy was statisfied. Two months later, when I wrote this blog, she was able to tell me, "The three states are caused by heat, attraction and repulsion."
Thanks for following us all the way here. You may download the completed model here.
Thanks my son Tony for proofreading the blog .
References:
Head, B. and Wilensky, U. (2013). NetLogo Membrane Formation model. http://ccl.northwestern.edu/netlogo/models/MembraneFormation. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.
Related link: More models in Physics and Chemistry