print(f'=====================================') print(f'Now generate plots in output folder') print(folder_output) print(f'=====================================') #++++++++++++++++++++++++++++++++++++++++++++++ # These lines have to be adjusted by the user. #++++++++++++++++++++++++++++++++++++++++++++++ #=========================== if(software=="nextnano++"): file = os.path.join(folder_output,input_file_name_variable+r'\bias_00000'+r'\bandedges.dat') my_input_file_no_extension = my_input_file_no_extension_nnp elif(software=="nextnano3"): file = os.path.join(folder_output,input_file_name_variable+r'\band_structure'+r'\BandEdges.dat') #=========================== df = nn.DataFile(file,product=software) dfV.append(df) fig, ax = plt.subplots(1) #++++++++++++++++++++++++++++++++++++++++++++++ # These lines have to be adjusted by the user. #++++++++++++++++++++++++++++++++++++++++++++++ #=========================== if(software=="nextnano++"): ax.plot(df.coords['x'].value,df.variables['Gamma'].value,label='Gamma') ax.plot(df.coords['x'].value,df.variables['electron_Fermi_level'].value, label='FermiLevel_el') ax.set_xlabel(f"{df.coords['x'].name} {df.coords['x'].unit}") ax.set_ylabel(f"Energy {df.variables['Gamma'].unit}") elif(software=="nextnano3"): ax.plot(df.coords['position'].value,df.variables['Gamma_bandedge'].value,label='Gamma')
inner_count = 0 fig_several = plt.figure() for i in ListOfValues: bias = round(bias, 1) #=========================== # Conduction and valence band edge #=========================== file_be = os.path.join( folder_output, my_input_file_no_extension + r'\bias_' + i + r'\bandedges.dat') print(f"Read in file:") print(file_be) df_be = nn.DataFile(file_be, product=software) #=========================== # Energy-resolved electron density #=========================== file_elec = os.path.join( folder_output, my_input_file_no_extension + r'\bias_' + i + r'\electron_density_vs_energy.fld') # file = os.path.join(folder_output,input_file_name_variable+r'\Results'+r'\LocalDOS_sg1_deg1.vtr') # Caution! Specify "format2D=AvsAscii_one_file" in the input file. Otherwise this line causes error due to the binary data reading. datafile_2d = nn.DataFile(file_elec, product=software) x = datafile_2d.coords['x'] y = datafile_2d.coords['y'] z_elec = datafile_2d.variables[0]
folder_output, input_file_name_variable + r'\Quantum_kp' + r'\kp8_psi_squared_el_kpar001_1D_per_shift.dat') file_psi_h = os.path.join( folder_output, input_file_name_variable + r'\Quantum_kp' + r'\kp8_psi_squared_hl_kpar001_1D_per_shift.dat') # file_abs = os.path.join(folder_output,input_file_name_variable+r'\optics'+r'\absorption_intraband_cb1_kp8.dat') #=========================== #=========================== # Conduction band edge #=========================== print(f"Read in file:") print(file_cb) df_cb = nn.DataFile(file_cb, product=software) # Electrons print(f"Read in file:") print(file_psi) df_psi = nn.DataFile(file_psi, product=software) print(f"Read in file:") if nn_file == 0: print(file_psi_hh) print(file_psi_lh) df_psi_hh = nn.DataFile(file_psi_hh, product=software) df_psi_lh = nn.DataFile(file_psi_lh, product=software) elif nn_file == 1: print(file_psi_h) df_psi_h = nn.DataFile(file_psi_h, product=software)
folder_bias = folder_results + r'\Source=0V, Drain=0V' print("output folder_bias:") print(folder_bias) folder_total_bias = os.path.join(folder, folder_bias) print("output folder_total_bias:") print(folder_total_bias) file_cb = folder_total_bias + r'\BandProfile' + r'\BandEdge_conduction.dat' #=========================== # Conduction band edge #=========================== print("Read in file:") print(file_cb) df = nn.DataFile(file_cb, software) fig, ax = plt.subplots(1) ax.plot(df.coords['Position'].value, df.variables['Conduction Band Edge'].value, label='Conduction Band Edge') ax.set_xlabel(f"{df.coords['Position'].name} {df.coords['Position'].unit}") ax.set_ylabel(f"Energy {df.variables['Conduction Band Edge'].unit}") ax.legend() fig.tight_layout() # plt.show() fig.savefig(file_cb + '.jpg') if (software == "nextnano.MSB"): extension2Dfile = '.vtr'
file = os.path.join( folder_output, input_file_name_variable + r'\bias_00000' + r'\transmission_cbr_Gamma1.dat') file_cb = os.path.join( folder_output, input_file_name_variable + r'\bias_00000' + r'\bandedge_Gamma.dat') elif (software == "nextnano3"): file = os.path.join( folder_output, input_file_name_variable + r'\Results' + r'\Transmission_cb_sg1_deg1.dat') # file = os.path.join(folder_output, input_file_name_variable+r'\band_structure'+r'\BandEdges_A000.dat') file_cb = os.path.join( folder_output, input_file_name_variable + r'\Results' + r'\cb_Gamma.dat') #=========================== df = nn.DataFile(file, product=software) dfV.append(df) # Conduction band edge print("Read in file:") print(file_cb) df_cb = nn.DataFile(file_cb, product=software) df_cbV.append(df_cb) print("current datafile: ", file) print(f"List of coordinates in the current datafile: {df.coords}") print(f"List of variables in the current datafile: {df.variables}") print("current datafile: ", file_cb) print(f"List of coordinates in the current datafile: {df_cb.coords}") print(f"List of variables in the current datafile: {df_cb.variables}")
contacts = [] for name in gdspols.labels: text = f.contacts_schottky(name=name, bias=0, barrier=0.75) lines = list(f.split_lines(text)) contacts.extend(lines) # Insert contacts into the input file idx = find_line_by_pattern('GATES-CONTACT', raw_lines) raw_lines = raw_lines[0:idx + 1] + contacts + raw_lines[idx + 1:] text = f.lines(*raw_lines) new_input = nn.InputFile() new_input.text = text new_input.fullpath = os.path.join(os.getcwd(), 'example3D_with_gds.in') # save at current working directory new_input.save(overwrite=True) new_input.execute() # Quick plot bias_folder = os.path.join(new_input.folder_output, 'bias_00000')# use 'bias_000_000_000' instead for older versions bandedge = os.path.join(bias_folder, 'bandedges_2d_rectangle_z_40.fld') df = nn.DataFile(bandedge, product='nextnano++') x, y, z = df['x'], df['y'], df['Gamma'] xv, yv, zv = x.value, y.value, z.value fig, ax = plt.subplots(1) pcolor = ax.pcolormesh(x.value, y.value, z.value.T, cmap='viridis') ax.set_xlabel(x.label) ax.set_ylabel(y.label) if True: # Add gds polygons on top of the plot gdspols.show(ax=ax, fill_kw=dict(color='r', alpha=0.2), onebyone=False) fig.savefig(os.path.join(bias_folder, 'bandedges_2d_rectangle_z_40.png'))
# In the case of ```bandedges_1d.dat```, there is one coordinate (x) and there are several variables (gamma band, electron fermi level, hole fermi level, etc). The structure in this file is a set of columns with a tabulator as delimiter. # # On the other hand, ```bandedges_2d.fld```, there are two coordinates (x and y) and also with several variables. Moreover, the structure of the raw data is organized in a totally different way than ```bandedges_1d.dat```. # # The user-friendlyness relies on the fact that in spite of the differences in the file formats, an unique class is used to load the information: ```nextnanopy.Datafile```. # # As a remark, you can omit the argument ```product```. In this case, it will try to detect automatically the nextnano product (nextnano++, nextnano3, nextnano.NEGF or nextnano.MSB), and then look for the best loading routine. This can be dangerous since it is not garanteed that the loaded data is correct. So, we recommend to always specify ```product```. # # ## Example of a 1D nextnano++ simulation # In[1]: import nextnanopy as nn datafile_1d = nn.DataFile(r'..\..\tests\datafiles\nextnano++\bandedges_1d.dat', product='nextnano++') print(datafile_1d) # ## How to access to the coordinates? # # You can access to the coordinates in ```datafile.coords```. It will return a dictionary of ```Coord``` objects. # # ```Coord``` objects contains information about: # - name (str) # - value (numpy.array) # - unit (str) # - dim (int) # - label (str, optional) # - metadata (dict, if there is any) # # Each information is an attribute. For example, if you want to get the unit a coordinate:
elif(software=="nextnano3"): file_cb = os.path.join(folder_output,input_file_name_variable+r'\band_structure'+r'\BandEdges.dat') if sg_kp == 'sg': file_psi = os.path.join(folder_output,input_file_name_variable+r'\Schroedinger_1band'+r'\cb1_sg1_deg1_psi_squared_shift.dat') file_abs = os.path.join(folder_output,input_file_name_variable+r'\optics'+r'\absorption_intraband_cb1_sg1_deg1.dat') elif sg_kp == 'kp': file_psi = os.path.join(folder_output,input_file_name_variable+r'\Schroedinger_kp'+r'\kp8_psi_squared_el_kpar001_1D_neu_shift.dat') file_abs = os.path.join(folder_output,input_file_name_variable+r'\optics'+r'\absorption_intraband_cb1_kp8.dat') #=========================== #=========================== # Conduction band edge #=========================== print(f"Read in file:") print(file_cb) df_cb = nn.DataFile(file_cb,product=software) print(f"Read in file:") print(file_psi) df_psi = nn.DataFile(file_psi,product=software) print(f"current datafile: ",file_cb) print(f"List of coordinates in the current datafile: {df_cb.coords}") print(f"List of variables in the current datafile: {df_cb.variables}") print(f"current datafile: ",file_psi) print(f"List of coordinates in the current datafile: {df_psi.coords}") print(f"List of variables in the current datafile: {df_psi.variables}") fig_psi, ax_psi = plt.subplots(1)