Example #1
0
def compute_energy(alat, nk, ecut):
    """
    Make an input template and select potential and structure, and the path where to run
    """
    potname = 'Fe.pbe-nd-rrkjus.UPF'
    potpath = os.path.join(os.environ['QE_POTENTIALS'], potname)
    pseudopots = {
        'Fe':
        PseudoPotential(path=potpath,
                        ptype='uspp',
                        element='Fe',
                        functional='GGA',
                        name=potname),
        'Co':
        PseudoPotential(path=potpath,
                        ptype='uspp',
                        element='Fe',
                        functional='GGA',
                        name=potname)
    }
    struc = make_struc(alat=alat)
    kpts = Kpoints(gridsize=[nk, nk, nk], option='automatic', offset=False)
    dirname = 'Fe_a_{}_ecut_{}_nk_{}'.format(alat, ecut, nk)
    runpath = Dir(
        path=os.path.join(os.environ['WORKDIR'], "Lab3/Problem1", dirname))
    input_params = PWscf_inparam({
        'CONTROL': {
            'calculation': 'scf',
            'pseudo_dir': os.environ['QE_POTENTIALS'],
            'outdir': runpath.path,
            'tstress': True,
            'tprnfor': True,
            'disk_io': 'none',
        },
        'SYSTEM': {
            'ecutwfc': ecut,
            'ecutrho': ecut * 8,
            'nspin': 2,
            'starting_magnetization(1)': 0.7,
            'occupations': 'smearing',
            'smearing': 'mp',
            'degauss': 0.02
        },
        'ELECTRONS': {
            'diagonalization': 'david',
            'mixing_beta': 0.5,
            'conv_thr': 1e-7,
        },
        'IONS': {},
        'CELL': {},
    })

    output_file = run_qe_pwscf(runpath=runpath,
                               struc=struc,
                               pseudopots=pseudopots,
                               params=input_params,
                               kpoints=kpts,
                               ncpu=2)
    output = parse_qe_pwscf_output(outfile=output_file)
    return output
Example #2
0
def compute_energy(alat, nk, ecut):
    """
    Make an input template and select potential and structure, and the path where to run
    """
    potname = 'Ge.pz-bhs.UPF'
    pseudopath = os.environ['QE_POTENTIALS']
    potpath = os.path.join(pseudopath, potname)
    pseudopots = {
        'Ge':
        PseudoPotential(name=potname,
                        path=potpath,
                        ptype='uspp',
                        element='Ge',
                        functional='LDA')
    }
    struc = make_struc(alat=alat)
    kpts = Kpoints(gridsize=[nk, nk, nk], option='automatic', offset=False)
    runpath = Dir(
        path=os.path.join(os.environ['WORKDIR'], "Lab2/Problem1", str(alat)))
    input_params = PWscf_inparam({
        'CONTROL': {
            'calculation': 'scf',
            'pseudo_dir': pseudopath,
            'outdir': runpath.path,
            'tstress': True,
            'tprnfor': True,
            'disk_io': 'none',
        },
        'SYSTEM': {
            'ecutwfc': ecut,
        },
        'ELECTRONS': {
            'diagonalization': 'david',
            'mixing_beta': 0.5,
            'conv_thr': 1e-7,
        },
        'IONS': {},
        'CELL': {},
    })

    output_file = run_qe_pwscf(runpath=runpath,
                               struc=struc,
                               pseudopots=pseudopots,
                               params=input_params,
                               kpoints=kpts)
    output = parse_qe_pwscf_output(outfile=output_file)
    return output
Example #3
0
def compute_energy(alat, nk, ecut, displ=0):
    """
    Make an input template and select potential and structure, and the path where to run
    """
    pseudopots = {'Pb': PseudoPotential(ptype='uspp', element='Pb', functional='LDA', name='Pb.pz-d-van.UPF'),
                  'Ti': PseudoPotential(ptype='uspp', element='Ti', functional='LDA', name='Ti.pz-sp-van_ak.UPF'),
                  'O': PseudoPotential(ptype='uspp', element='O', functional='LDA', name='O.pz-rrkjus.UPF')}
    struc = make_struc(alat=alat, displacement=displ)
    # fix the Pb and Ti atoms in place during relaxation
    constraint = Constraint(atoms={'0': [0,0,0], '1': [0,0,0]})
    kpts = Kpoints(gridsize=[nk, nk, nk], option='automatic', offset=True)
    dirname = 'PbTiO3_a_{}_ecut_{}_nk_{}_displ_{}'.format(alat, ecut, nk, displ)
    runpath = Dir(path=os.path.join(os.environ['WORKDIR'], "Lab3/Problem2", dirname))
    input_params = PWscf_inparam({
        'CONTROL': {
            'calculation': 'scf',
            'pseudo_dir': os.environ['QE_POTENTIALS'],
            'outdir': runpath.path,
            'tstress': True,
            'tprnfor': True,
            'disk_io': 'none'
        },
        'SYSTEM': {
            'ecutwfc': ecut,
            'ecutrho': ecut * 8,
             },
        'ELECTRONS': {
            'diagonalization': 'david',
            'mixing_beta': 0.7,
            'conv_thr': 1e-7,
        },
        'IONS': {
            'ion_dynamics': 'bfgs'
        },
        'CELL': {},
        })

    output_file = run_qe_pwscf(runpath=runpath, struc=struc,  pseudopots=pseudopots,
                               params=input_params, kpoints=kpts, constraint=constraint, ncpu=2)
    output = parse_qe_pwscf_output(outfile=output_file)
    return output
Example #4
0
def compute_energy(alat, nk, ecut):
    """
    Make an input template and select potential and structure, and the path where to run
    """
    start_time=time.time()
    potname = 'Au.pbe-n-kjpaw_psl.1.0.0.UPF'
    pseudopath = os.environ['QE_POTENTIALS']
    potpath = os.path.join(pseudopath, potname)
    pseudopots = {'Au': PseudoPotential(name=potname, path=potpath, ptype='paw', element='Au', functional='PBE')}
    struc = make_struc(alat=alat)
    kpts = Kpoints(gridsize=[nk, nk, nk], option='automatic', offset=False)
    runpath = Dir(path=os.path.join(os.environ['WORKDIR'], "final_project/bulk_cohesive_energy_QE/alat_convergence/", str(alat)))
    input_params = PWscf_inparam({
        'CONTROL': {
           # 'calculation': 'scf',
            'calculation':'vc-relax',
            'pseudo_dir': pseudopath,
            'outdir': runpath.path,
            'tstress': True,
            'tprnfor': True,
            'disk_io': 'none',
        },
        'SYSTEM': {
            'ecutwfc': ecut,
             },
        'ELECTRONS': {
            'diagonalization': 'david',
            'mixing_beta': 0.5,
            'conv_thr': 1e-7,
        },
        'IONS': {},
        'CELL': {},
        })

    output_file = run_qe_pwscf(runpath=runpath, struc=struc,  pseudopots=pseudopots,
                               params=input_params, kpoints=kpts,ncpu=4)
    output = parse_qe_pwscf_output(outfile=output_file)
    end_time=(time.time()-start_time)
    print('running time is',end_time)
    return output
Example #5
0
def compute_energy(nk,
                   ecut,
                   elements,
                   formula,
                   spacegroup,
                   sc=1,
                   directory="final_project",
                   ncpu=8,
                   functional="GGA"):
    """
    Make an input template and select potential and structure, and the path where to run
    """

    # Base Metal
    if ('Cu' in elements):
        e1 = 'Cu'
        if (functional == "GGA"):
            pot1 = 'Cu.rel-pbe-spn-kjpaw_psl.1.0.0.UPF'
        elif (functional == "LDA"):
            pot1 = 'Cu.pz-dn-rrkjus_psl.0.2.UPF'
            #pot1 = 'Cu.rel-pbe-spn-kjpaw_psl.1.0.0.UPF'

    # Alloying agent
    if ('Sn' in elements):
        e2 = 'Sn'
        if (functional == "GGA"):
            pot2 = 'Sn.rel-pbe-dn-kjpaw_psl.1.0.0.UPF'
        elif (functional == "LDA"):
            pot2 = 'Sn.pz-dn-rrkjus_psl.0.2.UPF'
        if ('Cu' not in elements):
            e1 = 'Sn'
            if (functional == "GGA"):
                pot1 = 'Sn.rel-pbe-dn-kjpaw_psl.1.0.0.UPF'
            elif (functional == "LDA"):
                pot1 = 'Sn.pz-dn-rrkjus_psl.0.2.UPF'

    # Put it together
    pot1path = './pseudopot/' + pot1
    if (len(elements) == 1):
        pseudopots = {
            e1:
            PseudoPotential(path=pot1path,
                            ptype='paw',
                            element=e1,
                            functional='GGA',
                            name=pot1)
        }
    elif (len(elements) == 2):
        pot2path = './pseudopot/' + pot2
        pseudopots = {
            e1:
            PseudoPotential(path=pot1path,
                            ptype='paw',
                            element=e1,
                            functional='GGA',
                            name=pot1),
            e2:
            PseudoPotential(path=pot2path,
                            ptype='paw',
                            element=e2,
                            functional='GGA',
                            name=pot2)
        }

    # Get structure
    struc = make_struc(formula, spacegroup, sc)
    kpts = Kpoints(gridsize=[nk, nk, nk], option='automatic', offset=False)

    # Directory
    dirname = '{}_{}_{}_{}_{}'.format(formula, spacegroup, nk, sc, ecut)

    # Path
    runpath = Dir(path=os.path.join(os.environ['WORKDIR'], "final_project/" +
                                    directory, dirname))

    # Create input
    input_params = PWscf_inparam({
        'CONTROL': {
            'calculation': 'scf',
            #'pseudo_dir': os.environ['QE_POTENTIALS'],
            'pseudo_dir': '/home/bond/Work/final_project/pseudopot',
            'outdir': runpath.path,
            'tstress': True,
            'tprnfor': True,
            'disk_io': 'none',
        },
        'SYSTEM': {
            'ecutwfc': ecut,
            'ecutrho': ecut * 10,
            'nspin': 4,
            'starting_magnetization(1)': 0,
            'starting_magnetization(2)': 0,
            'occupations': 'smearing',
            'smearing': 'mp',
            'degauss': 0.02,
            'ntyp': 2,
            'lspinorb': True
        },
        'ELECTRONS': {
            'diagonalization': 'david',
            'mixing_beta': 0.5,
            'conv_thr': 1e-7,
        },
        'IONS': {},
        'CELL': {},
    })

    # Run and parse
    #print(struc)
    #exit(1)
    output_file = run_qe_pwscf(runpath=runpath,
                               struc=struc,
                               pseudopots=pseudopots,
                               params=input_params,
                               kpoints=kpts,
                               ncpu=ncpu)
    output = parse_qe_pwscf_output(outfile=output_file, col=True)
    return output