#!/usr/local/bin/python #Solve the finite 1-D well #The constants here are for the (Ga,Al)As well in the problem sheet 2, #but can be redefined for any similar problem. #By Graham Lee #How this works: #1. define a value of kappa #2. use the energy relation to define k #3. see if this is consistent with the tan() relation #4. rinse #5. repeat #6. ??? #7. PROFIT!!!! # The program works in SI units, converting to eV to report the energies. # Good job Python supports infinite precision :-) import math effMassA=0.0632 effMassB=0.091 elecMass=9.109e-31 elecCharge=1.602e-19 hBar=1.055e-34 a=1.05e-8 kappa0=1.222e4 #Based on a crude estimation of the wavevector at the top of the well :) deltaE=0.149*elecCharge print "Here we go...." for i in range(1,50000): kappa=i*kappa0 k=math.sqrt((-1.0*effMassA*kappa*kappa/effMassB)+2.0*effMassA*elecMass*deltaE/(hBar*hBar)) if math.floor(1000.0*math.tan(k*a/2.0))==math.floor(1000.0*effMassA*kappa/(effMassB*k)): energy=hBar*hBar*k*k/(2.0*effMassA*elecMass*elecCharge) print "Even solution found at k="+str(k)+"m^-1" print " kappa="+str(kappa)+"m^-1" print "Energy of this solution ="+str(energy)+"eV" if math.floor(1000.0*math.tan(k*a/2.0))==math.floor(-1000.0*effMassB*k/(effMassA*kappa)): energy=hBar*hBar*k*k/(2.0*effMassA*elecMass*elecCharge) print "Odd solution found at k="+str(k)+"m^-1" print " kappa="+str(kappa)+"m^-1" print "Energy of this solution ="+str(energy)+"eV" print "Done." raw_input()