The program shows how to plot figure 14.4 page 248 presented in T. L. Hill, An Introduction to Statistical Thermodynamics, Dover, New York, 1986. The Bragg-Williams approximation gives pressure-volume isotherms similar to those obtained using the van der Waals equation and it predicts first-order phase transition. We use the symmetry condition to draw the horizontal stable equilibrium path. We can also use the thermodynamic equal-area theorem as shown at the end of the code.
A similar treatment using Mathematica
can be found at the following link:
Typical submission from this author. Simply reproduces figures found in a specific journal article. No user settable parameters. No variable descriptions. No help text to explain the code. Promotes poor programming practices to students.