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 cbm_character(software: str, base_path: str) -> None: """Uses output files from softwares that perform ab initio calculations to discover the first conduction band (CBM) and extract, in percentage, its character corresponding to each orbital type (s, p, d, ... ). The names of the files required for each software are listed below, it is worth mentioning that their names cannot be modified. VASP: PROCAR, EIGENVAL, vasprun.xml """ welcome_message("minushalf") softwares = {"VASP": Vasp()} factory = softwares[software.upper()] eigenvalues = factory.get_eigenvalues(base_path=base_path) fermi_energy = factory.get_fermi_energy(base_path=base_path) atoms_map = factory.get_atoms_map(base_path=base_path) num_bands = factory.get_number_of_bands(base_path=base_path) band_projection_file = factory.get_band_projection_class( base_path=base_path) band_structure = BandStructure(eigenvalues, fermi_energy, atoms_map, num_bands, band_projection_file) cbm_projection = band_structure.cbm_projection() normalized_df = projection_to_df(cbm_projection) click.echo(normalized_df.to_markdown()) end_message()
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_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