Pages

Saturday, March 8, 2025

Concerning Contagion

A measles outbreak has been in the news lately, and since the disease was previously considered eradicated in the US, I wanted to try a simple model of disease spread with and without vaccination. To represent a population, I used Python's NetworkX package, which gives us nodes (people) connected by edges (contact that can spread disease). In addition to vaccination status, I wanted to see how different levels of contact affected spread, so I generated the layouts using the Watts-Strogatz Graph, which takes a given number of nodes n, a community size k, and a rewiring parameter pwire. The nodes are arranged in a ring, with each connected to its k nearest neighbors. Then we randomly switch some of those connections according to pwire to randomize the interactions a bit.

Turning now to the nodes of these networks, the model for people I chose tracked a few qualities: Current infection, vaccination/immunity status, susceptibility to infection, and infectious period. Based on some stats I found from the CDC, I decided after being infected a person would be sick for 22 days, but only contagious for days 10-18. While contagious, each day a person's neighbors can become infected according to their susceptibility (0.5% for immune, 50% otherwise). I started the model with 10% of people infected, and ran until all cases were gone or a maximum of 300 steps (days). I ran several different values for k and pwire, as well as different vaccination levels.

After running the simulations, I tried to come up with some summary statistics. The first thing that came to mind was the fraction of people that get sick:

The x-axis shows the k parameter for each run, which represents the number of people each person has contact with. For the lower values of k, this shows clear separation in the different levels of vaccination – Low vaccination leads to high infection rates. With enough connection though, everyone encounters an unvaccinated person and gets sick.

That's just the number of people who ever get sick, but we can also look at how long the disease spreads before being eradicated:

Again we see a big uptick for high community size, to the point where disease is still spreading after 300 steps. For the smallest size, we again see separation in the vaccination rates, but there's also an effect from the pwire parameter. This is easier to understand if we look at a map of one of these communities:

Blue dots are people who have never been ill, red are currently sick, and green are vaccinated, or recovered. The twisting shape shows how the pwire parameter has connected a few people on opposite sides of the initial ring. The black dot in the plot above shows that for low pwire, the disease has to make its way around the whole ring, increasing the time to eradication. We can also look at a case with larger communities and more interconnection:

In this case, almost everyone immediately gets sick, which you might imagine would reduce the time before the disease is eradicated, but the increased connection also results in many more breakthrough infections.

I'm really impressed with the complex behavior this simple model was able to show! That said, I fully recognize it's just a toy, and should not be used for setting policy. I'm not headed to that farm upstate just yet...

Wednesday, February 26, 2025

Teach Your Physicist to Suck Eggs

Recently I was reminded of a neat science demo where burning a match inside a bottle can suck in a boiled egg that otherwise wouldn't fit:

I saw similar demos growing up, and I believe I was given the incorrect explanation of the match using up the oxygen to lower the pressure. As the video above points out, it's actually the heat from the fire that makes the air expand and escape from the bottle. After the air cools, the pressure is lower and the atmosphere pushes the egg into the bottle. I was curious whether I could determine the pressures involved in this demo.

Burning the match releases heat, which raises the temperature of the air in the bottle. According to the Energy Information Administration, burning a match releases 1 BTU of energy. Using air's heat capacity, density, and a volume of 1 L, we can calculate that this will raise the temperature by an impressive 1220 K. We can use the ideal gas law to see what that does to the air:

Increasing the temperature, T, will cause the pressure, P, to to go up. This pushes up on the egg allowing some air to escape. If we suppose that the pressure required is very small, we can instead assume all the energy from heating the air goes into expanding the volume, V. We could use this to find the final volume of the air, and thus how much escapes from the bottle, but we don't really care about the air that escapes. Instead, we can just suppose our 1 L bottle of air at a room temperature of 300 K is now at its new temperature of 1520 K, with the pressure remaining constant.

Now we can flip the relation, and suppose the volume and number of particles, N, stays constant. We can write

where the subscripts specify the initial and final states. Using the temperature we calculated and 1 atm of pressure, returning to room temperature would bring the pressure to approximately 0.25 atm. That implies the atmosphere is pushing down with 0.75 atm of net pressure. We can get the area of the egg's cross-section and multiply by the pressure for a force of 110 N, or about 25 lbs. Not enormous, but it's easy to see how applying that force unevenly by pushing with your fingers would just mush the egg.

Turning to the latter part of the video, how about getting the egg out again? The maximum pressure a person can blow is about 0.1 atm, 40% of the pressure that pushed it in. If you watch the video above though, you can see the egg goes into the bottle with a great deal of speed, while getting it out isn't nearly as violent, so these results appear to be consistent. Cool experiment to try if you've never seen it before!

Saturday, February 22, 2025

Window's Vista

This week, Futility Closet had a post about the Vista Paradox. The paradox is connected to an effect I discussed before, where the angular nature of our vision causes objects to move in unexpected ways. In this case, we're viewing a distant tower through a window. As we approach the window, the window takes up proportionately more of our vision that the tower, causing it to appear to shrink. I tried making an animation of this to test my understanding:

As expected, the tower (red) changes very little, while the closer window (blue) expands rapidly. Initially, I was concerned with how the window's proportions appear to change, but I checked with my mother Sally, and she gets the same expression I did. There still may be an error in my implementation though.

After reading the Futility Closet post, I was reminded of an effect often used in filmmaking called a Dolly Zoom: The camera moves forward (backward) while zooming out (in), causing the edges of the frame to stay where they are, but the center to contract (expand). The scene that always comes to my mind for this is one from Fellowship of the Ring:

makeagif

Using the same framework as above, I plotted a series of rings at different distances, but the same size. Then I moved the camera toward them, while fixing the edges of the plot to the nearest ring:

This effect makes the center appear to shrink, the opposite of the motion in the film, but exactly the same technique. It's neat to see this artifact of human perception appear in both architecture and filmmaking!