A blog of Python-related topics and code.

Visualizing Viviani's curve

Viviani's curve is the line of intersection between a sphere of radius $2a$ and a cylinder of radius $a$ which is tangent to the sphere and also passes through its centre.

The miscibility of a regular solution

A binary regular solution is one in which the two components, A and B, mix with an entropy of mixing given by the ideal solution model, $$ \Delta_\mathrm{mix}S = -R(x_1\ln x_1 + x_2\ln x_2) $$ but have a non-zero enthalpy of mixing given by the relation $$ \Delta_\mathrm{mix}H = \beta x_1 x_2 $$ where $\beta$ is a parameter describing the difference between the A–B interaction and the average of the A–A and B–B interactions. If $\beta > 0$, there may be some compositions which are immiscible at some temperatures. In this case, it can be shown that there is a maximum temperature, the upper critical solution temperature (UCST), given by $T_\mathrm{c} = \frac{\beta}{2R}$, above which all compositions are miscible.

The Klauber Triangle

enter image description here

The Ulam Spiral

The Ulam Spiral is a simple way to visualize the prime numbers which reveals unexpected, irregular structure. Starting at the centre of a rectangular grid of numbers and spiralling outwards, mark the primes as 1 and the composite numbers as 0.

$k$-means clustering of exoplanet data

The website hosts a repository of data on over 5000 exoplanets discovered by various missions and techniques. For this post, I have extracted data on the mass and orbital period of 2951 exoplanets: exoplanet-data-160824.csv. The planetary masses are expressed relative to the mass of Jupiter (M) and the orbital period is in days.