예제 #1
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()
예제 #2
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"]
예제 #3
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)
예제 #4
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)