Proc ReprintConstants

From Flooxs
Revision as of 20:33, 17 August 2010 by Nrowsey (talk | contribs) (New page: #----------------------------------------------------------- # Reprint Const Strings Just 1x for Contact Ridiculousness #----------------------------------------------------------- pro...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
#-----------------------------------------------------------
# Reprint Const Strings Just 1x for Contact Ridiculousness
#-----------------------------------------------------------
proc ReprintConsts { Mat } {
   global smaller
   set sm $smaller

   #------------------------------------------------------
   # Temperature-Dependent Variables first
   #------------------------------------------------------
  	#T-Vars: these are Doubles
   	foreach var {T Vt Chi Eg Nc Nv} {
		set $var [pdbGetDouble $Mat $var]
		eval set val \$$var
		puts "$var is $val"
   	};#these are the vars that have a T change only

   #Band Terms Ec(T), Ev(T) - these are strings
   	set Ec "(-(DevPsi)-($Chi))"
   	set Ev "(-(DevPsi)-($Chi)-($Eg))"

   #------------------------------------------------------
   # Initial Conditions: elec0 and hole0 for Poisson-Only
   #------------------------------------------------------    
	#elec0 and hole0

#------------------------------------------------------

		#Maxwell-Boltzmann statistics are default
	    #------------------------------------------------------    
   	set elec0 "(($Nc)*exp(-($Ec-0.0)/($Vt)))"
   	set hole0 "(($Nv)*exp(-(0.0-($Ev))/($Vt)))"
	    #------------------------------------------------------    
	    # Fermi-Dirac gamma0 for elec0 and hole0
       #------------------------------------------------------    
		if {[pdbGetBoolean $Mat FD]} {
			puts "\nFD statistics: modifying elec0 and hole0"	
		    #Forward Transform	- gamma0 for elec0 and hole0
#			set MAX 5
			set MAX 1
			set pi 3.1415926535
			#Define eta's
			set eta_n0 "((0.0-($Ec))/$Vt)"
			set eta_p0 "(($Ev-0.0)/$Vt)"
			#Define gamma's
			for {set i 1} {$i <= $MAX} {incr i} {
			    #calculate gm's: Laplace transform of x^(1/2)
				set sign [expr {pow(-1,[expr {$i+1}])}]
				set g    [expr {(sqrt($pi)/2.0)*pow($i,-1.5)}]
				set coef [expr {$i-1}]
			    #gamma=(F1/2(eta))/exp(eta))
				append gamma_n0 "+($sign)*$g*exp($coef*$eta_n0)"
				append gamma_p0 "+($sign)*$g*exp($coef*$eta_p0)"
			}

#			set elec0 "($Nc*($gamma_n0)*exp(-($Ec-0.0)/$Vt))"
#	        set hole0 "($Nv*($gamma_p0)*exp(-(0.0-($Ev))/$Vt))"
		}

   	# If Poisson Only - choose elec0/hole0 or Elec/Hole
		if {[pdbGetBoolean PoissonOnly]} {
			#if POnly, then Elec and Hole are const - use elec0 and hole0
			set elec $elec0
			set hole $hole0
    	} else {
			#else Elec and Hole are not const, use Elec and Hole
			set elec Elec
			set hole Hole
		}

   #nQFL and pQFL - MB is default
		set nQFL "(-(DevPsi)-$Chi+$Vt*log(abs($elec+$sm)/$Nc))"
		set pQFL "(-(DevPsi)-$Chi-$Eg-$Vt*log(abs($hole+$sm)/$Nv))"

   #------------------------------------------------------
   # Complete Ionization is Default
   #------------------------------------------------------
   #Na, Nd, and Doping - these are strings
#    	foreach var {Nd Na} {set $var "([solution print name=$var $Mat])"}
		foreach var {Nd Na} {set $var "([pdbGetDouble Silicon $var])"}
		set Doping "(($Nd)-($Na))";#complete ionization default
		upvar 1 Type Type
   	if {[string compare $Type "Ntype"] == 0} {set Doping "($Nd)"}
    	if {[string compare $Type "Ptype"] == 0} {set Doping "(0.0-($Na))"}

   #------------------------------------------------------
   # Incomplete Ionization - modifies Doping
   #------------------------------------------------------
   	#Dependent on: Vt, Ec, Ev, Nd, Na
   	upvar 1 Contact Contact
	    if {[pdbGetBoolean Silicon IncIon]} {;#if IncIon on, change Doping
	    	puts "IncIon is on: Changing the Doping Model on the Contact"
			set Ed0 [pdbGetDouble Arsenic Ed0]
			set Ea0 [pdbGetDouble Boron Ea0]
			#set deltaEd "($Ed0-(3.100e-8)*(($Nd)^(1.0/3.0))+(200.0*(($T)^(-(1.00)))-(0.66)))"
			#set deltaEa "($Ea0-(3.037e-8)*(($Na)^(1.0/3.0))+(200.0*(($T)^(-(0.95)))-(0.88)))"
			set deltaEd $Ed0;#use constant for now
			set deltaEa $Ea0
			set Ndplus "($Nd/(1.0+2.0*exp((-($Contact)-($Ec)+$deltaEd)/($Vt))))";#-Cont=+nQFL
			set Naplus "($Na/(1.0+4.0*exp(($Ev+$deltaEa-(-($Contact)))/($Vt))))";#-Cont=+pQFL
#			set Ndplus "($Nd/(1.0+2.0*exp(($nQFL-($Ec)+$deltaEd)/($Vt))))";#-Cont=+nQFL
#			set Naplus "($Na/(1.0+4.0*exp(($Ev+$deltaEa-($pQFL))/($Vt))))";#-Cont=+pQFL
			set Doping "(($Ndplus)-$Naplus)";#incomplete ionization
	    	if {[string compare $Type "Ntype"] == 0} {set Doping "($Ndplus)"}
	    	if {[string compare $Type "Ptype"] == 0} {set Doping "(0.0-($Naplus))"}
			puts "Doping is stored as: $Doping"
	    };#end of IncIon if

   #-----------------------------------------------------------
   # Fermi-Dirac Statistics: modifies log term in n/pQFL
   #-----------------------------------------------------------
  	#Dependent on: Doping, Nc, Nv, Chi, Eg, Vt
	if {[pdbGetBoolean $Mat FD]} {
		puts "\nFD statistics: modifying log term in n/pQFL on the contact"	
	
		#Reverted Series - eta_rev
		set A1  3.53553e-1
		set A2 -4.95009e-3
		set A3  1.48386e-4
		set A4 -4.42563e-6

		set Xn   "(($elec+$sm)/$Nc)"
		set Xp   "(($hole+$sm)/$Nv)"

		set eta_n_rev "(log($Xn))"
		set eta_p_rev "(log($Xp))"
# 		set eta_n_rev "(log($Xn)+($A1)*($Xn)+($A2)*(($Xn)^2)+($A3)*(($Xn)^3))"
#		set eta_p_rev "(log($Xp)+($A1)*($Xp)+($A2)*(($Xp)^2)+($A3)*(($Xp)^3))"
	
		for {set i 1} {$i <= 1} {incr i} {;#should be $i <= 4
		    eval set A \$A$i
# 		    append eta_n_rev "+($A)*(($Xn)^($i))"
#		    append eta_p_rev "+($A)*(($Xp)^($i))"
		}
		set nQFL "(-(DevPsi)-$Chi+$Vt*($eta_n_rev))"
		set pQFL "(-(DevPsi)-$Chi-$Eg-$Vt*($eta_p_rev))"
	}
    	
    #------------------------------------------------------
  	# Store the band-term strings globally in the pdb
   #------------------------------------------------------
   	foreach var {nQFL pQFL Doping elec0 hole0} {
			eval set val \$$var
			pdbSetString $Mat $var $val
			puts "$var is stored as: [pdbGetString $Mat $var]"
    	}

}