def test_from_txt_file():
    relpath = os.path.join('UserData', 'AlSb.txt')
    filepath = os.path.join(root_path, relpath)
    md = Material(file_path=filepath,
                  spectrum_type='wavelength',
                  unit='micrometer')
    n = md.get_nk_data(spectrum)
    assert np.isclose(np.real(n), 4.574074754901961)
    assert np.isclose(np.imag(n), 0.4318627450980393)
def test_from_yml_file():
    relpath = os.path.join('RefractiveIndexInfo', 'data', 'main', 'Ag',
                           'Hagemann.yml')
    filepath = os.path.join(root_path, relpath)
    md = Material(file_path=filepath,
                  spectrum_type='wavelength',
                  unit='micrometer')
    n = md.get_nk_data(spectrum)
    assert np.isclose(np.real(n), 0.23805806451612901)
    assert np.isclose(np.imag(n), 3.126040322580645)
Exemple #3
0
def make_example_yaml(dir_path):
    model_params = {
        'name': 'Sellmeier',
        'specrtrum_type': 'wavelength',
        'unit': 'micrometer',
        'valid_range': np.array([0.350, 2.0]),
        'parameters': np.array([0, 1.0, 0.05, 2.0, 0.1, 10., 25.])
    }
    mat = Material(model_kw=model_params,
                   spectrum_type='wavelength',
                   unit='micrometer')
    mat.meta_data['Reference'] = "Literature reference to the data"
    mat.meta_data['Comment'] = "Any additional information goes here"
    mat.meta_data['Name'] = "Short name of the material"
    mat.meta_data['FullName'] = "Full name of the material"
    mat.meta_data['Author'] = "The author of this data file"
    mat.meta_data['MetaComment'] = " This is a multiline meta-comment\n" + \
                                   " which provides information not\n" + \
                                   " in metadata"
    k_data = np.array([[400., 0.1], [500., 0.05], [600., 0.0], [700., 0.0]])
    interp = Interpolation(k_data, unit='nm')
    mat.data['imag'] = interp
    filepath = os.path.join(dir_path, "example_file2.yml")
    write = Writer(filepath, mat)
    write.write_file()
def test_from_model():
    wp = 8.55  # eV
    loss = 18.4e-3  #eV
    model_kw = {
        'name': 'Drude',
        'parameters': [wp, loss],
        'valid_range': [0.0, np.inf],
        'spectrum_type': 'energy',
        'unit': 'ev'
    }
    md = Material(model_kw=model_kw)
    n = md.get_nk_data(spectrum)

    assert np.isclose(np.real(n), 0.013366748652710245)
    assert np.isclose(np.imag(n), 3.2997524521729824)
Exemple #5
0
def make_anti_reflex_layers(keys):
    mat1 = keys['layer_order'][keys['AntiReflex_at']]
    mat2 = keys['layer_order'][keys['AntiReflex_at'] + 1]
    nLayers = keys['AntiReflex_n_layers']
    total_thickness = keys['height_AntiReflex']
    spectrum = Spectrum(keys['vacuum_wavelength'], unit='m')
    nk1 = np.real(keys['mat_' + mat1].get_nk_data(spectrum))
    nk2 = np.real(keys['mat_' + mat2].get_nk_data(spectrum))
    max_id = 0
    for key in keys['Domains']:
        if keys['Domains'][key] > max_id:
            max_id = keys['Domains'][key]
    max_id += 1

    for ilayer, layer in enumerate(keys['layer_order']):
        if layer == mat1:
            start_layer = ilayer
    for step in range(1, nLayers + 1):
        n = nk1 + (nk2 - nk1) * (step) / (nLayers + 1)
        new_data = np.vstack([spectrum.values, n]).T
        mat_name = 'mat_AntiReflex_{}'.format(step)
        keys[mat_name] = Material(tabulated_n=new_data, unit='m')
        t = total_thickness / nLayers
        height_name = 'height_AntiReflex_{}'.format(step)
        keys[height_name] = t
        layer_name = "AntiReflex_{}".format(step)
        keys['Domains'][layer_name] = max_id + step
        keys['layer_order'].insert(start_layer + step, layer_name)
    return keys
Exemple #6
0
def make_example_txt(dir_path):
    test_data = np.array([[400., 1.7, 0.1], [500., 1.6, 0.05],
                          [600., 1.5, 0.0], [700., 1.4, 0.0]])
    mat = Material(tabulated_nk=test_data,
                   spectrum_type='wavelength',
                   unit='nanometer')
    mat.meta_data['Reference'] = "Literature reference to the data"
    mat.meta_data['Comment'] = "Any additional information goes here"
    mat.meta_data['Name'] = "Short name of the material"
    mat.meta_data['FullName'] = "Full name of the material"
    mat.meta_data['Author'] = "The author of this data file"
    mat.meta_data['MetaComment'] = " This is a multiline meta-comment\n" + \
                                   " which provides information not\n" + \
                                   " in metadata"
    filepath = os.path.join(dir_path, "example_file.txt")
    write = Writer(filepath, mat)
    write.write_file()
def test_mat_init():
    md = Material(fixed_n=1.0)
    n = md.get_nk_data(spectrum)
    assert np.isclose(np.real(n), 1.0)
    assert np.isclose(np.imag(n), 0.0)