コード例 #1
0
def test_materials_property_map():
    int_map = DummyPartMap([0, 1])
    str_map = DummyPartMap(["part1", "part2"])
    part_materials1 = {0: "InAs", 1: "GaSb"}
    part_materials2 = {"part1": "InAs", "part2": "Al"}
    mat_lib = Materials(matDict={})
    mat_lib.add_material(
        "InAs",
        "semi",
        electronMass=0.026,
        directBandGap=417.0,
        valenceBandOffset=-590.0,
    )
    mat_lib.add_material("GaSb",
                         "semi",
                         electronMass=0.039,
                         directBandGap=812.0,
                         valenceBandOffset=-30.0)
    mat_lib.add_material("Al", "metal", workFunction=4280.0)

    prop_map1 = MaterialPropertyMap(int_map, part_materials1, mat_lib,
                                    "electronMass")
    assert prop_map1.get_part((1.0, 2.0)) == 1
    assert np.all(prop_map1.get_part(-np.ones((2, 3))) == 0)
    assert prop_map1((1.0, 2.0)) == mat_lib["GaSb"]["electronMass"]
    assert np.all(
        prop_map1(-np.ones((2, 3))) == mat_lib["InAs"]["electronMass"])

    prop_map2 = MaterialPropertyMap(str_map,
                                    part_materials2,
                                    mat_lib,
                                    "directBandGap",
                                    eunit="eV",
                                    fill_value=0.0)
    assert prop_map2.get_part((1.0, 2.0)) == "part2"
    assert np.all(prop_map2.get_part(-np.ones((2, 3))) == "part1")
    assert prop_map2((1.0, 2.0)) == 0.0
    assert np.all(
        prop_map2(-np.ones((2, 3))) == mat_lib.find("InAs", "eV")
        ["directBandGap"])
コード例 #2
0
ファイル: test_property_map.py プロジェクト: stjordanis/qmt
def test_materials_property_map():
    int_map = DummyPartMap([0, 1])
    str_map = DummyPartMap(['part1', 'part2'])
    part_materials1 = {0: 'InAs', 1: 'GaSb'}
    part_materials2 = {'part1': 'InAs', 'part2': 'Al'}
    mat_lib = Materials(matDict={})
    mat_lib.add_material('InAs', 'semi', electronMass=0.026, directBandGap=417.,
                         valenceBandOffset=-590.)
    mat_lib.add_material('GaSb', 'semi', electronMass=.039, directBandGap=812.,
                         valenceBandOffset=-30.)
    mat_lib.add_material('Al', 'metal', workFunction=4280.)

    prop_map1 = MaterialPropertyMap(int_map, part_materials1, mat_lib, 'electronMass')
    assert prop_map1.get_part((1., 2.)) == 1
    assert np.all(prop_map1.get_part(-np.ones((2, 3))) == 0)
    assert prop_map1((1., 2.)) == mat_lib['GaSb']['electronMass']
    assert np.all(prop_map1(-np.ones((2, 3))) == mat_lib['InAs']['electronMass'])

    prop_map2 = MaterialPropertyMap(str_map, part_materials2, mat_lib, 'directBandGap', eunit='eV',
                                    fill_value=0.)
    assert prop_map2.get_part((1., 2.)) == 'part2'
    assert np.all(prop_map2.get_part(-np.ones((2, 3))) == 'part1')
    assert prop_map2((1., 2.)) == 0.
    assert np.all(prop_map2(-np.ones((2, 3))) == mat_lib.find('InAs', 'eV')['directBandGap'])