def test_get_band_projection_kpt_9_band_8_aln_2d(file_path): """ Verify if the informations returned about projection in the 11ª band of the 9º kpoint is correct for the 2d GeC. """ procar_filename = file_path("/aln-2d/PROCAR") eigenval_filename = file_path("/aln-2d/EIGENVAL") vasprun_filename = file_path("/aln-2d/vasprun.xml") procar = Procar(procar_filename) vasprun = Vasprun(vasprun_filename) eigenval = Eigenvalues(eigenval_filename) band_structure = BandStructure(eigenvalues=eigenval.eigenvalues, fermi_energy=vasprun.fermi_energy, atoms_map=vasprun.atoms_map, num_bands=procar.num_bands, band_projection=procar) kpt_9_band_8_projection = { "Al": [0.000, 0.000, 0.033, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000], "N": [0.000, 0.000, 0.011, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000] } band_projection = band_structure.band_projection(9, 8) for atom_index, projections in band_projection.items(): for index, element in enumerate(projections): assert np.isclose(element, kpt_9_band_8_projection[atom_index][index])
def test_cbm_projection_aln_2d(file_path): """ Test if the projection of the valence maximum band is correct """ procar_filename = file_path("/aln-2d/PROCAR") eigenval_filename = file_path("/aln-2d/EIGENVAL") vasprun_filename = file_path("/aln-2d/vasprun.xml") projection = { "Al": [0.055, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000], "N": [0.132, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000] } procar = Procar(procar_filename) vasprun = Vasprun(vasprun_filename) eigenval = Eigenvalues(eigenval_filename) band_structure = BandStructure(eigenvalues=eigenval.eigenvalues, fermi_energy=vasprun.fermi_energy, atoms_map=vasprun.atoms_map, num_bands=procar.num_bands, band_projection=procar) cbm_projection = band_structure.cbm_projection() for atom_index, projections in cbm_projection.items(): for index, element in enumerate(projections): assert np.isclose(element, projection[atom_index][index])
def test_vasprun_parser_for_fermi_energy_and_atoms_aln_2d(file_path): """ Check if the parser for the vasprun.xml file is catching the right values for atom informations and fermi energy. """ filename = file_path("/aln-2d/vasprun.xml") vasprun = Vasprun(filename) fermi_energy = -3.93363725 atoms = {"1": "Al", "2": "N"} assert np.isclose(fermi_energy, vasprun.fermi_energy) for index, symbol in vasprun.atoms_map.items(): assert symbol == atoms[index]
def test_vasprun_parser_for_fermi_energy_and_atoms_pbte(file_path): """ Check if the parser for the vasprun.xml file is catching the right values for atom informations and fermi energy. """ filename = file_path("/pbte/vasprun.xml") vasprun = Vasprun(filename) fermi_energy = 5.20551128 atoms = {"1": "Te", "2": "Pb"} assert np.isclose(fermi_energy, vasprun.fermi_energy) for index, symbol in vasprun.atoms_map.items(): assert symbol == atoms[index]
def get_fermi_energy(self, filename: str = "vasprun.xml", base_path: str = None) -> float: """ Args: filename (str): Name of the vasprun.xml file. base_path (str): Path to the folder where the file is located. Returns: fermi_energy (dict): Energy of the fermi level """ if base_path: filename = os.path.join(base_path, filename) vasprun = Vasprun(filename) return vasprun.fermi_energy
def get_atoms_map(self, filename: str = "vasprun.xml", base_path: str = None) -> dict: """ Args: filename (str): Name of the vasprun.xml file. base_path (str): Path to the folder where the file is located. Returns: atoms_map (dict): Map of atomic symbols for their respective indexes """ if base_path: filename = os.path.join(base_path, filename) vasprun = Vasprun(filename) return vasprun.atoms_map
def test_is_metal_gan_3d(file_path): """ Confirms that ge GaN 3d is not an metal. """ procar_filename = file_path("/gan-3d/PROCAR") eigenval_filename = file_path("/gan-3d/EIGENVAL") vasprun_filename = file_path("/gan-3d/vasprun.xml") procar = Procar(procar_filename) vasprun = Vasprun(vasprun_filename) eigenval = Eigenvalues(eigenval_filename) band_structure = BandStructure(eigenvalues=eigenval.eigenvalues, fermi_energy=vasprun.fermi_energy, atoms_map=vasprun.atoms_map, num_bands=procar.num_bands, band_projection=procar) assert band_structure.is_metal() is False
def test_band_gap_aln_2d(file_path): """ Test AlN 2d band gap """ procar_filename = file_path("/aln-2d/PROCAR") eigenval_filename = file_path("/aln-2d/EIGENVAL") vasprun_filename = file_path("/aln-2d/vasprun.xml") procar = Procar(procar_filename) vasprun = Vasprun(vasprun_filename) eigenval = Eigenvalues(eigenval_filename) band_structure = BandStructure(eigenvalues=eigenval.eigenvalues, fermi_energy=vasprun.fermi_energy, atoms_map=vasprun.atoms_map, num_bands=procar.num_bands, band_projection=procar) assert np.isclose(band_structure.band_gap()["gap"], 2.924163)
def test_band_gap_gan_3d(file_path): """ Tests GaN 3d band gap . """ procar_filename = file_path("/gan-3d/PROCAR") eigenval_filename = file_path("/gan-3d/EIGENVAL") vasprun_filename = file_path("/gan-3d/vasprun.xml") procar = Procar(procar_filename) vasprun = Vasprun(vasprun_filename) eigenval = Eigenvalues(eigenval_filename) band_structure = BandStructure(eigenvalues=eigenval.eigenvalues, fermi_energy=vasprun.fermi_energy, atoms_map=vasprun.atoms_map, num_bands=procar.num_bands, band_projection=procar) assert np.isclose(band_structure.band_gap()["gap"], 1.5380389999999995)
def test_gec_2d_cbm(file_path): """ Test with GeC-2d """ procar_filename = file_path("/gec-2d/PROCAR") eigenval_filename = file_path("/gec-2d/EIGENVAL") vasprun_filename = file_path("/gec-2d/vasprun.xml") procar = Procar(procar_filename) vasprun = Vasprun(vasprun_filename) eigenval = Eigenvalues(eigenval_filename) band_structure = BandStructure(eigenvalues=eigenval.eigenvalues, fermi_energy=vasprun.fermi_energy, atoms_map=vasprun.atoms_map, num_bands=procar.num_bands, band_projection=procar) cbm_projection = band_structure.cbm_projection() cbm_df = projection_to_df(cbm_projection) correction_indexes = get_fractionary_correction_indexes(cbm_df) assert correction_indexes["Ge"][0] == "p"
def test_cbm_index_gan_3d(file_path): """ Test if the index of the conduction minimum band is correct """ procar_filename = file_path("/gan-3d/PROCAR") eigenval_filename = file_path("/gan-3d/EIGENVAL") vasprun_filename = file_path("/gan-3d/vasprun.xml") kpoint_cbm = 1 band_cbm = 10 procar = Procar(procar_filename) vasprun = Vasprun(vasprun_filename) eigenval = Eigenvalues(eigenval_filename) band_structure = BandStructure(eigenvalues=eigenval.eigenvalues, fermi_energy=vasprun.fermi_energy, atoms_map=vasprun.atoms_map, num_bands=procar.num_bands, band_projection=procar) cbm_index = band_structure.cbm_index() assert cbm_index[0] == kpoint_cbm assert cbm_index[1] == band_cbm
def test_vbm_index_aln_2d(file_path): """ Test if the index of the valence maximum band is correct """ procar_filename = file_path("/aln-2d/PROCAR") eigenval_filename = file_path("/aln-2d/EIGENVAL") vasprun_filename = file_path("/aln-2d/vasprun.xml") kpoint_vbm = 16 band_vbm = 4 procar = Procar(procar_filename) vasprun = Vasprun(vasprun_filename) eigenval = Eigenvalues(eigenval_filename) band_structure = BandStructure(eigenvalues=eigenval.eigenvalues, fermi_energy=vasprun.fermi_energy, atoms_map=vasprun.atoms_map, num_bands=procar.num_bands, band_projection=procar) vbm_index = band_structure.vbm_index() assert vbm_index[0] == kpoint_vbm assert vbm_index[1] == band_vbm
def test_bn_2d_vbm_without_treshold(file_path): """ Test with BN-2d without treshold """ procar_filename = file_path("/bn-2d/PROCAR") eigenval_filename = file_path("/bn-2d/EIGENVAL") vasprun_filename = file_path("/bn-2d/vasprun.xml") procar = Procar(procar_filename) vasprun = Vasprun(vasprun_filename) eigenval = Eigenvalues(eigenval_filename) band_structure = BandStructure(eigenvalues=eigenval.eigenvalues, fermi_energy=vasprun.fermi_energy, atoms_map=vasprun.atoms_map, num_bands=procar.num_bands, band_projection=procar) vbm_projection = band_structure.vbm_projection() vbm_df = projection_to_df(vbm_projection) correction_indexes = get_fractionary_correction_indexes(vbm_df, treshold=0) assert correction_indexes["N"][0] == "p" assert correction_indexes["B"][0] == "p"
def test_aln_2d_cbm_treshold_30(file_path): """ Test with AlN-2d with treshold 29 """ procar_filename = file_path("/aln-2d/PROCAR") eigenval_filename = file_path("/aln-2d/EIGENVAL") vasprun_filename = file_path("/aln-2d/vasprun.xml") procar = Procar(procar_filename) vasprun = Vasprun(vasprun_filename) eigenval = Eigenvalues(eigenval_filename) band_structure = BandStructure(eigenvalues=eigenval.eigenvalues, fermi_energy=vasprun.fermi_energy, atoms_map=vasprun.atoms_map, num_bands=procar.num_bands, band_projection=procar) cbm_projection = band_structure.cbm_projection() cbm_df = projection_to_df(cbm_projection) correction_indexes = get_fractionary_correction_indexes(cbm_df, treshold=29) assert correction_indexes["N"][0] == "s" assert len(correction_indexes["Al"]) == 0
def test_gec_2d_vbm_changing_treshold_13(file_path): """ Test with GeC-2d with treshold_13 """ procar_filename = file_path("/gec-2d/PROCAR") eigenval_filename = file_path("/gec-2d/EIGENVAL") vasprun_filename = file_path("/gec-2d/vasprun.xml") procar = Procar(procar_filename) vasprun = Vasprun(vasprun_filename) eigenval = Eigenvalues(eigenval_filename) band_structure = BandStructure(eigenvalues=eigenval.eigenvalues, fermi_energy=vasprun.fermi_energy, atoms_map=vasprun.atoms_map, num_bands=procar.num_bands, band_projection=procar) vbm_projection = band_structure.vbm_projection() vbm_df = projection_to_df(vbm_projection) correction_indexes = get_fractionary_correction_indexes(vbm_df, treshold=12) assert correction_indexes["C"][0] == "p" assert len(correction_indexes["Ge"]) == 0