示例#1
0
def test_parse_poscar_silly_write(fresh_aiida_env, vasp_structure, tmpdir):
    """
    Parse (read, write) a reference POSCAR with silly elemental names.

    Using the PoscarParser and compare the result to a reference structure.

    """

    parser = PoscarParser(data=vasp_structure)
    result = parser.get_quantity('poscar-structure', {})
    names = result['poscar-structure'].get_site_kindnames()
    assert names == ['Hamburger', 'Pizza']
    symbols = result['poscar-structure'].get_symbols_set()
    assert symbols == set(['As', 'In'])

    temp_file = str(tmpdir.join('POSCAR'))
    parser.write(temp_file)

    parser = PoscarParser(file_path=temp_file)
    result_reparse = parser.structure

    names = result_reparse.get_site_kindnames()
    assert names == ['Hamburger', 'Pizza']
    symbols = result_reparse.get_symbols_set()
    assert symbols == set(['X', 'X'])
示例#2
0
    def write_poscar(self, dst):  # pylint: disable=unused-argument
        """
        Write the POSCAR.

        Passes the structures node (StructureData) to the POSCAR parser for
        preparation and writes to dst.

        :param dst: absolute path of the file to write to
        """
        settings = self.inputs.get('settings')
        settings = settings.get_dict() if settings else {}
        poscar_precision = settings.get('poscar_precision', 10)
        poscar_parser = PoscarParser(data=self._structure(),
                                     precision=poscar_precision)
        poscar_parser.write(dst)
示例#3
0
def test_parse_poscar_reparse(fresh_aiida_env, vasp_structure, tmpdir):
    """
    Parse (read) a reference POSCAR file.

    Using the PoscarParser, parse(write), parse (read), and compare
    to reference structure.

    """

    path = data_path('poscar', 'POSCAR')
    parser = PoscarParser(file_path=path)

    temp_file = str(tmpdir.join('POSCAR'))
    parser.write(temp_file)

    parser = PoscarParser(file_path=temp_file)
    result = parser.structure

    structure = vasp_structure
    assert result.cell == structure.cell
    assert result.get_site_kindnames() == structure.get_site_kindnames()
    assert result.sites[2].position == structure.sites[2].position
示例#4
0
def test_parse_poscar_undercase(fresh_aiida_env, vasp_structure, tmpdir):
    """
    Parse a reference POSCAR.

    With potential elemental names using the PoscarParser and compare
    the result to a reference structure.

    """

    parser = PoscarParser(data=vasp_structure)
    result = parser.get_quantity('poscar-structure', {})
    names = result['poscar-structure'].get_site_kindnames()
    assert names == ['In', 'As', 'As', 'In_d', 'In_d', 'As']
    symbols = result['poscar-structure'].get_symbols_set()
    assert symbols == set(['As', 'In'])
    temp_file = str(tmpdir.join('POSCAR'))
    parser.write(temp_file)
    parser = PoscarParser(file_path=temp_file)
    result_reparse = parser.structure
    names = result_reparse.get_site_kindnames()
    assert names == ['In', 'As', 'As', 'In_d', 'In_d', 'As']
    symbols = result_reparse.get_symbols_set()
    assert symbols == set(['As', 'In'])