def test_to_dict_and_from_dict(self):
     file_name = os.path.join(test_dir, 'HEADER')
     header = Header.from_file(file_name)
     d = header.to_dict
     header2 = Header.from_dict(d)
     self.assertEqual(str(header), str(header2),
                      "Header failed to and from dict test")
Example #2
0
 def test_as_dict_and_from_dict(self):
     file_name = os.path.join(test_dir, 'HEADER')
     header = Header.from_file(file_name)
     d = header.as_dict()
     header2 = Header.from_dict(d)
     self.assertEqual(str(header), str(header2),
                      "Header failed to and from dict test")
Example #3
0
    def get_header(self, structure, source):
        """
        Creates header string from structure object

        Args:
            structure:
                pymatgen structure object
            source:
                string identifying source of structure
        Returns:
            HEADER string
        """
        header = Header(structure)
        Header.set_source(header, source)
        return header.get_string()
Example #4
0
 def test_get_string(self):
     cif_file = os.path.join(test_dir, 'CoO19128.cif')
     h = Header.from_cif_file(cif_file)
     head = str(h)
     self.assertEqual(head.splitlines()[3].split()[-1],
                      HeaderTest.header_string.splitlines()[3].split()[-1],
                      "Failed to generate HEADER from structure")
 def test_get_string(self):
     cif_file = os.path.join(test_dir, 'CoO19128.cif')
     h = Header.from_cif_file(cif_file)
     head = str(h)
     self.assertEqual(head.splitlines()[3].split()[-1],
                      HeaderTest.header_string.splitlines()[3].split()[-1],
                      "Failed to generate HEADER from structure")
Example #6
0
 def test_get_string(self):
     header = Header.from_string(HeaderTest.header_string)
     struc = header.struct
     central_atom = 'O'
     a = FeffAtoms(struc, central_atom)
     atoms = a.get_string()
     self.assertEqual(atoms.splitlines()[3].split()[4], central_atom,
                      "failed to create ATOMS string")
 def test_get_string(self):
     header = Header.from_string(HeaderTest.header_string)
     struc = header.struct
     central_atom = 'O'
     a = FeffAtoms(struc, central_atom)
     atoms = a.get_string()
     self.assertEqual(atoms.splitlines()[3].split()[4], central_atom,
                      "failed to create ATOMS string")
Example #8
0
 def test_as_dict_and_from_dict(self):
     file_name = os.path.join(test_dir, 'HEADER')
     header = Header.from_file(file_name)
     struct = header.struct
     atoms = FeffAtoms(struct, 'O')
     d = atoms.as_dict()
     atoms2 = FeffAtoms.from_dict(d)
     self.assertEqual(str(atoms), str(atoms2),
                      "FeffAtoms failed to and from dict test")
Example #9
0
 def test_init(self):
     filepath = os.path.join(test_dir, 'HEADER')
     header = Header.header_string_from_file(filepath)
     h = header.splitlines()
     hs = HeaderTest.header_string.splitlines()
     for i, line in enumerate(h):
         self.assertEqual(line, hs[i])
     self.assertEqual(HeaderTest.header_string.splitlines(),
                      header.splitlines(), "Failed to read HEADER file")
Example #10
0
 def test_as_dict_and_from_dict(self):
     file_name = os.path.join(test_dir, 'HEADER')
     header = Header.from_file(file_name)
     struct = header.struct
     pot = FeffPot(struct, 'O')
     d = pot.as_dict()
     pot2 = FeffPot.from_dict(d)
     self.assertEqual(str(pot), str(pot2),
                      "FeffPot to and from dict does not match")
 def test_to_dict_and_from_dict(self):
     file_name = os.path.join(test_dir, 'HEADER')
     header = Header.from_file(file_name)
     struct = header.struct
     atoms = FeffAtoms(struct, 'O')
     d = atoms.to_dict
     atoms2 = FeffAtoms.from_dict(d)
     self.assertEqual(str(atoms), str(atoms2),
                      "FeffAtoms failed to and from dict test")
 def test_init(self):
     filepath = os.path.join(test_dir, 'HEADER')
     header = Header.header_string_from_file(filepath)
     h = header.splitlines()
     hs = HeaderTest.header_string.splitlines()
     for i, line in enumerate(h):
         self.assertEqual(line, hs[i])
     self.assertEqual(HeaderTest.header_string.splitlines(),
                      header.splitlines(), "Failed to read HEADER file")
 def test_to_dict_and_from_dict(self):
     file_name = os.path.join(test_dir, 'HEADER')
     header = Header.from_file(file_name)
     struct = header.struct
     pot = FeffPot(struct, 'O')
     d=pot.to_dict
     pot2 = FeffPot.from_dict(d)
     self.assertEqual(str(pot), str(pot2),
                      "FeffPot to and from dict does not match")
Example #14
0
    def get_header(self, structure, source='', comment=''):
        """
        Creates header string from structure object

        Args:
            structure: A pymatgen structure object
            source: Source identifier used to create structure, can be defined
                however user wants to organize structures, calculations, etc.
                example would be Materials Project material ID number.
            comment: comment to include in header

        Returns:
            Header object to be used in feff.inp file from a pymatgen structure
        """
        return Header(structure, source, comment)
Example #15
0
 def test_from_string(self):
     header = Header.from_string(HeaderTest.header_string)
     self.assertEqual(header.struct.composition.reduced_formula, "CoO",
                      "Failed to generate structure from HEADER string")
 def test_from_string(self):
     header = Header.from_string(HeaderTest.header_string)
     self.assertEqual(header.struct.composition.reduced_formula, "CoO",
                      "Failed to generate structure from HEADER string")