T1=373.0 #initial temperature [K]
T2=573.0 #final temperature [K]
Q2=750.0 #Heat absorbed by carnot engine[J]
e=(T2-T1)/T2 #efficiency of the engine
W=e*Q2 #Workdone by the engine[J]
Q1=T1*Q2/T2 #Heat rejected by the engine[J]
print"Efficiency of the engine =",round(e,3)
print"\n Workdone by the engine =",round(W),"J"
print"\n Heat rejected by the engine =",round(Q1),"J"
T1=250.0 #temperature of heat rejection[K]
T2=1000.0 #temperature of heat absorption[K]
e=1-(T1/T2)
print"Efficiency of the corresponding carnot engine =",e,"or",e*100,"%"
print" Therefore , the inventors claim of 80% efficiency is absurd.The patent application should be rejected"
T1=323.0 #temperature [K]
T2=423.0 #temperature [K]
W=1.3 #work [KJ]
e=(T2-T1)/T2 #efficiency
Q2=W/e #minimum heat withdrawal from heat source[KJ]
print"Minimum heat withdrawal from heat source=",round(Q2,2),"kJ"
T=298 #Temperature [K]
n=1 #no. of moles
V1=500 #initial volume [cm3]
V2=1000 #final volume [cm3]
R=8.314 #Universal gas constant [J/mol/K]
import math
S=R*math.log(V2/V1) #molar entropy change at constant temperature[J/K]
print"Molar entropy change of argon =",round(S,1),"J/K"
W=1728.0 #Isothermal and reversible work done[J/mol]
T=298.0 #Isothermal temperature[K]
S=W/T #change in molar entropy for isothermal and reversible process
print"The change in molar entropy =",round(S,1),"JK^-1mol^-1"
H=-92.22 #Standard reaction enthalpy[KJ]
T=298 #Temperature [K]
#standard reaction enthalpy is H.Therefore, heat gained by the surroundings at 298K is -H
S=-H*1000/T #Change in entropy[J/K]
print"Change in entropy of the surroundings at 298k =",round(S,1),"J/K"
T1=298.0 #Initial Temperature[K]
T2=573.0 #Final Temperature[K]
Cv=29.1 #Specific Heat capacity of argon gas [J/K/mol]
n=1 #no. of moles
import math
S=n*Cv*math.log(T2/T1) #Change in entropy [J/K]
print"The change in entropy of the argon gas is",round(S,2),"J/K"
T1=276.0 #Initial temperature[K]
Tf=278.7 #Freezing point temperature[K]
Tb=353.3 #Boiling point temperature[K]
T2=373.0 #Final temperature[K]
Hf=9870.0 #Standard enthalpy of fusion[J/mol]
Hv=30800.0 #Standard enthalpy of vaporization[J/mol]
Cp=136.1 #Specific heat capacity of benzene[J/K/mol]
mol_wt=78.0 #molecular weight of benzene[g/mol]
mass=200.0 #weight of solid benzene[g]
print"Cp doesnot change within this temp limit"
import math
n=mass/mol_wt #no. of moles
S1=n*Cp*math.log(Tf/T1) #entropy change in heating [J/K]
S2=n*Hf/Tf #entropy change in melting[J/K]
S3=n*Cp*math.log(Tb/Tf) #entropy change in heating[J/K]
S4=n*Hv/Tb #entropy change in vaporization[J/K]
S5=n*Cp*math.log(T2/Tb) #entropy change in heating[J/K]
S=S1+S2+S3+S4+S5 #total entropy change in heating from 276 to 373K
print"Total entropy change in heating 200g benzene from 3 to 100`C is",round(S,1),"J/K or",round(S/1000,3),"KJ/K"
print"\nNOTE:In textbook the value of 'n' is wrongly calculated as 25.64 instead of 2.564,SO there is a error in answer shown in book"
mass=32 #weight of methane gas[gm]
P1=6*10**5 #Initial temperature[N/m2]
P2=3*10**5 #Final pressure[N/m2]
mol_wt=16 #molecular weight of methane gas[g/mol]
T=298 #Temperature[K]
R=8.314 #Universal gas constant[J/K/mol]
import math
n=mass/mol_wt #no. of moles
S=n*R*math.log(P1/P2) #change in entropy of gas[J/K]
print"The change in entropy of the gas is",round(S,2),"J/K"
import math
black=2 #No. of black balls
white=1 #No. of white ball
W=math.factorial(black+white)/(math.factorial(black)*math.factorial(white))
P=1.0/W
E1=0+1+2
E2=E1
E3=E2
E=E1+E2+E3
E_av=E/3
E1_dash=1+2+3
E2_dash=E1_dash
E3_dash=E2_dash
E_dash=E1_dash+E2_dash+E3_dash
change=E_dash-E
print"1.Total No. of possible configuration:",W
print"2.Probability of getting a configuration=",P,"or 1/3"
print"3.Total energy of system=",E
print" Therefore,Average energy=",E_av
print"4.In this case,Total energy=",E_dash
print" Change in total energy of system=",change
n=1.0 #no. of moles
T=273.0 #temperature [K]
Hf=6000.0 #enthalpy of fusion at 273K [J/mol]
k=1.38*(10**-23) #boltzmann constant[J/K]
p=Hf/(k*T)/2.303
print"\nTHE RESULT IS 10^24,which is too large to be displayed by ipython "
print"This value of w is very large to calculate for python,because it's in the range of 10^24"
print"The relative no. of distinguishable quantum states in 1 mole of water and ice at 273K is 10^24"
print"\nTHE RESULT IS 10^24,which is too large to be displayed by ipython "
T=300 #temperature[K]
n=4 #no. of moles of an ideal gas
P1=2.02*10**5 #initial pressure[N/m2]
P2=4.04*10**5 #final pressure[N/m2]
R=8.314 #Universal gas constant[J/K/mol]
import math
G=n*R*T*2.303*math.log10(P2/P1) #[J]
print" The change in Gibbs free energy is",round(G,1),"J"
n=1 #no. of moles
T=300 #temperature[K]
V1=2 #initial volume[m3]
V2=20 #final volume[m3]
R=8.314 #Universal gas constant[J/K/mol]
import math
A=-n*R*T*2.303*math.log10(V2/V1) #Change in work function[J/mol]
print"The change in Helmholts free energy is",round(A),"J/mol"
print"C6H12O6(s) + 6O2(g) --> 6CO2(g) + 6H2O(l)"
T=298 #Temperature[k]
R=8.314 #Universal gas constant[J/K/mol]
S=182.45 #standard entropy change at 298K [J/K]
U=-2808 #change in internal energy at 298K[KJ/mol]
#reaction is taking place in bomb calorimeter so no volume change
#therefore U=Q at constant volume
A=U-T*S*0.001 #Energy extracted as heat[KJ/mol]
Wmax=A #work done [KJ/mol]
dn=6-6 #change in no. of moles
H=U+dn*R*T #Change in enthalpy of the bomb calorimeter[KJ]
print"The energy change that can be extracted as heat is",round(A),"KJ/mol"
print"\nThe energy change that can be extracted as work is",round(-A),"KJ/mol"
print"\nThe change in enthalpy of bomb calorimeter is",round(H),"KJ/mol"
print"C8H18(g)+12.5O2(g)-->8CO2(g)+9H2O(l)"
T=298.0 #temperature[K]
S=421.5 #change in entropy[J/K]
H=-5109000.0 #Heat of reaction[J]
R=8.314 #Universal gas constant[J/K/mol]
dn=8-(1+12.5) #change in no. of moles
U=H #[J]
A=U-T*S #Change in helmholts free energy[J]
G=A+dn*R*T #Change in Gibbs free energy[J]
print"The change in Helmholts free energy is",round(A),"J"
print"\nThe change in Gibbs free energy is",round(G),"J"
print"The calculation is not precise in book,that's why a slight change in answer"
print"C3H6(g)+4.5O2(g)-->3CO2(g)+3H2O(l)"
S=-339.23 #standard change in entropy [J/K]
T=298 #temperature[K]
Hf1=20.42 #enthalpy of formation of C3H6(g)[J]
Hf2=-393.51 #enthalpy of formation of CO2(g)[J]
Hf3=-285.83 #enthalpy of formation of H2O(l)[J]
dn=3-4.5-1 #change in no. of moles
R=8.314 #Universal gas constant[J/K/mol]
H=3*Hf2+3*Hf3-Hf1 #Enthalpy of the reaction[J]
U=H-dn*R*0.001*T #Change in internal energy of the reaction[J]
A=U-T*S*0.001 #Helmholts free energy change[J]
G=A+dn*R*0.001*T #Gibbs free energy change[J]
print"The change in Helmholts free energy is",round(A,2),"kJ"
print"\nThe change in Gibbs free energy is",round(G,2),"kJ"
print"CH4(g)+2O2(g)-->CO2(g)+2H2O(l)"
S1=-242.98 #standard entropy change for the combustion reaction[J/K]
Hf1=-74.81 #Enthalpy of formation of CH4(g)[KJ/mol]
Hf2=-393.51 #Enthalpy of formation of CO2(g)[KJ/mol]
Hf3=-285.83 #Enthalpy of formation of H2O(l)[KJ/mol]
T=298 #temperature[K]
H=Hf2+2*Hf3-Hf1 #Change in enthalpy of reaction[KJ]
S2=-H*1000/T #Change in entropy of the surrounding[J/K]
Stotal=(S1+S2)*0.001 #Total entropy change
print"The total change in entropy is",round(Stotal,2),"KJ/K"
print"2H2(g)+O2(g)-->2H2O(l)"
Hf1=-285.83 #standard enthalpy of formation of H2O(l)[KJ/mol]
S=-327 #Standard entropy change for the same reaction[J/K]
T=298 #temperature[K]
H=2*Hf1-0-0 #Enthalpy of the reaction[KJ/mol]
G=H-T*S*0.001 #Change in Gibbs free energy[KJ]
print"The change in Gibbs free energy is",round(G,2),"KJ\n "
print"As change in Gibbs free energy is negative.Therefore,the reaction is spontaneous"
print"CH4(g)+2O2(g)-->CO2(g)+2H2O(l)"
S=-242.98 #standard entropy change for reaction [J/K]
T=298 #temperature[K]
Gf1=-50.72 #standard Gibbs free energy of formation for CH4(g)[KJ/mol]
Gf2=-394.36 #standard Gibbs free energy of formation for CO2(g)[KJ/mol]
Gf3=-237.13 #standard Gibbs free energy of formation for H2O(l)[KJ/mol]
G=Gf2+2*Gf3-Gf1 #Standard Gibbs free energy for reaction[KJ/mol]
H=G+T*S*0.001 #Standard enthalpy of reaction [KJ]
print"The standard enthalpy of reaction is",round(H,2),"kJ"
print"C6H12O6(s)+6O2(g)-->6CO2(g)+6H2O(l)"
mass=25.0 #mass of glucose for combustion under standard condition[gm]
T=298 #temperature[K]
Gf1=-910 #Standard Gibbs free energy of formation for C6H12O6[KJ/mol]
Gf2=-394.4 #Standard Gibbs free energy of formation for CO2(g)[KJ/mol]
Gf3=-237.13 #Standard Gibbs free energy of formation for H2O(l)[KJ/mol]
mol_wt=180.0 #molecular weight of glucose[gm/mol]
G=6*Gf2+6*Gf3-Gf1
n=mass/mol_wt #no. of moles
Gactual=G*n #Gibbs free energy for the combustion of 0.139mol of glucose
print"The energy that can be extracted as non-expansion work is",round(-Gactual),"KJ"
a=1.39*10**-2 #constant for a vanderwaal's gas[lit2.atm/mol2]
b=3.92*10**-2 #constant for a vanderwaal's gas[lit2.atm/mol2]
R=0.082 #Universal gas constant[lit.atm/deg/mol]
Ti=(2*a)/(R*b) #inversion temperature [K]
print"The inversion temperature for the gas is",round(Ti,3)," K"
T=169.25 #Boiling point[K]
R=8.314 #Universal gas constant[J/K/mol]
print"dlnP/dT=He/R*T**2"
print"dlnP/dT=(2.303*834.13/T**2)+(1.75/T)-(2.30*8.375*10**-3)"
print"Therefore using these two equations we calculate the He(enthalpy) of ethylene"
x=(2.303*834.13/T**2)+(1.75/T)-(2.30*8.375*10**-3) #it is dlnP/dT
He=R*0.001*T**2*x #Enthalpy of vaporization[J/mol]
print"\n\nThe Enthalpy of vaporization of ethylene at its boiling point is",round(He,3),"KJ/mol"
P1=101.3 #Initial Pressure[KPa]
P2=60 #Final Pressure[KPa]
He=31.8 #Enthalpy of vaporization[KJ/mol]
R=8.314 #Universal gas constant[J/K/mol]
T1=353.2 #boiling point of benzene at 101.3KPa[K]
import math
x=(T1**-1)-(R*0.001*math.log(P2/P1)/He)
T2=x**-1 #Boiling point of benzene at 60KPa
print"The boiling point of benzene at 60KPa is",round(T2,1),"K"
P1=0.016 #Vapour pressure of pure ethanol at 273K[bar]
P2=0.470 #Vapour pressure of pure ethanol at 333K[bar]
T1=273 #initial temperature [K]
T2=333 #final temperature[K]
R=8.314 #Universal gas constant[J/K/mol]
P=1.01 #vapour pressure at normal boiling point[bar]
import math
x=(T2**-1)-(T1**-1)
He=-R*0.001*math.log(P2/P1)/x #molar enthalpy of vaporization[J/mol]
t=(T2**-1)-(R*0.001*math.log(P/P2)/He)
T=(t**-1)-273 #normal boiling point [C]
print"\n\nThe normal boiling point for pure ethanol is ",round(T,1),"C"
print"The molar enthalpy of vapourization is",round(He,2),"J/mol"
T2=353.2 #normal boiling point of benzene at 1.01325bar[K]
T1=298 #temperature [K]
R=8.314 #Universal gas constant[J/K/mol]
P2=1.01325 #Vapour pressure of benzene[bar]
import math
#benzene obey's Trouton's rule
print" from Troutons rule , "
print" He/Tb=85J/K/mol"
He=85*T2 #molar enthalpy of vapourization[J/K/mol]
x=(T2**-1)-(T1**-1)
t=-He*x/R
P1=P2/math.exp(t)
print"\nThe vapour pressure of benzene at 298K is",round(P1,3)," bar"
c=1 #no. of components(only CO2)
p=2 #no. of phases(liquid + gas)
F=c-p+2 #degree of freedom
print"Degrees of freedom is",F
print"Degrees of freedom 1 means that either pressure or temperature can be varied independently,i.e.when temperature is fixed,pressure is automatically fixed"
c=1 #no. of components
p=1 #no. of phases
F=c-p+2 #Degrees of freedom
print"Degrees of freedom,F is",F
print"Degrees of freedom 2 means both the pressure and temperature can be varied independently"
P=1.75*10**-5 #Vapour pressure of pure water at 293K[torr]
dP=1.1*10**-7 #Lowering in vapour pressure of water
x=dP/P #mole fraction of sucrose
print"The mole fraction of sucrose is",round(x,6)
P=94.6 #The vapour pressure of pure benzene at 298K[torr]
n1=20.0 #no. of moles of pure benzene
n2=5.0 #no. of moles of pure naphthalene
x=n1/(n1+n2) #(mole fraction of benzene)
p=x*P #the partial vapour pressure of benzene[torr]
print"The partial vapour pressure of benzene is",p,"torr"
x=0.28 #mole fraction of solute
R=8.314 #Universal gas constant[J/K/mol]
T=298 #temperature[K]
import math
du=R*T*math.log(1-x) #reduction in chemical potential[J/mol]
print"The reduction in chemical potential is",round(-du,1),"J/mol"
Kb=0.51 #ebullioscopic constant of water [K*Kg/mol]
n=155.0/180.0 #no. of moles of glucose
m=n/1 #[mol/Kg]
Ti=373.0 #Boiling point temperature of water[K]
Tf=(Ti+Kb*m)-273 #boiling point temperature of the solution[C]
print"The boiling point of the solution is",round(Tf,2),"degree C"
Ti=5.44 #freezing point of pure benzene[K]
Tf=4.63 #freezing point of solution[K]
m1=2.12 #mass of the solute[gm]
m2=125.0 #mass of the benzene[gm]
Kf=5.12 #cryoscopic constant of pure benzene[K*Kg/mol]
dTf=Ti-Tf #depression in freezing point[K]
M2=(m1*1000*Kf)/(m2*dTf) #molar mass of solute
print"The molar mass of solute is",round(M2),"(approx)"
print"N2(g)+3H2(g)<=>2NH3(g)"
T=298 #Temperature[K]
Gf1=-16450 #Gibb's free energy of formation for NH3(g)[J/mol]
R=8.314 #Universal gas constant[J/K/mol]
import math
Gf=2*Gf1 #Gibb's free energy for the reaction[KJ]
x=Gf/R/T
Kp=math.exp(-x)
print"The Kp for above reaction is",round(Kp),"or 5.85*10^5,in scientific notation(APPROX)"
print"0.5N2(g)+1.5H2(g)<=>NH3(g)"
T=298 #Temperature[K]
Kp=900 #Equilibrium constant for above reaction
P1=0.32 #partial pressure of N2(g)[bar]
P2=0.73 #partial pressure of H2(g)[bar]
P3=0.98 #partial pressure of NH3(g)[bar]
R=8.314 #Universal gas constant[J/K/mol]
import math
G=-R*T*math.log(Kp)
x=(P1**0.5)*(P2**1.5)
p=P3/x
Gr=(G+R*T*math.log(p))*0.001
print"The reaction Gibbs free energy is",round(Gr*1000),"J/mol "
print"N2(g)+3H2(g)<=>2NH3(g)"
Kp1=5.85*10**5 #equilibrium constant at 298K
H1=-46.11 #standard enthalpy of formation of NH3(g)[KJ/mol]
T1=298 #Initial temperature[K]
T2=423 #Final temperature[K]
R=8.314 #Universal gas constant[J/K/mol]
import math
H=2*H1 #enthalpy for reaction [KJ]
t=(T1**-1)-(T2**-1)
x=-H*t/(R*0.001)
Kp2=Kp1*math.exp(x)
print"The Equilibrium constant for reaction at 423K is",round(Kp2)
print"Zn(s)|ZnCl2(aq)||CdSO4(aq)|Cd(s)"
T=298.0 #Temperature[K]
R=8.314 #Universal gas constant[J/K/mol]
E1=-0.7618 #Standard electrode potential for Zn2+/Zn [volts]
E2=-0.403 #Standard electrode potential for Cd2+/Cd [volts]
F=96500.0 #Faraday's constant[coulomb/mol]
n=2.0 #no. of electrons balancing
Ei=E2-E1 #Standard potential for the reaction[volts]
import math
Gi=-n*F*Ei #Standard Gibb's Free Energy [KJ/mol]
Ki=math.exp(-Gi/R/T) #Equilibrium constant
print"The Free energy for the rection is",Gi*0.001,"KJ/mol"
print"The value of equilibrium constant is",Ki
print"Cd(s)|CdSO4(aq),Hg2SO4(s)|Hg(l)"
E3=0.6141 #Standard electrode potential for Hg2SO4(s),SO4^2-/Hg(l) [volts]
Eii=E3-E2 #Standard potantial for the reaction[volts]
Gii=-n*F*Eii #Standard Gibb's free energy[KJ/mol]
Kii=math.exp(-Gii/R/T) #Equilibrium constant
print"The Free energy for the rection is",round(Gii*0.001,1),"KJ/mol"
print"The value of equilibrium constant is",Kii
print"PLEASE REDO the last line calculation,It is showing wrong result in my PC"
print"Zn(s)|ZnCl2(soln)||AgCl(s)|Ag-Ag|AgCl(s)|ZnCl2(soln)|Zn(s)"
m1=0.02 #concentration[M]
Y1=0.65 #mean ionic activity coefficient
m2=1.5 #concentration[M]
Y2=0.29 #mean ionic activity coefficient
R=8.314 #Universal gas constant[J/K/mol]
T=298 #Temperature [K]
F=96500 #Faraday's constant[coulomb/mol]
import math
E=R*T*(math.log(m2*Y2/m1/Y1))*3/2/F #[volts]
print"The overall e.m.f of the cell is",round(E,4),"volt"
print"H2(g,1atm)|HCl(aq)|HCl(aq)|H2(g,1atm)"
m1=0.02 #concentration[M]
Y1=0.88 #mean ionic activity coefficient
m2=1 #concentration[M]
Y2=0.81 #mean ionic activity coefficient
R=8.314 #universal gas constant[J/K/mol]
T=298 #Temperature[K]
F=96487 #Faraday's constant[coulombs/mol]
t=0.178 #Tranference number of Cl-1
import math
E=-2*t*R*T*(math.log(m1*Y1/m2/Y2))/F #e.m.f of the cell[volts]
print"The e.m.f of the cell is",round(E,3)," volts"
print"\nWrongly calculated in book as 0.351 volt"
print"The values for reaction that goes on within the cadmium cell"
n=2 #no. of moles
E=1.01463 #standard cadmium cell potential[volts]
d=-5*10**-5 #i.e d=dE/dT[V/K]
F=96500 #[coulomb/mol]
T=298 #Temperature [K]
dG=-n*E*F #Change in Gibb's free energy[J]
dS=n*F*d #Change in entropy [J/K]
dH=dG+T*dS #change in enthalpy[J]
print" dG=",dG,"J\nWrongly calculated in book as -195815 J"
print"\n dS=",dS,"J/K"
print"\n dH=",dH,"J"