Canonic bosons.py

From Werner KRAUTH

(Difference between revisions)
Jump to: navigation, search
Revision as of 00:17, 9 December 2016
Werner (Talk | contribs)

← Previous diff
Revision as of 00:36, 9 December 2016
Werner (Talk | contribs)

Next diff →
Line 1: Line 1:
-This is the program Canonic_bosons.py, that is useful for Homework 13+This is the python program Canonic_bosons.py useful for the homework session
 +of [[ICFP_Stat_Physics_2016|week 13 of my ICFP Lectures on statistical mechanics]].

Revision as of 00:36, 9 December 2016

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