def test(): print "test2::test called" print "test2 __file__: ", __file__ print "test2 __name__: ", __name__ print "test2 __srcdir__: ", __srcdir__ #@UndefinedVariable print "test2 __script_root__: ", __script_root__ #@UndefinedVariable __loads__(["apis/original/OriginalApi?clazz=TheApi?ns=Fred"]) #@UndefinedVariable print "continue..." # Import a library file whos sys-path is already specified on the cmdline via: '--libraries': import dummy dummy.dummy(123) Fred.press('15') #@UndefinedVariable Fred.sleep(1) #@UndefinedVariable # Importing a nested test module: from output.scripts.one.test1 import test as test1 # and executing it's test, returning the result: return "-".join(["test2::test", test1()])
def test(): print "test2::test called" print "test2 __file__: ", __file__ print "test2 __name__: ", __name__ print "test2 __srcdir__: ", __srcdir__ #@UndefinedVariable print "test2 __script_root__: ", __script_root__ #@UndefinedVariable __loads__(["apis/original/OriginalApi?clazz=TheApi?ns=Fred" ]) #@UndefinedVariable print "continue..." # Import a library file whos sys-path is already specified on the cmdline via: '--libraries': import dummy dummy.dummy(123) Fred.press('15') #@UndefinedVariable Fred.sleep(1) #@UndefinedVariable # Importing a nested test module: from output.scripts.one.test1 import test as test1 # and executing it's test, returning the result: return "-".join(["test2::test", test1()])
def getInstruments(): NewInstDic={} NewFuncDic={} info=[] InstrumentList=rm.list_resources() for i in range(len(InstrumentList)): try: inst=rm.open_resource(InstrumentList[i]) infonew=inst.query('*IDN?')+InstrumentList[i] info.append(infonew) inst.close() except: pass for a in info: if "Keithley2400" in a: instname="Keithley2400"+a.split('\n')[1] NewFuncDic[instname]=KeFunc NewInstDic[instname]=Keithley2400.Keithley2400(a.split('\n')[1]) for a in info: if "Stanford" in a: instname="SR830"+a.split('\n')[1] NewFuncDic[instname]=SRFunc NewInstDic[instname]=SR830.SR830(a.split('\n')[1]) for a in info: if "Agilent" in a: instname="AG33500B"+a.split('\n')[1] NewFuncDic[instname]=AGFunc NewInstDic[instname]=AG33500B.AG33500B(a.split('\n')[1]) for a in info: if "ITC" in a: instname="ITC"+a.split('\n')[1] NewFuncDic[instname]=ITCFunc NewInstDic[instname]=AG33500B.AG33500B(a.split('\n')[1]) NewFuncDic['dummy']=dumFunc NewFuncDic['MercuryIPS']=IpsFunc NewFuncDic['MercuryITC']=ITCFunc NewInstDic['dummy']=dummy.dummy() NewInstDic['MercuryIPS']=MercuryIPS.ips() NewInstDic['MercuryITC']=MercuryITC.Mercury() return NewInstDic,NewFuncDic
def main(): parser = OptionParser(usage="usage: python3 %prog [options]", version="%prog 1.0") parser.add_option( "--trainDir", action="store", dest="trainDir", default="../data/dicom-images-train/", help="pick the directory that stores all the training DICOM data") parser.add_option("--trainCsv", action="store", dest="trainCsv", default="../data/train-rle.csv", help="pick the csv file that stores training masks") # FIXME commented out for now until the model ran success # parser.add_option("--testDir", # action="store", # dest="testDir", # default="../data/dicom-images-test", # help="pick the directory that stores all the testing DICOM data") # we do not seem to have the testing set ground truth # parser.add_option("--testCsv", # action="store", # dest="testCsv", # default="../data/train-rle.csv", # help="pick the csv file that stores training masks") (options, args) = parser.parse_args() train_dir = options.trainDir train_csv = options.trainCsv train_glob = train_dir + "*/*/*.dcm" print("train_dir:" + train_dir) print("train_csv:" + train_csv) # train_fns = sorted(glob.glob(train_glob))[:500] # df_full = pd.read_csv(train_csv, index_col='ImageId') # FIXME remove the limit if you wanna run with full data x, y = preproc(train_dir, train_csv, limit=50) model = dummy() model.train(x, y)
def test_basic(self): self.assertEqual(dummy(), 3)
Date: February 2020 """ import numpy as np import matplotlib.pyplot as plt # close all open figures plt.close('all') # step 1: call a file with a truss definition, make sure you import this file usePreloaded = False if usePreloaded: #this will load a set of variables to get you going without element, node & truss working from dummy import dummy Tr = dummy() else: #use this section to validate that your code can handle a truss input book_ex = True if book_ex: from book_example import book_example Tr = book_example() else: from bridge_150cm import bridge_150cm Tr = bridge_150cm() # step 2: generate empty/zero matrices, # the number of rows and columns is equal to 2*(highest node number used +1) K = np.zeros( (2 * (Tr.getHighestNodeNr() + 1), 2 * (Tr.getHighestNodeNr() + 1)))
def poisson(spNd, spFn, Ec_old, F_prime, div_avd, charge_fac, Eg1, Eg2, Es, Ed, Nx, Ny, Ntotal): Temp = Te transport_model = transportmodel.value fermi_flag = fermiflag1.value Lsda = round(Lsd / dx) Lg_topa = round(Lg_top / dx) Lg_bota = round(Lg_bot / dx) t_topa = round(t_top / dy) t_bota = round(t_bot / dy) t_sia = round(t_si / dy) ###########################INPUT AND OUTPUT VARIABLES###################### # spNd is the 3d net dopant density # 1 column of Ntotal element # spFn is the 3d electron density converted quasi Fermi energy # from the solutions of transport equation # 1 column of Ntotal elements # Ec_old is the input old potential energy profile # 1 column of Ntotal elements # F_prime is the derivative matrix of Ne=0 F (Ntotal by Ntotal) # criterion_inner is the poisson solver convergence criterion in eV # Ec is the new potential profile computed # 1 column of Ntotal elements # All equations involved assume ISS UNITS <- KDC No such thing! # Uses SI units (kg-m-s) I think ###############################INITIALIZATION############################## delta_Ec = np.zeros((Ntotal, 1)) F = np.zeros((Ntotal, 1)) MF_prime = np.zeros((Ntotal, Ntotal)) Ec = np.zeros((Ntotal, 1)) Fn = np.zeros((Ntotal, 1)) Nd = np.zeros((Ntotal, 1)) dummy_fun = np.zeros((Ntotal, 1)) dummy_fun_prime = np.zeros((Ntotal, 1)) iter_inner = 0 error_inner = 1 Ec = np.real(Ec_old) Nd = np.real(spNd) Fn = np.real(spFn) if ox_pnt_flag == 0: div_avdt = 0 elif ox_pnt_flag == 1: div_avdt = div_avd ##########################START OF INNER LOOP###################################### while error_inner >= criterion_inner: Ec = np.reshape(Ec, (Ntotal, 1)) iter_inner = iter_inner + 1 print '%s %i \n' % ('iter_inner = ', iter_inner) ####################THE START OF DUMMY VARIABLE DEFINITION################# dummy_fun = charge_fac * ((Nd + div_avdt) / Nc - dummy( (Fn - Ec) / (k_B * Temp / q), dummy_flag, fermi_flag)) dummy_fun_prime = charge_fac * dummy_prime( (Fn - Ec) / (k_B * Temp / q), dummy_flag, fermi_flag) / (k_B * Temp / q) ########################THE END OF DUMMY VARIABLE DEFINITION############### if ox_pnt_flag == 0: # NO ELECTRON PENETRATION INTO OXIDE REGIONS #################################EVALUATE F######################################### #############################Top gate insulator region############################## for i in np.arange(0, Nx * (t_topa + 1)): if (i >= 0 and i <= Lsda - 1): F[i] = Ec[i] - Ec[i + Nx] elif (i >= Lsda and i <= (Lsda + Lg_topa)): F[i] = Ec[i] - Eg1 elif (i >= (Lsda + Lg_topa) + 1 and i <= Nx - 1): F[i] = Ec[i] - Ec[i + Nx] elif (i >= (Nx * t_topa) and i <= Nx * (t_topa + 1) - 1): F[i] = -1.0/8.0*(dy/dx)*eps_top/eps_si*Ec[i-Nx-1] \ - (dx/dy-1/4.0/(dx/dy))*eps_top/eps_si*Ec[i-Nx] \ - 1.0/8.0*(dy/dx)*eps_top/eps_si*Ec[i-Nx+1] \ - 3.0/8.0*(dy/dx)*(eps_top+eps_si)/eps_si*Ec[i-1] \ + (dx/dy+3.0/4.0/(dx/dy))*(eps_top+eps_si)/eps_si*Ec[i] \ - 3.0/8.0*(dy/dx)*(eps_top+eps_si)/eps_si*Ec[i+1] \ - 1.0/8.0*(dy/dx)*Ec[i+Nx-1] \ - (dx/dy-1.0/4.0/(dx/dy))*Ec[i+Nx] \ - 1.0/8.0*(dy/dx)*Ec[i+Nx+1] else: F[i] = -(dx/dy)*eps_top/eps_si*Ec[i-Nx] \ -(dy/dx)*eps_top/eps_si*Ec[i-1] \ +2.0*(dx/dy+dy/dx)*eps_top/eps_si*Ec[i] \ -(dy/dx)*eps_top/eps_si*Ec[i+1] \ -(dx/dy)*eps_top/eps_si*Ec[i+Nx] #########################Bottom gate insulator region############################## for i in np.arange((Ntotal - Nx * (t_bota + 1)), Ntotal): if (i >= (Ntotal - Nx * (t_bota + 1)) and i < (Ntotal - Nx * t_bota)): F[i] = -1.0/8.0*(dy/dx)*Ec[i-Nx-1] \ - (dx/dy-1.0/4.0/(dx/dy))*Ec[i-Nx] \ - 1.0/8.0*(dy/dx)*Ec[i-Nx+1] \ - 3.0/8.0*(dy/dx)*(eps_bot+eps_si)/eps_si*Ec[i-1] \ + (dx/dy+3.0/4.0/(dx/dy))*(eps_bot+eps_si)/eps_si*Ec[i] \ - 3.0/8.0*(dy/dx)*(eps_bot+eps_si)/eps_si*Ec[i+1] \ - 1.0/8.0*(dy/dx)*eps_bot/eps_si*Ec[i+Nx-1] \ - (dx/dy-1.0/4.0/(dx/dy))*eps_bot/eps_si*Ec[i+Nx] \ - 1.0/8.0*(dy/dx)*eps_bot/eps_si*Ec[i+Nx+1] elif (i >= (Ntotal - Nx) and i < (Ntotal - Nx + Lsda)): F[i] = Ec[i] - Ec[i - Nx] elif (i >= (Ntotal - Nx + Lsda) and i <= (Ntotal - Nx + Lsda + Lg_bota)): F[i] = Ec[i] - Eg2 elif (i >= (Ntotal - Nx + 1 + Lsda + Lg_bota) and i < Ntotal): F[i] = Ec[i] - Ec[i - Nx] else: F[i] = -(dx/dy)*eps_bot/eps_si*Ec[i-Nx] \ - (dy/dx)*eps_bot/eps_si*Ec[i-1] \ + 2.0*(dx/dy+dy/dx)*eps_bot/eps_si*Ec[i] \ - (dy/dx)*eps_bot/eps_si*Ec[i+1] \ - (dx/dy)*eps_bot/eps_si*Ec[i+Nx] #####################Specify the F matrix in the silicon film region################ for i in np.arange(Nx * (t_topa + 1), (Ntotal - Nx * (t_bota + 1) + 1) - 1): F[i] = -(dx / dy) * Ec[i - Nx] - (dy / dx) * Ec[i - 1] + 2 * ( dx / dy + dy / dx) * Ec[i] + dummy_fun[i] - ( dy / dx) * Ec[i + 1] - (dx / dy) * Ec[i + Nx] #***************`*Modify the F matrix at the right and left boundaries*************** i_l = 0 i_r = Nx - 1 for j in np.arange(0, Ny): if j == 0: F[i_l] = 2 * Ec[i_l] - Ec[i_l + 1] - Ec[i_l + Nx] F[i_r] = 2 * Ec[i_r] - Ec[i_r - 1] - Ec[i_r + Nx] elif (j > 0 and j < (round(Nx * (t_topa + 1) / Nx)) - 1): F[i_l] = Ec[i_l] - Ec[i_l + 1] F[i_r] = Ec[i_r] - Ec[i_r - 1] elif (j >= round(Nx * (t_topa) / Nx) and j < round(Ntotal - Nx * t_bota / Nx)): F[i_l] = Ec[i_l] - Ec[i_l + 1] F[i_r] = Ec[i_r] - Ec[i_r - 1] elif (j >= round(Ntotal - Nx * t_bota / Nx) and j < Ny - 1): F[i_l] = Ec[i_l] - Ec[i_l + 1] F[i_r] = Ec[i_r] - Ec[i_r - 1] elif (j == Ny - 1 and ((Ntotal - Nx + 1) < (Ntotal - Nx + 1 + Lsda)) and ((Ntotal - Nx + 1 + Lsda + Lg_bota) < Ntotal)): F[i_l] = 2 * Ec[i_l] - Ec[i_l + 1] - Ec[i_l - Nx] F[i_r] = 2 * Ec[i_r] - Ec[i_r - 1] - Ec[i_r - Nx] i_l = (1 + j) * Nx i_r = (j + 2) * Nx - 1 ##############################END OF EVALUATING F################################## ###############################EVALUATE MF_prime################################### # MF_prime matrix in the silicon film region for j_row in np.arange(Nx * (t_topa + 1) / Nx, (Ntotal - Nx * t_bota) / Nx - 1): for j_col in np.arange(1, Nx - 1): ii = j_row * Nx + j_col MF_prime[ii, ii] = dummy_fun_prime[ii] ###############END OF EVALUATION FOR NO PENETRATION INTO THE OXIDE################# elif ox_pnt_flag == 1: #(ACCOUNTING FOR ELECTRON PENETRATION INTO OXIDE REGIONS) #################################EVALUATE F######################################## ##########################Top gate insulator region################################ for i in np.arange(0, Nx * (t_topa + 1)): if (i >= 0 and i < Lsda + 1 - 1): F[i] = Ec[i] - Ec[i + Nx] elif (i >= Lsda and i < (Lsda + Lg_topa) + 1): F[i] = Ec[i] - Eg1 elif (i >= (Lsda + Lg_topa) + 1 and i < Nx): F[i] = Ec[i] - Ec[i + Nx] elif (i >= (Nx * t_topa + 1) and i <= Nx * (t_topa + 1)): F[i] = -1.0/8.0*(dy/dx)*eps_top/eps_si*Ec[i-Nx-1] \ - (dx/dy-1.0/4.0/(dx/dy))*eps_top/eps_si*Ec[i-Nx] \ - 1.0/8.0*(dy/dx)*eps_top/eps_si*Ec[i-Nx+1] \ - 3.0/8.0*(dy/dx)*(eps_top+eps_si)/eps_si*Ec[i-1] \ + (dx/dy+3.0/4.0/(dx/dy))*(eps_top+eps_si)/eps_si*Ec[i] \ + dummy_fun[i] \ - 3.0/8.0*(dy/dx)*(eps_top+eps_si)/eps_si*Ec[i+1] \ - 1.0/8.0*(dy/dx)*Ec[i+Nx-1] \ - (dx/dy-1.0/4.0/(dx/dy))*Ec[i+Nx] \ - 1.0/8.0*(dy/dx)*Ec[i+Nx+1] else: F[i] = -(dx/dy)*eps_top/eps_si*Ec[i-Nx] \ - (dy/dx)*eps_top/eps_si*Ec[i-1] \ + 2.0*(dx/dy+dy/dx)*eps_top/eps_si*Ec[i]+dummy_fun[i] \ - (dy/dx)*eps_top/eps_si*Ec[i+1] \ - (dx/dy)*eps_top/eps_si*Ec[i+Nx] ############################Bottom gate insulator region########################### for i in np.arange((Ntotal - Nx * (t_bota + 1)), Ntotal): if (i >= (Ntotal - Nx * (t_bota + 1)) and i < Ntotal - Nx * t_bota): F[i] = -1.0/8.0*(dy/dx)*Ec[i-Nx-1] \ - (dx/dy-1.0/4.0/(dx/dy))*Ec[i-Nx] \ - 1.0/8.0*(dy/dx)*Ec[i-Nx+1] \ - 3.0/8.0*(dy/dx)*(eps_bot+eps_si)/eps_si*Ec[i-1] \ + (dx/dy+3.0/4.0/(dx/dy))*(eps_bot+eps_si)/eps_si*Ec[i] \ + dummy_fun[i] \ - 3.0/8.0*(dy/dx)*(eps_bot+eps_si)/eps_si*Ec[i+1] \ - 1.0/8.0*(dy/dx)*eps_bot/eps_si*Ec[i+Nx-1] \ - (dx/dy-1.0/4.0/(dx/dy))*eps_bot/eps_si*Ec[i+Nx] \ - 1.0/8.0*(dy/dx)*eps_bot/eps_si*Ec[i+Nx+1] elif (i >= (Ntotal - Nx) and i < (Ntotal - Nx + 1 + Lsda) - 1): F[i] = Ec[i] - Ec[i - Nx] elif (i >= (Ntotal - Nx + Lsda) and i < (Ntotal - Nx + 1 + Lsda + Lg_bota)): F[i] = Ec[i] - Eg2 elif (i >= (Ntotal - Nx + 1 + Lsda + Lg_bota) and i < Ntotal): F[i] = Ec[i] - Ec[i - Nx] else: F[i] = -(dx/dy)*eps_bot/eps_si*Ec[i-Nx] \ - (dy/dx)*eps_bot/eps_si*Ec[i-1] \ + 2.0*(dx/dy+dy/dx)*eps_bot/eps_si*Ec[i] + dummy_fun[i] \ - (dy/dx)*eps_bot/eps_si*Ec[i+1] \ - (dx/dy)*eps_bot/eps_si*Ec[i+Nx] ##################Specify the F matrix in the silicon film region################# for i in np.arange(Nx * (t_topa + 1), (Ntotal - Nx * (t_bota + 1) + 1) - 1): F[i] = -(dx / dy) * Ec[i - Nx] - (dy / dx) * Ec[ i - 1] + 2.0 * (dx / dy + dy / dx) * Ec[i] + dummy_fun[ i] - (dy / dx) * Ec[i + 1] - (dx / dy) * Ec[i + Nx] #***************Modify the F matrix at the right and left boundaries************** i_l = 0 i_r = Nx - 1 for j in np.arange(0, Ny): if j == 0: F[i_l] = 2 * Ec[i_l] - Ec[i_l + 1] - Ec[i_l + Nx] F[i_r] = 2 * Ec[i_r] - Ec[i_r - 1] - Ec[i_r + Nx] elif (j > 0 and j < round(Nx * (t_topa + 1) / Nx) - 1): F[i_l] = Ec[i_l] - Ec[i_l + 1] F[i_r] = Ec[i_r] - Ec[i_r - 1] elif (j >= round(Nx * (t_topa) / Nx) and j <= round(Ntotal - Nx * t_bota / Nx - 1)): F[i_l] = Ec[i_l] - Ec[i_l + 1] F[i_r] = Ec[i_r] - Ec[i_r - 1] elif (j > round(Ntotal - Nx * t_bota / Nx - 1) and j < Ny - 1): F[i_l] = Ec[i_l] - Ec[i_l + 1] F[i_r] = Ec[i_r] - Ec[i_r - 1] elif (j == Ny - 1 and ((Ntotal - Nx + 1) < (Ntotal - Nx + 1 + Lsda)) and ((Ntotal - Nx + 1 + Lsda + Lg_bota) < Ntotal)): F[i_l] = 2 * Ec[i_l] - Ec[i_l + 1] - Ec[i_l - Nx] F[i_r] = 2 * Ec[i_r] - Ec[i_r - 1] - Ec[i_r - Nx] i_l = (1 + j) * Nx i_r = (j + 2) * Nx - 1 ##########################END OF EVALUATING F################################### #############################EVALUATE MF_prime################################## # MF_prime matrix in the silicon film region for i in np.arange(Nx, (Ntotal - Nx + 1) - 1): MF_prime[i, i] = dummy_fun_prime[i] for j in np.arange(1, (Ny - 1)): MF_prime[(j - 1) * Nx + 1, (j - 1) * Nx + 1] = 0 MF_prime[j * Nx, j * Nx] = 0 ###############END OF EVALUATION FOR PENETRATION INTO OXIDE ################### ##############END OF ELECTRON PENETRATION INTO OXIDE OPTION SWITCH############# MF_prime = F_prime + sparse.csr_matrix(MF_prime) #######################END OF EVALUATING MF_prime############################## ############################SOLVING FOR delta_Ec############################### delta_Ec = -spsolve(sparse.csr_matrix(MF_prime), sparse.csr_matrix(F)) for i in np.arange(0, Ntotal): if abs(delta_Ec[i]) <= 1: delta_Ec[i] = delta_Ec[i] elif 1 < abs(delta_Ec[i]) and abs(delta_Ec[i]) < 3.7: delta_Ec[i] = np.sign(delta_Ec[i]) * np.power( abs(delta_Ec[i]), 0.20) elif abs(delta_Ec[i]) >= 3.7: delta_Ec[i] = np.sign(delta_Ec[i]) * np.log(abs(delta_Ec[i])) ##########################END OF SOLVING FOR delta_Ec######################### Ec = np.reshape(Ec, (1, Ntotal)) Ec = Ec + delta_Ec error_inner = max(abs(np.real(F))) print '%s %e \n' % ('error_inner = ', error_inner) max_delta_Ec = max(abs(np.real(delta_Ec))) MF_prime = np.zeros((Ntotal, Ntotal)) F = np.zeros((Ntotal, 1)) ##########################END OF INNER LOOP (WHILE) ####################### return Ec
target=data_train_pd.target, min_samples_leaf=100, smoothing=10, noise_level=0.01) data_train_pd['ps_car_11_cat_te'] = train_encoded data_train_pd.drop('ps_car_11_cat', axis=1, inplace=True) meta.loc['ps_car_11_cat', 'keep'] = False # Updating the meta data_test_pd['ps_car_11_cat_te'] = test_encoded data_test_pd.drop('ps_car_11_cat', axis=1, inplace=True) meta_test.loc['ps_car_11_cat', 'keep'] = False # Updating the meta #%% #We create dummy variables to deal with the categorical variables print('Before dummification train contains {} variables '.format( data_train_pd.shape[1])) data_train_pd = dummy(data_train_pd, meta) print('After dummification train contains {} variables '.format( data_train_pd.shape[1])) print('Before dummification test contains {} variables '.format( data_test_pd.shape[1])) data_test_pd = dummy(data_test_pd, meta_test) print('After dummification test contains {} variables '.format( data_test_pd.shape[1])) #%% #We create polynomial interaction variables for the continous variables print('Before creating interactions we have {} variables in train'.format( data_train_pd.shape[1])) data_train_pd = createPoly(data_train_pd, meta) print('After creating interactions we have {} variables in train'.format( data_train_pd.shape[1])) print('Before creating interactions we have {} variables in test'.format(
def main(args): configure_logging() logger.info('Started runnning') print(dummy.dummy())
dataset = WMHdataset('./WMH') assert dataset.AbleToRetrieveData(), 'not able to locate the directory of dataset' dataset.InitDataset(splitRatio=1.0, shuffle=True) # Take everything 100% X_ph = tf.placeholder('float32', [None, 84, 256, 256, 1]) #float32 y_ph = tf.placeholder('uint8', [None, 84, 256, 256, 1]) #X_ph = tf.placeholder('float32', [None, None, None, None, 1]) #y_ph = tf.placeholder('uint8', [None, None, None, None, 1]) #y_ph_cat = y_ph[:,:,:,:,0] # # Works for Softmax filter2 y_ph_cat = tf.one_hot(y_ph,3) # --> unstack into 3 categorical Tensor [?, 84, 256, 256, 1, 3] y_ph_cat = y_ph_cat[:,:,:,:,0,:] #y_ph_cat = tf.reduce_max(y_ph_cat, 4) # --> collapse the extra 4th redundant dimension print('Init Model') # seq = WMH_model3D.dummy() seq = dummy.dummy() # works for Label01 filter2 #y_train_sb = (seq.train_fprop(X_ph))[:,:,:,:,1] # works! but change the reshape #y_test_sb = (seq.test_fprop(X_ph))[:,:,:,:,1] # works! maybe new variable print('TRAINING') # for one hot y_train_sb = (seq.train_fprop(X_ph)) #y_train_sb = (seq.train_fprop())[0][0] print('TESTING') y_test_sb = (seq.test_fprop(X_ph)) #y_test_sb = (seq.test_fprop())[0][0] print('TRAINED') #train_cost_background = (1 - smooth_iou(y_ph_cat[:,:,:,:,0] , y_train_sb[:,:,:,:,0]) )
def poisson(spNd, spFn, Ec_old, F_prime, div_avd, charge_fac, Eg1, Eg2, Es, Ed, Nx, Ny, Ntotal): Temp = Te transport_model = transportmodel.value fermi_flag = fermiflag1.value Lsda = round(Lsd/dx) Lg_topa = round(Lg_top/dx) Lg_bota = round(Lg_bot/dx) t_topa = round(t_top/dy) t_bota = round(t_bot/dy) t_sia = round(t_si/dy) ###########################INPUT AND OUTPUT VARIABLES###################### # spNd is the 3d net dopant density # 1 column of Ntotal element # spFn is the 3d electron density converted quasi Fermi energy # from the solutions of transport equation # 1 column of Ntotal elements # Ec_old is the input old potential energy profile # 1 column of Ntotal elements # F_prime is the derivative matrix of Ne=0 F (Ntotal by Ntotal) # criterion_inner is the poisson solver convergence criterion in eV # Ec is the new potential profile computed # 1 column of Ntotal elements # All equations involved assume ISS UNITS <- KDC No such thing! # Uses SI units (kg-m-s) I think ###############################INITIALIZATION############################## delta_Ec = np.zeros((Ntotal,1)) F = np.zeros((Ntotal,1)) MF_prime = np.zeros((Ntotal,Ntotal)) Ec = np.zeros((Ntotal,1)) Fn = np.zeros((Ntotal,1)) Nd = np.zeros((Ntotal,1)) dummy_fun = np.zeros((Ntotal,1)) dummy_fun_prime = np.zeros((Ntotal,1)) iter_inner = 0 error_inner = 1 Ec = np.real(Ec_old) Nd = np.real(spNd) Fn = np.real(spFn) if ox_pnt_flag == 0: div_avdt = 0 elif ox_pnt_flag == 1: div_avdt = div_avd ##########################START OF INNER LOOP###################################### while error_inner >= criterion_inner: Ec = np.reshape(Ec, (Ntotal, 1)) iter_inner = iter_inner+1 print '%s %i \n' % ('iter_inner = ', iter_inner) ####################THE START OF DUMMY VARIABLE DEFINITION################# dummy_fun = charge_fac * ((Nd+div_avdt)/Nc - dummy((Fn-Ec)/(k_B*Temp/q), dummy_flag,fermi_flag)) dummy_fun_prime = charge_fac * dummy_prime((Fn-Ec)/(k_B*Temp/q), dummy_flag,fermi_flag)/(k_B*Temp/q) ########################THE END OF DUMMY VARIABLE DEFINITION############### if ox_pnt_flag == 0: # NO ELECTRON PENETRATION INTO OXIDE REGIONS #################################EVALUATE F######################################### #############################Top gate insulator region############################## for i in np.arange(0,Nx*(t_topa+1)): if(i >= 0 and i <= Lsda-1): F[i] = Ec[i]-Ec[i+Nx] elif(i >= Lsda and i <= (Lsda+Lg_topa)): F[i] = Ec[i]-Eg1 elif(i >= (Lsda+Lg_topa)+1 and i<=Nx-1): F[i] = Ec[i]-Ec[i+Nx] elif(i >= (Nx*t_topa) and i <= Nx*(t_topa+1) -1): F[i] = -1.0/8.0*(dy/dx)*eps_top/eps_si*Ec[i-Nx-1] \ - (dx/dy-1/4.0/(dx/dy))*eps_top/eps_si*Ec[i-Nx] \ - 1.0/8.0*(dy/dx)*eps_top/eps_si*Ec[i-Nx+1] \ - 3.0/8.0*(dy/dx)*(eps_top+eps_si)/eps_si*Ec[i-1] \ + (dx/dy+3.0/4.0/(dx/dy))*(eps_top+eps_si)/eps_si*Ec[i] \ - 3.0/8.0*(dy/dx)*(eps_top+eps_si)/eps_si*Ec[i+1] \ - 1.0/8.0*(dy/dx)*Ec[i+Nx-1] \ - (dx/dy-1.0/4.0/(dx/dy))*Ec[i+Nx] \ - 1.0/8.0*(dy/dx)*Ec[i+Nx+1] else: F[i] = -(dx/dy)*eps_top/eps_si*Ec[i-Nx] \ -(dy/dx)*eps_top/eps_si*Ec[i-1] \ +2.0*(dx/dy+dy/dx)*eps_top/eps_si*Ec[i] \ -(dy/dx)*eps_top/eps_si*Ec[i+1] \ -(dx/dy)*eps_top/eps_si*Ec[i+Nx] #########################Bottom gate insulator region############################## for i in np.arange((Ntotal-Nx*(t_bota+1)),Ntotal): if(i >= (Ntotal-Nx*(t_bota+1)) and i<(Ntotal-Nx*t_bota)): F[i] = -1.0/8.0*(dy/dx)*Ec[i-Nx-1] \ - (dx/dy-1.0/4.0/(dx/dy))*Ec[i-Nx] \ - 1.0/8.0*(dy/dx)*Ec[i-Nx+1] \ - 3.0/8.0*(dy/dx)*(eps_bot+eps_si)/eps_si*Ec[i-1] \ + (dx/dy+3.0/4.0/(dx/dy))*(eps_bot+eps_si)/eps_si*Ec[i] \ - 3.0/8.0*(dy/dx)*(eps_bot+eps_si)/eps_si*Ec[i+1] \ - 1.0/8.0*(dy/dx)*eps_bot/eps_si*Ec[i+Nx-1] \ - (dx/dy-1.0/4.0/(dx/dy))*eps_bot/eps_si*Ec[i+Nx] \ - 1.0/8.0*(dy/dx)*eps_bot/eps_si*Ec[i+Nx+1] elif(i >= (Ntotal-Nx) and i < (Ntotal-Nx+Lsda)): F[i] = Ec[i]-Ec[i-Nx] elif(i >= (Ntotal-Nx+Lsda) and i<=(Ntotal-Nx+Lsda+Lg_bota)): F[i] = Ec[i]-Eg2 elif(i >= (Ntotal-Nx+1+Lsda+Lg_bota) and i < Ntotal): F[i] = Ec[i]-Ec[i-Nx] else: F[i] = -(dx/dy)*eps_bot/eps_si*Ec[i-Nx] \ - (dy/dx)*eps_bot/eps_si*Ec[i-1] \ + 2.0*(dx/dy+dy/dx)*eps_bot/eps_si*Ec[i] \ - (dy/dx)*eps_bot/eps_si*Ec[i+1] \ - (dx/dy)*eps_bot/eps_si*Ec[i+Nx] #####################Specify the F matrix in the silicon film region################ for i in np.arange(Nx*(t_topa+1),(Ntotal-Nx*(t_bota+1)+1)-1): F[i] = -(dx/dy)*Ec[i-Nx]-(dy/dx)*Ec[i-1]+2*(dx/dy+dy/dx)*Ec[i]+dummy_fun[i]-(dy/dx)*Ec[i+1]-(dx/dy)*Ec[i+Nx] #***************`*Modify the F matrix at the right and left boundaries*************** i_l = 0 i_r = Nx-1 for j in np.arange(0,Ny): if j == 0: F[i_l]=2*Ec[i_l]-Ec[i_l+1]-Ec[i_l+Nx] F[i_r]=2*Ec[i_r]-Ec[i_r-1]-Ec[i_r+Nx] elif(j > 0 and j < (round(Nx*(t_topa+1)/Nx)) - 1): F[i_l]=Ec[i_l]-Ec[i_l+1] F[i_r]=Ec[i_r]-Ec[i_r-1] elif(j >= round(Nx*(t_topa)/Nx) and j < round(Ntotal-Nx*t_bota/Nx)): F[i_l]=Ec[i_l]-Ec[i_l+1] F[i_r]=Ec[i_r]-Ec[i_r-1] elif(j >= round(Ntotal-Nx*t_bota/Nx) and j < Ny-1): F[i_l]=Ec[i_l]-Ec[i_l+1] F[i_r]=Ec[i_r]-Ec[i_r-1] elif(j == Ny-1 and ((Ntotal-Nx+1)<(Ntotal-Nx+1+Lsda)) and ((Ntotal-Nx+1+Lsda+Lg_bota)<Ntotal)): F[i_l]=2*Ec[i_l]-Ec[i_l+1]-Ec[i_l-Nx] F[i_r]=2*Ec[i_r]-Ec[i_r-1]-Ec[i_r-Nx] i_l = (1+j)*Nx i_r = (j+2)*Nx - 1 ##############################END OF EVALUATING F################################## ###############################EVALUATE MF_prime################################### # MF_prime matrix in the silicon film region for j_row in np.arange (Nx*(t_topa+1)/Nx, (Ntotal-Nx*t_bota)/Nx-1): for j_col in np.arange(1,Nx-1): ii = j_row*Nx+j_col MF_prime[ii,ii] = dummy_fun_prime[ii] ###############END OF EVALUATION FOR NO PENETRATION INTO THE OXIDE################# elif ox_pnt_flag == 1: #(ACCOUNTING FOR ELECTRON PENETRATION INTO OXIDE REGIONS) #################################EVALUATE F######################################## ##########################Top gate insulator region################################ for i in np.arange(0, Nx*(t_topa+1)): if(i >= 0 and i < Lsda+1-1) : F[i] = Ec[i]-Ec[i+Nx] elif(i >= Lsda and i < (Lsda+Lg_topa)+1): F[i] = Ec[i]-Eg1 elif(i >= (Lsda+Lg_topa)+1 and i<Nx): F[i] = Ec[i]-Ec[i+Nx] elif(i >= (Nx*t_topa+1) and i <= Nx*(t_topa+1)): F[i] = -1.0/8.0*(dy/dx)*eps_top/eps_si*Ec[i-Nx-1] \ - (dx/dy-1.0/4.0/(dx/dy))*eps_top/eps_si*Ec[i-Nx] \ - 1.0/8.0*(dy/dx)*eps_top/eps_si*Ec[i-Nx+1] \ - 3.0/8.0*(dy/dx)*(eps_top+eps_si)/eps_si*Ec[i-1] \ + (dx/dy+3.0/4.0/(dx/dy))*(eps_top+eps_si)/eps_si*Ec[i] \ + dummy_fun[i] \ - 3.0/8.0*(dy/dx)*(eps_top+eps_si)/eps_si*Ec[i+1] \ - 1.0/8.0*(dy/dx)*Ec[i+Nx-1] \ - (dx/dy-1.0/4.0/(dx/dy))*Ec[i+Nx] \ - 1.0/8.0*(dy/dx)*Ec[i+Nx+1] else: F[i] = -(dx/dy)*eps_top/eps_si*Ec[i-Nx] \ - (dy/dx)*eps_top/eps_si*Ec[i-1] \ + 2.0*(dx/dy+dy/dx)*eps_top/eps_si*Ec[i]+dummy_fun[i] \ - (dy/dx)*eps_top/eps_si*Ec[i+1] \ - (dx/dy)*eps_top/eps_si*Ec[i+Nx] ############################Bottom gate insulator region########################### for i in np.arange((Ntotal-Nx*(t_bota+1)),Ntotal): if(i >= (Ntotal-Nx*(t_bota+1)) and i < Ntotal-Nx*t_bota): F[i] = -1.0/8.0*(dy/dx)*Ec[i-Nx-1] \ - (dx/dy-1.0/4.0/(dx/dy))*Ec[i-Nx] \ - 1.0/8.0*(dy/dx)*Ec[i-Nx+1] \ - 3.0/8.0*(dy/dx)*(eps_bot+eps_si)/eps_si*Ec[i-1] \ + (dx/dy+3.0/4.0/(dx/dy))*(eps_bot+eps_si)/eps_si*Ec[i] \ + dummy_fun[i] \ - 3.0/8.0*(dy/dx)*(eps_bot+eps_si)/eps_si*Ec[i+1] \ - 1.0/8.0*(dy/dx)*eps_bot/eps_si*Ec[i+Nx-1] \ - (dx/dy-1.0/4.0/(dx/dy))*eps_bot/eps_si*Ec[i+Nx] \ - 1.0/8.0*(dy/dx)*eps_bot/eps_si*Ec[i+Nx+1] elif(i >= (Ntotal-Nx) and i < (Ntotal-Nx+1+Lsda)-1): F[i] = Ec[i]-Ec[i-Nx] elif(i >= (Ntotal-Nx+Lsda) and i < (Ntotal-Nx+1+Lsda+Lg_bota)): F[i] = Ec[i]-Eg2 elif(i >= (Ntotal-Nx+1+Lsda+Lg_bota) and i < Ntotal): F[i] = Ec[i]-Ec[i-Nx] else: F[i] = -(dx/dy)*eps_bot/eps_si*Ec[i-Nx] \ - (dy/dx)*eps_bot/eps_si*Ec[i-1] \ + 2.0*(dx/dy+dy/dx)*eps_bot/eps_si*Ec[i] + dummy_fun[i] \ - (dy/dx)*eps_bot/eps_si*Ec[i+1] \ - (dx/dy)*eps_bot/eps_si*Ec[i+Nx] ##################Specify the F matrix in the silicon film region################# for i in np.arange(Nx*(t_topa+1), (Ntotal-Nx*(t_bota+1)+1)-1): F[i] = -(dx/dy)*Ec[i-Nx]-(dy/dx)*Ec[i-1]+2.0*(dx/dy+dy/dx)*Ec[i]+dummy_fun[i]-(dy/dx)*Ec[i+1]-(dx/dy)*Ec[i+Nx] #***************Modify the F matrix at the right and left boundaries************** i_l = 0 i_r = Nx-1 for j in np.arange(0, Ny): if j == 0: F[i_l] = 2*Ec[i_l]-Ec[i_l+1]-Ec[i_l+Nx] F[i_r] = 2*Ec[i_r]-Ec[i_r-1]-Ec[i_r+Nx] elif (j > 0 and j < round(Nx*(t_topa+1)/Nx) - 1): F[i_l] = Ec[i_l]-Ec[i_l+1] F[i_r] = Ec[i_r]-Ec[i_r-1] elif (j >= round(Nx*(t_topa)/Nx) and j <= round(Ntotal-Nx*t_bota/Nx - 1)): F[i_l] = Ec[i_l]-Ec[i_l+1] F[i_r] = Ec[i_r]-Ec[i_r-1] elif (j > round(Ntotal-Nx*t_bota/Nx -1) and j<Ny-1): F[i_l]=Ec[i_l]-Ec[i_l+1] F[i_r]=Ec[i_r]-Ec[i_r-1] elif(j == Ny-1 and ((Ntotal-Nx+1)<(Ntotal-Nx+1+Lsda)) and ((Ntotal-Nx+1+Lsda+Lg_bota)<Ntotal)): F[i_l] = 2*Ec[i_l]-Ec[i_l+1]-Ec[i_l-Nx] F[i_r] = 2*Ec[i_r]-Ec[i_r-1]-Ec[i_r-Nx] i_l = (1+j)*Nx i_r = (j+2)*Nx - 1 ##########################END OF EVALUATING F################################### #############################EVALUATE MF_prime################################## # MF_prime matrix in the silicon film region for i in np.arange(Nx, (Ntotal-Nx+1)-1): MF_prime[i, i] = dummy_fun_prime[i] for j in np.arange(1, (Ny-1)): MF_prime[(j-1)*Nx+1, (j-1)*Nx+1] = 0 MF_prime[j*Nx, j*Nx] = 0 ###############END OF EVALUATION FOR PENETRATION INTO OXIDE ################### ##############END OF ELECTRON PENETRATION INTO OXIDE OPTION SWITCH############# MF_prime = F_prime+sparse.csr_matrix(MF_prime) #######################END OF EVALUATING MF_prime############################## ############################SOLVING FOR delta_Ec############################### delta_Ec = - spsolve(sparse.csr_matrix(MF_prime), sparse.csr_matrix(F)) for i in np.arange(0, Ntotal): if abs(delta_Ec[i]) <= 1: delta_Ec[i] = delta_Ec[i] elif 1<abs(delta_Ec[i]) and abs(delta_Ec[i]) <3.7: delta_Ec[i] = np.sign(delta_Ec[i])*np.power(abs(delta_Ec[i]),0.20) elif abs(delta_Ec[i]) >= 3.7: delta_Ec[i] = np.sign(delta_Ec[i])*np.log(abs(delta_Ec[i])) ##########################END OF SOLVING FOR delta_Ec######################### Ec = np.reshape(Ec,(1,Ntotal)) Ec = Ec+delta_Ec error_inner = max(abs(np.real(F))) print '%s %e \n' % ('error_inner = ', error_inner) max_delta_Ec = max(abs(np.real(delta_Ec))) MF_prime = np.zeros((Ntotal, Ntotal)) F = np.zeros((Ntotal, 1)) ##########################END OF INNER LOOP (WHILE) ####################### return Ec ########################################################################### ###########################END OF FUNCTION POISSON######################### ###########################################################################