def setup_module(module): ################ Light parameters ##################### # Set up light objects wl_super = 500.0 wavelengths = np.array([wl_super]) light_list = [ objects.Light(wl, theta=20, phi=40, max_order_PWs=1) for wl in wavelengths ] light = light_list[0] ################ Scattering matrices (for distinct layers) ############## """ Calculate scattering matrices for each distinct layer. Calculated in the order listed below, however this does not influence final structure which is defined later """ # period must be consistent throughout simulation!!! period = 600 NW_diameter = 120 num_BM = 20 NW_array = objects.NanoStruct('2D_array', period, NW_diameter, height_nm=2330, inclusion_a=materials.Si_c, background=materials.Air, loss=True, make_mesh_now=False, mesh_file='600_120.mail') sim_NW_array = NW_array.calc_modes(light, num_BM=num_BM) superstrate = objects.ThinFilm(period=period, height_nm='semi_inf', material=materials.Air, loss=False) sim_superstrate = superstrate.calc_modes(light) substrate = objects.ThinFilm(period=period, height_nm='semi_inf', material=materials.SiO2_a, loss=False) sim_substrate = substrate.calc_modes(light) ################ Construct & solve for full solar cell structure ############## """ Now when defining full structure order is critical and solar_cell list MUST be ordered from bottom to top! """ stack = Stack((sim_substrate, sim_NW_array, sim_superstrate)) stack.calc_scat() module.stack_list = [stack] last_light_object = light_list.pop() param_layer = NW_array # Specify the layer for which the parameters should be printed on figures. params_string = plotting.gen_params_string(param_layer, last_light_object, max_num_BMs=num_BM) active_layer_nu = 1 plotting.t_r_a_write_files(stack_list, wavelengths)
def setup_module(module): start = time.time() # Run in parallel across wavelengths. # This has to be in a setup_module otherwise nosetests will crash :( pool = Pool(2) module.stack_list = pool.map(simulate_stack, light_list) last_light_object = light_list.pop() param_layer = NW_array # Specify the layer for which the parameters should be printed on figures. params_string = plotting.gen_params_string(param_layer, last_light_object, max_num_BMs=num_BM) active_layer_nu = 1 Efficiency = plotting.t_r_a_plots(stack_list, wavelengths, params_string, active_layer_nu=active_layer_nu)
def setup_module(module): ################ Light parameters ##################### # Set up light objects wl_super = 500.0 wavelengths = np.array([wl_super]) light_list = [objects.Light(wl, theta = 20, phi = 40, max_order_PWs = 1) for wl in wavelengths] light = light_list[0] ################ Scattering matrices (for distinct layers) ############## """ Calculate scattering matrices for each distinct layer. Calculated in the order listed below, however this does not influence final structure which is defined later """ # period must be consistent throughout simulation!!! period = 600 NW_diameter = 120 num_BM = 20 NW_array = objects.NanoStruct('2D_array', period, NW_diameter, height_nm = 2330, inclusion_a = materials.Si_c, background = materials.Air, loss = True, make_mesh_now = False, mesh_file='600_120.mail') sim_NW_array = NW_array.calc_modes(light, num_BM = num_BM) superstrate = objects.ThinFilm(period = period, height_nm = 'semi_inf', material = materials.Air, loss = False) sim_superstrate = superstrate.calc_modes(light) substrate = objects.ThinFilm(period = period, height_nm = 'semi_inf', material = materials.SiO2_a, loss = False) sim_substrate = substrate.calc_modes(light) ################ Construct & solve for full solar cell structure ############## """ Now when defining full structure order is critical and solar_cell list MUST be ordered from bottom to top! """ stack = Stack((sim_substrate, sim_NW_array, sim_superstrate)) stack.calc_scat() module.stack_list = [stack] last_light_object = light_list.pop() param_layer = NW_array # Specify the layer for which the parameters should be printed on figures. params_string = plotting.gen_params_string(param_layer, last_light_object, max_num_BMs=num_BM) active_layer_nu = 1 plotting.t_r_a_write_files(stack_list, wavelengths)
def setup_module(module): # Run in parallel across wavelengths. # This has to be in a setup_module otherwise nosetests will crash :( pool = Pool(3) module.stack_list = pool.map(simulate_stack, light_list) # # Run one at a time # module.stack_list = map(simulate_stack, light_list) last_light_object = light_list.pop() param_layer = homo_film2 # Specify the layer for which the parameters should be printed on figures. params_string = plotting.gen_params_string(param_layer, last_light_object) active_layer_nu = 3 # Specify which layer is the active one (where absorption generates charge carriers). # Plot total transmission, reflection, absorption & that of each layer. # Also calculate efficiency of active layer. Efficiency = plotting.t_r_a_plots(stack_list, wavelengths, params_string, active_layer_nu=active_layer_nu)
return [height_list] # Run in parallel across wavelengths. pool = Pool(num_cores) stacks_wl_list = pool.map(simulate_stack, light_list) # Run one at a time # stacks_wl_list = map(simulate_stack, light_list) ######################## Plotting ######################## last_light_object = light_list.pop() param_layer = NHs # Specify the layer for which the parameters should be printed on figures. params_string = plotting.gen_params_string(param_layer, last_light_object, max_num_BMs=max_num_BMs) wls_normed = wavelengths/period for h in range(len(NH_heights)): height = NH_heights[h] wl_list = [] stack_label = 0 for wl in range(len(wavelengths)): wl_list.append(stacks_wl_list[wl][stack_label][h]) mess_name = '_h%(h)i'% {'h' : h, } plotting.EOT_plot(wl_list, wls_normed, params_string, add_name = mess_name) # Dispersion plotting.omega_plot(wl_list, wavelengths, params_string)
stack = Stack((sim_substrate, sim_mirror, sim_grating, sim_homo_film, sim_superstrate)) stack.calc_scat(pol='TE') return stack # Run in parallel across wavelengths. pool = Pool(num_cores) stack_list = pool.map(simulate_stack, light_list) ######################## Plotting ######################## last_light_object = light_list.pop() param_layer = grating_1 # Specify the layer for which the parameters should be printed on figures. params_string = plotting.gen_params_string(param_layer, last_light_object, max_num_BMs=num_BM) active_layer_nu = 3 # Specify which layer is the active one (where absorption generates charge carriers). # Plot total transmission, reflection, absorption & that of each layer. # Also calculate efficiency of active layer. Efficiency = plotting.t_r_a_plots(stack_list, wavelengths, params_string, active_layer_nu=active_layer_nu) # Dispersion # plotting.omega_plot(stack_list, wavelengths, params_string) # # Energy Concentration # which_layer = 2 # which_modes = [1,2] # can be a single mode or multiple # plotting.E_conc_plot(stack_list, which_layer, which_modes, wavelengths,
# Run in parallel across wavelengths. pool = Pool(num_cores) stacks_wl_list = pool.map(simulate_stack, light_list) # Pull apart simultaneously simulated stakes into single stack, all wls arrays. # Unnecissary if just returning a single stack np.array(stacks_wl_list) ######################## Plotting ######################## last_light_object = light_list.pop() param_layer = substrate # Specify the layer for which the parameters should be printed on figures. params_string = plotting.gen_params_string(param_layer, last_light_object) stack_label = 0 # Specify which stack you are dealing with. stack_wl_list = [] for i in range(len(wavelengths)): stack_wl_list.append(stacks_wl_list[i][stack_label]) # Plot total transmission, reflection, absorption & that of each layer. Efficiency = plotting.t_r_a_plots(stack_wl_list, wavelengths, params_string, stack_label=stack_label) ######################## Wrapping up ######################## print '\n*******************************************' print 'The ultimate efficiency is %12.8f' % Efficiency print '-------------------------------------------'
return [stack0] # Run in parallel across wavelengths. pool = Pool(num_cores) stacks_wl_list = pool.map(simulate_stack, light_list) # Pull apart simultaneously simulated stakes into single stack, all wls arrays. # Unnecissary if just returning a single stack np.array(stacks_wl_list) ######################## Plotting ######################## last_light_object = light_list.pop() param_layer = substrate # Specify the layer for which the parameters should be printed on figures. params_string = plotting.gen_params_string(param_layer, last_light_object) stack_label = 0 # Specify which stack you are dealing with. stack_wl_list = [] for i in range(len(wavelengths)): stack_wl_list.append(stacks_wl_list[i][stack_label]) # Plot total transmission, reflection, absorption & that of each layer. Efficiency = plotting.t_r_a_plots(stack_wl_list, wavelengths, params_string, stack_label=stack_label) ######################## Wrapping up ######################## print '\n*******************************************' print 'The ultimate efficiency is %12.8f' % Efficiency print '-------------------------------------------'
def setup_module(module): ################ Simulation parameters ################ # Number of CPUs to use im simulation num_cores = 1 # # Alternatively specify the number of CPUs to leave free on machine # leave_cpus = 4 # num_cores = mp.cpu_count() - leave_cpus # Remove results of previous simulations plotting.clear_previous('.txt') plotting.clear_previous('.pdf') # plotting.clear_previous('.log') ################ Light parameters ##################### # # Set up light objects # wavelengths = [310, 410, 531.2007, 707.495, 881.786, 987.9632] # light_list = [objects.Light(wl) for wl in wavelengths] # Single wavelength run wl_super = 500.0 wavelengths = np.array([wl_super]) light_list = [objects.Light(wl, theta = 20, phi = 40, max_order_PWs = 1) for wl in wavelengths] light = light_list[0] ################ Scattering matrices (for distinct layers) ############## """ Calculate scattering matrices for each distinct layer. Calculated in the order listed below, however this does not influence final structure which is defined later """ # period must be consistent throughout simulation!!! period = 600 cover = objects.ThinFilm(period = period, height_nm = 'semi_inf', material = materials.Air, loss = False) sim_cover = cover.calc_modes(light) NW_diameter = 120 num_BM = 20 grating_1 = objects.NanoStruct('NW_array', period, NW_diameter, height_nm = 2330, inclusion_a = materials.Si_c, background = materials.Air, loss = True, make_mesh_now = True, force_mesh = True, lc_bkg = 0.07, lc2= 1.5, lc3= 2.0) sim_grat1 = grating_1.calc_modes(light, num_BM = num_BM) # will only ever use top scattering matrices for the bottom layer bottom = objects.ThinFilm(period = period, height_nm = 'semi_inf', material = materials.SiO2_a, loss = False) sim_bot = bottom.calc_modes(light) ################ Construct & solve for full solar cell structure ############## """ Now when defining full structure order is critical and solar_cell list MUST be ordered from bottom to top! """ stack = Stack((sim_bot, sim_grat1, sim_cover)) stack.calc_scat() module.stack_list = [stack] last_light_object = light_list.pop() param_layer = grating_1 # Specify the layer for which the parameters should be printed on figures. params_string = plotting.gen_params_string(param_layer, last_light_object, max_num_BMs=num_BM) active_layer_nu = 1 Efficiency = plotting.t_r_a_plots(stack_list, wavelengths, params_string, active_layer_nu=active_layer_nu)