Beispiel #1
0
    def sub_create_bands_data(cls, user=None):
        from aiida.orm.data.array.kpoints import KpointsData
        from aiida.orm import JobCalculation
        from aiida.orm.data.structure import StructureData
        from aiida.common.links import LinkType
        from aiida.orm.data.array.bands import BandsData
        import numpy

        s = StructureData(cell=((2., 0., 0.), (0., 2., 0.), (0., 0., 2.)))
        s.append_atom(position=(0., 0., 0.),
                      symbols=['Ba', 'Ti'],
                      weights=(1., 0.),
                      name='mytype')
        if user is not None:
            s.dbnode.user = user._dbuser
        s.store()

        c = JobCalculation(computer=cls.computer,
                           resources={
                               'num_machines': 1,
                               'num_mpiprocs_per_machine': 1
                           })
        if user is not None:
            c.dbnode.user = user._dbuser
        c.store()
        c.add_link_from(s, "S1", LinkType.INPUT)
        c._set_state(calc_states.RETRIEVING)

        # define a cell
        alat = 4.
        cell = numpy.array([
            [alat, 0., 0.],
            [0., alat, 0.],
            [0., 0., alat],
        ])

        k = KpointsData()
        k.set_cell(cell)
        k.set_kpoints_path()
        if user is not None:
            k.dbnode.user = user._dbuser
        k.store()

        b = BandsData()
        b.set_kpointsdata(k)
        input_bands = numpy.array(
            [numpy.ones(4) * i for i in range(k.get_kpoints().shape[0])])
        b.set_bands(input_bands, units='eV')
        if user is not None:
            b.dbnode.user = user._dbuser
        b.store()

        b.add_link_from(c, link_type=LinkType.CREATE)

        return b
Beispiel #2
0
        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_path([('G', 'M', 2)])

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

            k.store()
            b.store()

            return b
Beispiel #3
0
    def run_bands(self):
        """
        Run the SiestaBaseWorkChain in scf+bands mode on the primitive cell of the relaxed input structure
        """
        self.report('Running bands calculation')

        try:
            structure = self.ctx.workchain_relax.out.output_structure
        except:
            self.abort_nowait('failed to get the output structure from the relaxation run')
            return
        
        self.ctx.structure_relaxed_primitive = structure


        inputs = dict(self.ctx.inputs)

        kpoints_mesh = KpointsData()
        kpoints_mesh.set_cell_from_structure(self.ctx.structure_relaxed_primitive)
        kpoints_mesh.set_kpoints_mesh_from_density(
            distance=self.ctx.protocol['kpoints_mesh_density'],
            offset=self.ctx.protocol['kpoints_mesh_offset'])

        bandskpoints = KpointsData()
        bandskpoints.set_cell(structure.cell, structure.pbc)
        bandskpoints.set_kpoints_path(kpoint_distance = 0.05)
        self.ctx.kpoints_path = bandskpoints

        # Final input preparation, wrapping dictionaries in ParameterData nodes
        inputs['bandskpoints'] = self.ctx.kpoints_path           
        inputs['kpoints'] = kpoints_mesh
        inputs['structure'] = self.ctx.structure_relaxed_primitive
        inputs['parameters'] = ParameterData(dict=inputs['parameters'])
        inputs['basis'] = ParameterData(dict=inputs['basis'])
        inputs['settings'] = ParameterData(dict=inputs['settings'])
        
        running = submit(SiestaBaseWorkChain, **inputs)
        
        self.report('launching SiestaBaseWorkChain<{}> in scf+bands mode'.format(running.pid))
        
        return ToContext(workchain_bands=running)
Beispiel #4
0
def _legacy_get_explicit_kpoints_path(structure, **kwargs):
    """
    Call the get_explicit_kpoints_path of the legacy implementation

    :param structure: a StructureData node
    :param float kpoint_distance: parameter controlling the distance between kpoints. Distance is
        given in crystal coordinates, i.e. the distance is computed in the space of b1, b2, b3.
        The distance set will be the closest possible to this value, compatible with the requirement
        of putting equispaced points between two special points (since extrema are included).
    :param bool cartesian: if set to true, reads the coordinates eventually passed in value as cartesian coordinates
    :param float epsilon_length: threshold on lengths comparison, used to get the bravais lattice info
    :param float epsilon_angle: threshold on angles comparison, used to get the bravais lattice info
    """
    args_recognized = [
        'value', 'kpoint_distance', 'cartesian', 'epsilon_length',
        'epsilon_angle'
    ]
    args_unknown = set(kwargs).difference(args_recognized)

    if args_unknown:
        raise ValueError("unknown arguments {}".format(args_unknown))

    point_coords, path, bravais_info, explicit_kpoints, labels = legacy.get_explicit_kpoints_path(
        cell=structure.cell, pbc=structure.pbc, **kwargs)

    kpoints = KpointsData()
    kpoints.set_cell(structure.cell)
    kpoints.set_kpoints(explicit_kpoints)
    kpoints.labels = labels

    parameters = {
        'bravais_info': bravais_info,
        'point_coords': point_coords,
        'path': path,
    }

    return {
        'parameters': ParameterData(dict=parameters),
        'explicit_kpoints': kpoints
    }
def execute(args):
    """
    The main execution of the script, which will run some preliminary checks on the command
    line arguments before passing them to the workchain and running it
    """
    try:
        code = Code.get_from_string(args.codename)
    except NotExistent as exception:
        print "Execution failed: could not retrieve the code '{}'".format(args.codename)
        print "Exception report: {}".format(exception)
        return

    try:
        structure = load_node(args.structure)
    except:
        #
        # Slightly distorted structure
        #
        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,],
        ]

        # Si
        # This was originally given in the "ScaledCartesian" format
        #
        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.245*alat,0.250*alat),symbols=['Si'])
        
        #print "Execution failed: failed to load the node for the given structure pk '{}'".format(args.structure)
        #print "Exception report: {}".format(exception)
        #return

    if not isinstance(structure, StructureData):
        print "The provided pk {} for the structure does not correspond to StructureData, aborting...".format(args.parent_calc)
        return

    kpoints = KpointsData()
    kpoints.set_kpoints_mesh(args.kpoints)
    bandskpoints = KpointsData()

    bandskpoints.set_cell(structure.cell, structure.pbc)
    bandskpoints.set_kpoints_path(kpoint_distance = 0.05)


    parameters = {
                'xc-functional': 'LDA',
                'xc-authors': 'CA',
                'spinpolarized': False,
                'meshcutoff': '150.0 Ry',
                'max-scfiterations': 50,
                'dm-numberpulay': 4,
                'dm-mixingweight': 0.3,
                'dm-tolerance': 1.e-4,
                'Solution-method': 'diagon',
                'electronic-temperature': '25 meV',
                'md-typeofrun': 'cg',
                'md-numcgsteps': 10,
                'md-maxcgdispl': '0.1 Ang',
                'md-maxforcetol': '0.04 eV/Ang'
    }

    # default basis
    basis = {
        'pao-energy-shift': '100 meV',
        '%block pao-basis-sizes': """
        Si DZP                    """,
    }
    
    settings = {}
    options  = {
        'resources': {
            'num_machines': 1
        },
        'max_wallclock_seconds': args.max_wallclock_seconds,
    }

    run(
        SiestaBaseWorkChain,
        code=code,
        structure=structure,
        pseudo_family=Str(args.pseudo_family),
        kpoints=kpoints,
        bandskpoints=bandskpoints,
        parameters=ParameterData(dict=parameters),
        settings=ParameterData(dict=settings),
        options=ParameterData(dict=options),
        basis=ParameterData(dict=basis),
        max_iterations=Int(args.max_iterations),
    )
Beispiel #6
0
def execute(args):
    """
    The main execution of the script, which will run some preliminary checks on the command
    line arguments before passing them to the workchain and running it
    """
    try:
        code = Code.get_from_string(args.codename)
    except NotExistent as exception:
        print "Execution failed: could not retrieve the code '{}'".format(
            args.codename)
        print "Exception report: {}".format(exception)
        return

    try:
        vibra_code = Code.get_from_string(args.vibra_codename)
    except NotExistent as exception:
        print "Execution failed: could not retrieve the code '{}'".format(
            args.stm_codename)
        print "Exception report: {}".format(exception)
        return

    protocol = Str(args.protocol)

    # Structure. Bulk silicon

    SuperCell_1 = 1
    SuperCell_2 = 1
    SuperCell_3 = 1
    scnumbers = np.array([SuperCell_1, SuperCell_2, SuperCell_3])
    scarray = ArrayData()
    scarray.set_array('sca', scnumbers)

    alat = 5.43  # Angstrom. Not passed to the fdf file (only for internal use)
    cell = [[
        0.,
        alat / 2,
        alat / 2,
    ], [
        alat / 2,
        0.,
        alat / 2,
    ], [
        alat / 2,
        alat / 2,
        0.,
    ]]
    pf = alat * 0.125
    na = 2
    x0 = [[pf, pf, pf], [-pf, -pf, -pf]]

    s1 = StructureData(cell=cell)
    for i in range(na):
        s1.append_atom(position=(x0[i][0], x0[i][1], x0[i][2]), symbols=['Si'])

    bandskpoints = KpointsData()
    kpp = [(1, 1., 1., 1.), (15, 0., 0.5, 0.5), (25, 0., 0., 0.),
           (20, 0.5, 0.5, 0.5), (20, 0., 0.5, 0.5), (15, 0.25, 0.5, 0.75),
           (20, 0.5, 0.5, 0.5)]
    lpp = [[0, '\Gamma'], [1, 'X'], [2, '\Gamma'], [3, 'L'], [4, 'X'],
           [5, 'W'], [6, 'L']]
    bandskpoints.set_cell(s1.cell, s1.pbc)
    bandskpoints.set_kpoints(kpp, labels=lpp)

    if args.structure > 0:
        structure = load_node(args.structure)
    else:
        structure = s1

    run(SiestaVibraWorkChain,
        code=code,
        vibra_code=vibra_code,
        scarray=scarray,
        structure=structure,
        protocol=protocol,
        bandskpoints=bandskpoints)