Ejemplo n.º 1
0
def main():
    warnings.filterwarnings("ignore", category=UserWarning,
                            module="pymatgen")
    warnings.filterwarnings("ignore", category=RuntimeWarning,
                            module="amset")
    warnings.filterwarnings("ignore", category=FutureWarning,
                            module="scipy")
    warnings.filterwarnings("ignore", category=DeprecationWarning)

    args = _get_parser().parse_args()
    args_dict = vars(args)

    if args.print_log is not False:
        initialize_amset_logger(log_error_traceback=True)

    settings_override: Dict[str, Dict[str, Any]] = defaultdict(dict)
    for section in amset_defaults:
        for setting in amset_defaults[section]:
            if setting in args_dict and args_dict[setting] is not None:
                settings_override[section][setting] = args_dict[setting]

    runner = AmsetRunner.from_directory(
        directory=args.directory,
        vasprun=args.vasprun,
        settings_file=args.settings,
        settings_override=settings_override)

    runner.run()
Ejemplo n.º 2
0
    def __init__(self,
                 band_structure: BandStructure,
                 num_electrons: int,
                 material_properties: Dict[str, Any],
                 doping: Optional[Union[List, np.ndarray]] = None,
                 temperatures: Optional[Union[List, np.ndarray]] = None,
                 scattering_type: Optional[Union[str, List[str],
                                                 float]] = "auto",
                 num_extra_kpoints: Optional[int] = None,
                 performance_parameters: Optional[Dict[str, float]] = None,
                 output_parameters: Optional[Dict[str, Any]] = None,
                 interpolation_factor: int = 10,
                 scissor: Optional[float] = None,
                 user_bandgap: Optional[float] = None,
                 soc: bool = False):
        self._band_structure = band_structure
        self._num_electrons = num_electrons
        self.scattering_type = scattering_type
        self.interpolation_factor = interpolation_factor
        self.scissor = scissor
        self.user_bandgap = user_bandgap
        self.soc = soc
        self.doping = doping
        self.temperatures = temperatures
        self.num_extra_kpoints = num_extra_kpoints

        if self.doping is None:
            self.doping = np.concatenate(
                [np.logspace(16, 21, 6), -np.logspace(16, 21, 6)])

        if self.temperatures is None:
            self.temperatures = np.array([300])

        # set materials and performance parameters
        # if the user doesn't specify a value then use the default
        params = copy.deepcopy(amset_defaults)
        self.performance_parameters = params["performance"]
        self.material_properties = params["material"]
        self.output_parameters = params["output"]
        self.performance_parameters.update(performance_parameters)
        self.material_properties.update(material_properties)
        self.output_parameters.update(output_parameters)

        if (self.output_parameters["print_log"]
                or self.output_parameters["log_error_traceback"]):
            initialize_amset_logger(
                log_traceback=output_parameters["log_error_traceback"])
Ejemplo n.º 3
0
    def test_densify(self):
        # mesh = np.array([100, 100, 100])
        # kpts = get_dense_kpoint_mesh_spglib(mesh, spg_order=True, shift=0.)
        # extra_points = np.array([[0.001, 0, 0], [0.002, 0, 0], [0.003, 0, 0]])
        # pv = PeriodicVoronoi(Lattice([3, 0, 0, 0, 3, 0, 0, 0, 3]),
        #                      kpts, mesh, extra_points)
        # vols = pv.compute_volumes()
        # idx = np.argsort(vols)
        # all_k = np.concatenate([kpts, extra_points])
        # print(all_k[idx][:12])
        # print(vols[idx][:12])

        initialize_amset_logger(log_error_traceback=True)

        vr = Vasprun(os.path.join(amset_files, "vasprun.xml.gz"),
                     parse_projected_eigen=True)
        bs = vr.get_band_structure()
        inter = Interpolater(bs,
                             vr.parameters["NELECT"],
                             interpolate_projections=True,
                             interpolation_factor=5)
        amset_data = inter.get_amset_data(energy_cutoff=2, bandgap=1.33)
        amset_data.calculate_dos()
        amset_data.set_doping_and_temperatures(doping=np.array([1e13]),
                                               temperatures=np.array([300]))
        amset_data.calculate_fd_cutoffs(fd_tolerance=0.000001)

        densifier = BandDensifier(inter,
                                  amset_data,
                                  energy_cutoff=2,
                                  bandgap=1.33)
        # print(amset_data.ir_to_full_kpoint_mapping[:200])
        # print(max(amset_data.ir_to_full_kpoint_mapping))
        # print(len(amset_data.ir_to_full_kpoint_mapping))
        print("IR Kpoints idx max", max(amset_data.ir_kpoints_idx))
        amset_data.set_extra_kpoints(*densifier.densify(0.008))
        print(amset_data.ir_to_full_kpoint_mapping.max())
        print(len(amset_data.ir_kpoints))
        print(len(amset_data.ir_kpoints_idx))
        print(max(amset_data.ir_kpoints_idx))
        # print(max(amset_data.ir_to_full_kpoint_mapping))
        # print(len(amset_data.ir_to_full_kpoint_mapping))

        # x = extra_kpts[0][2]
        all_kpoints = amset_data.full_kpoints
        weights = amset_data.kpoint_weights
        mask = (all_kpoints[:, 2] == 0.)

        center_points = all_kpoints[mask][:, :2]
        center_labels = map("{:.3g}".format, weights[mask])

        from scipy.spatial import Voronoi, voronoi_plot_2d
        vor = Voronoi(center_points)
        import matplotlib
        matplotlib.use("TkAgg")
        import matplotlib.pyplot as plt
        voronoi_plot_2d(vor)

        # plt.xlim((-0.48, -0.38))
        # plt.ylim((-0.48, -0.38))
        ax = plt.gca()

        for i, txt in enumerate(center_labels):
            kx = center_points[i][0]
            ky = center_points[i][1]
            if -0.38 > kx > -0.48 and -0.38 > ky > -0.48:
                ax.annotate(str(txt), (kx, ky))

        plt.show()