Exemplo n.º 1
0
def build_flow(options):
    # Working directory (default is the name of the script with '.py' removed and "run_" replaced by "flow_")
    if not options.workdir:
        if os.getenv("READTHEDOCS", False):
            __file__ = os.path.join(os.getcwd(), "run_phfrozen_ebands.py")
        options.workdir = os.path.basename(__file__).replace(
            ".py", "").replace("run_", "flow_")

    # build the structures
    base_structure = abilab.Structure.from_file(data.cif_file("si.cif"))
    modifier = abilab.StructureModifier(base_structure)

    etas = [-0.1, 0, +0.1]
    ph_displ = np.reshape(np.zeros(3 * len(base_structure)), (-1, 3))
    ph_displ[0, :] = [+1, 0, 0]
    ph_displ[1, :] = [-1, 0, 0]

    displaced_structures = modifier.displace(ph_displ, etas, frac_coords=False)

    flow = flowtk.Flow(options.workdir, manager=options.manager)

    for structure in displaced_structures:
        # Create the work for the band structure calculation.
        scf_input, nscf_input = make_scf_nscf_inputs(structure)

        work = flowtk.BandStructureWork(scf_input, nscf_input)
        flow.register_work(work)

    return flow
Exemplo n.º 2
0
def build_flow(options):
    # Working directory (default is the name of the script with '.py' removed and "run_" replaced by "flow_")
    if not options.workdir:
        options.workdir = os.path.basename(sys.argv[0]).replace(".py", "").replace("run_","flow_")

    flow = flowtk.Flow(options.workdir, manager=options.manager)

    pseudos = abidata.pseudos("14si.pspnc")

    # Get the unperturbed structure.
    base_structure = abidata.structure_from_ucell("Si")

    etas = [-.001, 0, +.001]
    ph_displ = np.reshape(np.zeros(3*len(base_structure)), (-1,3))
    ph_displ[0,:] = [+1, 0, 0]
    ph_displ[1,:] = [-1, 0, 0]

    # Build new structures by displacing atoms according to the phonon displacement
    # ph_displ (in cartesian coordinates). The Displacement is normalized so that
    # the maximum atomic diplacement is 1 Angstrom and then multiplied by eta.
    modifier = abilab.StructureModifier(base_structure)

    displaced_structures = modifier.displace(ph_displ, etas, frac_coords=False)

    # Generate the different shifts to average
    ndiv = 2
    shift1D = np.arange(1,2*ndiv+1,2)/(2*ndiv)
    all_shifts = [[x,y,z] for x in shift1D for y in shift1D for z in shift1D]
    all_shifts = [[0, 0, 0]]

    for structure, eta in zip(displaced_structures, etas):
        for shift in all_shifts:
            flow.register_work(raman_work(structure, pseudos, shift))

    return flow
Exemplo n.º 3
0
def raman_flow():

    # Get the unperturbed structure.
    base_structure = abilab.Structure.from_abivars(unit_cell)

    pseudos = ["14si.pspnc"]

    workdir = os.path.join(os.path.dirname(__file__), "test_abipy_new")

    manager = abilab.TaskManager.from_user_config()
    #manager = abilab.TaskManager.from_file("bfo_manager.yml")

    policy = TaskPolicy(autoparal=0)
    gs_manager = manager.deepcopy()

    # Initialize flow. Each workflow in the flow defines a complete BSE calculation for given eta.
    flow = abilab.Flow(workdir, manager)

    # There will be kppa/natom kpoints in the unit cell !
    kppa = 3456  # ngkpt = [12,12,12] for the primitive cell
    kppa_gs = 1728  # ngkpt = [8,8,8] for the primitive cell

    etas = [-1, 0, 1]  # Anyway, it rescales everything at the end :-)
    eta = 0.01

    scale_matrix = [[-1, 0, 1], [-1, 1, 0], [-1, -1, 0]]

    ph_tot = np.array([[0.01, 0.011, 0.021], [-0.01, 0.041, -0.02]])
    modifier = abilab.StructureModifier(base_structure)

    displaced_structure = modifier.frozen_phonon([0.5, 0.5, 0.5],
                                                 ph_tot,
                                                 do_real=True,
                                                 frac_coords=False,
                                                 scale_matrix=scale_matrix)

    structure = displaced_structure

    ksampgs = KSampling.automatic_density(structure,
                                          kppa_gs,
                                          chksymbreak=0,
                                          shifts=[0, 0, 0])

    gs_inp = gs_input(structure, pseudos, ksampgs)
    wflow = abilab.Work()
    gs_t = wflow.register_scf_task(gs_inp)
    gs_t.set_manager(gs_manager)
    flow.register_work(wflow, workdir="gs_task")

    ksamp = KSampling.automatic_density(structure,
                                        kppa,
                                        chksymbreak=0,
                                        shifts=[1 / 4, 1 / 4, 1 / 4])
    flow.register_work(raman_workflow(structure, pseudos, gs_t, ksamp),
                       workdir="bse_task")

    return flow.allocate()
Exemplo n.º 4
0
def raman_flow(options):
    # Get the unperturbed structure.
    pseudos = data.pseudos("14si.pspnc")

    base_structure = data.structure_from_ucell("Si")

    ngkpt = [6, 6, 6]

    etas = [-.002, -.001, 0, +.001, +.002]
    ph_displ = np.reshape(np.zeros(3 * len(base_structure)), (-1, 3))
    ph_displ[0, :] = [+1, 0, 0]
    ph_displ[1, :] = [-1, 0, 0]

    # Build new structures by displacing atoms according to the phonon displacement
    # ph_displ (in cartesian coordinates). The Displacement is normalized so that
    # the maximum atomic diplacement is 1 Angstrom and then multiplied by eta.
    modifier = abilab.StructureModifier(base_structure)

    displaced_structures = modifier.displace(ph_displ, etas, frac_coords=False)

    # Initialize flow. Each workflow in the flow defines a complete BSE calculation for given eta.
    workdir = options.workdir
    if not options.workdir:
        workdir = os.path.basename(__file__).replace(".py", "").replace(
            "run_", "flow_")
    #workdir = os.path.join(os.path.dirname(__file__), base_structure.formula.replace(" ","") + "_RAMAN")

    manager = options.manager
    shell_manager = manager.to_shell_manager(mpi_procs=1)
    ddk_manager = manager.deepcopy()

    flow = abilab.Flow(workdir, manager=manager)

    # Generate the different shifts to average
    ndiv = 1
    shift1D = np.arange(1, 2 * ndiv + 1, 2) / (2 * ndiv)
    all_shifts = [[x, y, z] for x in shift1D for y in shift1D for z in shift1D]

    for structure, eta in zip(displaced_structures, etas):
        for ishift, shift in enumerate(all_shifts):
            flow.register_work(raman_work(structure, pseudos, ngkpt, shift,
                                          ddk_manager, shell_manager),
                               workdir="eta_" + str(eta) + "shift_" +
                               str(ishift))

    return flow