def _update_links(self): self.iEg = IntrinsicBandGap( material=self._cal_dts['material'], author=self._cal_dts['iEg_author'], temp=self._cal_dts['temp'], multiplier=self._cal_dts['multiplier'], ) self.BGN = BandGapNarrowing( material=self._cal_dts['material'], author=self._cal_dts['BGN_author'], temp=self._cal_dts['temp'], nxc=self._cal_dts['nxc'], )
def update(self, **kwargs): ''' a function to update the intrinsic BandGap inputs: temperature: (optional) in kelvin author: (optional) the author used. If not provided the last provided author is used If no author has been provided, Couderc's model is used output: The intrinsic carrier concentration in cm^-3. Note this is not the effective intrinsic carrier concentration ''' self.calculationdetails = kwargs # a check to make sure the model hasn't changed if 'author' in kwargs.keys(): self.change_model(self._cal_dts['author']) # if the model required the energy gap, calculate it if self.model == 'ni_temp_eg': Eg = IntrinsicBandGap(material=self._cal_dts['material'], author=self.vals['eg_model']).update( temp=self._cal_dts['temp'], multiplier=1) else: Eg = 0 self.ni = getattr(ni_models, self.model)(self.vals, temp=self._cal_dts['temp'], Eg=Eg) return self.ni
def check_models(self, Plot=True): ''' Displays a plot of all the models against experimental data ''' # fig = plt.figure('Intrinsic carriers') fig, ax = plt.subplots(1) fig.suptitle('Intrinsic carrier concentration') # fig.set_title('Intrinsic carriers') temp = np.linspace(100, 500) Eg = IntrinsicBandGap(material='Si', author='Passler2002').update(temp=1, multiplier=1) Eg = 1.17 for author in self.available_models(): ni = self.update(temp=temp, author=author) if Plot: ax.plot(np.log(temp), np.log(ni * np.exp(Eg / 2. * Const.e / Const.k / temp)), label=author) a = self.update(temp=300, author=author) print('{1} \t {0:.2e}'.format(a[0], author)) test_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'Si', 'check data', 'ni.csv') data = np.genfromtxt(test_file, delimiter=',', names=True, skip_header=1, filling_values=np.inf) if Plot: for name in data.dtype.names[1:]: ax.plot( np.log(data['Temp']), np.log(data[name] * np.exp(Eg / 2. * Const.e / Const.k / data['Temp'])), 'o', label='experimental values\'s: ' + name) ax.set_xlabel('log(Temperature (K))') ax.set_ylabel(r'$log(n_i \times e^{Eg_0(0)/kT} )$') ax.legend(loc=0) ax.set_xlim(4, 6) ax.set_ylim(42, 47) plt.show()
class BandGap(HelperFunctions): ''' A simple class to combine the intrinsic band gap and band gap narrowing classes for easy access ''' _cal_dts = { 'material': 'Si', 'temp': 300., 'iEg_author': None, 'multiplier': 1., 'BGN_author': None, 'dopant': 'boron', 'nxc': 1, 'Na': 1e16, 'Nd': 0, } def __init__(self, **kwargs): # update any values in cal_dts # that are passed self.calculationdetails = kwargs # pass values to models self._update_links() def _update_links(self): self.iEg = IntrinsicBandGap( material=self._cal_dts['material'], author=self._cal_dts['iEg_author'], temp=self._cal_dts['temp'], multiplier=self._cal_dts['multiplier'], ) self.BGN = BandGapNarrowing( material=self._cal_dts['material'], author=self._cal_dts['BGN_author'], temp=self._cal_dts['temp'], nxc=self._cal_dts['nxc'], ) def plot_all_models(self): self.iEg.plot_all_models() self.BGN.plot_all_models() def update(self, **kwargs): ''' Calculates the band gap ''' self.calculationdetails = kwargs # just prints a warning if the model is for the incorrect # dopants dopant_model_list = self.BGN.available_models('dopant', self._cal_dts['dopant']) # check dopant and model line up if self._cal_dts['BGN_author'] not in dopant_model_list: sys.exit( '''\nThe BGN author you have selected was not for your''' ''' selected dopant.\n''' '''Please try selecting one of the following authors:\n\t''' + str('\n\t'.join([i for i in dopant_model_list])) + '''\nFor the selected dopant: {0}\n'''.format( self._cal_dts['dopant'])) Eg = self.iEg.update(material=self._cal_dts['material'], author=self._cal_dts['iEg_author'], temp=self._cal_dts['temp'], multiplier=self._cal_dts['multiplier'], ) - \ self.BGN.update(material=self._cal_dts['material'], author=self._cal_dts['BGN_author'], temp=self._cal_dts['temp'], nxc=self._cal_dts['nxc'], Na=self._cal_dts['Na'], Nd=self._cal_dts['Nd'], ) return Eg def check_models(self): self.iEg.check_models() self.BGN.check_models()
class BandGap(BaseModelClass): ''' A simple class that combines the intrinsic band gap and band gap narrowing classes for easy access Inputs to this class are: 1. material: (str) The elemental name for the material. Defualt (Si) 2. temp: (float) The temperature of the material in Kelvin (300) 3. iEg_author: (str) The author of the intrinsic band gap model to be used 4. multiplier: (float) A multipler. This is a hack that people use to adjust the bandgap to achieve other desired values. 5. BGN_author: (str) The author of the band gap narrowing. 4. nxc: (array like cm^-3) The number of excess carriers 5. Na: (array like cm^-3) The number of acceptor dopants 6. Nd: (array like cm^-3) The number of donar dopants ''' _cal_dts = { 'material': 'Si', 'temp': 300., 'iEg_author': None, 'multiplier': 1., 'BGN_author': None, 'dopant': 'boron', 'nxc': 1, 'Na': 1e16, 'Nd': 0, } def __init__(self, **kwargs): # update any values in cal_dts # that are passed self.calculationdetails = kwargs # pass values to models self._update_links() def _update_links(self): self.iEg = IntrinsicBandGap( material=self._cal_dts['material'], author=self._cal_dts['iEg_author'], temp=self._cal_dts['temp'], multiplier=self._cal_dts['multiplier'], ) self.BGN = BandGapNarrowing( material=self._cal_dts['material'], author=self._cal_dts['BGN_author'], temp=self._cal_dts['temp'], nxc=self._cal_dts['nxc'], ) def plot_all_models(self): self.iEg.plot_all_models() self.BGN.plot_all_models() def update(self, **kwargs): ''' Calculates the band gap ''' self.calculationdetails = kwargs # just prints a warning if the model is for the incorrect # dopants dopant_model_list = self.BGN.available_models('dopant', self._cal_dts['dopant']) # check dopant and model line up if self._cal_dts['BGN_author'] not in dopant_model_list: sys.exit( '''\nThe BGN author you have selected was not for your''' ''' selected dopant.\n''' '''Please try selecting one of the following authors:\n\t''' + str('\n\t'.join([i for i in dopant_model_list])) + '''\nFor the selected dopant: {0}\n'''.format( self._cal_dts['dopant'])) Eg = self.iEg.update(material=self._cal_dts['material'], author=self._cal_dts['iEg_author'], temp=self._cal_dts['temp'], multiplier=self._cal_dts['multiplier'], ) - \ self.BGN.update(material=self._cal_dts['material'], author=self._cal_dts['BGN_author'], temp=self._cal_dts['temp'], nxc=self._cal_dts['nxc'], Na=self._cal_dts['Na'], Nd=self._cal_dts['Nd'], ) return Eg def check_models(self): self.iEg.check_models() self.BGN.check_models()