Canonic bosons.py

From Werner KRAUTH

Revision as of 00:36, 9 December 2016; view current revision
←Older revision | Newer revision→
Jump to: navigation, search

This is the python program Canonic_bosons.py useful for the homework session of week 13 of my ICFP Lectures on statistical mechanics.


import math, cmath, numpy, pylab
 
N0vec = []
dos = [1, 3, 6, 10, 15]
T = 1.0
beta = 1.0 / T
Zint = complex(0.0, 0.0)
eps = 0.001
dellambda = 0.01
oldl = complex(-math.pi, dellambda)
complexi = complex(0.0, 1.0)
for RL in numpy.arange(-math.pi, math.pi, 0.00001):
    newl = RL + eps * complexi
    integrand = cmath.exp(-complexi * 5 * newl)
    for E in range(5):
        integrand /= (1.0 - cmath.exp( - beta * E + complexi * newl)) ** dos[E]
    Zint += integrand * (newl - oldl) / (2.0 * math.pi)
    oldl = newl
print Zint
Personal tools