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)

    active_layer_nu = 3 # Specify which layer is the active one (where absorption generates charge carriers).
    plotting.t_r_a_plots(stack_list, active_layer_nu=active_layer_nu, save_txt=True)
def setup_module(module):
    # Remove results of previous simulations
    plotting.clear_previous(".log")
    plotting.clear_previous(".pdf")
    plotting.clear_previous(".txt")

    ################ Light parameters #####################
    wavelengths = np.linspace(800, 1600, 1)
    light_list = [objects.Light(wl, max_order_PWs=6, theta=0.0, phi=0.0) for wl in wavelengths]
    light = light_list[0]

    period = 760

    superstrate = objects.ThinFilm(period, height_nm="semi_inf", world_1d=True, material=materials.Air, loss=False)

    substrate = objects.ThinFilm(period, height_nm="semi_inf", world_1d=True, material=materials.Air, loss=False)

    grating_1 = objects.NanoStruct(
        "1D_array",
        period,
        diameter1=int(round(0.25 * period)),
        diameter2=int(round(0.25 * period)),
        height_nm=150,
        inclusion_a=materials.Material(1.46 + 0.0j),
        inclusion_b=materials.Material(1.46 + 0.0j),
        background=materials.Material(3.61 + 0.0j),
        loss=True,
        lc_bkg=0.005,
    )

    grating_2 = objects.NanoStruct(
        "1D_array",
        period,
        int(round(0.25 * period)),
        height_nm=900,
        background=materials.Material(3.61 + 0.0j),
        inclusion_a=materials.Material(1.46 + 0.0j),
        loss=True,
        lc_bkg=0.005,
    )

    ################ Evaluate each layer individually ##############
    sim_superstrate = superstrate.calc_modes(light)
    sim_substrate = substrate.calc_modes(light)
    sim_grating_1 = grating_1.calc_modes(light)
    sim_grating_2 = grating_2.calc_modes(light)

    ################ Evaluate full solar cell structure ##############
    """ Now when defining full structure order is critical and
    stack list MUST be ordered from bottom to top!
    """

    stack = Stack((sim_substrate, sim_grating_1, sim_grating_2, sim_superstrate))
    stack.calc_scat(pol="TE")
    module.stack_list = [stack]

    plotting.t_r_a_plots(stack_list, save_txt=True)
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)

    plotting.t_r_a_plots(stack_list, save_txt=True)
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)

    plotting.t_r_a_plots(stack_list, save_txt=True)
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)

    active_layer_nu = 3  # Specify which layer is the active one (where absorption generates charge carriers).
    plotting.t_r_a_plots(stack_list,
                         active_layer_nu=active_layer_nu,
                         save_txt=True)
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):
    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):
    # 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) 
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)
# Run in parallel across wavelengths.
pool = Pool(num_cores)
stacks_list = pool.map(simulate_stack, light_list)
# Save full simo data to .npz file for safe keeping!
np.savez('Simo_results', stacks_list=stacks_list)

######################## Post Processing ########################
# We can represent the strength with which different orders are excited
# in k-space.
plotting.t_func_k_plot_1D(stacks_list)
# This corresponds to Fig 2 of Handmer et al. Optics Lett. 35, 2010.
# (The PW_amplitudes plots correspond to Fig 1 of this paper).

# Lastly we also plot the transmission, reflection and absorption of each
# layer and the stack.
plotting.t_r_a_plots(stacks_list, xvalues=azi_angles)


######################## Wrapping up ########################
# Calculate and record the (real) time taken for simulation
elapsed = (time.time() - start)
hms     = str(datetime.timedelta(seconds=elapsed))
hms_string = 'Total time for simulation was \n \
    %(hms)s (%(elapsed)12.3f seconds)'% {
            'hms'       : hms,
            'elapsed'   : elapsed, }

python_log = open("python_log.log", "w")
python_log.write(hms_string)
python_log.close()
Example #11
0
# 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,
#     params_string)

######################## Single Wavelength Plotting ########################
# Plot transmission as a function of k vector.
# plotting.t_func_k_plot(stack_list)

# # Visualise the Scattering Matrices
# for i in range(len(wavelengths)):




param_layer = NWs # 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)

#### Example 1: simple multilayered stack.
stack_label = 1 # Specify which stack you are dealing with.
stack1_wl_list = []
for i in range(len(wavelengths)):
    stack1_wl_list.append(stacks_wl_list[i][stack_label])
active_layer_nu = 1

Efficiency = plotting.t_r_a_plots(stack1_wl_list, wavelengths, params_string, 
    active_layer_nu=active_layer_nu, stack_label=stack_label) 
# Dispersion
plotting.omega_plot(stack1_wl_list, wavelengths, params_string, stack_label=stack_label) 












pool = Pool(num_cores)
stacks_list = pool.map(simulate_stack, light_list)
# Save full simo data to .npz file for safe keeping!
np.savez('Simo_results', stacks_list=stacks_list)


######################## Plotting ########################

# We here wish to know the photovoltaic performance of the structure,
# where all light absorbed in the NW layer is considered to produce exactly
# one electron-hole pair.
# To do this we specify which layer of the stack is the PV active layer
# (default active_layer_nu=1), and indicate that we want to calculate
# the ideal short circuit current (J_sc) of the cell.
# We could also calculate the 'ultimate efficiency' by setting ult_eta=True.
plotting.t_r_a_plots(stacks_list, active_layer_nu=1, J_sc=True)

# We also plot the dispersion relation for each layer.
plotting.omega_plot(stacks_list, wavelengths)

######################## Wrapping up ########################
# Calculate and record the (real) time taken for simulation
elapsed = (time.time() - start)
hms     = str(datetime.timedelta(seconds=elapsed))
hms_string = 'Total time for simulation was \n \
    %(hms)s (%(elapsed)12.3f seconds)'% {
            'hms'       : hms,
            'elapsed'   : elapsed, }

python_log = open("python_log.log", "w")
python_log.write(hms_string)
Example #14
0
                                           max_num_BMs=num_BM)

#### Individual spectra of multilayered stack where one layer has many heights.
stack_label = 0
active_layer_nu = 1
# for h in range(num_h):
h = 0
gen_name = '_h-'
h_name = str(h)
additional_name = gen_name + h_name  # You can add an arbitry string onto the end of the spectra filenames.
stack3_hs_wl_list = []
for i in range(len(wavelengths)):
    stack3_hs_wl_list.append(stacks_wl_list[i][h])
Efficiency = plotting.t_r_a_plots(stack3_hs_wl_list,
                                  wavelengths,
                                  params_string,
                                  active_layer_nu=active_layer_nu,
                                  stack_label=stack_label,
                                  add_name=additional_name)

# Calculate and record the (real) time taken for simulation
elapsed = (time.time() - start)
hms = str(datetime.timedelta(seconds=elapsed))
hms_string = 'Total time for simulation was \n \
    %(hms)s (%(elapsed)12.3f seconds)' % {
    'hms': hms,
    'elapsed': elapsed,
}

python_log = open("python_log.log", "w")
python_log.write(hms_string)
python_log.close()
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)
    # Shear is relative to top layer (ie incident light) and in units of d.
    stack = Stack((sim_substrate, sim_grating_1, sim_grating_2, sim_superstrate), \
        shears = ([(0.1,0.0),(-0.3,0.1),(0.2,0.5)]) )
    stack.calc_scat(pol = 'TE')

    return stack


# Run in parallel across wavelengths.
pool = Pool(num_cores)
stacks_list = pool.map(simulate_stack, light_list)
# Save full simo data to .npz file for safe keeping!
np.savez('Simo_results', stacks_list=stacks_list)

plotting.t_r_a_plots(stacks_list)

######################## Wrapping up ########################
# Calculate and record the (real) time taken for simulation
elapsed = (time.time() - start)
hms     = str(datetime.timedelta(seconds=elapsed))
hms_string = 'Total time for simulation was \n \
    %(hms)s (%(elapsed)12.3f seconds)'% {
            'hms'       : hms,
            'elapsed'   : elapsed, }

python_log = open("python_log.log", "w")
python_log.write(hms_string)
python_log.close()

print hms_string
param_layer = Au_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=num_BM)


#### Individual spectra of multilayered stack where one layer has many heights.
stack_label = 0
active_layer_nu = 1
# for h in range(num_h):
h = 0
gen_name = '_h-'
h_name = str(h)
additional_name = gen_name+h_name # You can add an arbitry string onto the end of the spectra filenames.
stack3_hs_wl_list = []
for i in range(len(wavelengths)):
    stack3_hs_wl_list.append(stacks_wl_list[i][h])
Efficiency = plotting.t_r_a_plots(stack3_hs_wl_list, wavelengths, params_string, 
    active_layer_nu=active_layer_nu, stack_label=stack_label, add_name = additional_name)


# Calculate and record the (real) time taken for simulation
elapsed = (time.time() - start)
hms     = str(datetime.timedelta(seconds=elapsed))
hms_string = 'Total time for simulation was \n \
    %(hms)s (%(elapsed)12.3f seconds)'% {
            'hms'       : hms,
            'elapsed'   : elapsed, }

python_log = open("python_log.log", "w")
python_log.write(hms_string)
python_log.close()

print '*******************************************'
# We here chose a subset of orders to plot.
plotting.PW_amplitudes(stacks_list, chosen_PWs = [-1,0,2], \
    lay_interest = 1)

# When many plane wave orders are included these last plots can become confusing,
# so instead one may wish to sum together the amplitudes of all propagating orders,
# of all evanescent orders, and all far-evanescent orders
# (which have in plane k>n_H * k0).
plotting.evanescent_merit(stacks_list, lay_interest = 0)


plotting.BM_amplitudes(stacks_list, lay_interest = 2, chosen_BMs = [0,1,2,3,4,5])

# Lastly we also plot the transmission, reflection and absorption of each
# layer and the stack.
plotting.t_r_a_plots(stacks_list, xvalues = wavelengths)


######################## Wrapping up ########################
# Calculate and record the (real) time taken for simulation
elapsed = (time.time() - start)
hms     = str(datetime.timedelta(seconds=elapsed))
hms_string = 'Total time for simulation was \n \
    %(hms)s (%(elapsed)12.3f seconds)'% {
            'hms'       : hms,
            'elapsed'   : elapsed, }

python_log = open("python_log.log", "w")
python_log.write(hms_string)
python_log.close()
# 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 '-------------------------------------------'

# Calculate and record the (real) time taken for simulation
elapsed = (time.time() - start)
hms     = str(datetime.timedelta(seconds=elapsed))
hms_string = 'Total time for simulation was \n \
    %(hms)s (%(elapsed)12.3f seconds)'% {
            'hms'       : hms,
            'elapsed'   : elapsed, }
# Run in parallel across wavelengths.
pool = Pool(num_cores)
stacks_list = pool.map(simulate_stack, light_list)
# Save full simo data to .npz file for safe keeping!
np.savez('Simo_results', stacks_list=stacks_list)

######################## Plotting ########################
eta = []
for s in range(len(sub_ns)):
    stack_label = s  # Specify which stack you are dealing with.
    stack1_wl_list = []
    for i in range(len(wavelengths)):
        stack1_wl_list.append(stacks_list[i][stack_label])
    sub_n = sub_ns[s]
    Efficiency = plotting.t_r_a_plots(stack1_wl_list,
                                      ult_eta=True,
                                      stack_label=stack_label,
                                      add_name=str(s))
    eta.append(100.0 * Efficiency[0])
    # Dispersion of structured layer is the same for all cases.
    if s == 0:
        plotting.omega_plot(stack1_wl_list,
                            wavelengths,
                            stack_label=stack_label)

# Now plot as a function of substrate refractive index.
import matplotlib
matplotlib.use('pdf')
import matplotlib.pyplot as plt
fig = plt.figure()
linesstrength = 3
font = 18
def setup_module(module):
    # Remove results of previous simulations
    plotting.clear_previous('.log')
    plotting.clear_previous('.pdf')
    plotting.clear_previous('.txt')

    ################ Light parameters #####################
    wavelengths = np.linspace(800, 1600, 1)
    light_list = [
        objects.Light(wl, max_order_PWs=6, theta=0.0, phi=0.0)
        for wl in wavelengths
    ]
    light = light_list[0]

    period = 760

    superstrate = objects.ThinFilm(period,
                                   height_nm='semi_inf',
                                   world_1d=True,
                                   material=materials.Air,
                                   loss=False)

    substrate = objects.ThinFilm(period,
                                 height_nm='semi_inf',
                                 world_1d=True,
                                 material=materials.Air,
                                 loss=False)

    grating_1 = objects.NanoStruct('1D_array',
                                   period,
                                   diameter1=int(round(0.25 * period)),
                                   diameter2=int(round(0.25 * period)),
                                   height_nm=150,
                                   inclusion_a=materials.Material(1.46 + 0.0j),
                                   inclusion_b=materials.Material(1.46 + 0.0j),
                                   background=materials.Material(3.61 + 0.0j),
                                   loss=True,
                                   lc_bkg=0.005)

    grating_2 = objects.NanoStruct('1D_array',
                                   period,
                                   int(round(0.25 * period)),
                                   height_nm=900,
                                   background=materials.Material(3.61 + 0.0j),
                                   inclusion_a=materials.Material(1.46 + 0.0j),
                                   loss=True,
                                   lc_bkg=0.005)

    ################ Evaluate each layer individually ##############
    sim_superstrate = superstrate.calc_modes(light)
    sim_substrate = substrate.calc_modes(light)
    sim_grating_1 = grating_1.calc_modes(light)
    sim_grating_2 = grating_2.calc_modes(light)

    ################ Evaluate full solar cell structure ##############
    """ Now when defining full structure order is critical and
    stack list MUST be ordered from bottom to top!
    """

    stack = Stack(
        (sim_substrate, sim_grating_1, sim_grating_2, sim_superstrate))
    stack.calc_scat(pol='TE')
    module.stack_list = [stack]

    plotting.t_r_a_plots(stack_list, save_txt=True)
    return saveStack


# Run in parallel across wavelengths.
pool = Pool(num_cores)
stacks_list = pool.map(simulate_stack, light_list)
# Save full simo data to .npz file for safe keeping!
np.savez('Simo_results', stacks_list=stacks_list)

######################## Plotting ########################
# Just to show how it's done we can add the height of the layer and some extra
# details to the file names and plot titles.
title = 'what_a_lovely_day-'

plotting.t_r_a_plots(stacks_list, add_height=Au_NHs.height_nm, add_name=title)


# Calculate and record the (real) time taken for simulation
elapsed = (time.time() - start)
hms     = str(datetime.timedelta(seconds=elapsed))
hms_string = 'Total time for simulation was \n \
    %(hms)s (%(elapsed)12.3f seconds)'% {
            'hms'       : hms,
            'elapsed'   : elapsed, }

python_log = open("python_log.log", "w")
python_log.write(hms_string)
python_log.close()

print '*******************************************'
Example #23
0
    stack.calc_scat(pol = 'TE')

    return stack


# Run in parallel across wavelengths.
pool = Pool(num_cores)
stacks_list = pool.map(simulate_stack, light_list)
# Save full simo data to .npz file for safe keeping!
np.savez('Simo_results', stacks_list=stacks_list)


######################## Plotting ########################

# Plot the transmission, reflection and absorption.
plotting.t_r_a_plots(stacks_list, active_layer_nu=1)

# We also plot the dispersion relation for the NW layer.
plotting.omega_plot(stacks_list, wavelengths)

######################## Wrapping up ########################
# Calculate and record the (real) time taken for simulation
elapsed = (time.time() - start)
hms     = str(datetime.timedelta(seconds=elapsed))
hms_string = 'Total time for simulation was \n \
    %(hms)s (%(elapsed)12.3f seconds)'% {
            'hms'       : hms,
            'elapsed'   : elapsed, }

python_log = open("python_log.log", "w")
python_log.write(hms_string)
        """

        stack = Stack(
            (sim_substrate, sim_grating_1, sim_grating_2, sim_superstrate))
        # stack = Stack((sim_substrate, sim_grating_2, sim_superstrate))
        stack.calc_scat(pol='TE')
        return stack

    # Run in parallel across wavelengths.
    pool = Pool(num_cores)
    stacks_list = pool.map(simulate_stack, light_list)
    # Save full simo data to .npz file for safe keeping!
    np.savez('Simo_results', stacks_list=stacks_list)

    additional_name = str(int(PWs))
    plotting.t_r_a_plots(stacks_list, add_name=additional_name)

######################## Wrapping up ########################
# Calculate and record the (real) time taken for simulation
elapsed = (time.time() - start)
hms = str(datetime.timedelta(seconds=elapsed))
hms_string = 'Total time for simulation was \n \
    %(hms)s (%(elapsed)12.3f seconds)' % {
    'hms': hms,
    'elapsed': elapsed,
}

# python_log = open("python_log.log", "w")
# python_log.write(hms_string)
# python_log.close()
Example #25
0
# Run in parallel across wavelengths.
pool = Pool(num_cores)
stacks_list = pool.map(simulate_stack, light_list)
# Save full simo data to .npz file for safe keeping!
np.savez('Simo_results', stacks_list=stacks_list)

######################## Plotting ########################

# We here wish to know the photovoltaic performance of the structure,
# where all light absorbed in the NW layer is considered to produce exactly
# one electron-hole pair.
# To do this we specify which layer of the stack is the PV active layer
# (default active_layer_nu=1), and indicate that we want to calculate
# the ideal short circuit current (J_sc) of the cell.
# We could also calculate the 'ultimate efficiency' by setting ult_eta=True.
plotting.t_r_a_plots(stacks_list, active_layer_nu=1, J_sc=True)

# We also plot the dispersion relation for each layer.
plotting.omega_plot(stacks_list, wavelengths)

######################## Wrapping up ########################
# Calculate and record the (real) time taken for simulation
elapsed = (time.time() - start)
hms = str(datetime.timedelta(seconds=elapsed))
hms_string = 'Total time for simulation was \n \
    %(hms)s (%(elapsed)12.3f seconds)' % {
    'hms': hms,
    'elapsed': elapsed,
}

python_log = open("python_log.log", "w")
    stack.calc_scat(pol = 'TE')

    return stack


# Run in parallel across wavelengths.
pool = Pool(num_cores)
stacks_list = pool.map(simulate_stack, light_list)
# Save full simo data to .npz file for safe keeping!
np.savez('Simo_results', stacks_list=stacks_list)


######################## Plotting ########################

# Plot the transmission, reflection and absorption.
plotting.t_r_a_plots(stacks_list, active_layer_nu=1)

# We also plot the dispersion relation for the NW layer.
plotting.omega_plot(stacks_list, wavelengths)

######################## Wrapping up ########################
# Calculate and record the (real) time taken for simulation
elapsed = (time.time() - start)
hms     = str(datetime.timedelta(seconds=elapsed))
hms_string = 'Total time for simulation was \n \
    %(hms)s (%(elapsed)12.3f seconds)'% {
            'hms'       : hms,
            'elapsed'   : elapsed, }

python_log = open("python_log.log", "w")
python_log.write(hms_string)
    return saveStack


# Run in parallel across wavelengths.
pool = Pool(num_cores)
stacks_list = pool.map(simulate_stack, light_list)
# Save full simo data to .npz file for safe keeping!
np.savez('Simo_results', stacks_list=stacks_list)

######################## Plotting ########################
# Just to show how it's done we can add the height of the layer and some extra
# details to the file names and plot titles.
title = 'what_a_lovely_day-'

plotting.t_r_a_plots(stacks_list, add_height=Au_NHs.height_nm, add_name=title)

# Calculate and record the (real) time taken for simulation
elapsed = (time.time() - start)
hms = str(datetime.timedelta(seconds=elapsed))
hms_string = 'Total time for simulation was \n \
    %(hms)s (%(elapsed)12.3f seconds)' % {
    'hms': hms,
    'elapsed': elapsed,
}

python_log = open("python_log.log", "w")
python_log.write(hms_string)
python_log.close()

print '*******************************************'
pool = Pool(num_cores)
stacks_list = pool.map(simulate_stack, light_list)
# Save full simo data to .npz file for safe keeping!
np.savez('Simo_results', stacks_list=stacks_list)



######################## Plotting ########################
eta = []
for s in range(len(sub_ns)):
    stack_label = s # Specify which stack you are dealing with.
    stack1_wl_list = []
    for i in range(len(wavelengths)):
        stack1_wl_list.append(stacks_list[i][stack_label])
    sub_n = sub_ns[s]
    Efficiency = plotting.t_r_a_plots(stack1_wl_list, ult_eta=True,
        stack_label=stack_label, add_name = str(s))
    eta.append(100.0*Efficiency[0])
    # Dispersion of structured layer is the same for all cases.
    if s == 0:
        plotting.omega_plot(stack1_wl_list, wavelengths, stack_label=stack_label)

# Now plot as a function of substrate refractive index.
import matplotlib
matplotlib.use('pdf')
import matplotlib.pyplot as plt
fig = plt.figure()
linesstrength = 3
font = 18
ax1 = fig.add_subplot(1,1,1)
ax1.plot(sub_ns,eta, 'k-o', linewidth=linesstrength)
ax1.set_xlabel('Substrate refractive index',fontsize=font)
Example #29
0
# 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 '-------------------------------------------'

# Calculate and record the (real) time taken for simulation
elapsed = (time.time() - start)
hms = str(datetime.timedelta(seconds=elapsed))
hms_string = 'Total time for simulation was \n \
    %(hms)s (%(elapsed)12.3f seconds)' % {
    'hms': hms,
    'elapsed': elapsed,
}
        stack = Stack((sim_substrate, sim_grating_1, sim_grating_2, sim_superstrate))
        # stack = Stack((sim_substrate, sim_grating_2, sim_superstrate))
        stack.calc_scat(pol = 'TE')
        return stack



    # Run in parallel across wavelengths.
    pool = Pool(num_cores)
    stacks_list = pool.map(simulate_stack, light_list)
    # Save full simo data to .npz file for safe keeping!
    np.savez('Simo_results', stacks_list=stacks_list)


    additional_name = str(int(PWs))
    plotting.t_r_a_plots(stacks_list, add_name = additional_name)



######################## Wrapping up ########################
# Calculate and record the (real) time taken for simulation
elapsed = (time.time() - start)
hms     = str(datetime.timedelta(seconds=elapsed))
hms_string = 'Total time for simulation was \n \
    %(hms)s (%(elapsed)12.3f seconds)'% {
            'hms'       : hms,
            'elapsed'   : elapsed, }

# python_log = open("python_log.log", "w")
# python_log.write(hms_string)
# python_log.close()
# Run in parallel across wavelengths.
pool = Pool(num_cores)
stacks_list = pool.map(simulate_stack, light_list)
# Save full simo data to .npz file for safe keeping!
np.savez('Simo_results', stacks_list=stacks_list)

######################## Post Processing ########################
# We can represent the strength with which different orders are excited
# in k-space.
plotting.t_func_k_plot_1D(stacks_list)
# This corresponds to Fig 2 of Handmer et al. Optics Lett. 35, 2010.
# (The PW_amplitudes plots correspond to Fig 1 of this paper).

# Lastly we also plot the transmission, reflection and absorption of each
# layer and the stack.
plotting.t_r_a_plots(stacks_list, xvalues=azi_angles)

######################## Wrapping up ########################
# Calculate and record the (real) time taken for simulation
elapsed = (time.time() - start)
hms = str(datetime.timedelta(seconds=elapsed))
hms_string = 'Total time for simulation was \n \
    %(hms)s (%(elapsed)12.3f seconds)' % {
    'hms': hms,
    'elapsed': elapsed,
}

python_log = open("python_log.log", "w")
python_log.write(hms_string)
python_log.close()
# We can now stack these layers of finite thickness however we wish.
    stack = Stack((sim_substrate, sim_TF_1, sim_TF_3, sim_TF_2, sim_TF_1, \
        sim_superstrate))
    stack.calc_scat(pol = 'TM')

    return stack

# Run wavelengths in parallel across num_cores CPUs using multiprocessing package.
pool = Pool(num_cores)
stacks_list = pool.map(simulate_stack, light_list)
# Save full simo data to .npz file for safe keeping!
np.savez('Simo_results', stacks_list=stacks_list)

######################## Post Processing ########################
# We will now see the absorption in each individual layer as well as of the stack.
plotting.t_r_a_plots(stacks_list)

######################## Wrapping up ########################
print '\n*******************************************'
# Calculate and record the (real) time taken for simulation,
elapsed = (time.time() - start)
hms     = str(datetime.timedelta(seconds=elapsed))
hms_string = 'Total time for simulation was \n \
    %(hms)s (%(elapsed)12.3f seconds)'% {
            'hms'       : hms,
            'elapsed'   : elapsed, }
print hms_string
print '*******************************************'
print ''

# and store this info.
Example #33
0
plotting.PW_amplitudes(stacks_list, chosen_PWs = [-1,0,2], \
    lay_interest = 1)

# When many plane wave orders are included these last plots can become confusing,
# so instead one may wish to sum together the amplitudes of all propagating orders,
# of all evanescent orders, and all far-evanescent orders
# (which have in plane k>n_H * k0).
plotting.evanescent_merit(stacks_list, lay_interest=0)

plotting.BM_amplitudes(stacks_list,
                       lay_interest=2,
                       chosen_BMs=[0, 1, 2, 3, 4, 5])

# Lastly we also plot the transmission, reflection and absorption of each
# layer and the stack.
plotting.t_r_a_plots(stacks_list, xvalues=wavelengths)

######################## Wrapping up ########################
# Calculate and record the (real) time taken for simulation
elapsed = (time.time() - start)
hms = str(datetime.timedelta(seconds=elapsed))
hms_string = 'Total time for simulation was \n \
    %(hms)s (%(elapsed)12.3f seconds)' % {
    'hms': hms,
    'elapsed': elapsed,
}

python_log = open("python_log.log", "w")
python_log.write(hms_string)
python_log.close()