def test_BL_correction():

    wl = np.linspace(800, 950, 4) * 1e-9

    GaAs = material("GaAs")()

    thick_cell = SolarCell([Layer(material=GaAs, width=si("20um"))])

    opts = State()
    opts.position = None
    prepare_solar_cell(thick_cell, opts)
    position = np.arange(0, thick_cell.width, 1e-9)
    opts.position = position
    opts.recalculate_absorption = True
    opts.no_back_reflexion = False

    opts.BL_correction = False
    opts.wavelength = wl
    solve_tmm(thick_cell, opts)

    no_corr = thick_cell.absorbed

    opts.BL_correction = True

    solve_tmm(thick_cell, opts)

    with_corr = thick_cell.absorbed

    assert with_corr == approx(
        np.array([6.71457872e-01, 6.75496354e-01, 2.09738887e-01, 0]))
    assert no_corr == approx(
        np.array([6.71457872e-01, 6.75496071e-01, 2.82306407e-01, 0]))
Пример #2
0
def solve_optics(solar_cell, options):
    """ Solves the optical properties of the structure, calculating the reflectance, absorptance and transmitance. The "optics_method" option controls which method is used to calculate the optical properties of the solar cell:

    - None: The calculation is skipped. Only useful for solar cells involving just "2-diode" kind of junctions.
    - BL: Uses the Beer-Lambert law to calculate the absorption in each layer. Front surface reflexion has to provided externally. It is the default method and the most flexible one.
    - TMM: Uses a transfer matrix calculation to obtain the RAT. Not valid for DB or 2D junction
    - RCWA: Uses the rigorous wave coupled analysisto obtain the RAT. This allows to include 2D photonic crystals in the structure, for example. Not valid for DB or 2D junctions
    - external: The reflection and absorption profiles are provided externally by the user, and therefore no calculation is performed by Solcore.

    :param solar_cell: A solar_cell object
    :param options: Options for the optics solver
    :return: None
    """
    print('Solving optics of the solar cell...')
    if options.optics_method is None:
        print('Warning: Not solving the optics of the solar cell.')
    elif options.optics_method == 'external':
        solve_external_optics(solar_cell, options)
    elif options.optics_method == 'BL':
        solve_beer_lambert(solar_cell, options)
    elif options.optics_method == 'TMM':
        solve_tmm(solar_cell, options)
    elif options.optics_method == 'RCWA':
        solve_rcwa(solar_cell, options)
    else:
        raise ValueError(
            'ERROR in "solar_cell_solver":\n\tOptics solver method must be None, "external", "BL", "TMM" or "RCWA".')