#initiation of variable
from math import log ,log10
V_Cd=-0.403 #Half Cell Potential of Cd++|Cd in volt
V_Ni=-0.250 #Half Cell Potential of Ni++|Ni volt
C_Ni=10.0**-3
C_Cd=0.5
n=2 #Net electron exchange in Redox reaction
#part A
#calcualation
dV=V_Ni-V_Cd # Potential difference in volts
#results
print " Standard Cell potential is : %.3f V" %dV
#partB
V=-dV-(0.0592*log10(C_Ni/C_Cd)/n)
#results
print" Net EMF is : %.3f V" %V
print" That is,",
if V<0 :
print"\t Cd is oxidised & Ni is reduced"
else :
print"\t Cd is reduced & Ni is oxidised"
#initiation of variable
from math import log ,log10,floor
VH_H2=0.0 # half cell voltage
VZn_Zn2=-0.763 # half cell voltage
iZn=10.0**-7 # current density in A/cm^2
iH2=10.0**-10 # current density in A/cm^2
beta_Zn=0.09
beta_H2=-0.08
n=2.0 #Exchange of 2 electrons
F=96500.0#Faradays constant
#partA
#calculation
i_c=10**((VH_H2-VZn_Zn2-(beta_H2*log10(iH2))+(beta_Zn*log10(iZn)))/(beta_Zn-beta_H2))
r=i_c/(n*F)
#results
print"Rate of oxidation with zinc is %.2e A/cm^2" %i_c
print" Rate of oxidation is %.2e mol/cm^2-s" %(floor(r*1e12)/1e12)
#Part B
Vc=VH_H2+(beta_H2*log10(i_c/iH2))
#results
print" Corrosion potential is %.3f V" %Vc