Exemplo n.º 1
0
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()
Exemplo n.º 2
0
def band_gap(software: str, base_path: str) -> None:
    """Uses output files from softwares that perform ab initio calculations to
      provide the locations of VBM, CBM and the Gap value in electronvolts.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)

    gap_report = band_structure.band_gap()
    click.echo(gap_report["vbm"])
    click.echo(gap_report["cbm"])
    click.echo("Gap: {:.3f}eV".format(gap_report["gap"]))
    end_message()
Exemplo n.º 3
0
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])
Exemplo n.º 4
0
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])
Exemplo n.º 5
0
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
Exemplo n.º 6
0
    def _get_result_gap(self) -> float:
        """
        Return the gap after the optimization of all potfiles
        """
        calculation_folder = "calculate_{}_gap".format(self.correction_type)
        if os.path.exists(calculation_folder):
            shutil.rmtree(calculation_folder)
        os.mkdir(calculation_folder)

        for file in self.input_files:
            shutil.copyfile(file, os.path.join(calculation_folder, file))

        potfile_path = os.path.join(calculation_folder,
                                    self.potential_filename)
        potential_file = open(potfile_path, "w")
        try:
            for atom in self.atoms:
                atom_potfilename = "{}.{}".format(
                    self.potential_filename.upper(), atom.lower())
                atom_potpath = os.path.join(self.corrected_potfiles_folder,
                                            atom_potfilename)
                with open(atom_potpath) as file:
                    potential_file.write(file.read())
        finally:
            potential_file.close()
        ## Run ab initio calculations
        self.runner.run(calculation_folder)

        eigenvalues = self.software_factory.get_eigenvalues(
            base_path=calculation_folder)
        fermi_energy = self.software_factory.get_fermi_energy(
            base_path=calculation_folder)
        atoms_map = self.software_factory.get_atoms_map(
            base_path=calculation_folder)
        num_bands = self.software_factory.get_number_of_bands(
            base_path=calculation_folder)
        band_projection_file = self.software_factory.get_band_projection_class(
            base_path=calculation_folder)

        band_structure = BandStructure(eigenvalues, fermi_energy, atoms_map,
                                       num_bands, band_projection_file)

        gap_report = band_structure.band_gap()
        return gap_report["gap"]
Exemplo n.º 7
0
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)
Exemplo n.º 8
0
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)
Exemplo n.º 9
0
def test_create_bandstrutcture_gan_3d(file_path):
    """
    Tests create method for GaN 3d
    """
    software_module = Vasp()

    band_structure = BandStructure.create(software_module,
                                          file_path("/gan-3d/"))

    assert isinstance(band_structure, BandStructure)
    assert band_structure.is_metal() is False
Exemplo n.º 10
0
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"
Exemplo n.º 11
0
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
Exemplo n.º 12
0
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
Exemplo n.º 13
0
def test_create_bandstrutcture_bn_2d(file_path):
    """
    Tests create method for BN 2d
    """
    softare_module = Vasp()
    kpoint_vbm = 24
    band_vbm = 4

    band_structure = BandStructure.create(softare_module, file_path("/bn-2d/"))

    vbm_index = band_structure.vbm_index()
    assert isinstance(band_structure, BandStructure)
    assert vbm_index[0] == kpoint_vbm
    assert vbm_index[1] == band_vbm
Exemplo n.º 14
0
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"
Exemplo n.º 15
0
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
Exemplo n.º 16
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