Exemplo n.º 1
0
    def get_structuredata_ncf(self):
        """
        This routine returns an AiiDA Structure Data type produced from the ``inp.xml``
        file. not a calcfunction

        :param self: a FleurinpData instance to be parsed into a StructureData
        :returns: StructureData node, or None
        """
        from aiida.orm import StructureData
        from masci_tools.util.xml.xml_getters import get_structure_data

        xmltree, schema_dict = self.load_inpxml()

        atoms, cell, pbc = get_structure_data(xmltree,
                                              schema_dict,
                                              site_namedtuple=True)

        struc = StructureData(cell=cell, pbc=pbc)

        for atom in atoms:
            struc.append_atom(position=atom.position,
                              symbols=atom.symbol,
                              name=atom.kind)

        # TODO DATA-DATA links are not wanted, you might want to use a cf instead
        #struc.add_link_from(self, label='self.structure', link_type=LinkType.CREATE)
        # label='self.structure'
        # return {label : struc}
        return struc
def prepare_plotting_structure(return_struc=False, show_empty_atoms=False):

    # find and plot structure, extract if from parent of bandstructure calc
    Sb2Te3_6QL_bandstruc = load_node(
        UUID_HOST_BANDSTRUC)  # -0.5eV..+0.3eV, corrected K-path
    structure0, _ = VoronoiCalculation.find_parent_structure(
        Sb2Te3_6QL_bandstruc)

    if structure0.has_vacancies:
        cell = structure0.cell

        # correct cell ...
        cell[2] = [i * 8 for i in cell[2]]

        stmp = StructureData(cell=cell)
        for site in structure0.sites:
            k = structure0.get_kind(site.kind_name)
            pos = np.array(site.position)
            pos[2] = -pos[2]
            if not k.has_vacancies:
                stmp.append_atom(position=pos, symbols=k.symbol)
            elif show_empty_atoms:
                stmp.append_atom(position=pos, symbols='X')
            #else:
            #    print("removing atom", site)
        stmp.set_pbc(structure0.pbc)
        structure = stmp

    if return_struc:
        return structure

    # now construct ase object and use ase's viewer
    ase_atoms = structure.get_ase()

    return ase_atoms
Exemplo n.º 3
0
def get_supercell(
    structure: orm.StructureData,
    supercell_shape: orm.Dict,
) -> orm.StructureData:
    """Generate a supercell from a given StructureData

    :param structure: original structure that will be used to generate the supercell
    :type structure: orm.StructureData
    :param supercell_shape: dictionary with the supercell information
    :type supercell_shape: orm.Dict
    :return: generated supercell
    :rtype: orm.StructureData
    """
    symbols = np.array([site.kind_name for site in structure.sites])
    positions = np.array([site.position for site in structure.sites])
    cell = np.array(structure.cell)
    supercell_shape = np.array(supercell_shape.dict.shape)

    supercell_array = np.dot(cell, np.diag(supercell_shape))

    supercell = StructureData(cell=supercell_array)
    for k in range(positions.shape[0]):
        for entry in itertools.product(
                *[range(i) for i in supercell_shape[::-1]]):
            position = positions[k, :] + np.dot(np.array(entry[::-1]), cell)
            symbol = symbols[k]
            supercell.append_atom(position=position, symbols=symbol)

    return supercell
Exemplo n.º 4
0
    def setUpClass(cls, *args, **kwargs):
        super(TestKpoints, cls).setUpClass(*args, **kwargs)

        alat = 5.430  # angstrom
        cell = [[
            0.5 * alat,
            0.5 * alat,
            0.,
        ], [
            0.,
            0.5 * alat,
            0.5 * alat,
        ], [0.5 * alat, 0., 0.5 * alat]]
        cls.alat = alat
        structure = StructureData(cell=cell)
        structure.append_atom(position=(0.000 * alat, 0.000 * alat,
                                        0.000 * alat),
                              symbols=['Si'])
        structure.append_atom(position=(0.250 * alat, 0.250 * alat,
                                        0.250 * alat),
                              symbols=['Si'])
        cls.structure = structure
        # Define the expected reciprocal cell
        val = 2. * np.pi / alat
        cls.expected_reciprocal_cell = np.array([[val, val, -val],
                                                 [-val, val, val],
                                                 [val, -val, val]])
Exemplo n.º 5
0
    def _generate_structure2():
        """Return a `StructureData` representing bulk silicon."""
        from aiida.orm import StructureData

        def rel_to_abs(vector, cell):
            """
            converts interal coordinates to absolut coordinates in Angstroem.
            """
            if len(vector) == 3:
                postionR = vector
                row1 = cell[0]
                row2 = cell[1]
                row3 = cell[2]
                new_abs_pos = [
                    postionR[0] * row1[0] + postionR[1] * row2[0] +
                    postionR[2] * row3[0], postionR[0] * row1[1] +
                    postionR[1] * row2[1] + postionR[2] * row3[1],
                    postionR[0] * row1[2] + postionR[1] * row2[2] +
                    postionR[2] * row3[2]
                ]
                return new_abs_pos

        bohr_a_0 = 0.52917721092  # A
        a = 5.167355275190 * bohr_a_0
        cell = [[0.0, a, a], [a, 0.0, a], [a, a, 0.0]]
        structure = StructureData(cell=cell)
        pos1 = rel_to_abs((1. / 8., 1. / 8., 1. / 8.), cell)
        pos2 = rel_to_abs((-1. / 8., -1. / 8., -1. / 8.), cell)
        structure.append_atom(position=pos1, symbols='Si')
        structure.append_atom(position=pos2, symbols='Si')

        return structure
Exemplo n.º 6
0
    def _generate_structure(structure_id='silicon'):
        """Return a `StructureData` representing bulk silicon or a snapshot of a single water molecule dynamics."""
        from aiida.orm import StructureData

        if structure_id == 'silicon':
            param = 5.43
            cell = [[param / 2., param / 2., 0], [param / 2., 0, param / 2.],
                    [0, param / 2., param / 2.]]
            structure = StructureData(cell=cell)
            structure.append_atom(position=(0., 0., 0.),
                                  symbols='Si',
                                  name='Si')
            structure.append_atom(position=(param / 4., param / 4.,
                                            param / 4.),
                                  symbols='Si',
                                  name='Si')
        elif structure_id == 'water':
            structure = StructureData(
                cell=[[5.29177209, 0., 0.], [0., 5.29177209, 0.],
                      [0., 0., 5.29177209]])
            structure.append_atom(
                position=[12.73464656, 16.7741411, 24.35076238],
                symbols='H',
                name='H')
            structure.append_atom(
                position=[-29.3865565, 9.51707929, -4.02515904],
                symbols='H',
                name='H')
            structure.append_atom(
                position=[1.04074437, -1.64320127, -1.27035021],
                symbols='O',
                name='O')
        else:
            raise KeyError('Unknown structure_id=\'{}\''.format(structure_id))
        return structure
Exemplo n.º 7
0
    def create_structure_bands():
        """Create bands structure object."""
        alat = 4.  # angstrom
        cell = [
            [
                alat,
                0.,
                0.,
            ],
            [
                0.,
                alat,
                0.,
            ],
            [
                0.,
                0.,
                alat,
            ],
        ]
        strct = StructureData(cell=cell)
        strct.append_atom(position=(0., 0., 0.), symbols='Fe')
        strct.append_atom(position=(alat / 2., alat / 2., alat / 2.),
                          symbols='O')
        strct.store()

        @calcfunction
        def connect_structure_bands(strct):  # pylint: disable=unused-argument
            alat = 4.
            cell = np.array([
                [alat, 0., 0.],
                [0., alat, 0.],
                [0., 0., alat],
            ])

            kpnts = KpointsData()
            kpnts.set_cell(cell)
            kpnts.set_kpoints([[0., 0., 0.], [0.1, 0.1, 0.1]])

            bands = BandsData()
            bands.set_kpointsdata(kpnts)
            bands.set_bands([[1.0, 2.0], [3.0, 4.0]])
            return bands

        bands = connect_structure_bands(strct)

        # Create 2 groups and add the data to one of them
        g_ne = Group(label='non_empty_group')
        g_ne.store()
        g_ne.add_nodes(bands)

        g_e = Group(label='empty_group')
        g_e.store()

        return {
            DummyVerdiDataListable.NODE_ID_STR: bands.id,
            DummyVerdiDataListable.NON_EMPTY_GROUP_ID_STR: g_ne.id,
            DummyVerdiDataListable.EMPTY_GROUP_ID_STR: g_e.id
        }
Exemplo n.º 8
0
    def create_structure_bands():
        alat = 4.  # angstrom
        cell = [
            [
                alat,
                0.,
                0.,
            ],
            [
                0.,
                alat,
                0.,
            ],
            [
                0.,
                0.,
                alat,
            ],
        ]
        s = StructureData(cell=cell)
        s.append_atom(position=(0., 0., 0.), symbols='Fe')
        s.append_atom(position=(alat / 2., alat / 2., alat / 2.), symbols='O')
        s.store()

        @calcfunction
        def connect_structure_bands(structure):
            alat = 4.
            cell = np.array([
                [alat, 0., 0.],
                [0., alat, 0.],
                [0., 0., alat],
            ])

            k = KpointsData()
            k.set_cell(cell)
            k.set_kpoints([[0., 0., 0.], [0.1, 0.1, 0.1]])

            b = BandsData()
            b.set_kpointsdata(k)
            b.set_bands([[1.0, 2.0], [3.0, 4.0]])

            return b

        b = connect_structure_bands(s)

        # Create 2 groups and add the data to one of them
        g_ne = Group(label='non_empty_group')
        g_ne.store()
        g_ne.add_nodes(b)

        g_e = Group(label='empty_group')
        g_e.store()

        return {
            TestVerdiDataListable.NODE_ID_STR: b.id,
            TestVerdiDataListable.NON_EMPTY_GROUP_ID_STR: g_ne.id,
            TestVerdiDataListable.EMPTY_GROUP_ID_STR: g_e.id
        }
Exemplo n.º 9
0
def h2_structure(aiida_profile, db_test_app):
    a = 10

    cell = ((a, 0., 0.), (0., a, 0.), (0., 0., a))
    s = StructureData(cell=cell)
    s.append_atom(position=(0., 0., 0.), symbols=["H"])
    s.append_atom(position=(a / 2, a / 2, a / 2), symbols=["H"])
    s.label = "h2"
    return s
Exemplo n.º 10
0
def get_x2_structure(x):
    """Return a O2 molecule in a box"""
    a = 10

    cell = ((a, 0., 0.), (0., a, 0.), (0., 0., a))
    s = StructureData(cell=cell)
    s.append_atom(position=(0., 0., 0.), symbols=[x])
    s.append_atom(position=(1.4, 0., 0.), symbols=[x])
    s.label = "O2"
    return s
Exemplo n.º 11
0
    def _generate_structure():
        """Return a `StructureData` representing bulk silicon."""
        from aiida.orm import StructureData

        param = 5.43
        cell = [[param / 2., param / 2., 0], [param / 2., 0, param / 2.], [0, param / 2., param / 2.]]
        structure = StructureData(cell=cell)
        structure.append_atom(position=(0., 0., 0.), symbols='Si', name='Si')
        structure.append_atom(position=(param / 4., param / 4., param / 4.), symbols='Si', name='Si')

        return structure
Exemplo n.º 12
0
    def _generate_structure(element='Si'):
        """Return a `StructureData` representing bulk silicon."""
        from aiida.orm import StructureData

        a = 5.43
        cell = [[a / 2., a / 2., 0], [a / 2., 0, a / 2.], [0, a / 2., a / 2.]]
        structure = StructureData(cell=cell)
        structure.append_atom(position=(0., 0., 0.), symbols=element)
        structure.append_atom(position=(a / 4., a / 4., a / 4.), symbols=element)

        return structure
Exemplo n.º 13
0
    def _generate_structure(elements=('Ar',)):
        """Return a ``StructureData``."""
        from aiida.orm import StructureData

        structure = StructureData(cell=[[1, 0, 0], [0, 1, 0], [0, 0, 1]])

        for index, element in enumerate(elements):
            symbol = re.sub(r'[0-9]+', '', element)
            structure.append_atom(position=(index * 0.5, index * 0.5, index * 0.5), symbols=symbol, name=element)

        return structure
Exemplo n.º 14
0
def structure_from_input(cell, positions, symbols):
    """
    Receives the dictionary cell parsed from CASTEP
    Convert it into an AiiDA structure object
    """

    out_structure = StructureData(cell=cell)

    for symbol, position in zip(symbols, positions):

        out_structure.append_atom(symbols=symbol, position=position)

    return out_structure
Exemplo n.º 15
0
def newStructure(structure, changeDict):
    """

    :code:`newStructure` will create a new structure by replacing the changeList atom to new type of atoms,
    very useful if there are different chemical states of the same atom in the structure.

    :param structure: previous structure with conventional atomic symbols
    :type structure: aiida.orm.StructureData object

    :param changeDict: A dictionary where the i-th atom's label will be replaced. e.g. 'Fe' to 'Fe2'
    :type changeDict: python dictionary

    :returns: return an object which stores the change of the label
    :rtype: aiida.orm.StructureData object

    """

    # create the kind_names list
    kind_names = []
    structure_ase = structure.get_ase()

    for atom in structure_ase:
        kind_names.append(atom.symbol)

    for key, value in changeDict.items():
        for ind, atomSymbol in enumerate(kind_names):
            if atomSymbol == key:
                kind_names[ind] = value

    # since I recreate kind_names from structure, then they must be the same.
    # if len(structure.sites) != len(kind_names):
    #     raise ValueError('The number of new kind names must be equal to the number of sites in the structure.')

    new_structure = StructureData(
        cell=structure.cell,
        pbc=structure.pbc,
    )

    for site, kind_name in zip(structure.sites, kind_names):
        kind = structure.get_kind(site.kind_name)

        new_structure.append_atom(name=kind_name,
                                  symbols=kind.symbols,
                                  weights=kind.weights,
                                  position=site.position)

    return new_structure
Exemplo n.º 16
0
    def get_structure(self):

        """
        Returns the structure used to calculate the NAC parameters

        :return: StructureData
        """

        structure = StructureData(cell=self.get_attr('cell'))

        symbols = self.get_attr('symbols')
        positions = self.get_attr('positions')
        for symbol, position in zip(symbols, positions):
            structure.append_atom(position=position,
                                  symbols=symbol)

        return structure
Exemplo n.º 17
0
    def _generate_structure_W():
        """Return a `StructureData` representing bulk tungsten."""
        from aiida.orm import StructureData

        # W bcc structure
        bohr_a_0 = 0.52917721092  # A
        a = 3.013812049196 * bohr_a_0
        cell = [[-a, a, a], [a, -a, a], [a, a, -a]]
        structure = StructureData(cell=cell)
        structure.append_atom(position=(0., 0., 0.), symbols='W', name='W')

        #param = 3.18968 # 1.58950065353588 * 0.5291772109
        #cell = [[-param, param, param], [param, -param, param], [param, param, -param]]
        #structure = StructureData(cell=cell)
        #structure.append_atom(position=(0., 0., 0.), symbols='W', name='W')

        return structure
Exemplo n.º 18
0
def get_supercell(structure, supercell_shape):
    import itertools

    symbols = np.array([site.kind_name for site in structure.sites])
    positions = np.array([site.position for site in structure.sites])
    cell = np.array(structure.cell)
    supercell_shape = np.array(supercell_shape.dict.shape)

    supercell_array = np.dot(cell, np.diag(supercell_shape))

    supercell = StructureData(cell=supercell_array)
    for k in range(positions.shape[0]):
        for r in itertools.product(*[range(i) for i in supercell_shape[::-1]]):
            position = positions[k, :] + np.dot(np.array(r[::-1]), cell)
            symbol = symbols[k]
            supercell.append_atom(position=position, symbols=symbol)

    return supercell
Exemplo n.º 19
0
def get_sto_structure():
    """Return a STO structure"""
    a = 3.905

    cell = ((a, 0., 0.), (0., a, 0.), (0., 0., a))
    s = StructureData(cell=cell)
    s.append_atom(position=(0., 0., 0.), symbols=["Sr"])
    s.append_atom(position=(a / 2, a / 2, a / 2), symbols=["Ti"])
    s.append_atom(position=(a / 2, a / 2, 0.), symbols=["O"])
    s.append_atom(position=(a / 2, 0., a / 2), symbols=["O"])
    s.append_atom(position=(0., a / 2, a / 2), symbols=["O"])
    s.label = "STO"
    return s
Exemplo n.º 20
0
    def get_STO_structure():
        """Return a STO structure"""
        from aiida.plugins import DataFactory
        a = 3.905

        cell = ((a, 0., 0.), (0., a, 0.), (0., 0., a))
        s = StructureData(cell=cell)
        s.append_atom(position=(0., 0., 0.), symbols=["Sr"])
        s.append_atom(position=(a / 2, a / 2, a / 2), symbols=["Ti"])
        s.append_atom(position=(a / 2, a / 2, 0.), symbols=["O"])
        s.append_atom(position=(a / 2, 0., a / 2), symbols=["O"])
        s.append_atom(position=(0., a / 2, a / 2), symbols=["O"])
        s.label = "STO"
        return s
Exemplo n.º 21
0
def create_structure(
        traj_block,
        symbol_field="element",
        position_fields=("x", "y", "z"),
        original_structure=None,
):
    symbols = traj_block.atom_fields[symbol_field]
    positions = np.array([traj_block.atom_fields[f] for f in position_fields],
                         dtype=float).T

    if original_structure is not None:
        kind_names = original_structure.get_site_kindnames()
        kind_symbols = [
            original_structure.get_kind(n).symbol for n in kind_names
        ]
        if symbols != kind_symbols:
            raise ValueError(
                "original_structure has different symbols:: {} != {}".format(
                    kind_symbols, symbols))
        structure = original_structure.clone()
        structure.reset_cell(traj_block.cell)
        structure.reset_sites_positions(positions)

        return structure

    pbcs = []
    for pbc in traj_block.pbc:
        if pbc == "pp":
            pbcs.append(True)
        elif pbc == "ff":
            pbcs.append(False)
        else:
            raise NotImplementedError("pbc = {}".format(traj_block.pbc))

    structure = StructureData(cell=traj_block.cell, pbc=pbcs)
    for symbol, position in zip(symbols, positions):
        structure.append_atom(position=position, symbols=symbol)

    return structure
Exemplo n.º 22
0
    def _generate_structure(scale=None):
        """Return a `StructureData` representing bulk silicon."""
        from aiida.orm import StructureData

        param = 5.43
        cell = [[param / 2., param / 2., 0], [param / 2., 0, param / 2.],
                [0, param / 2., param / 2.]]
        structure = StructureData(cell=cell)
        structure.append_atom(position=(0., 0., 0.), symbols='Si', name='Si')
        structure.append_atom(position=(param / 4., param / 4., param / 4.),
                              symbols='Si',
                              name='SiDiff')

        if scale:
            the_ase = structure.get_ase()
            new_ase = the_ase.copy()
            new_ase.set_cell(the_ase.get_cell() * float(scale),
                             scale_atoms=True)
            new_structure = StructureData(ase=new_ase)
            structure = new_structure

        return structure
Exemplo n.º 23
0
def get_mixture_cell():
    """Return a STO structure"""
    a = 3.905

    cell = ((a, 0., 0.), (0., a, 0.), (0., 0., a))
    s = StructureData(cell=cell)
    s.append_atom(position=(0., 0., 0.),
                  symbols=["Sr", "Ti"],
                  weights=(0.5, 0.5),
                  name='SrTi')
    s.append_atom(position=(a / 2, a / 2, a / 2), symbols=["Ti"])
    s.append_atom(position=(a / 2, a / 2, 0.), symbols=["O"])
    s.append_atom(position=(a / 2, 0., a / 2), symbols=["O"], name='O1')
    s.append_atom(position=(0., a / 2, a / 2), symbols=["O"], name='O2')
    s.label = "STO"
    return s
Exemplo n.º 24
0
    def create_structure_data():
        """Create StructureData object."""
        alat = 4.  # angstrom
        cell = [
            [
                alat,
                0.,
                0.,
            ],
            [
                0.,
                alat,
                0.,
            ],
            [
                0.,
                0.,
                alat,
            ],
        ]

        # BaTiO3 cubic structure
        struc = StructureData(cell=cell)
        struc.append_atom(position=(0., 0., 0.), symbols='Ba')
        struc.append_atom(position=(alat / 2., alat / 2., alat / 2.),
                          symbols='Ti')
        struc.append_atom(position=(alat / 2., alat / 2., 0.), symbols='O')
        struc.append_atom(position=(alat / 2., 0., alat / 2.), symbols='O')
        struc.append_atom(position=(0., alat / 2., alat / 2.), symbols='O')
        struc.store()

        # Create 2 groups and add the data to one of them
        g_ne = Group(label='non_empty_group')
        g_ne.store()
        g_ne.add_nodes(struc)

        g_e = Group(label='empty_group')
        g_e.store()

        return {
            DummyVerdiDataListable.NODE_ID_STR: struc.id,
            DummyVerdiDataListable.NON_EMPTY_GROUP_ID_STR: g_ne.id,
            DummyVerdiDataListable.EMPTY_GROUP_ID_STR: g_e.id
        }
Exemplo n.º 25
0
    def _generate_film_structure():
        """Return a `StructureData` representing bulk silicon."""
        from aiida.orm import StructureData
        from aiida_fleur.common.constants import BOHR_A
        a = 7.497 * BOHR_A
        cell = [[0.7071068 * a, 0.0, 0.0], [0.0, 1.0 * a, 0.0],
                [0.0, 0.0, 0.7071068 * a]]
        structure = StructureData(cell=cell)
        structure.append_atom(position=(0., 0., -1.99285 * BOHR_A),
                              symbols='Fe')
        structure.append_atom(position=(0.5 * 0.7071068 * a, 0.5 * a, 0.0),
                              symbols='Pt')
        structure.append_atom(position=(0., 0., 1.99285 * BOHR_A),
                              symbols='Fe')
        structure.pbc = (True, True, False)

        return structure
    ],
    [
        0.,
        0.5 * alat,
        0.5 * alat,
    ],
    [
        0.5 * alat,
        0.,
        0.5 * alat,
    ],
]
#The atom positions were originally given in the "ScaledCartesian" format
#but standard for aiida structures is Cartesian in Angstrom
structure = StructureData(cell=cell)
structure.append_atom(position=(0.000 * alat, 0.000 * alat, 0.000 * alat),
                      symbols=['Si'])
structure.append_atom(position=(0.250 * alat, 0.250 * alat, 0.250 * alat),
                      symbols=['Si'])

#The parameters
parameters = Dict(
    dict={
        'xc-functional': 'LDA',
        'xc-authors': 'CA',
        'max-scfiterations': 4,
        'dm-numberpulay': 4,
        'dm-mixingweight': 0.3,
        'dm-tolerance': 1.e-5,
        'Solution-method': 'diagon',
        'electronic-temperature': '25 meV',
        'write-forces': True,
Exemplo n.º 27
0
############################

a = 5.404
cell = [[a, 0, 0], [0, a, 0], [0, 0, a]]

symbols = ['Si'] * 8
scaled_positions = [(0.875, 0.875, 0.875), (0.875, 0.375, 0.375),
                    (0.375, 0.875, 0.375), (0.375, 0.375, 0.875),
                    (0.125, 0.125, 0.125), (0.125, 0.625, 0.625),
                    (0.625, 0.125, 0.625), (0.625, 0.625, 0.125)]

structure = StructureData(cell=cell)
positions = np.dot(scaled_positions, cell)

for i, scaled_position in enumerate(scaled_positions):
    structure.append_atom(position=np.dot(scaled_position, cell).tolist(),
                          symbols=symbols[i])

structure.store()

dynaphopy_parameters = {
    'supercell': [[2, 0, 0], [0, 2, 0], [0, 0, 2]],
    'primitive': [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]],
    'mesh': [40, 40, 40],
    'md_commensurate': True,
    'temperature': 300
}  # Temperature can be omitted (If ommited calculated from Max.-Boltz.)

dynaphopy_machine = {
    'num_machines': 1,
    'parallel_env': 'mpi*',
    'tot_num_mpiprocs': 16
    ],
    [
        0.,
        0.5 * alat,
        0.5 * alat,
    ],
    [
        0.5 * alat,
        0.,
        0.5 * alat,
    ],
]
#The atom positions were originally given in the "ScaledCartesian" format
#but standard for aiida structures is Cartesian in Angstrom 
structure = StructureData(cell=cell)
structure.append_atom(position=(0.000 * alat, 0.000 * alat, 0.000 * alat),
                      symbols=['Si'], name='Si_one')
structure.append_atom(position=(0.260 * alat, 0.250 * alat, 0.250 * alat),
                      symbols=['Si'], name='alt_Si')

#The parameters
parameters = Dict(
    dict={
        'xc-functional': 'LDA',
        'xc-authors': 'CA',
        'max-scfiterations': 50,
        'dm-numberpulay': 4,
        'dm-mixingweight': 0.3,
        'dm-tolerance': 1.e-3,
        'Solution-method': 'diagon',
        'electronic-temperature': '25 meV',
        'md-typeofrun': 'cg',
Exemplo n.º 29
0
def from_sirius_json(sirius_json):
    """Create input provenance from sirius_json. Assuming quantities
    are given in atomic units!

    Returns structure (unit_cell, sites) and magnetization

    Keyword Arguments:
    sirius_json -- sirius_json (as dict)

    Returns:
    - StructureData
    - magnetization dictionary
    - kpoint

    """
    sirius_unit_cell = sirius_json['unit_cell']

    if 'lattice_vectors_scale' in sirius_unit_cell:
        lattice_vectors_scale = sirius_unit_cell['lattice_vectors_scale']
    else:
        lattice_vectors_scale = 1

    cell_angstrom = np.array(sirius_unit_cell['lattice_vectors']
                             ) * lattice_vectors_scale * bohr_to_ang

    magnetization = read_magnetization(sirius_unit_cell['atoms'])

    # get kpoints
    kpoints = KpointsData()
    if 'vk' in sirius_json['parameters']:
        kpoints.set_kpoints(sirius_json['parameters']['vk'])
    else:
        ngridk = sirius_json['parameters']['ngridk']
        kpoints.set_kpoints_mesh(ngridk)

    structure = StructureData(cell=to_list(cell_angstrom))
    if 'atom_coordinate_units' in sirius_unit_cell:
        if sirius_unit_cell['atom_coordinate_units'] in ['A', 'a.u.', 'au']:
            # atom positions are already given in angstrom, nothing to convert
            for atom_type in sirius_unit_cell['atoms']:
                for lposmag in sirius_unit_cell['atoms'][atom_type]:
                    lpos = np.array(lposmag[:3])
                    if sirius_unit_cell['atom_coordinate_units'] in [
                            'a.u.', 'au'
                    ]:
                        structure.append_atom(position=tuple(lpos *
                                                             bohr_to_ang),
                                              symbols=atom_type)
                    else:
                        structure.append_atom(position=tuple(lpos),
                                              symbols=atom_type)
        else:
            raise ValueError('invalid entry for atom_coordinate_units')
    else:
        # atom positions are given in relative coordinates
        for atom_type in sirius_unit_cell['atoms']:
            for lposmag in sirius_unit_cell['atoms'][atom_type]:
                lpos = np.array(lposmag[:3])
                apos = np.dot(cell_angstrom.T, lpos)
                structure.append_atom(position=tuple(apos), symbols=atom_type)

    return structure, magnetization, kpoints
from aiida.plugins import WorkflowFactory

from aiida_wannier90.orbitals import generate_projections

pw_code = load_code("<CODE LABEL>")  # Replace with the QE pw.x code label
wannier_code = load_code(
    "<CODE LABEL>")  # Replace with the Wannier90 wannier.x code label
pw2wannier90_code = load_code(
    "<CODE LABEL>")  # Replace with the QE pw2wannier90.x code label
pseudo_family_name = "<UPF FAMILY NAME>"  # Replace with the name of the pseudopotential family for SSSP efficiency

# GaAs structure
a = 5.68018817933178  # angstrom
structure = StructureData(
    cell=[[-a / 2., 0, a / 2.], [0, a / 2., a / 2.], [-a / 2., a / 2., 0]])
structure.append_atom(symbols=['Ga'], position=(0., 0., 0.))
structure.append_atom(symbols=['As'], position=(-a / 4., a / 4., a / 4.))

# 4x4x4 k-points mesh for the SCF
kpoints_scf = KpointsData()
kpoints_scf.set_kpoints_mesh([4, 4, 4])

# 10x10x10 k-points mesh for the NSCF/Wannier90 calculations
kpoints_nscf = KpointsData()
kpoints_nscf.set_kpoints_mesh([10, 10, 10])

# k-points path for the band structure
kpoint_path = Dict(
    dict={
        'point_coords': {
            'GAMMA': [0.0, 0.0, 0.0],