I have a MATLAB script for calculating the entropy of a molecule according to its vibrational frequencies, and which I know to be correct by comparing it with experimental results. The MATLAB script is as follows:
h=6.626*10^-34;
k=1.380*10^-23;
N=6.022*10^23;
n=N/1000;
R=N*k;
P0=101325; % Abhijit's operating pressure
m=16.042*1.67*10^-27;
T=975+273.15; % Abhijit's operating temperature
B=1/(k*T);
c=3*10^8;
v1=[3015,3006,2946,2894,1460,1455,1368,1241,1232,1000,945,652,252,223,183];
f1=v1*c*100;
s4ppafin=N*sum(((h*f1)/(T*(exp((B*h*f1)-1))))-(k*log(1-exp(-h*B*f1))))
This MATLAB code produces an output of 100.8006. My attempt to reproduce this code in Python is as follows:
import numpy as np
# Do harmonic oscillator entropy approx. for the 4thppaFin system
c=3*10**8 # Approx. speed of light, m/s
h=6.626*10**-34 # Planck's constant, J/s
k=1.38*10**-23 # Boltzmann's constant, J/K
N=6.022*10**23 # Avogardo's number, particles/mole
R=N*k # Ideal Gas Constant, J/(mol*k)
T=975+273.15 # Refernce temperature, Abhijit's operating condition
B=1/(k*T) # Thermodynamic Beta
v=np.array([3015.0,3006,2946,2894,1460,1455,1368,1241,1232,1000,945,652,252,223,183],dtype=float)
f=np.array([c*100*i for i in v],dtype=float)
print(f)
q=[0]*len(f) # Part. func. init. for HO approx.
# q=np.array(q)
for i in range (len(f)):
q[i]=((h*f[i])/(T*(np.exp((B*h*f[i])-1))))-(k*np.log(1-np.exp(-h*B*f[i])));
print(q)
S=N*sum(q)
print(S)
Here, the output is 145.25.
What is the cause for the Python script to produce a different number?