##Ex.14.4.1.;Calculate the efficiency of the generator and also compare with the carnot efficiency
import math
##cathode work funtion
flux_c=2.5;##unit=volts
##anode work funtion
flux_a=2.;##unit=volts
##Temp. of cathode
Tc=2000.;##unit=degree k
##Temp. of surrounding
Ts=1000.;##unit=degree k
##plasma potentail drop
flux_p=0.1;##unit=volts
##Net output voltage
V=flux_c-flux_a-flux_p
print'%s %.2f %s'%(" V=",V," volt");
##charge of an electron
e=1.6*10**-19.;##unit=coulomb
##boltzmann constant
k=1.38*10**-23.;##unit=joule/degree kelvin
A=1.20*10**6;
##one electron volt=1.6*10**-19 joule
##The net current in the generator J=J_cathode-J_anode
##let EC=e**(-flux_c/k*Tc)
EC=math.e**(-(1.6*10**-19*flux_c)/(k*Tc));
J_cathode=A*(Tc*Tc)*EC##J_cathode=A*Tc**2*e**(-flux_c/k*Tc)
print'%s %.2f %s'%("\n J_cathode=",J_cathode," amp/m^2");
##let EA=e**(-flux_c/k*Ts)
EA=math.e**(-(1.6*10**-19*flux_a)/(k*Ts));
J_anode=A*(Ts**2)*EA;##J_cathode=A*Ts**2*e**(-flux_c/k*Ts)
print'%s %.2f %s'%("\n J_anode=",J_anode," amp/m^2");
##The net current can be taken =Jc,as Ja can be neglected in comparison with Jc
J=J_cathode;
print'%s %.2f %s'%("\n J=",J," amp/m^2");
##The heat supplied to the cathode Qc/Ac=J(flux_c+((2*k*Tc)/e))+samestion of sigma*(Tc**4-Ts**4)
##let QA=Qc/Ac; and
a=2.5+((2*1.38*10**-23*2000.)/(1.6*10**-19));
b=J*a;
c=(0.2*5.67*(10**-12.)*(10**-4.)*((2000**4)-(1000**4)));
##therefore
QA=b+c; ##since: QA=(J*(2.5+((2*(1.38*10**-23)*2000*)/(1.6*10**-19))))+(0.2*5.67*(10**-12)*(10**-4)*((2000**4)-(1000**4)))
print'%s %.2f %s'%("\n The heat supplied to the cathode Qc/Ac=",QA," watt/m^2");
##efficiency of the generator
ng=((J*V)/(7.026*10**6))*100.;
print'%s %.2f %s'%("\n ng=",ng," persent");
##carnot efficiency this device
T1=2000.;
T2=1000.;
T=2000.;
nc=((T1-T2)/T)*100.;
print'%s %.2f %s'%("\n nc=",nc," persent");
##Value of "The heat supplied to the cathode Qc/Ac" is given wrong
##value of charge e is taken wrong;corrected by giving value 1.6*10**-19
##value of J anode is differ from calculated value.