import numpy as np
import matplotlib.pyplot as plt
import scipy.special
from itertools import combinations
nlevels = 6
Counting = 0
for p1 in range(nlevels):
for p2 in range(nlevels):
for p3 in range (nlevels):
for p4 in range (nlevels):
for p5 in range (nlevels):
iconfig = np.zeros(nlevels)
iconfig[p1] += 1
iconfig[p2] += 1
iconfig[p3] += 1
iconfig[p4] += 1
iconfig[p5] += 1
print('%s' % str(iconfig))
Counting += 1
print ('Total number of microstates for this system is', Counting)
nlevels = 6
Counting = 0
for p1 in range(nlevels):
for p2 in range(nlevels):
for p3 in range (nlevels):
for p4 in range (nlevels):
for p5 in range (nlevels):
iconfig = np.zeros(nlevels)
iconfig[p1] += 1
iconfig[p2] += 1
iconfig[p3] += 1
iconfig[p4] += 1
iconfig[p5] += 1
energy_1 = iconfig[0]*0
energy_2 = iconfig[1]*1
energy_3 = iconfig[2]*2
energy_4 = iconfig[3]*3
energy_5 = iconfig[4]*4
energy_6 = iconfig[5]*5
totalenergy = energy_1+energy_2+energy_3+energy_4+energy_5+energy_6
if totalenergy == 5:
Counting+=1
print('%s' % str(iconfig))
else:
Counting=Counting
print ('Total number of allowed microstates for this system is', Counting)
array = np.zeros((126,6))
nlevels = 6
Counting = 0
for p1 in range(nlevels):
for p2 in range(nlevels):
for p3 in range (nlevels):
for p4 in range (nlevels):
for p5 in range (nlevels):
iconfig = np.zeros(nlevels)
iconfig[p1] += 1
iconfig[p2] += 1
iconfig[p3] += 1
iconfig[p4] += 1
iconfig[p5] += 1
energy_1 = iconfig[0]*0
energy_2 = iconfig[1]*1
energy_3 = iconfig[2]*2
energy_4 = iconfig[3]*3
energy_5 = iconfig[4]*4
energy_6 = iconfig[5]*5
totalenergy = energy_1+energy_2+energy_3+energy_4+energy_5+energy_6
if totalenergy == 5:
print('%s' % str(iconfig))
array[Counting,:] = iconfig
Counting+=1
else:
Counting=Counting
print(array)
uniquearray = np.unique(array, axis=0)
print(uniquearray)
weight_array,weights = np.unique(array,axis=0,return_counts=True)
print(weight_array)
print(weights)