#Calculate the transmittance
#Initialization of variables
import math
wl=256*math.pow(10,-9) #m
t=1 #mm
C=0.050 #mol/L
T=0.16
t2=2 #mm
#calculations
E=-math.log10(T) /(C*t)
A1=-math.log10(T)
A2=E*C*t2
Tr=math.pow(10,(-A2))
#results
print '%s %.3f' %("Transmittance = ",Tr)
#calculate the Quenching rate constant and half life
#Initialization of variables
import math
import numpy as np
from numpy import linalg
Q=[1., 2., 3., 4., 5]
t1=[5.2, 9.4, 13.7, 18., 22.2]
t2=[1.1, 2., 2.9, 4., 4.5]
#calculations
A = np.vstack([Q, np.ones(len(Q))]).T
kqbykf=np.linalg.lstsq(A,t1)[0]
slope1=kqbykf[0] *1000.
kq=np.linalg.lstsq(A,t2)[0]
slope2=kq[0] *math.pow(10,10)
kq=slope2
kf=kq/slope1
thalf=math.log (2) /kf
#results
print '%s %.1e %s' %("Quenching rate constant =",kq,"L ml^-1 s^-1")
print '%s %.1e %s' %("\n Half life=",thalf,"s")