Quark Stars

2 August, 2024

 

Wow — evidence that very massive neutron stars may have cores made of deconfined quark matter! The idea of a ‘quark star’ is not new, but I didn’t know it was a serious possibility.

An ordinary neutron star has a core made mostly of densely packed neutrons. A matchbox-sized chunk of this stuff weighs about 3 billion tonnes. But if you squeeze this stuff hard enough, eventually the neutrons break. Each neutron consists of 3 quarks held together by gluons. So when the neutrons break you get ‘quark matter’ — a sea of quarks and gluons, no longer confined in neutrons.

We’ve made something similar here on Earth: at CERN and Brookhaven, physicists smack atomic nuclei at each other so hard that the protons and neutrons break and momentarily form a ‘quark-gluon plasma’. But the conditions in a neutron star core are different: cooler, but more pressure — and not just temporary.

This new paper tries to take the measured properties of massive neutron stars and see if they fit a model where the inner core is made of deconfined quark matter:

• Eemeli Annala, Tyler Gorda, Joonas Hirvonen, Oleg Komoltsev, Aleksi Kurkela, Joonas Nättilä and Aleksi Vuorinen, Strongly interacting matter exhibits deconfined behavior in massive neutron stars, Nature Communications 14 (2023), 8451.

They say it does with about 80% probability! I’d take this with a big grain of salt, but it’s an exciting possibility. It’s not every day we find quintillions of tonnes of a new state of matter.

For me, the coolest part is that deconfined quark matter may have an extra symmetry, called ‘conformal symmetry’. This means that if you zoom in on it, it looks almost the same. An atom looks like a blob with some specific size. So does a neutron. But a system with conformal symmetry is just a blur spread out everywhere — and if you zoom in or zoom out, you see something very similar. This is crazy.

We see matter with conformal symmetry elsewhere too, like at ‘critical points’. As you know, when you heat water it boils. There’s a sharp divide between liquid and gas. But as you keep boosting the pressure, the boiling point increases. And at 647 degrees kelvin and 220 times ordinary atmospheric pressure something weird happens: the distinction between liquid and gas ends! This is called a ‘critical point’.

Right at the critical point, water looks weird. It look like a blur of droplets floating in gas. But if you look at any droplet you’ll see it’s full of bubbles of gas. And if you look in any of these bubbles you see it’s full of droplets. As you keep zooming in, you keep seeing basically the same thing…. droplets of liquid in gas, bubbles of gas in liquid…. until you get down to the scale of atoms. So we say this stuff has ‘conformal symmetry’.

The math of this is incredibly cool: it’s called ‘conformal field theory’, and a lot of mathematicians and physicists study it. So it would be really neat if extremely heavy neutron stars turn out to be made of deconfined quark matter with conformal symmetry… or even just approximate conformal symmetry.


Agent-Based Models (Part 14)

1 August, 2024

I’ve been explaining our software for agent-based models based on stochastic C-set rewriting systems. But my only example so far has been the Game of Life, which is not what most people would call stochastic: it’s a deterministic model!

In fact, a deterministic model is just a stochastic model where all the probabilities for events to happen are 0 or 1. So we can call the Game of Life stochastic if we want. But that’s not very satisfying! So let’s tweak the Game of Life to make it more random.

It’s very easy to do! We only need to change one line of code—in fact, just one word in one line of code. We can just change this:

TickRule(name, I_L, I_R; ac) = 
ABMRule(name, Rule(I_L, I_R; ac), DiscreteHazard(1));

to this:

TickRule(name, I_L, I_R; ac) = 
ABMRule(name, Rule(I_L, I_R; ac), ContinuousHazard(1));

Recall from Part 9 that in a stochastic C-set rewriting system, all changes to the state of our model arise from ‘rewrite rules’, and attached to every rewrite rule there is a ‘timer’. The timer says the probability the rewrite will happen, as a function of time (if nothing else happens first that prevents it).

DiscreteHazard(1) and ContinuousHazard(1) are examples of such timers. In what follows, let’s arbitrarily measure time in seconds.

DiscreteHazard(1) means that the rewrite happens 1 second after it’s first able to happen, with probability 100% (if nothing else happens first that prevents this rewrite from happening). In the Game of Life, all rewrite rules have this timer attached to them.

ContinuousHazard(1) means that the rewrite happens stochastically, and the probability that it still hasn’t happened after t seconds decays exponentially like this:

exp(-t)

(if nothing else happens first that prevents this rewrite from happening).

If all our rewrite rules contain DiscreteHazard(1), as they do in the Game of Life, everything in our model occurs in equally spaced time steps, each one second after the next. If we take the Game of Life and replace this timer with ContinuousHazard(1), we get a funny variant where cells are born and die at random times.

You can see more details and an example here:

Conway’s Game of Life. Bonus: stochastic Game of Life.

But what does this line of code mean in the first place, one might ask:

TickRule(name, I_L, I_R; ac) = 
ABMRule(name, Rule(I_L, I_R; ac), DiscreteHazard(1));

Here is what’s going on:

1) We want to give each rewrite rule a name.

2) The rewrite rule itself is a little diagram of C-sets like this:

L \stackrel{I_L}{\hookleftarrow} I \stackrel{I_R}{\to} R

To apply this rewrite rule to a C-set S, we find inside that C-set an instance of the pattern L, called a ‘match’, and replace it with the pattern R. The C-set I can be thought of as the common part of L and I. The maps IL and IR tell us how this common part fits into L and R.

Since the convention in AlgebraicJulia (and elsewhere) is that a morphism knows its source and target, to specify the rewrite rule it’s enough to give the maps IL and IR. That’s what I_L and I_R stand for.

3) In addition, we can also give our rule ‘application conditions’:

positive application conditions say a rule can only be applied if some condition holds,
negative application conditions say a rule can never be applied if some condition holds.

I gave examples taken from the Game of Life Part 11.

4) We must also give our rule a timer.

All four steps are accomplished in an expression of the form

ABMRule(name, Rule(I_L, I_R; ac), DiscreteHazard(1))

where of course the I_L and I_R and ac need to be filled in with specifics.

But we may get sick of typing the timer every time. So, we can define a shorter command TickRule thus:

TickRule(name, I_L, I_R; ac) = 
ABMRule(name, Rule(I_L, I_R; ac), DiscreteHazard(1));

That’s all!


Part 1: The challenge of developing a unified mathematical framework for agent-based models, and designing software that implements this framework.

Part 2: Our project to develop software for agent-based models at the International Centre for Mathematical Sciences, May 1 – June 12 2024.

Part 3: Coalgebras for describing diverse forms of dynamics.

Part 4: The Para construction and its dual, for dealing with agents that are affected by, or affect, the external environment.

Part 5: A proposal for research on modular agent-based models in public health.

Part 6: Describing the stochastic time evolution of non-interacting agents using state charts.

Part 7: Describing the stochastic interaction of agents using state charts.

Part 8: How to describe the birth and death of agents using state charts.

Part 9: The theory of ‘stochastic C-set rewriting systems’: our framework for describing agents using simple data structures that randomly change state at discrete moments in time.

Part 10: A choice of category C suitable for the Game of Life.

Part 11: Stochastic C-set rewrite rules that describe time evolution in the Game of Life.

Part 12: The formalism of ‘attributed C-sets’, for endowing agents with attributes.

Part 13: Literate code for the Game of Life in our software framework for agent-based models.


Tritone Substitutions

27 July, 2024

A ‘tritone substitution’ is a popular trick for making your music sound more sophisticated. I’ll show you a couple of videos with lots of examples. But since I’m mathematician, let me start with the bare-bones basics.

The fifth note of the major scale is called the dominant. In the key of C it’s G.

A dominant seventh chord is a 4-note chord where you start at the dominant and go up the major scale skipping every other note. In the key of C it’s the notes in boldface here:

G A B C D E F

Below I’ve drawn blue edges from G to B, from B to D, and from D to F:

Any dominant seventh chord has two notes that are opposite each other—shown in orange here. We say they’re a tritone apart.

A tritone is very dissonant, so the dominant seventh chord really wants to ‘resolve’ to something more sweet. This tendency is a major driving force in classical music and jazz! There’s a lot more to say about it.

But never mind. What if we take my picture and rotate it 180 degrees? Then we get a new chord! This trick is called a tritone substitution.

Let’s look at it:

Here you see our original dominant seventh chord (with notes connected by blue edges):

G B D F

and its tritone substitution (with notes connected by red edges):

C♯ F G♯ B

Each note in the tritone substitution is a tritone higher than the corresponding note in the dominant seventh chord—so it’s the point on the opposite side of the circle.

But two notes in the dominant seventh were directly opposite each other to begin with: B and F. So these two notes are also in the tritone substitution!

This makes the tritone substitution sound a lot like the original dominant seventh chord.

See the square of notes? Three are in the original dominant seventh, and three are in the tritone substitution. Musicians like such squares of notes, even though they’re quite dissonant. They’re called diminished seventh chords. But let me stop here instead of blasting you with too much information.

Let’s actually listen to some tritone substitutions:

Here David Bennett plays a bunch of songs that use tritone substitutions. I’m very glad to learn that the slippery, suave sound at a certain point of The Girl from Ipanema comes from using a tritone substitution. He also plays a version without the tritone substitution, and you can hear how boring it is by comparison!

Music theorists tend to bombard their audience with more information than nonexperts can swallow in one sitting. David Bennett could have made a nice easy video full of examples where musicians apply a tritone substitution to a dominant seventh chord in its most natural position, where it starts at the 5th note in the major scale. But you can also take a dominant seventh chord and move it up or down, getting a chord called a secondary dominant, and then do a tritone substitution to that. And Bennett feels compelled to show us all the possibilities, and how they get used in fairly well-known tunes.

If you start getting overwhelmed, don’t feel bad. Let me show you another explanation of tritone substitutions:

I really love the friendly, laid-back yet analytical style of Michael Keithson. He’s great at explaining how you could have invented harmony theory on your own starting from a few basic principles. He’s like the music theory teacher I always wish I had.

His pose above is a parody of the sneaky punch that a tritone substitution can pack. Speaking of which, if you want to sound like a hipster, you say tritone sub. Don’t mix this up with the submarine used by the Greek sea god born of Poseidon and Aphrodite: that’s the ‘Triton sub’.

In this video Keithson explains tritone subs. He starts out basic. Then he gets into all the ways you can use a tritone sub. You may want to quit at some point when it gets too complicated. I think it’s better to just zone out and listen to his piano playing. Even if you don’t follow all his words, you’ll get a sense of what tritone subs can do!

Understanding tritone subs well requires understanding dominant chords, and Keithson has a good lesson on those, too:


Agent-Based Models (Part 13)

24 July, 2024

Our 6-week Edinburgh meeting for creating category-based software for agent-based models is done, yet my collaborators are still busy improving and expanding this software. I want to say more about how it works. I have a lot of catching up to do!

Today I mainly want to announce that Kris Brown has made a great page explaining our software through a working example:

Conway’s Game of Life.

His explanation uses an idea interesting in its own right: ‘literate programming’, where the code is not merely documented, but worked into a clear explanation of the code in plain English. I would copy it all onto this blog, but that’s not extremely easy—so just go there!

His explanation is a good alternative or supplement to mine. This is how my explanation went:

Part 9: The theory of ‘stochastic C-set rewriting systems’. This is our framework for describing agents using somewhat general but still simple data structures that randomly change state at discrete moments in time.

Part 10: Here I describe a choice of category C suitable for the Game of Life. For this choice, C-sets describe living and dead cells, and the edges connecting them.

Part 11: Here I explain stochastic C-set rewrite rules that describe time evolution in the Game of Life.

Part 12: Here I describe the formalism of ‘attributed C-sets’. In the Game of Life we merely use these a way to assign coordinates to cells: they don’t affect the running of the game, only how we display it. But in other agent-based models they become much more important: for example, some agents might have a ‘weight’ or ‘height’ or other quantitative information attached to them, which may change with time, and these are treated as ‘attributes’.

So, there’s plenty you can read about our approach to the Game of Life.

But as I mentioned before, the Game of Life is a very degenerate example of a stochastic C-set rewriting system, because it’s actually deterministic! What if we want a truly stochastic example?

It’s easy. I’ll talk about that next time.


Part 1: The challenge of developing a unified mathematical framework for agent-based models, and designing software that implements this framework.

Part 2: Our project to develop software for agent-based models at the International Centre for Mathematical Sciences, May 1 – June 12 2024.

Part 3: Coalgebras for describing diverse forms of dynamics.

Part 4: The Para construction and its dual, for dealing with agents that are affected by, or affect, the external environment.

Part 5: A proposal for research on modular agent-based models in public health.

Part 6: Describing the stochastic time evolution of non-interacting agents using state charts.

Part 7: Describing the stochastic interaction of agents using state charts.

Part 8: How to describe the birth and death of agents using state charts.

Part 9: The theory of ‘stochastic C-set rewriting systems’: our framework for describing agents using simple data structures that randomly change state at discrete moments in time.

Part 10: A choice of category C suitable for the Game of Life.

Part 11: Stochastic C-set rewrite rules that describe time evolution in the Game of Life.

Part 12: The formalism of ‘attributed C-sets’, for endowing agents with attributes.

Part 13: Literate code for the Game of Life in our software framework for agent-based models.


What is Entropy?

20 July, 2024

I wrote a little book about entropy; here’s the current draft:

What is Entropy?

If you see typos and other mistakes, or have trouble understanding things, please let me know!

An alternative title would be 92 Tweets on Entropy, but people convinced me that title wouldn’t age well: in decade or two few people may remember what ‘tweets’ were.

Here is the foreword, which explains the basic idea.

Foreword

Once there was a thing called Twitter, where people exchanged short messages called ‘tweets’. While it had its flaws, I came to like it and eventually decided to teach a short course on entropy in the form of tweets. This little book is a slightly expanded version of that course.

It’s easy to wax poetic about entropy, but what is it? I claim it’s the amount of information we don’t know about a situation, which in principle we could learn. But how can we make this idea precise and quantitative? To focus the discussion I decided to tackle a specific puzzle: why does hydrogen gas at room temperature and pressure have an entropy corresponding to about 23 unknown bits of information per molecule? This gave me an excuse to explain these subjects:

• information
• Shannon entropy and Gibbs entropy
• the principle of maximum entropy
• the Boltzmann distribution
• temperature and coolness
• the relation between entropy, expected energy and temperature
• the equipartition theorem
• the partition function
• the relation between expected energy, free energy and entropy
• the entropy of a classical harmonic oscillator
• the entropy of a classical particle in a box
• the entropy of a classical ideal gas.

I have largely avoided the second law of thermodynamics, which says that entropy always increases. While fascinating, this is so problematic that a good explanation would require another book! I have also avoided the role of entropy in biology, black hole physics, etc. Thus, the aspects of entropy most beloved by physics popularizers will not be found here. I also never say that entropy is ‘disorder’.

I have tried to say as little as possible about quantum mechanics, to keep the physics prerequisites low. However, Planck’s constant shows up in the formulas for the entropy of the three classical systems mentioned above. The reason for this is fascinating: Planck’s constant provides a unit of volume in position-momentum space, which is necessary to define the entropy of these systems. Thus, we need a tiny bit of quantum mechanics to get a good approximate formula for the entropy of hydrogen, even if we are trying our best to treat this gas classically.

Since I am a mathematical physicist, this book is full of math. I spend more time trying to make concepts precise and looking into strange counterexamples than an actual ‘working’ physicist would. If at any point you feel I am sinking into too many technicalities, don’t be shy about jumping to the next tweet. The really important stuff is in the boxes. It may help to reach the end before going back and learning all the details. It’s up to you.

Acknowledgements

I thank Jacopo Bertolotti for the animation at the top of this article. I’ve also gotten important corrections from many people, some listed in the comments below.


Van der Waals Forces

17 June, 2024

Even though helium is the least reactive of the noble gases, you can make a molecule of two helium atoms! Yes, He2 is a thing! It’s called ‘dihelium’ or the helium dimer.

But the two helium atoms aren’t held together by a bond. Instead, they’re held together by a much weaker force: the van der Waals force. So this isn’t an ordinary molecule. It’s huge! The distance between nuclei is 70 times bigger than it is for H2. And it’s very loosely held together, so you’ll only see it at extremely low temperatures.

Such a molecule held together by the van der Waals force is called a van der Waals molecule.

But what’s the van der Waals force? This is actually a name for a few different forces that exist between electrically neutral objects:

• If you put a permanent dipole next to a spherically symmetrical atom like helium, the dipole’s electric field will distort that atom and make it a dipole too! Then they will interact with a force that goes like 1/𝑟⁷. This is called the permanent dipole / induced dipole force or Debye force.

• If you put two randomly oriented dipoles next to each other, they will tend to line up, to reduce free energy. Then they interact with a force that again goes like 1/𝑟⁷. This is called the Keesom force.

• If you put two spherically quantum systems like helium atoms next to each other, they will develop dipole moments that tend to line up, and again they interact with a force that goes like 1/𝑟⁷. This is called the London force.

• Also, neutral atoms repel each other due to the Pauli exclusion principle when their electron clouds overlap significantly.

For dihelium, the most important force is the London force, which unfortunately is the hardest one to understand. But qualitatively it works like this:



Start with two neutral atoms. Each is a nucleus surrounded by electrons. If they start out spherically symmetric, like helium, and far enough apart that their electron clouds don’t overlap, there should be no electrostatic force between them.

But wait—the electrons are randomly moving around! Sometimes they move to make each atom into a ‘dipole’, with the nucleus on one side and the electrons over on the other side. If these two dipoles point the same way, this lowers the energy—so this will tend to happen. And now the two atoms attract… since two dipoles pointing the same way attract.

But this effect is small. The gif vastly exaggerates how much the electrons move to one side of each proton. And this van der Waals force dies off fast with distance, like 1/𝑟⁷. So we have two objects held together by a very weak force. That’s why the helium dimer is so huge.

Now let’s think a bit about why the van der Waals force obeys a 1/𝑟⁷ force law. Where the heck does that number 7 come from? It’s so weird! It’s best to warm up by considering some simpler force laws.

Two point charges: 1/𝑟²

We start with a single point charge at rest. If you put another point charge a distance 𝑟 away, it will feel a force proportional to 1/𝑟². So we say the first charge creates an electric field that goes like 1/𝑟².

A point charge and a dipole: 1/𝑟³

If we put a positive and negative charge in the field of another point charge, but quite close to each other, that other point charge will push on them with a total force proportional to

1/𝑟² − 1/(𝑟+ε)²

For small ε this is approximately proportional to the derivative of 1/𝑟², which is some number times 1/𝑟³. So, we say a dipole in the field of a point charge feels a 1/𝑟³ force.

A dipole and a point charge: 1/𝑟³

For the same reason, a dipole creates an electric field that goes like 1/𝑟³: if you put a point charge near the dipole, not too close, the two poles in the dipole are at distance 𝑟 and 𝑟+ε from this charge, so it feels a force proportional to

1/𝑟² − 1/(𝑟+ε)²

and we repeat the same calculation as before. Or, just use “for every force there is an equal opposite force”.

A dipole and a dipole: 1/𝑟⁴

Next consider a dipole in the field produced by another dipole! The first dipole consists of two opposite charges, each feeling the field produced by the other dipole, so the total force on it is proportional to

1/𝑟³ − 1/(𝑟+ε)³

which for small ε is proportional to 1/𝑟⁴. So the force between two dipoles goes like 1/𝑟⁴.

A dipole and an induced dipole: 1/𝑟⁷

Next think about a helium atom at a distance 𝑟 from a dipole like a water molecule. On its own helium is not a dipole, but in an electric field it becomes a dipole with strength or ‘moment’ proportional to the electric field it’s in, which goes like 1/𝑟³. We know the force between dipoles goes like 1/𝑟⁴, but now on top of that our helium atom is a dipole with moment proportional to 1/𝑟³, so the force is proportional to

1/𝑟⁴ × 1/𝑟³ = 1/𝑟⁷

The same calculation works for any initially spherically symmetric neutral object in the field of a dipole, as long as that object is considerably smaller than its distance to the dipole. The object will become a dipole thanks to the field of the other dipole, so we call it an ‘induced dipole’. The 1/𝑟⁷ force between a dipole and an induced dipole is called the Debye force.

Two randomly oriented dipoles: 1/𝑟⁷

There’s a statistical mechanics approach to computing the interaction between two systems that are dipoles with orientations that can move around randomly due to thermal fluctuations. This explained in Section 3.2.2 here:

• Gunnar Karlström and Bo Jönsson, Intermolecular Interactions.

Individually each object has zero dipole moment on average, but together they tend to line up, to reduce free energy. You again get a 1/𝑟⁷ force. This is called the Keesom force.

We can use this idea to explain what’s going on with two helium atoms—but only in very hand-wavy way, where we imagine superpositions are like probability distributions. A better explanation must use quantum mechanics.

Two induced dipoles, not too far from each other: 1/𝑟⁷

Two initially spherically symmetric neutral atoms can also create dipole moments in each other due to quantum effects! If we ignore the time it takes light to travel between the two atoms, they can both synch up and this produces a 1/𝑟⁷ force. A quantum-mechanical derivation of this force law can be seen here:

• Barry R. Holstein, The van der Waals interaction, American Journal of Physics 69 (2001), 441–449.

This is called the London force. It’s morally similar to the Keesom force because we look at the combined system in its ground state, or lowest-energy state, and this happens when the electrons of each atom move in such a way to create two aligned dipoles… a lot like in the gif above.

But while the derivation in the paper is widely used, it’s pretty sketchy, since it approximates the electrons with harmonic oscillators, as if they were attached to their locations with springs! This is called the Drude model.

Two induced dipoles, far apart: 1/𝑟⁸

However, when our two spherical symmetric neutral atoms are sufficiently far apart, the time it takes light to travel between them becomes important! Then the London force switches over (smoothly) to a 1/𝑟⁸ force!

To understand this, we need not only quantum mechanics but also special relativity. Thus, we need quantum electrodynamics. Holstein’s paper is also good for this. He says that the exchange of two photons between the atoms is relevant here, and thus fourth-order perturbation theory. He says that in the usual Coulomb gauge this leads to a “rather complicated analysis” involving thirteen Feynman diagrams, but he presents a simpler approach.

Further reading

What I’ve described so far is just the tip of the iceberg when it comes to van der Waals forces. One has to get a lot more detailed to make quantitative predictions. For a really good account, after reading the above articles, dive into this:

• Joseph O. Hirschfelder, Charles F. Curtiss and R. Byron Bird, The Molecular Theory of Gases and Liquids, John Wiley & Sons, 1964.


The Grotthuss Mechanism

9 June, 2024


If you could watch an individual water molecule, once in a while you’d see it do this.

As it bounces around, every so often it hits another water molecule hard enough enough for one to steal a hydrogen nucleus—that is, a proton—from the other!

The water molecule with the missing proton is called a hydroxide ion, OH⁻. The one with an extra proton is called a hydronium ion, H₃O⁺.

This process is called the ‘autoionization’ of water. Thanks to this, a few molecules in a glass of water are actually OH⁻ or H₃O⁺, not the H₂O you expect.

And this gives a cool way for protons to move through water. Here’s a little movie of how it works, made by Mark Petersen:



A positively charged proton gets passed from one molecule to another! This is called the ‘Grotthuss mechanism’, because Theodor Grotthuss proposed this theory in his paper “Theory of decomposition of liquids by electrical currents” back in 1806. It was quite revolutionary at the time, since ions were not well understood.

Something like this theory is true. But in fact, I believe all the pictures I’ve shown so far are oversimplified! A hydronium ion is too powerfully positive to remain a lone H₃O⁺. It usually attracts a bunch of other water molecules by the van der Waals force and creates larger structures. You can see these here:

Water, Azimuth, 29 November 2013.

Water with even trace amounts of salts in it conducts electricity vastly better than pure water, because when salts dissolve in water they create free ions. So, the Grotthus mechanism seems to be the dominant form of electrical conduction in water only when the water is extremely pure. According to Wikipedia:

Pure water containing no exogenous ions is an excellent electronic insulator, but not even “deionized” water is completely free of ions. Water undergoes autoionization in the liquid state when two water molecules form one hydroxide anion (OH⁻) and one hydronium cation (H₃O⁺). Because of autoionization, at ambient temperatures pure liquid water has a similar intrinsic charge carrier concentration to the semiconductor germanium and an intrinsic charge carrier concentration three orders of magnitude greater than the semiconductor silicon, hence, based on charge carrier concentration, water can not be considered to be a completely dielectric material or electrical insulator but to be a limited conductor of ionic charge.

Because water is such a good solvent, it almost always has some solute dissolved in it, often a salt. If water has even a tiny amount of such an impurity, then the ions can carry charges back and forth, allowing the water to conduct electricity far more readily.

It is known that the theoretical maximum electrical resistivity for water is approximately 18.2 MΩ·cm (182 kΩ·m) at 25 °C. This figure agrees well with what is typically seen on reverse osmosis, ultra-filtered and deionized ultra-pure water systems used, for instance, in semiconductor manufacturing plants. A salt or acid contaminant level exceeding even 100 parts per trillion (ppt) in otherwise ultra-pure water begins to noticeably lower its resistivity by up to several kΩ·m.

I have a couple of questions:

Puzzle 1. What fraction of water molecules are autoionized at any time? It should be possible to compute this for water at 25℃ knowing that

[H₃O⁺] [OH⁻] = 1.006 × 10-14

at this temperature.

Puzzle 2. How often, on average, does an individual water molecule autoionize? Wikipedia says it happens about once every 10 hours, and cites this paper:

• Manfred Eigen and L. De Maeyer, Untersuchungen über die Kinetik der Neutralisation I, Z. Elektrochem. 59 (1955), 986.

But I don’t know how this was estimated, so I don’t know how seriously to take it.

If we knew answers to Puzzles 1 and 2, maybe we could compute how long an individual molecule remains ionized each time it autoionizes, on average. But I’m worried about a lot of subtleties that I don’t really understand.

For more, read:

• Wikipedia, Self-ionization of water.

• Wikipedia, Grotthuss mechanism.


Agent-Based Models (Part 12)

5 June, 2024

Today I’d like to wrap up my discussion of how to implement the Game of Life in our agent-based model software called AlgebraicABMs.

Kris Brown’s software for the Game of Life is here:

• game_of_life: code and explanation of the code.

He now has carefully documented the code to help you walk through it, and to see it in a beautiful format I recommend clicking on ‘explanation of the code’.

A fair amount of the rather short program is devoted to building the grid on which the Game of Life runs, and displaying the game as it runs. Instead of talking about this in detail—for that, read Kris Brown’s documentation!—I’ll just explain some of the underlying math.

In Part 10, I explained ‘C-sets’, which we use to represent ‘combinatorial’ information about the state of the world in our agent-based models. By ‘combinatorial’ I mean things that can be described using finite sets and maps between finite sets, like:

• what is the set of people in the model?
• for each person, who is their father and mother?
• for each pair of people, are they friends?
• what are the social networks by which people interact?

and so on.

But in addition to combinatorial information, our models need to include quantitative information about the state of the world. For example, entities can have real-valued attributes, integer-valued attributes and so on:

• people have ages and incomes,
• reservoirs have water levels,

and so on. To represent all of these we use ‘attributed C-sets’.

Attributed C-sets are an important data structure available in AlgebraicJulia. They have already been used to handle various kinds of networks that crucially involve quantitative information, e.g.

Petri nets where each species has a ‘value’ and each transition has a `rate constant’

• ‘stock-flow diagrams where each stock has a ‘value’ and each flow has a `flow function’.

In the Game of Life we are using attributed C-sets in a milder way. Our approach to the Game of Life lets the cells be vertices of an arbitrary graph. But suppose we want that graph to be a square grid, like this:

Yes, this is a bit unorthodox: the cells are shown as circles rather than squares, and we’re drawing edges between them to say which are neighbors of which. Green cells are live; red cells are dead.

But my point here is that to display this picture, we want the cells to have x and y coordinates! And we can treat these coordinates as ‘attributes’ of the cells.

We’re using attributes in a ‘mild’ way here because the cells’ coordinates don’t change with time—and they don’t even show up in the rules for the Game of Life, so they don’t affect how the state of the world changes with time. We’re only using them to create a picture of the state of the world. But in most agent-based models, attributes will play a more significant role. So it’s good to talk about attributes.

Here’s how we get cells to have coordinates in AlgebraicJulia. First we do this:

@present SchLifeCoords <: SchLifeGraph begin
  Coords::AttrType
  coords::Attr(V, Coords)
end

Here we are taking the schema SchLifeGraph, which I explained in Part 10 and which looks like this:

and we’re making this schema larger by giving the object V (for ‘vertex’) an attribute called coords:

Note that Coords looks like just another object in our schema, and it looks like our schema has another morphism

coords: V → Coords

However, Coords is not just any old object in our schema: it’s an ‘attribute type’. And coords: V → Coords is not just any old morphism: it’s an ‘attribute’. And now I need to tell you what these things mean!

Simply put, while an instance of our schema will assign arbitrary finite sets to V and E (since a graph can have an arbitrary finite set of vertices and edges), Coords will be forced to be a particular set, which happens not to be finite, namely the set of pairs of integers, ℤ2.

In the code, this happens here:

@acset_type LifeStateCoords(SchLifeCoords){Tuple{Int,Int}} <: 
           AbstractSymmetricGraph;

You can see that the type ‘pair of integers’ is getting invoked. There’s also some more mysterious stuff going on. But instead of explaining that stuff, let me say more about the math of attributed C-sets. What are they, really?

Attributed C-sets

Attributed C-sets were introduced here:

• Evan Patterson, Owen Lynch and James Fairbanks, Categorical data structures for technical computing, Compositionality 4 5 (2022).

and further explained here:

• Owen Lynch, The categorical scoop on attributed C-sets, AlgebraicJulia blog, 5 October 2020.

The first paper gives two ways of thinking about attributed C-sets, and Owen’s paper gives a third more sophisticated way. I will go in the other direction and give a less sophisticated way.

I defined schemas and their instances in Part 10; now let me generalize all that stuff.

Remember, I said that a schema consists of:

1) a finite set of objects,

2) a finite set of morphisms, where each morphism goes from some object to some other object: e.g. if x and y are objects in our schema, we can have a morphism f: x → y, and

3) a finite set of equations between formal composites of morphisms in our schema: e.g. if we have morphisms f: x → y, g: y → z and h: x → z in our schema, we can have an equation h = g ∘ f.

Now we will add on an extra layer of structure, namely:

4) a subset of objects called attribute types, and

5) a subset of morphisms f: x → y called attributes where y is an attribute type and x is not, and

6) a set K(x) for each attribute type.

Mathematically K(x) is often an infinite set, like the integers ℤ or real numbers ℝ. But in AlgebraicJulia, K(x) can be any data type that has elements, e.g. Int (for integers) or Float32 (for single-precision floating-point numbers).

People still call this more elaborate thing a schema, though as a mathematician that makes me nervous.

An instance of this more elaborate kind of schema consists of:

1) a finite set F(x) for each object in the schema, and

2) a function F(f): F(x) → F(y) for each morphism in the schema, such that

3) whenever composites of morphisms in the schema obey an equation, their corresponding functions obey the corresponding equation, e.g. if h = g ∘ f in the schema then F(h) = F(g) ∘ F(f), and

4) F(x) = K(x) when x is an attribute type.

If our schema presents some category C, we also call an instance of it an attributed C-set.

But I hope you understand the key point. This setup gives us a way to ‘nail down’ the set F(x) when x is an attribute type, forcing it to equal the same set K(x) for every instance F. In the Game of Life, we choose

K(Coord) = ℤ2

This forces

F(Coord) = ℤ2

for every instance F. This in turn forces the coordinates of every vertex v ∈ F(V) to be a pair of integers for every instance F—that is, for every state of the world in the Game of Life.

This is all I will say about our implementation of the Game of Life. It’s rather atypical as agent-based models go, so while it illustrates many aspects of our methodology, for others we’ll need to turn to some other models. Xiaoyan Li has been working hard on some models of pertussis (whooping cough), so I should talk about those.


Part 1: The challenge of developing a unified mathematical framework for agent-based models, and designing software that implements this framework.

Part 2: Our project to develop software for agent-based models at the International Centre for Mathematical Sciences, May 1 – June 12 2024.

Part 3: Coalgebras for describing diverse forms of dynamics.

Part 4: The Para construction and its dual, for dealing with agents that are affected by, or affect, the external environment.

Part 5: A proposal for research on modular agent-based models in public health.

Part 6: Describing the stochastic time evolution of non-interacting agents using state charts.

Part 7: Describing the stochastic interaction of agents using state charts.

Part 8: How to describe the birth and death of agents using state charts.

Part 9: The theory of ‘stochastic C-set rewriting systems’: our framework for describing agents using simple data structures that randomly change state at discrete moments in time.

Part 10: A choice of category C suitable for the Game of Life.

Part 11: Stochastic C-set rewrite rules that describe time evolution in the Game of Life.

Part 12: The formalism of ‘attributed C-sets’, for endowing agents with attributes.

Part 13: Literate code for the Game of Life in our software framework for agent-based models.


Transition Metals (Part 2)

1 June, 2024

Why is copper red? Why is it so soft compared to, say, nickel—the element right next to it in the periodic table? Why is it such a good conductor of electricity?

All of this stems from a violation of Hund’s rules. Let me explain.

In Part 1, I explained the basic math of transition metals. Now I just want to talk about how the first row of transition metals fill up the 10 orbitals in the 3d subshell, and what’s special about copper:

These elements have all the electrons that argon does: that’s the [Ar] in this chart. Most also have two electrons in the 4s subshell: one spin up, and one spin down. So the action mainly happens in the 3d subshell. This has 10 slots for electrons: 5 spin up, and 5 spin down. If you don’t know why 5, read Part 1.

Hund’s rules predict how these 10 slots are filled. It predicts that we first get 5 metals with 1, 2, 3, 4, and 5 spin-up electrons, and then 5 more metals that add in 1, 2, 3, 4, and 5 spin-down electrons. And that’s almost what we see.

But notice: when we hit chromium we get an exception! Chromium steals an electron from the 4s subshell to get 5 spin-up electrons in the 4d subshell. And we get an another exception when we hit copper. Can you guess why?

The short answer is that in every atom, its electrons are arranged so as to minimize energy. Hund’s rules are a good guess about how this works. But they’re not the whole story. It turns out that electrons in the d subshell can lower their energy if we have the maximum number possible, namely 5, with spins pointing in the same direction. (We arbitrarily call this direction ‘up’, but there’s nothing special about the ‘up’ direction so don’t lose sleep over that.

So: Hund’s rules predict that we get 5 spin-up electrons when we hit manganese, with 5 electrons in the d subshell. And that’s true. But the energy-lowering effect is strong enough that chromium ‘jumps the gun’ and steals one electron from the somewhat lower-energy s subshell to put 5 spin-up electrons in the d subshell! So chromium also has 5 electrons in the d subshell.

Similarly, Hund’s rules predict that we get 5 spin-up and 5 spin-down electrons when we reach zinc, with 10 electrons in the d subshell. And that’s true. But the element before zinc, namely copper, jumps the gun and steals an electron from the s subshell, so it also has 10 electrons in the d subshell.

The lone electron in its 4s shell makes copper a great conductor of electricity: these electrons can easily hop from atom to atom. And that in turn means that blue and green light are energetic enough to push those electrons around, so copper absorbs blue and green light… while still reflecting the lower-energy red light!

Similar things happen with the elements directly below copper in the periodic table: silver and gold. Wikipedia explains it a bit more technically:

Copper, silver, and gold are in group 11 of the periodic table; these three metals have one s-orbital electron on top of a filled d-electron shell and are characterized by high ductility, and electrical and thermal conductivity. The filled d-shells in these elements contribute little to interatomic interactions, which are dominated by the s-electrons through metallic bonds. Unlike metals with incomplete d-shells, metallic bonds in copper are lacking a covalent character and are relatively weak. This observation explains the low hardness and high ductility of single crystals of copper”

Copper is one of a few metallic elements with a natural color other than gray or silver. Pure copper is orange-red and acquires a reddish tarnish when exposed to air. This is due to the low plasma frequency of the metal, which lies in the red part of the visible spectrum, causing it to absorb the higher-frequency green and blue colors.”

It would take more work to understand why copper, silver and gold have such different colors! People often blame the color of gold on relativistic effects, but this of course is not a full explanation:

• Physics FAQ, Relativity in chemistry: the color of gold.


Agent-Based Models (Part 11)

24 May, 2024

Last time I began explaining how to run the Game of Life on our software for stochastic C-set rewriting systems. Remember that a stochastic stochastic C-set rewriting system consists of three parts:

• a category C that describes the type of data that’s stochastically evolving in time

• a collection of ‘rewrite rules’ that say how this data is allowed to change

• for each rewrite rule, a ‘timer’ that says the probability that we apply the rule as a function of time.

I explained all this with more mathematical precision in Part 9.

Now let’s return to an example of all this: the Game of Life. To see the code, go here.

Specifying the category C

Last time we specified a category C for the Game of Life. This takes just a tiny bit of code:

using AlgebraicABMs, Catlab, AlgebraicRewriting

@present SchLifeGraph <: SchSymmetricGraph begin 
  Life::Ob
  live::Hom(Life,V)
end

This code actually specifies a ‘schema’ for C, as explained last time, and it calls this schema SchLifeGraph. The schema consists of three objects:

E, V, Life

four morphisms:

src: E → V
tgt: E → V
inv: E → E
life: Life → V

and three equations:

src ∘ inv = tgt
tgt ∘ inv = src
inv ∘ inv = 1E

We can automatically visualize the schema, though this doesn’t show the equations:

An instance of this schema, called a C-set, is a functor F: C → Set. In other words, it’s:

• a set of edges F(E),
• a set of vertices F(V), also called cells in the Game of Life
• a map F(src): F(E) → F(V) specifying the source of each edge,
• a map F(tgt): F(E) → F(V) specifying the target of each edge,
• a map F(inv): F(E) → F(E) that turns around each edge, switching its source and target, such that turning around an edge twice gives you the original edge again,
• a set F(Life) of living cells, and
• a map F(live): F(Life) → F(V) saying which cells are alive.

More precisely, cells in the image of F(Life) are called alive and those not in its image are called dead.

Specifying the rewrite rules and timers

Next we’ll specify 3 rewrite rules for the Game of Life, and their timers. The code looks like this; it’s terse, but it will take some time to explain:

# ## Create model by defining update rules

# A cell dies due to underpopulation if it has 
# < 2 living neighbors

underpop = 
  TickRule(:Underpop, to_life, id(Cell); 
  ac=[NAC(living_neighbors(2))]);

# A cell dies due to overpopulation if it has 
# > 3 living neighbors

overpop = 
  TickRule(:Overpop, to_life, id(Cell); 
  ac=[PAC(living_neighbors(4))]);

# A cell is born if it has 3 living neighbors

birth = TickRule(:Birth, id(Cell), to_life; 
                 ac=[PAC(living_neighbors(3; alive=false)),
                     NAC(living_neighbors(4; alive=false)),
                     NAC(to_life)]); 

These are the three rewrite rules:

underpop says a vertex in our graph switches from being alive to dead if it has less than 2 living neighbors

overpop says a vertex switches from being alive to dead if it has more than 3 living neighbors

birth says a vertex switches from being dead to alive if it has exactly 3 living neighbors.

Each of these rewrite rules comes with a timer that says the rule is applied wherever possible at each tick of the clock. This is specified by invoking TickRule, which I’ll explain in more detail elsewhere.

In Part 9 I said a bit about what a ‘rewrite rule’ actually is. I said it’s a diagram of C-sets

L \stackrel{\ell}{\hookleftarrow} I \stackrel{r}{\to} R

where \ell is monic. The idea is roughly that we can take any C-set, find a map from L into it, and replace that copy of L with a copy of R. This deserves to be explained more clearly, but right now I just want to point out that in our software, we specify each rewrite rule by giving its morphisms \ell and r.

For example,

underpop = TickRule(:Underpop, to_life, id(Cell);

says that underpop gives a rule where \ell is a morphism called to_life and r is a morphism called id(Cell). to_life is a way of picking out a living cell, and id(Cell) is a way of picking out a dead cell. So, this rewrite rule kills off a living cell. But I will explain this in more detail later.

Similarly,

TickRule(:Overpop, to_life, id(Cell);

kills off a living cell, and

birth = TickRule(:Birth, id(Cell), to_life;

makes a dead cell become alive.

But there’s more in the description of each of these rewrite rules, starting with a thing called ac. This stands for application conditions. To give our models more expressivity, we can require that some conditions hold for each rewrite rule to be applied! This goes beyond the framework described in Part 9.

Namely: we can impose positive application conditions, saying that certain patterns must be present for a rewrite rule to be applied. We can also impose negative application conditions, saying that some patterns must not be present. We denote the former by PAC and the latter by NAC. You can see both in our Game of Life example:

# ## Create model by defining update rules

# A cell dies due to underpopulation if it has 
# < 2 living neighbors

underpop = 
  TickRule(:Underpop, to_life, id(Cell); 
  ac=[NAC(living_neighbors(2))]);

# A cell dies due to overpopulation if it has 
# > 3 living neighbors

overpop = 
  TickRule(:Overpop, to_life, id(Cell); 
  ac=[PAC(living_neighbors(4))]);

# A cell is born if it has 3 living neighbors

birth = TickRule(:Birth, id(Cell), to_life; 
                 ac=[PAC(living_neighbors(3; alive=false)),
                     NAC(living_neighbors(4; alive=false)),
                     NAC(to_life)]); 

For underpop, the negative application condition says we cannot kill off a cell if it has 2 distinct living neighbors (or more).

For overpop, the positive application condition says we can only kill off a cell if it has 4 distinct living neighbors (or more).

For birth, the positive application condition says we can only bring a cell to life if it has 3 distinct living neighbors (or more), and the negative application conditions say we cannot bring it to life it has 4 distinct living neighbors (or more) or if it is already alive.

There’s a lot more to explain. Don’t be shy about asking questions! But I’ll stop here for now, because I’ve shown you the core aspects of Kris Brown’s code that expresses the Game of Life as a stochastic C-set writing system.


Part 1: The challenge of developing a unified mathematical framework for agent-based models, and designing software that implements this framework.

Part 2: Our project to develop software for agent-based models at the International Centre for Mathematical Sciences, May 1 – June 12 2024.

Part 3: Coalgebras for describing diverse forms of dynamics.

Part 4: The Para construction and its dual, for dealing with agents that are affected by, or affect, the external environment.

Part 5: A proposal for research on modular agent-based models in public health.

Part 6: Describing the stochastic time evolution of non-interacting agents using state charts.

Part 7: Describing the stochastic interaction of agents using state charts.

Part 8: How to describe the birth and death of agents using state charts.

Part 9: The theory of ‘stochastic C-set rewriting systems’: our framework for describing agents using simple data structures that randomly change state at discrete moments in time.

Part 10: A choice of category C suitable for the Game of Life.

Part 11: Stochastic C-set rewrite rules that describe time evolution in the Game of Life.

Part 12: The formalism of ‘attributed C-sets’, for endowing agents with attributes.

Part 13: Literate code for the Game of Life in our software framework for agent-based models.