Exemple #1
0
 def test_as_dict_and_from_dict(self):
     file_name = os.path.join(test_dir, 'PARAMETERS')
     tags = Tags.from_file(file_name)
     d=tags.as_dict()
     tags2 = Tags.from_dict(d)
     self.assertEqual(tags, tags2,
                      "Parameters do not match to and from dict")
Exemple #2
0
 def test_as_dict_and_from_dict(self):
     file_name = os.path.join(test_dir, 'PARAMETERS')
     tags = Tags.from_file(file_name)
     d=tags.as_dict()
     tags2 = Tags.from_dict(d)
     self.assertEqual(tags, tags2,
                      "Parameters do not match to and from dict")
Exemple #3
0
 def test_eels_tags(self):
     ans_1 = {
         "CONTROL": [1, 1, 1, 1, 1, 1],
         "COREHOLE": "Fsr",
         "EDGE": "K",
         "ELNES": {
             "ANGLES": "7.6 6.4",
             "BEAM_ENERGY": "200 1 0 1",
             "ENERGY": "4.0 .04 0.1",
             "MESH": "50 1",
             "POSITION": "0 0",
         },
         "EXCHANGE": [0, 0.0, 0.0, 2],
         "FMS": [7.5],
         "PRINT": [1, 0, 0, 0, 0, 0],
         "RPATH": [-1],
         "S02": [0.0],
         "SCF": [6, 0, 30, 0.2, 5],
     }
     tags_1 = Tags.from_file(
         os.path.join(PymatgenTest.TEST_FILES_DIR, "feff_eels_powder.inp"))
     self.assertEqual(dict(tags_1), ans_1)
     ans_1["ELNES"]["BEAM_ENERGY"] = "200 0 1 1"
     ans_1["ELNES"]["BEAM_DIRECTION"] = "1 0 0"
     tags_2 = Tags.from_file(
         os.path.join(PymatgenTest.TEST_FILES_DIR, "feff_eels_x.inp"))
     self.assertEqual(dict(tags_2), ans_1)
Exemple #4
0
    def test_post_distdiff(self):
        feff_dict_input = FEFFDictSet.from_directory(
            os.path.join(PymatgenTest.TEST_FILES_DIR, "feff_dist_test"))
        self.assertTrue(feff_dict_input.tags == Tags.from_file(
            os.path.join(PymatgenTest.TEST_FILES_DIR,
                         "feff_dist_test/feff.inp")))
        self.assertTrue(
            str(feff_dict_input.header()) == str(
                Header.from_file(
                    os.path.join(PymatgenTest.TEST_FILES_DIR,
                                 "feff_dist_test/HEADER"))))
        feff_dict_input.write_input("feff_dist_regen")
        origin_tags = Tags.from_file(
            os.path.join(PymatgenTest.TEST_FILES_DIR,
                         "feff_dist_test/PARAMETERS"))
        output_tags = Tags.from_file(
            os.path.join(".", "feff_dist_regen/PARAMETERS"))
        origin_mole = Atoms.cluster_from_file(
            os.path.join(PymatgenTest.TEST_FILES_DIR,
                         "feff_dist_test/feff.inp"))
        output_mole = Atoms.cluster_from_file(
            os.path.join(".", "feff_dist_regen/feff.inp"))
        original_mole_dist = np.array(
            origin_mole.distance_matrix[0, :]).astype(np.float64)
        output_mole_dist = np.array(output_mole.distance_matrix[0, :]).astype(
            np.float64)
        original_mole_shell = [x.species_string for x in origin_mole]
        output_mole_shell = [x.species_string for x in output_mole]

        self.assertTrue(np.allclose(original_mole_dist, output_mole_dist))
        self.assertTrue(origin_tags == output_tags)
        self.assertTrue(original_mole_shell == output_mole_shell)

        shutil.rmtree(os.path.join(".", "feff_dist_regen"))
Exemple #5
0
 def test_diff(self):
     filepath1 = os.path.join(PymatgenTest.TEST_FILES_DIR, "PARAMETERS")
     parameters1 = Tags.from_file(filepath1)
     filepath2 = os.path.join(PymatgenTest.TEST_FILES_DIR, "PARAMETERS.2")
     parameters2 = Tags.from_file(filepath2)
     self.assertEqual(
         Tags(parameters1).diff(parameters2),
         {
             "Different": {},
             "Same": {
                 "CONTROL": [1, 1, 1, 1, 1, 1],
                 "MPSE": [2],
                 "OPCONS": "",
                 "SCF": [6.0, 0, 30, 0.2, 1],
                 "EXCHANGE": [0, 0.0, 0.0, 2],
                 "S02": [0.0],
                 "COREHOLE": "Fsr",
                 "FMS": [8.5, 0],
                 "XANES": [3.7, 0.04, 0.1],
                 "EDGE": "K",
                 "PRINT": [1, 0, 0, 0, 0, 0],
                 "LDOS": [-30.0, 15.0, 0.1],
             },
         },
     )
Exemple #6
0
 def test_as_dict_and_from_dict(self):
     file_name = os.path.join(PymatgenTest.TEST_FILES_DIR, "PARAMETERS")
     tags = Tags.from_file(file_name)
     d = tags.as_dict()
     tags2 = Tags.from_dict(d)
     self.assertEqual(tags, tags2,
                      "Parameters do not match to and from dict")
Exemple #7
0
 def test_eels_tags(self):
     ans_1 = {
         'CONTROL': [1, 1, 1, 1, 1, 1],
         'COREHOLE': 'Fsr',
         'EDGE': 'K',
         'ELNES': {
             'ANGLES': '7.6 6.4',
             'BEAM_ENERGY': '200 1 0 1',
             'ENERGY': '4.0 .04 0.1',
             'MESH': '50 1',
             'POSITION': '0 0'
         },
         'EXCHANGE': [0, 0.0, 0.0, 2],
         'FMS': [7.5],
         'PRINT': [1, 0, 0, 0, 0, 0],
         'RPATH': [-1],
         'S02': [0.0],
         'SCF': [6, 0, 30, 0.2, 5]
     }
     tags_1 = Tags.from_file(os.path.join(test_dir, 'feff_eels_powder.inp'))
     self.assertEqual(dict(tags_1), ans_1)
     ans_1["ELNES"]["BEAM_ENERGY"] = '200 0 1 1'
     ans_1["ELNES"]["BEAM_DIRECTION"] = '1 0 0'
     tags_2 = Tags.from_file(os.path.join(test_dir, 'feff_eels_x.inp'))
     self.assertEqual(dict(tags_2), ans_1)
Exemple #8
0
    def test_postfeffset(self):
        self.mp_xanes.write_input(os.path.join(".", "xanes_3"))
        feff_dict_input = FEFFDictSet.from_directory(os.path.join(".", "xanes_3"))
        self.assertTrue(
            feff_dict_input.tags
            == Tags.from_file(os.path.join(".", "xanes_3/feff.inp"))
        )
        self.assertTrue(
            str(feff_dict_input.header())
            == str(Header.from_file(os.path.join(".", "xanes_3/HEADER")))
        )
        feff_dict_input.write_input("xanes_3_regen")
        origin_tags = Tags.from_file(os.path.join(".", "xanes_3/PARAMETERS"))
        output_tags = Tags.from_file(os.path.join(".", "xanes_3_regen/PARAMETERS"))
        origin_mole = Atoms.cluster_from_file(os.path.join(".", "xanes_3/feff.inp"))
        output_mole = Atoms.cluster_from_file(
            os.path.join(".", "xanes_3_regen/feff.inp")
        )
        original_mole_dist = np.array(origin_mole.distance_matrix[0, :]).astype(
            np.float64
        )
        output_mole_dist = np.array(output_mole.distance_matrix[0, :]).astype(
            np.float64
        )
        original_mole_shell = [x.species_string for x in origin_mole]
        output_mole_shell = [x.species_string for x in output_mole]

        self.assertTrue(np.allclose(original_mole_dist, output_mole_dist))
        self.assertTrue(origin_tags == output_tags)
        self.assertTrue(original_mole_shell == output_mole_shell)

        shutil.rmtree(os.path.join(".", "xanes_3"))
        shutil.rmtree(os.path.join(".", "xanes_3_regen"))

        reci_mp_xanes = MPXANESSet(
            self.absorbing_atom, self.structure, user_tag_settings={"RECIPROCAL": ""}
        )
        reci_mp_xanes.write_input("xanes_reci")
        feff_reci_input = FEFFDictSet.from_directory(os.path.join(".", "xanes_reci"))
        self.assertTrue("RECIPROCAL" in feff_reci_input.tags)

        feff_reci_input.write_input("Dup_reci")
        self.assertTrue(os.path.exists(os.path.join(".", "Dup_reci", "HEADER")))
        self.assertTrue(os.path.exists(os.path.join(".", "Dup_reci", "feff.inp")))
        self.assertTrue(os.path.exists(os.path.join(".", "Dup_reci", "PARAMETERS")))
        self.assertFalse(os.path.exists(os.path.join(".", "Dup_reci", "ATOMS")))
        self.assertFalse(os.path.exists(os.path.join(".", "Dup_reci", "POTENTIALS")))

        tags_original = Tags.from_file(os.path.join(".", "xanes_reci/feff.inp"))
        tags_output = Tags.from_file(os.path.join(".", "Dup_reci/feff.inp"))
        self.assertTrue(tags_original == tags_output)

        stru_orig = Structure.from_file(os.path.join(".", "xanes_reci/Co2O2.cif"))
        stru_reci = Structure.from_file(os.path.join(".", "Dup_reci/Co2O2.cif"))
        self.assertTrue(stru_orig.__eq__(stru_reci))

        shutil.rmtree(os.path.join(".", "Dup_reci"))
        shutil.rmtree(os.path.join(".", "xanes_reci"))
    def test_setup(self):
        with cd(test_dir):
            with ScratchDir('.', copy_from_current_on_enter=True):
                f = FeffJob("hello", backup=True)
                f.setup()

                parameter = Tags.from_file('feff.inp')
                parameter_orig = Tags.from_file('feff.inp.orig')
                self.assertEqual(parameter, parameter_orig)

                atom = Atoms.cluster_from_file('feff.inp')
                atom_origin = Atoms.cluster_from_file('feff.inp.orig')
                self.assertEqual(atom, atom_origin)
Exemple #10
0
    def test_setup(self):
        with cd(test_dir):
            with ScratchDir('.', copy_from_current_on_enter=True):
                f = FeffJob("hello", backup=True)
                f.setup()

                parameter = Tags.from_file('feff.inp')
                parameter_orig = Tags.from_file('feff.inp.orig')
                self.assertEqual(parameter, parameter_orig)

                atom = Atoms.cluster_from_file('feff.inp')
                atom_origin = Atoms.cluster_from_file('feff.inp.orig')
                self.assertEqual(atom, atom_origin)
 def _check_run(self, d):
     run_dir = d["dir_name"]
     #ref_feff_inp = os.path.join(module_dir, "reference_files", "feff_eels.inp")
     self.assertEqual(d["edge"], self.edge)
     self.assertEqual(d["absorbing_atom"], self.absorbing_atom)
     tags = Tags.from_file(os.path.join(run_dir, "feff.inp"))
     self.assertEqual(d["input_parameters"], tags.as_dict())
Exemple #12
0
    def tags(self):
        """
        FEFF job parameters.

        Returns:
            Tags
        """
        if "RECIPROCAL" in self.config_dict:
            if self.small_system:
                self.config_dict["CIF"] = "{}.cif".format(
                    self.structure.formula.replace(" ", ""))
                self.config_dict["TARGET"] = self.atoms.center_index + 1
                self.config_dict["COREHOLE"] = "RPA"
                logger.warning("Setting COREHOLE = RPA for K-space calculation")
                if not self.config_dict.get("KMESH", None):
                    abc = self.structure.lattice.abc
                    mult = (self.nkpts * abc[0] * abc[1] * abc[2]) ** (1 / 3)
                    self.config_dict["KMESH"] = [int(round(mult / l)) for l in abc]
            else:
                logger.warning("Large system(>=14 atoms), removing K-space settings")
                del self.config_dict["RECIPROCAL"]
                self.config_dict.pop("CIF", None)
                self.config_dict.pop("TARGET", None)
                self.config_dict.pop("KMESH", None)
                self.config_dict.pop("STRFAC", None)

        return Tags(self.config_dict)
 def _check_run(self, d):
     run_dir = d["dir_name"]
     self.assertEqual(d["edge"], self.edge)
     self.assertEqual(d["absorbing_atom"], self.absorbing_atom)
     tags = Tags.from_file(os.path.join(run_dir, "feff.inp"))
     self.assertEqual(d["input_parameters"], tags.as_dict())
     xmu = np.loadtxt((os.path.join(run_dir, "xmu.dat")))
     self.assertEqual(d["spectrum"], xmu.tolist())
Exemple #14
0
 def test_init(self):
     filepath = os.path.join(PymatgenTest.TEST_FILES_DIR, "PARAMETERS")
     parameters = Tags.from_file(filepath)
     parameters["RPATH"] = 10
     self.assertEqual(parameters["COREHOLE"], "Fsr",
                      "Failed to read PARAMETERS file")
     self.assertEqual(parameters["LDOS"], [-30.0, 15.0, 0.1],
                      "Failed to read PARAMETERS file")
Exemple #15
0
 def test_init(self):
     filepath = os.path.join(test_dir, 'PARAMETERS')
     parameters = Tags.from_file(filepath)
     parameters["RPATH"] = 10
     self.assertEqual(parameters["COREHOLE"], "Fsr",
                      "Failed to read PARAMETERS file")
     self.assertEqual(parameters["LDOS"], [-30., 15., .1],
                      "Failed to read PARAMETERS file")
Exemple #16
0
 def test_init(self):
     filepath = os.path.join(test_dir, 'PARAMETERS')
     parameters = Tags.from_file(filepath)
     parameters["RPATH"] = 10
     self.assertEqual(parameters["COREHOLE"], "Fsr",
                      "Failed to read PARAMETERS file")
     self.assertEqual(parameters["LDOS"], [-30., 15., .1],
                      "Failed to read PARAMETERS file")
 def _check_run(self, d):
     run_dir = d["dir_name"]
     self.assertEqual(d["edge"], self.edge)
     self.assertEqual(d["absorbing_atom"], self.absorbing_atom)
     tags = Tags.from_file(os.path.join(run_dir, "feff.inp"))
     self.assertEqual(d["input_parameters"], tags.as_dict())
     xmu = np.loadtxt((os.path.join(run_dir, "xmu.dat")))
     self.assertEqual(d["spectrum"], xmu.tolist())
Exemple #18
0
    def tags(self):
        """
        FEFF job parameters.

        Returns:
            Tags
        """
        return Tags(self.config_dict)
Exemple #19
0
    def test_postfeffset(self):
        self.mp_xanes.write_input(os.path.join('.', 'xanes_3'))
        feff_dict_input = FEFFDictSet.from_directory(os.path.join('.', 'xanes_3'))
        self.assertTrue(feff_dict_input.tags == Tags.from_file(os.path.join('.', 'xanes_3/feff.inp')))
        self.assertTrue(str(feff_dict_input.header()) == str(Header.from_file(os.path.join('.', 'xanes_3/HEADER'))))
        feff_dict_input.write_input('xanes_3_regen')
        origin_tags = Tags.from_file(os.path.join('.', 'xanes_3/PARAMETERS'))
        output_tags = Tags.from_file(os.path.join('.', 'xanes_3_regen/PARAMETERS'))
        origin_mole = Atoms.cluster_from_file(os.path.join('.', 'xanes_3/feff.inp'))
        output_mole = Atoms.cluster_from_file(os.path.join('.', 'xanes_3_regen/feff.inp'))
        original_mole_dist = np.array(origin_mole.distance_matrix[0, :]).astype(np.float64)
        output_mole_dist = np.array(output_mole.distance_matrix[0, :]).astype(np.float64)
        original_mole_shell = [x.species_string for x in origin_mole]
        output_mole_shell = [x.species_string for x in output_mole]

        self.assertTrue(np.allclose(original_mole_dist, output_mole_dist))
        self.assertTrue(origin_tags == output_tags)
        self.assertTrue(original_mole_shell == output_mole_shell)

        shutil.rmtree(os.path.join('.', 'xanes_3'))
        shutil.rmtree(os.path.join('.', 'xanes_3_regen'))

        reci_mp_xanes = MPXANESSet(self.absorbing_atom, self.structure,
                                   user_tag_settings={"RECIPROCAL": ""})
        reci_mp_xanes.write_input('xanes_reci')
        feff_reci_input = FEFFDictSet.from_directory(os.path.join('.', 'xanes_reci'))
        self.assertTrue("RECIPROCAL" in feff_reci_input.tags)

        feff_reci_input.write_input('Dup_reci')
        self.assertTrue(os.path.exists(os.path.join('.', 'Dup_reci', 'HEADER')))
        self.assertTrue(os.path.exists(os.path.join('.', 'Dup_reci', 'feff.inp')))
        self.assertTrue(os.path.exists(os.path.join('.', 'Dup_reci', 'PARAMETERS')))
        self.assertFalse(os.path.exists(os.path.join('.', 'Dup_reci', 'ATOMS')))
        self.assertFalse(os.path.exists(os.path.join('.', 'Dup_reci', 'POTENTIALS')))

        tags_original = Tags.from_file(os.path.join('.', 'xanes_reci/feff.inp'))
        tags_output = Tags.from_file(os.path.join('.', 'Dup_reci/feff.inp'))
        self.assertTrue(tags_original == tags_output)

        stru_orig = Structure.from_file(os.path.join('.', 'xanes_reci/Co2O2.cif'))
        stru_reci = Structure.from_file(os.path.join('.', 'Dup_reci/Co2O2.cif'))
        self.assertTrue(stru_orig.__eq__(stru_reci))

        shutil.rmtree(os.path.join('.', 'Dup_reci'))
        shutil.rmtree(os.path.join('.', 'xanes_reci'))
Exemple #20
0
 def test_diff(self):
     filepath1 = os.path.join(test_dir, 'PARAMETERS')
     parameters1 = Tags.from_file(filepath1)
     filepath2 = os.path.join(test_dir, 'PARAMETERS.2')
     parameters2 = Tags.from_file(filepath2)
     self.assertEqual(Tags(parameters1).diff(parameters2),
                      {'Different': {},
                       'Same': {'CONTROL': [1, 1, 1, 1, 1, 1],
                                'MPSE': [2],
                                'OPCONS': '',
                                'SCF': [6.0, 0, 30, .2, 1],
                                'EXCHANGE': [0, 0.0, 0.0, 2],
                                'S02': [0.0],
                                'COREHOLE': 'Fsr',
                                'FMS': [8.5, 0],
                                'XANES': [3.7, 0.04, 0.1],
                                'EDGE': 'K',
                                'PRINT': [1, 0, 0, 0, 0, 0],
                                'LDOS': [-30., 15., .1]}})
Exemple #21
0
 def test_diff(self):
     filepath1 = os.path.join(test_dir, 'PARAMETERS')
     parameters1 = Tags.from_file(filepath1)
     filepath2 = os.path.join(test_dir, 'PARAMETERS.2')
     parameters2 = Tags.from_file(filepath2)
     self.assertEqual(Tags(parameters1).diff(parameters2),
                      {'Different': {},
                       'Same': {'CONTROL': [1, 1, 1, 1, 1, 1],
                                'MPSE': [2],
                                'OPCONS': '',
                                'SCF': [6.0, 0, 30, .2, 1],
                                'EXCHANGE': [0, 0.0, 0.0, 2],
                                'S02': [0.0],
                                'COREHOLE': 'Fsr',
                                'FMS': [8.5, 0],
                                'XANES': [3.7, 0.04, 0.1],
                                'EDGE': 'K',
                                'PRINT': [1, 0, 0, 0, 0, 0],
                                'LDOS': [-30., 15., .1]}})
Exemple #22
0
    def test_post_distdiff(self):
        feff_dict_input = FEFFDictSet.from_directory(os.path.join(test_dir, 'feff_dist_test'))
        self.assertTrue(feff_dict_input.tags == Tags.from_file(os.path.join(test_dir, 'feff_dist_test/feff.inp')))
        self.assertTrue(
            str(feff_dict_input.header()) == str(Header.from_file(os.path.join(test_dir, 'feff_dist_test/HEADER'))))
        feff_dict_input.write_input('feff_dist_regen')
        origin_tags = Tags.from_file(os.path.join(test_dir, 'feff_dist_test/PARAMETERS'))
        output_tags = Tags.from_file(os.path.join('.', 'feff_dist_regen/PARAMETERS'))
        origin_mole = Atoms.cluster_from_file(os.path.join(test_dir, 'feff_dist_test/feff.inp'))
        output_mole = Atoms.cluster_from_file(os.path.join('.', 'feff_dist_regen/feff.inp'))
        original_mole_dist = np.array(origin_mole.distance_matrix[0, :]).astype(np.float64)
        output_mole_dist = np.array(output_mole.distance_matrix[0, :]).astype(np.float64)
        original_mole_shell = [x.species_string for x in origin_mole]
        output_mole_shell = [x.species_string for x in output_mole]

        self.assertTrue(np.allclose(original_mole_dist, output_mole_dist))
        self.assertTrue(origin_tags == output_tags)
        self.assertTrue(original_mole_shell == output_mole_shell)

        shutil.rmtree(os.path.join('.', 'feff_dist_regen'))
Exemple #23
0
 def test_eels_tags(self):
     ans_1 = {'CONTROL': [1, 1, 1, 1, 1, 1],
              'COREHOLE': 'Fsr',
              'EDGE': 'K',
              'ELNES': {'ANGLES': '7.6 6.4',
                        'BEAM_ENERGY': '200 1 0 1',
                        'ENERGY': '4.0 .04 0.1',
                        'MESH': '50 1',
                        'POSITION': '0 0'},
              'EXCHANGE': [0, 0.0, 0.0, 2],
              'FMS': [7.5],
              'PRINT': [1, 0, 0, 0, 0, 0],
              'RPATH': [-1],
              'S02': [0.0],
              'SCF': [6, 0, 30, 0.2, 5]}
     tags_1 = Tags.from_file(os.path.join(test_dir, 'feff_eels_powder.inp'))
     self.assertEqual(dict(tags_1), ans_1)
     ans_1["ELNES"]["BEAM_ENERGY"] = '200 0 1 1'
     ans_1["ELNES"]["BEAM_DIRECTION"] = '1 0 0'
     tags_2 = Tags.from_file(os.path.join(test_dir, 'feff_eels_x.inp'))
     self.assertEqual(dict(tags_2), ans_1)
Exemple #24
0
    def run_task(self, fw_spec):
        calc_dir = os.getcwd()
        if "calc_dir" in self:
            calc_dir = self["calc_dir"]
        elif self.get("calc_loc"):
            calc_dir = get_calc_loc(self["calc_loc"],
                                    fw_spec["calc_locs"])["path"]

        logger.info("PARSING DIRECTORY: {}".format(calc_dir))

        db_file = env_chk(self.get('db_file'), fw_spec)

        cluster_dict = None
        tags = Tags.from_file(filename="feff.inp")
        if "RECIPROCAL" not in tags:
            cluster_dict = Atoms.cluster_from_file("feff.inp").as_dict()
        doc = {
            "input_parameters":
            tags.as_dict(),
            "cluster":
            cluster_dict,
            "structure":
            self["structure"].as_dict(),
            "absorbing_atom":
            self["absorbing_atom"],
            "spectrum_type":
            self["spectrum_type"],
            "spectrum":
            np.loadtxt(os.path.join(calc_dir, self["output_file"])).tolist(),
            "edge":
            self.get("edge", None),
            "metadata":
            self.get("metadata", None),
            "dir_name":
            os.path.abspath(os.getcwd()),
            "last_updated":
            datetime.utcnow()
        }

        if not db_file:
            with open("feff_task.json", "w") as f:
                f.write(json.dumps(doc, default=DATETIME_HANDLER))

        else:
            db = FeffCalcDb.from_db_file(db_file, admin=True)
            db.insert(doc)

        logger.info("Finished parsing the spectrum")

        return FWAction(stored_data={"task_id": doc.get("task_id", None)})
    def run_task(self, fw_spec):
        calc_dir = os.getcwd()
        if "calc_dir" in self:
            calc_dir = self["calc_dir"]
        elif self.get("calc_loc"):
            calc_dir = get_calc_loc(self["calc_loc"], fw_spec["calc_locs"])["path"]

        logger.info("PARSING DIRECTORY: {}".format(calc_dir))

        db_file = env_chk(self.get('db_file'), fw_spec)

        cluster_dict = None
        tags = Tags.from_file(filename="feff.inp")
        if "RECIPROCAL" not in tags:
            cluster_dict = Atoms.cluster_from_file("feff.inp").as_dict()
        doc = {"input_parameters": tags.as_dict(),
               "cluster": cluster_dict,
               "structure": self["structure"].as_dict(),
               "absorbing_atom": self["absorbing_atom"],
               "spectrum_type": self["spectrum_type"],
               "spectrum": np.loadtxt(os.path.join(calc_dir, self["output_file"])).tolist(),
               "edge": self.get("edge", None),
               "metadata": self.get("metadata", None),
               "dir_name": os.path.abspath(os.getcwd()),
               "last_updated": datetime.today()}

        if not db_file:
            with open("feff_task.json", "w") as f:
                f.write(json.dumps(doc, default=DATETIME_HANDLER))
        # db insertion
        else:
            db = MMFeffDb.from_db_file(db_file, admin=True)
            db.insert(doc)

        logger.info("Finished parsing the spectrum")

        return FWAction(stored_data={"task_id": doc.get("task_id", None)})
Exemple #26
0
        ],
        coords_are_cartesian=False,
        tol=1e-9,
    )
    print(zno_structure)
    print(zno_structure.get_space_group_info())
    out_file_name = '/home/yugin/PycharmProjects/neurons/data/src/feff.inp.new2'
    file_name = '/home/yugin/PycharmProjects/neurons/data/src/feff.inp.old'
    atoms_obj = Atoms(zno_structure, 'O', 12)
    pprint(atoms_obj.struct.cart_coords)
    pprint(atoms_obj.get_lines())

    header_obj = Header(struct=zno_structure)
    pot_obj = Potential(zno_structure, 'O')


    tags_obj = Tags().from_file(filename=file_name)
    pprint(tags_obj.as_dict())

    pot_obj.pot_string_from_file(filename=file_name)
    pprint(pot_obj)
    atoms_obj.atoms_string_from_file(filename=file_name)
    pprint(atoms_obj.as_dict())

    header_obj.write_file(out_file_name)
    tags_obj.write_file(out_file_name)
    pot_obj.write_file(out_file_name)
    atoms_obj.write_file(out_file_name)
    # paths_obj = Paths()
    # header_obj.from_file(file_name)
    print()
 def _check_run(self, d):
     run_dir = d["dir_name"]
     self.assertEqual(d["edge"], self.edge)
     self.assertEqual(d["absorbing_atom"], self.absorbing_atom)
     tags = Tags.from_file(os.path.join(run_dir, "feff.inp"))
     self.assertEqual(d["input_parameters"], tags.as_dict())
 def _check_run(self, d):
     run_dir = d["dir_name"]
     self.assertEqual(d["edge"], self.edge)
     self.assertEqual(d["absorbing_atom"], self.absorbing_atom)
     tags = Tags.from_file(os.path.join(run_dir, "feff.inp"))
     self.assertEqual(d["input_parameters"], tags.as_dict())
Exemple #29
0
 def init_tags(self):
     self._tags = Tags().from_file(filename=self.path_to_src_feff_input)