# Van der Waals.py

(Difference between revisions)
 Revision as of 16:05, 30 September 2018Werner (Talk | contribs) (OOou)← Previous diff Current revisionWerner (Talk | contribs) Line 1: Line 1: This is the python2 program useful for the homework session This is the python2 program useful for the homework session - of [[ICFP_Stat_Physics_2018|week 04 of my ICFP Lectures on statistical mechanics]]. You can run it directly, or else translate it into the computer language of your choice. + of [[ICFP_Stat_Physics_2019|week 04 of my ICFP Lectures on statistical mechanics]]. You can run it directly, or else translate it into the computer language of your choice.

## Current revision

This is the python2 program useful for the homework session of week 04 of my ICFP Lectures on statistical mechanics. You can run it directly, or else translate it into the computer language of your choice.

```import pylab, numpy
for t in numpy.arange(0.3, 1.5, 0.1):
vval = []
pval = []
for v in numpy.arange(0.34, 4.0, 0.001):
p = 8.0 * t / 3.0 / (v - 0.333333) - 3.0 / v ** 2
vval.append(v)
pval.append(p)
pylab.plot(vval, pval, label='\$T=\$'+ str(t))
pylab.title("van der Waals equation of state")
pylab.xlabel("reduced volume \$v\$")
pylab.ylabel("reduced pressure \$p\$")
pylab.xlim([0.0,3.5])
pylab.ylim([-2.0,4.0])
pylab.legend(loc='upper right')
pylab.savefig('Eq_state_vdw.png')
pylab.show()
```