Pages

Monday, May 5, 2025

Oh, what a world, what a world!

A while ago, Marika started making homemade vegetable broth from scraps. The recipe makes a large batch at a time, so we freeze it in cubes to use as needed. Last week, I was defrosting some in the microwave, and I started wondering about the ideal power settings to use. Microwaves are designed to heat the water molecules in food – The molecules are electrically polarized, and the oscillating electric field from the microwave makes them rotate back and forth, which translates into heat. In ice, though, the molecules are locked in a crystal formation, and unable to absorb energy as efficiently. If we run the microwave at full power, a lot of that energy will be wasted until the ice begins to melt. That's why the defrost settings opt for lower power and longer time. Once we get some liquid water though, we could increase the power and let the water conduct heat into the ice it surrounds.

I was able to find a paper on simulations of water and ice in a microwave, which included some nice plots of the energy absorbed over time. I used an online tool to extract the data, then did some linear fits to estimate a power level for each:

You may notice I've left out units on this plot – Usually a major faux pas in physics, but (possibly due to suffering from a cold) I found I had to fudge things a bit to get my simulation to work, so bear with me.

With this information in hand, we can imagine starting with a block of ice at a given temperature, and applying a given amount of power, which is scaled according to the factor found above. Once the ice begins to melt, the water can absorb energy more efficiently, and then transfer that energy to the ice through conduction. Recall that to change phases, materials need to absorb some extra energy, called the latent heat. Therefore, the key points of the simulation are

  • The ice must be heated up to melting point
  • Once at the melting point, additional energy transforms ice to water
  • Water heats up as it absorbs energy
  • Ice can absorb energy from the water according to the volume of water and difference in temperature

We stop the simulation once all the ice has melted. I tried out a series of different power/time settings for melting the ice most efficiently. They're plotted below, with the y-axis showing the fractional power delivered at each time. The length of the line shows how long it took all the ice to melt, and the color shows the total energy used (the area under the curve).

To defrost as quickly as possible, it's best to just blast full power, but this wastes a bunch of energy. To see why, we can look in detail at the max and min total energy cases:

These show that the vast majority of the time is spent just getting the ice up to 0°C. Once that happens, the water begins absorbing energy and speeds up the melting considerably. One caveat with this though is that the energy differences in the above are not huge – This makes sense, since the fraction of power absorbed by the ice and the energy needed to heat it to melting are constant. In my sickened state I didn't have the energy to test out heating routines as much as I'd like. I encourage you to try your own optimization of broth heating.

Sunday, April 13, 2025

Tess-Elation

This week something brought to mind a computer program I had growing up called TesselMania. It was a kids' art program for making tessellations, a type of repeating tiling of a plane. What stuck in my mind as I thought back to it was the question of how to generate such tilings – The program let you manipulate a shape, but it would make changes in reaction to your adjustments to maintain the necessary symmetries. I wondered what the precise rules were for maintaining a shape that could be tessellated.

I couldn't find a really general technique – I imagined there would be a wealth of math papers on the topic, but maybe I didn't dig deep enough. What I did find was an Instructables page about making tessellations with paper tiles. This gave a good recipe I could follow for my own program:

  1. Start with a square tile
  2. Cut a shape from the top side of the tile
  3. Rotate the shape around the top right corner of the square to join it to the right side
  4. Cut a shape from the bottom of the tile
  5. Rotate the shape around the bottom left corner of the square to join it to the left side

I was able to translate this into a Python script which works nicely! As above, I start with a square and divide the top and bottom lines into N points. Each point gets displaced randomly up or down, and then we apply the transforms described to get the sides. Once we have one tile, we can rotate it around the corners to make a grid:

N = 4

N = 6

N = 10

I was pretty happy with this, but a little unsatisfied with the spikiness – To me, tessellations with curvy bits feel more impressive. I wondered if I could take the points I was using to make the tiles and run them through a spline interpolator to smooth things out. For a simple solution, that gave some nice results:

N = 4

N = 6

N = 10

The N = 10 case is still a bit spiky, but 4 and 6 have some nice blobbiness! Still missing is fully interlocking designs, since that would require a more complicated definition of the tile edges, but since it's been over a month since I last got something up here, I thought I should do my best to wrap something up, rather than let it sit forever in my growing "Unfinished" folder. If there are any other TesselMania fans out there, I hope you'll give my script a try!

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...