def intrho(self, EFn, EFp): assert (len(self.dopants) == 1), "Should have one dopant" #d=self.dopants.values()[0] # if d["type"]=="donor": # intrho_maj=\ # -q*kT*(self.Nc*int_fermi_dirac_one_half((mu-self.Ec)/kT) # +d["conc"]*fermi_dirac_zero(-(mu-self.Ec+d["E"]+np.log(2)*kT)/kT)) # elif d["type"]=="acceptor": # intrho_maj=\ # -q*kT*(self.Nv*int_fermi_dirac_one_half((self.Ev-mu)/kT) # +d["conc"]*fermi_dirac_zero(-(self.Ev+d["E"]-mu+np.log(4)*kT)/kT)) #print 'sup: ',intrho_maj[-1], self._intrho_ref, self.Nc*int_fermi_dirac_one_half((mu-self.Ec)/kT)[-1] # intrho=intrho_maj-self._intrho_ref+self._minorrho*(mu-self.mu_bulk) eterm = -q * kT * self.Nc * int_fermi_dirac_one_half( (EFn - self.Ec) / kT) hterm = -q * kT * self.Nv * int_fermi_dirac_one_half( (self.Ev - EFp) / kT) if (len(self.dopants) != 1): return d = self.dopants.values()[0] if d["type"] == "donor": dterm = -q * kT * d["conc"] * fermi_dirac_zero( -(EFn - self.Ec + d["E"] + np.log(2) * kT) / kT) elif d["type"] == "acceptor": dterm = -q * kT * d["conc"] * fermi_dirac_zero( -(self.Ev + d["E"] - EFp + np.log(4) * kT) / kT) intrho = eterm + hterm + dterm - self.intrho_ref return intrho
def _recomputeMuBulk(self): # If undoped, EBulk=0 (ie intrinsic) if not len(self.dopants.values()): self.mu_bulk=0 else: # Find the net doping netDope=sum([ v["conc"]*(-1 if v["type"]=="donor" else 1) for v in self.dopants.values()]) # Use the net doping with complete ionization to get a starting guess (E0) for EBulk if(not netDope): mu_0=0 else: mu_0=np.sign(-netDope)*kT*np.log(abs(netDope)/self.ni) # Find EBulk to minimize the net charge in the material res=sciopt.minimize_scalar(lambda mu:abs(self.rho(mu,mu)),sorted([0,mu_0]),method='Golden') self.mu_bulk=res.x eterm=-q*kT*self.Nc*int_fermi_dirac_one_half((self.mu_bulk-self.Ec)/kT) hterm=-q*kT*self.Nv*int_fermi_dirac_one_half((self.Ev-self.mu_bulk)/kT) if(len(self.dopants)!=1): return d=self.dopants.values()[0] if d["type"]=="donor": dterm=-q*kT*d["conc"]*fermi_dirac_zero(-(self.mu_bulk-self.Ec+d["E"]+np.log(2)*kT)/kT) elif d["type"]=="acceptor": dterm=-q*kT*d["conc"]*fermi_dirac_zero(-(self.Ev+d["E"]-self.mu_bulk+np.log(4)*kT)/kT) self.intrho_ref=eterm+hterm+dterm
def _recomputeMuBulk(self): # If undoped, EBulk=0 (ie intrinsic) if not len(self.dopants.values()): self.mu_bulk = 0 else: # Find the net doping netDope = sum([ v["conc"] * (-1 if v["type"] == "donor" else 1) for v in self.dopants.values() ]) # Use the net doping with complete ionization to get a starting guess (E0) for EBulk if (not netDope): mu_0 = 0 else: mu_0 = np.sign(-netDope) * kT * np.log(abs(netDope) / self.ni) # Find EBulk to minimize the net charge in the material res = sciopt.minimize_scalar(lambda mu: abs(self.rho(mu, mu)), sorted([0, mu_0]), method='Golden') self.mu_bulk = res.x eterm = -q * kT * self.Nc * int_fermi_dirac_one_half( (self.mu_bulk - self.Ec) / kT) hterm = -q * kT * self.Nv * int_fermi_dirac_one_half( (self.Ev - self.mu_bulk) / kT) if (len(self.dopants) != 1): return d = self.dopants.values()[0] if d["type"] == "donor": dterm = -q * kT * d["conc"] * fermi_dirac_zero( -(self.mu_bulk - self.Ec + d["E"] + np.log(2) * kT) / kT) elif d["type"] == "acceptor": dterm = -q * kT * d["conc"] * fermi_dirac_zero( -(self.Ev + d["E"] - self.mu_bulk + np.log(4) * kT) / kT) self.intrho_ref = eterm + hterm + dterm
def intrho(self,EFn,EFp): assert(len(self.dopants)==1),"Should have one dopant" #d=self.dopants.values()[0] # if d["type"]=="donor": # intrho_maj=\ # -q*kT*(self.Nc*int_fermi_dirac_one_half((mu-self.Ec)/kT) # +d["conc"]*fermi_dirac_zero(-(mu-self.Ec+d["E"]+np.log(2)*kT)/kT)) # elif d["type"]=="acceptor": # intrho_maj=\ # -q*kT*(self.Nv*int_fermi_dirac_one_half((self.Ev-mu)/kT) # +d["conc"]*fermi_dirac_zero(-(self.Ev+d["E"]-mu+np.log(4)*kT)/kT)) #print 'sup: ',intrho_maj[-1], self._intrho_ref, self.Nc*int_fermi_dirac_one_half((mu-self.Ec)/kT)[-1] # intrho=intrho_maj-self._intrho_ref+self._minorrho*(mu-self.mu_bulk) eterm=-q*kT*self.Nc*int_fermi_dirac_one_half((EFn-self.Ec)/kT) hterm=-q*kT*self.Nv*int_fermi_dirac_one_half((self.Ev-EFp)/kT) if(len(self.dopants)!=1): return d=self.dopants.values()[0] if d["type"]=="donor": dterm=-q*kT*d["conc"]*fermi_dirac_zero(-(EFn-self.Ec+d["E"]+np.log(2)*kT)/kT) elif d["type"]=="acceptor": dterm=-q*kT*d["conc"]*fermi_dirac_zero(-(self.Ev+d["E"]-EFp+np.log(4)*kT)/kT) intrho=eterm+hterm+dterm - self.intrho_ref return intrho # if d["type"]=="acceptor": # self._intrho=\ # q*(self.Nv*int_fermi_dirac_one_half((self.Ev-self.mu_bulk)/kT) # -d["conc"]*fermi_dirac_zero(-(self.Ec-d["Ed"]-self.mu_bulk+log(2))/kT)) #if __name__ == "__main__": # # uno=Material("GaN",{"Mg":8e19}) # print uno.mu_bulk # dos=Material("GaN",{"Si":2e19}) # print dos.mu_bulk # print "phib: ",uno.mu_bulk-dos.mu_bulk # # print "N" # tmat=Material("GaN",{"Si":2e19}) # #print tmat.Ec-tmat.mu_bulk # defi=np.linspace(0,1.5,1000000) # rhos=tmat.rho(tmat.mu_bulk-defi,tmat.mu_bulk-defi) # #print rhos[-1]/q # print (np.cumsum(rhos)*(defi[1]-defi[0]))[-1]/q # print -tmat.intrho(tmat.mu_bulk-defi,tmat.mu_bulk-defi)[-1]/q # # print "P" # tmat=Material("GaN",{"Mg":8e19}) # print tmat.Ev-tmat.mu_bulk # defi=-np.linspace(0,1.5,1000000) # rhos=tmat.rho(tmat.mu_bulk-defi,tmat.mu_bulk-defi) # print rhos[-1]/q # print (np.cumsum(rhos)*(defi[1]-defi[0]))[-1]/q # print -tmat.intrho(tmat.mu_bulk-defi,tmat.mu_bulk-defi)[-1]/q # # print "SPACING" # nds=tmat.Nd_ionized(tmat.mu_bulk-defi) # print (np.cumsum(nds)*(defi[1]-defi[0]))[-1] # print 2e19*kT*fermi_dirac_zero(-(tmat.mu_bulk-defi[-1]-tmat.Ec+.015+np.log(2)*kT)/kT)-2e19*kT*fermi_dirac_zero(-(tmat.mu_bulk-tmat.Ec+.015+np.log(2)*kT)/kT) # # print "MORE SPACING" # ns=tmat.n(tmat.mu_bulk-defi) # ns2=tmat.Nc*fermi_dirac_one_half((tmat.mu_bulk-defi-tmat.Ec)/kT) # print (np.cumsum(ns)*(defi[1]-defi[0]))[-1] # print tmat.Nc*kT*(int_fermi_dirac_one_half((tmat.mu_bulk-defi[-1]-tmat.Ec)/kT)-int_fermi_dirac_one_half((tmat.mu_bulk-tmat.Ec)/kT)) #