Exemple #1
0
    def show_cmdline(cls, args):
        if args.lib:
            text = read_json(args.lib)
            cls.show_libinfo(text["src"])

        if args.band:
            text = read_json(args.band)
            filename = text["filename"]
            kptfile = text["kptfile"]
            efermi = text.pop("efermi", 0.0)
            energy_range = text.pop("energy_range", [])
            shift = text.pop("shift", False)
            label = text.pop("label", None)
            color = text.pop("color", None)
            outfile = text.pop("outfile", "band.png")
            cls.show_bandinfo(filename, kptfile, efermi,
                              energy_range, shift, label, color, outfile)

        if args.dos:
            text = read_json(args.dos)
            tdosfile = text.pop("tdosfile", '')
            pdosfile = text.pop("pdosfile", '')
            efermi = text.pop("efermi", 0.0)
            energy_range = text.pop("energy_range", [])
            dos_range = text.pop("dos_range", [])
            shift = text.pop("shift", False)
            species = text.pop("species", [])
            tdosfig = text.pop("tdosfig", "tdos.png")
            pdosfig = text.pop("pdosfig", "pdos.png")
            prec = text.pop("prec", 0.01)
            cls.show_dosinfo(tdosfile, pdosfile, efermi,
                             energy_range, dos_range, shift, species, tdosfig, pdosfig, prec)
Exemple #2
0
 def convert_cmdline(cls, args):
     if args.file:
         text = read_json(args.file)
         srcfile = text["srcfile"]
         convert = text["convert"]
         if convert == "poscar_to_stru":
             pps, orbitals, masses, magmoms, move, abfs = cls._init_for_convert_STRU(
                 text)
             tofile = text.pop("tofile", "STRU")
             Convert().POSCAR_to_STRU(srcfile, tofile, pps, orbitals,
                                      masses, magmoms, move, abfs)
         elif convert == "cif_to_stru":
             pps, orbitals, masses, magmoms, move, abfs = cls._init_for_convert_STRU(
                 text)
             tofile = text.pop("tofile", "STRU")
             Convert().CIF_to_STRU(srcfile, tofile, pps, orbitals, masses,
                                   magmoms, move, abfs)
         elif convert == "stru_to_poscar":
             ntype = text["ntype"]
             tofile = text.pop("tofile", "POSCAR")
             Convert().STRU_to_POSCAR(srcfile, tofile, ntype)
         elif convert == "stru_to_cif":
             ntype = text["ntype"]
             tofile = text.pop("tofile", "STRU.cif")
             Convert().STRU_to_CIF(srcfile, tofile, ntype)
Exemple #3
0
 def set_input(self):
     input_params = {
         "file_list": read_json("folders"),
         "info": {
             "Nt_all": [self.element],
             "Nu": {
                 self.element: self.Nu
             },
             "Nb_true": [self.ref_band] * self.dimer_num,
             "weight": [1] * self.dimer_num,
             "Rcut": {
                 self.element: self.rcut
             },
             "dr": {
                 self.element: self.dr
             },
             "Ecut": {
                 self.element: self.ecutwfc
             },
             "lr": self.lr,
             "cal_T": self.cal_T,
             "cal_smooth": self.cal_smooth
         },
         "C_init_info": {
             "init_from_file": False
         },
         "V_info": {
             "init_from_file": True,
             "same_band": True
         }
     }
     return input_params
Exemple #4
0
    def run_cmdline(cls, args):
        if args.batch and args.local:
            text = read_json(args.batch)
            save_files = text.pop("save_files", True)
            external_command = text.pop("external_command", '')
            cls.batch_run(text["src"], text["dst"],
                          text["version"], external_command, save_files)

        elif args.batch and not args.local:
            cls.batch_with_script(args.batch, args.parallel)

        elif args.single and args.local:
            text = read_json(args.single)
            save_files = text.pop("save_files", True)
            external_command = text.pop("external_command", '')
            cls.single_run(text["src"], text["dst"],
                           text["version"], external_command, save_files)

        elif args.single and not args.local:
            cls.single_with_script(args.single)
Exemple #5
0
    def batch_with_script(cls, filename: str_PathLike, parallel: bool = False):
        """Batch run with script

        :params filename: absolute path of `input.json`
        :params parallel: whether to test in parallel. Default: False
        """

        if parallel:
            text = read_json(filename)
            for subsrc in os.listdir(text["src"]):
                subdst = os.path.join(text["dst"], os.path.basename(subsrc))
                os.makedirs(subdst)
                new_filename = os.path.join(subdst, os.path.basename(filename))
                write_json(filename, new_filename, src=os.path.join(
                    text["src"], os.path.basename(subsrc)), dst=subdst)
                os.chdir(subdst)
                line = f"abacuskit run --single={new_filename} --local True"
                submit_script(new_filename, line)

        else:
            line = f"abacuskit run --batch={filename} --local True"
            submit_script(filename, line)