Пример #1
0
    def run_task(self, fw_spec):
        lobster_cmd = env_chk(self.get("lobster_cmd"), fw_spec)
        gzip_output = self.get("gzip_output", True)
        gzip_WAVECAR = self.get("gzip_WAVECAR", False)
        if gzip_WAVECAR:
            add_files_to_gzip = VASP_OUTPUT_FILES
        else:
            add_files_to_gzip = [f for f in VASP_OUTPUT_FILES if f not in ["WAVECAR"]]

        handler_groups = {"default": [], "no_handler": []}
        validator_groups = {
            "default": [
                LobsterFilesValidator(),
                EnoughBandsValidator(output_filename="lobsterout"),
            ],
            "strict": [
                ChargeSpillingValidator(output_filename="lobsterout"),
                LobsterFilesValidator(),
                EnoughBandsValidator(output_filename="lobsterout"),
            ],
            "no_validator": [],
        }

        handler_group = self.get("handler_group", "default")
        if isinstance(handler_group, str):
            handlers = handler_groups[handler_group]
        else:
            handlers = handler_group

        validator_group = self.get("validator_group", "default")
        if isinstance(validator_group, str):
            validators = validator_groups[validator_group]
        else:
            validators = handler_group

        # LobsterJob gzips output files, Custodian would gzip all output files (even slurm)
        jobs = [
            LobsterJob(
                lobster_cmd=lobster_cmd,
                output_file="lobster.out",
                stderr_file="std_err_lobster.txt",
                gzipped=gzip_output,
                add_files_to_gzip=add_files_to_gzip,
            )
        ]
        c = Custodian(
            handlers=handlers,
            jobs=jobs,
            validators=validators,
            gzipped_output=False,
            max_errors=5,
        )
        c.run()

        if os.path.exists(zpath("custodian.json")):
            stored_custodian_data = {"custodian": loadfn(zpath("custodian.json"))}
            return FWAction(stored_data=stored_custodian_data)
Пример #2
0
 def test_as_dict(self):
     v = ChargeSpillingValidator(output_filename=os.path.join(
         test_files_lobster, "lobsterout.normal"))
     d = v.as_dict()
     v2 = ChargeSpillingValidator.from_dict(d)
     self.assertIsInstance(v2, ChargeSpillingValidator)
Пример #3
0
    def test_check_and_correct(self):
        v = ChargeSpillingValidator(output_filename=os.path.join(
            test_files_lobster, "lobsterout.normal"))
        self.assertFalse(v.check())

        v2 = ChargeSpillingValidator(output_filename=os.path.join(
            test_files_lobster, "lobsterout.largespilling"))
        self.assertTrue(v2.check())

        v2b = ChargeSpillingValidator(output_filename=os.path.join(
            test_files_lobster, "lobsterout.largespilling_2"))
        self.assertTrue(v2b.check())

        v3 = ChargeSpillingValidator(output_filename=os.path.join(
            test_files_lobster, "nolobsterout", "lobsterout"))
        self.assertFalse(v3.check())

        v4 = ChargeSpillingValidator(output_filename=os.path.join(
            test_files_lobster, "no_spin", "lobsterout"))
        self.assertFalse(v4.check())