def test_as_dict_and_from_dict(self): file_name = os.path.join(test_dir, 'PARAMETERS') tags = FeffTags.from_file(file_name) d = tags.as_dict() tags2 = FeffTags.from_dict(d) self.assertEqual(tags, tags2, "Parameters do not match to and from dict")
def test_to_dict_and_from_dict(self): file_name = os.path.join(test_dir, 'PARAMETERS') tags = FeffTags.from_file(file_name) d=tags.to_dict tags2 = FeffTags.from_dict(d) self.assertEqual(tags, tags2, "Parameters do not match to and from dict")
def test_init(self): filepath = os.path.join(test_dir, 'PARAMETERS') parameters = FeffTags.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 test_diff(self): filepath1 = os.path.join(test_dir, 'PARAMETERS') parameters1 = FeffTags.from_file(filepath1) filepath2 = os.path.join(test_dir, 'PARAMETERS.2') parameters2 = FeffTags.from_file(filepath2) self.assertEqual(FeffTags(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]}})
def get_feff_tags(self, calc_type): """ Reads standard parameters for XANES or EXAFS calculation from FeffInputSets.cfg file. Args: calc_type: at this time either 'XANES' or 'EXAFS' string is supported for K shell excitation. In the future this will be expanded to inlude other shells and material class differentiation. Returns: FeffTags object """ if calc_type.upper() == "XANES": fefftags = FeffTags(self.xanes_settings) elif calc_type.upper() == "EXAFS": fefftags = FeffTags(self.exafs_settings) else: raise ValueError("{} is not a valid calculation type" .format(calc_type)) return fefftags