コード例 #1
0
def test_minimal_init():
    from machines import job
    from qmcpack import Qmcpack, generate_qmcpack

    sim = generate_qmcpack(
        job=job(machine='ws1', cores=1),
        system=get_system(),
    )

    assert (isinstance(sim, Qmcpack))

    sim = generate_qmcpack(
        identifier='afqmc',
        job=job(machine='ws1', cores=1),
        input_type='basic_afqmc',
    )

    assert (isinstance(sim, Qmcpack))

    clear_all_sims()
コード例 #2
0
def get_qmcpack_sim(type='rsqmc', **kwargs):
    from machines import job
    from qmcpack import Qmcpack, generate_qmcpack

    if type == 'rsqmc':
        tiling = kwargs.pop('tiling', (1, 1, 1))

        sim = generate_qmcpack(job=job(machine='ws1', cores=1),
                               system=get_system(tiling=tiling),
                               **kwargs)
    elif type == 'afqmc':
        sim = generate_qmcpack(job=job(machine='ws1', cores=1),
                               input_type='basic_afqmc',
                               **kwargs)
    else:
        failed()
    #end if

    assert (isinstance(sim, Qmcpack))

    return sim
コード例 #3
0
ファイル: qmcpack_calculations.py プロジェクト: sbak5/hclib
def twist_averaged_qmc(identifier='',
                       system=None,
                       pseudos=None,
                       functional=None,
                       jastrows='generateJ12',
                       meshfactor=1.0,
                       ecut=200,
                       conv_thr=1e-8,
                       kgrid=None,
                       kshift=None,
                       kinetic_E=True,
                       shared_orb=True,
                       perform_opt=False,
                       opt=None,
                       opt_calcs=None,
                       opt_kpoint=(0, 0, 0),
                       block_opt=False,
                       qmc_calcs=None,
                       force_write=False,
                       block_qmc=False,
                       basepath='',
                       directory='twist_average',
                       dftdir='dft',
                       optdir='opt',
                       qmcdir='qmc',
                       dftjob=None,
                       p2cjob=None,
                       p2qjob=None,
                       wfcjob=None,
                       optjob=None,
                       qmcjob=None):
    error(
        'do not use this function (twist_averaged_qmc) unless you update it!')
    if p2cjob is None:
        p2cjob = Job(cores=1)
    #end if
    if p2qjob is None:
        p2qjob = Job(cores=1)
    #end if
    if wfcjob is None:
        wfcjob = Job(cores=1)
    #end if

    sims = []

    if system is None:
        error('system is a required input to basic_qmc')
    #end if
    if pseudos is None:
        error('pseudos is a required input to basic_qmc')
    #end if
    if identifier != '':
        directory = directory + '_' + identifier
        qmcid = identifier
    else:
        qmcid = 'qmc'
    #end if

    dftpseudos, qmcpseudos = sort_pseudos(pseudos)

    structure = system.structure
    if kgrid != None and kshift != None:
        system = system.copy()
        structure = system.structure
        structure.clear_kpoints()
        structure.add_kmesh(kgrid, kshift)
    #end if
    if shared_orb:
        kpoints = ['shared_orb']
    else:
        kpoints = structure.kpoints
    #end if

    optpath = os.path.join(basepath, directory, optdir)
    qmcpath = os.path.join(basepath, directory, qmcdir)

    if perform_opt and opt is None:
        optsims = optimization(identifier=identifier,
                               system=system,
                               pseudos=pseudos,
                               functional=functional,
                               jastrows=jastrows,
                               meshfactor=meshfactor,
                               ecut=ecut,
                               conv_thr=conv_thr,
                               kinetic_E=kinetic_E,
                               block_qmc=block_opt,
                               force_write=force_write,
                               opt_calcs=opt_calcs,
                               opt_kpoint=opt_kpoint,
                               basepath=os.path.join(basepath, directory),
                               dftjob=dftjob,
                               p2cjob=p2cjob,
                               p2qjob=p2qjob,
                               wfcjob=wfcjob,
                               optjob=optjob)
        opt = optsims[-1]
        sims.extend(optsims)
    #end if

    n = 0
    qmcs = []
    for kpoint in kpoints:
        if shared_orb:
            sys = system
            idext = ''
        else:
            sys = system.copy()
            sys.structure.kpoints = array([kpoint])
            idext = '_' + str(n).zfill(3)
        #end if

        dftpath = os.path.join(basepath, directory, dftdir + idext)

        if sys.folded_system != None:
            dftsys = sys.folded_system
        else:
            dftsys = sys
        #end if

        scf = generate_pwscf(identifier='scf',
                             path=dftpath,
                             job=dftjob,
                             input_type='scf',
                             input_dft=functional,
                             ecut=ecut,
                             conv_thr=conv_thr,
                             pseudos=dftpseudos,
                             system=dftsys)
        p2q = generate_pw2qmcpack(identifier='p2q',
                                  path=dftpath,
                                  job=p2qjob,
                                  write_psir=False)
        wfc = generate_wfconvert(identifier='wfc',
                                 path=dftpath,
                                 job=wfcjob,
                                 spline=False)
        qmc = generate_qmcpack(identifier=qmcid + '_twist' + idext,
                               path=qmcpath,
                               job=qmcjob,
                               block=block_qmc,
                               force_write=force_write,
                               input_type='basic',
                               pseudos=qmcpseudos,
                               system=sys,
                               jastrows=jastrows,
                               meshfactor=meshfactor,
                               calculations=qmc_calcs)

        qmcs.append(qmc)

        p2q.depends(scf, 'orbitals')
        wfc.depends(p2q, 'orbitals')
        qmc.depends(wfc, 'orbitals')
        if opt is not None:
            qmc.depends(opt, 'jastrow')
        #end if
        sims += [scf, p2q, wfc]

        if kinetic_E:
            p2c = generate_pw2casino(identifier='p2c',
                                     path=dftpath,
                                     job=p2cjob)
            p2c.depends(scf, 'orbitals')
            sims.append(p2c)
        #end if

        n += 1
    #end for

    if shared_orb:
        sims.extend(qmcs)
    else:
        taqmc = BundledQmcpack(identifier=identifier,
                               path=qmcpath,
                               job=qmcjob,
                               block=block_qmc,
                               force_write=force_write,
                               app_name='qmcapp_complex',
                               sims=qmcs,
                               system=system)
        sims.append(taqmc)
        for qmc in qmcs:
            qmc.block = True
        #end for
    #end if

    return sims
コード例 #4
0
ファイル: qmcpack_calculations.py プロジェクト: sbak5/hclib
def optimization(identifier='',
                 system=None,
                 pseudos=None,
                 functional=None,
                 jastrows='generateJ12',
                 meshfactor=1.0,
                 ecut=200,
                 conv_thr=1e-8,
                 kinetic_E=True,
                 block_qmc=False,
                 force_write=False,
                 opt_calcs=None,
                 opt_kpoint=None,
                 basepath='',
                 directory='optimization',
                 dftdir='dft',
                 optdir='opt',
                 dftjob=None,
                 p2cjob=None,
                 p2qjob=None,
                 wfcjob=None,
                 optjob=None):
    error('do not use this function (optimization) unless you update it!')
    if p2cjob is None:
        p2cjob = Job(cores=1)
    #end if
    if p2qjob is None:
        p2qjob = Job(cores=1)
    #end if
    if wfcjob is None:
        wfcjob = Job(cores=1)
    #end if
    if system is None:
        error('system is a required input to optimization')
    #end if
    if pseudos is None:
        error('pseudos is a required input to optimization')
    #end if
    if identifier != '':
        directory = directory + '_' + identifier
        qmcid = identifier
    else:
        qmcid = 'qmc'
    #end if

    dftpath = os.path.join(basepath, directory, dftdir)
    optpath = os.path.join(basepath, directory, optdir)

    dftpseudos, qmcpseudos = sort_pseudos(pseudos)

    sys = system.copy()
    if opt_kpoint != None:
        sys.structure.kpoints = array([array(opt_kpoint)])
    #end if
    optjob.set_processes()

    if sys.folded_system != None:
        dftsys = sys.folded_system
    else:
        dftsys = sys
    #end if

    scf = generate_pwscf(identifier='scf',
                         path=dftpath,
                         job=dftjob,
                         input_type='scf',
                         input_dft=functional,
                         ecut=ecut,
                         conv_thr=conv_thr,
                         pseudos=dftpseudos,
                         system=dftsys)
    p2q = generate_pw2qmcpack(identifier='p2q',
                              path=dftpath,
                              job=p2qjob,
                              write_psir=False)
    wfc = generate_wfconvert(identifier='wfc',
                             path=dftpath,
                             job=wfcjob,
                             spline=False)
    opt = generate_qmcpack(identifier='opt',
                           path=optpath,
                           job=optjob,
                           block=block_qmc,
                           force_write=force_write,
                           input_type='opt_jastrow',
                           pseudos=qmcpseudos,
                           system=sys,
                           jastrows=jastrows,
                           meshfactor=meshfactor,
                           opt_calcs=opt_calcs,
                           processes=optjob.processes,
                           threads=optjob.threads)
    p2q.depends(scf, 'orbitals')
    wfc.depends(p2q, 'orbitals')
    opt.depends(wfc, 'orbitals')

    if kinetic_E:
        p2c = generate_pw2casino(identifier='p2c', path=dftpath, job=p2cjob)
        p2c.depends(scf, 'orbitals')
        sims = [scf, p2c, p2q, wfc, opt]
    else:
        sims = [scf, p2q, wfc, opt]
    #end if

    return sims
コード例 #5
0
ファイル: qmcpack_calculations.py プロジェクト: sbak5/hclib
def sqd_qmc(identifier='',
            system=None,
            filling=None,
            updown=None,
            down=None,
            up=None,
            grid_type='log',
            ri=1e-6,
            rf=400,
            npts=10001,
            max_iter=1000,
            etot_tol=1e-8,
            eig_tol=1e-12,
            mix_ratio=0.7,
            jastrows='generateJ12',
            sqd_jastrow=True,
            sqd_jastrow_qmc=False,
            vmc_timestep=0.5,
            perform_opt=False,
            opt=None,
            opt_calcs=None,
            sample_factor=1.0,
            block_opt=False,
            skip_submit_opt=False,
            qmc_calcs=None,
            estimators=None,
            block_qmc=False,
            force_write=False,
            skip_submit_qmc=False,
            basepath='',
            directory='qmc_sqd',
            hfdir='hf',
            optdir='opt',
            qmcdir='qmc',
            hfjob=None,
            optjob=None,
            qmcjob=None,
            opt_dependencies=None,
            return_list=True):
    if system is None:
        error('system is a required input to sqd_qmc')
    #end if
    if identifier != '':
        directory = directory + '_' + identifier
        qmcid = identifier
    else:
        qmcid = 'qmc'
    #end if
    hfid = 'hf'

    hfpath = os.path.join(basepath, directory, hfdir)
    optpath = os.path.join(basepath, directory, optdir)
    qmcpath = os.path.join(basepath, directory, qmcdir)

    sys = system.copy()

    #add vmc timestep and nonlocalmoves to qmc_calcs, if requested
    if qmc_calcs != None and vmc_timestep != None:
        for calc in qmc_calcs:
            if isinstance(calc, loop):
                calc = calc.qmc
            #end if
            if isinstance(calc, vmc) or isinstance(calc, linear) or isinstance(
                    calc, cslinear) and not 'timestep' in calc:
                calc.timestep = vmc_timestep
            #end if
        #end for
    #end if

    hf = generate_sqd(identifier=hfid,
                      path=hfpath,
                      job=hfjob,
                      system=sys,
                      filling=filling,
                      updown=updown,
                      up=up,
                      down=down,
                      grid_type=grid_type,
                      ri=ri,
                      rf=rf,
                      npts=npts,
                      max_iter=max_iter,
                      etot_tol=etot_tol,
                      eig_tol=eig_tol,
                      mix_ratio=mix_ratio)
    qmc = generate_qmcpack(identifier=qmcid,
                           path=qmcpath,
                           job=qmcjob,
                           block=block_qmc,
                           force_write=force_write,
                           skip_submit=skip_submit_qmc,
                           input_type='basic',
                           system=sys,
                           jastrows=jastrows,
                           estimators=estimators,
                           calculations=qmc_calcs)
    qmc.depends(hf, 'orbitals')
    if sqd_jastrow_qmc:
        qmc.depends(hf, 'jastrow')
    #end if

    sims = obj(hf=hf, qmc=qmc)

    if perform_opt:
        opt_sys = sys
        optjob.set_processes()
        opt = generate_qmcpack(identifier='opt',
                               path=optpath,
                               job=optjob,
                               block=block_opt,
                               skip_submit=skip_submit_opt,
                               force_write=force_write,
                               input_type='opt_jastrow',
                               system=opt_sys,
                               jastrows=jastrows,
                               timestep=vmc_timestep,
                               sample_factor=sample_factor,
                               opt_calcs=opt_calcs,
                               processes=optjob.processes,
                               threads=optjob.threads)
    #end if
    if opt is not None:
        if sqd_jastrow:
            opt.depends(hf, 'jastrow')
        #end if
        opt.depends(hf, 'orbitals')
        if opt_dependencies != None:
            opt.depends(*opt_dependencies)
        #end if
        sims.opt = opt
        qmc.depends(opt, 'jastrow')
    #end if

    if return_list:
        order = ['hf', 'opt', 'qmc']
        simlist = []
        for simid in order:
            if simid in sims:
                simlist.append(sims[simid])
                del sims[simid]
            #end if
        #end for
        return simlist
    else:
        return sims
コード例 #6
0
ファイル: qmcpack_calculations.py プロジェクト: sbak5/hclib
def basic_qmc(identifier='',
              system=None,
              pseudos=None,
              functional=None,
              folded_dft=True,
              ecut=200,
              ecutrho=None,
              conv_thr=1e-8,
              mixing_beta=.7,
              nosym=True,
              nscf=False,
              hubbard_u=None,
              start_mag=None,
              kinetic_E=False,
              wfconvert=False,
              bconds=None,
              jastrows='generateJ12',
              meshfactor=1.0,
              det_format='new',
              precision='float',
              vmc_timestep=None,
              nonlocalmoves=None,
              perform_opt=False,
              opt=None,
              opt_calcs=None,
              opt_kpoint=None,
              sample_factor=1.0,
              block_opt=False,
              skip_submit_opt=False,
              qmc_calcs=None,
              estimators=None,
              corrections=None,
              block_qmc=False,
              force_write=False,
              skip_submit_qmc=False,
              basepath='',
              directory='qmc_calc',
              dftdir='scf',
              dftoptdir='scfopt',
              optdir='opt',
              qmcdir='qmc',
              scfjob=None,
              p2cjob=None,
              p2qjob=None,
              wfcjob=None,
              optjob=None,
              qmcjob=None,
              dft_dependencies=None,
              opt_dependencies=None,
              remove_cell=False,
              return_list=True):

    if p2cjob is None:
        p2cjob = Job(cores=1)
    #end if
    if p2qjob is None:
        p2qjob = Job(cores=1)
    #end if
    if wfcjob is None:
        wfcjob = Job(cores=1)
    #end if
    if system is None:
        error('system is a required input to basic_qmc')
    #end if
    if pseudos is None:
        error('pseudos is a required input to basic_qmc')
    #end if
    if identifier != '':
        directory = directory + '_' + identifier
        qmcid = identifier
    else:
        qmcid = 'qmc'
    #end if

    dftpath = os.path.join(basepath, directory, dftdir)
    dftoptpath = os.path.join(basepath, directory, dftoptdir)
    optpath = os.path.join(basepath, directory, optdir)
    qmcpath = os.path.join(basepath, directory, qmcdir)

    dftpseudos, qmcpseudos = sort_pseudos(pseudos)

    sys = system.copy()

    structdep = None
    if dft_dependencies != None:
        for dep in dft_dependencies:
            if dep[1] == 'structure':
                structdep = dep
            #end if
        #end for
    #end if

    #add vmc timestep and nonlocalmoves to qmc_calcs, if requested
    if qmc_calcs != None:
        for calc in qmc_calcs:
            if isinstance(calc, loop):
                calc = calc.qmc
            #end if
            if isinstance(calc, vmc) or isinstance(calc, linear) or isinstance(
                    calc, cslinear):
                if vmc_timestep != None and not 'timestep' in calc:
                    calc.timestep = vmc_timestep
                #end if
                if nonlocalmoves != None:
                    calc.nonlocalpp = nonlocalmoves
                #end if
            elif isinstance(calc, dmc):
                if nonlocalmoves != None:
                    calc.nonlocalmoves = nonlocalmoves
                #end if
            #end if
        #end for
    #end if

    if not nscf:
        scf_id = 'scf'
        scf_it = 'scf'
    else:
        scf_id = 'nscf'
        scf_it = 'nscf'
    #end if

    scf = generate_pwscf(identifier=scf_id,
                         path=dftpath,
                         job=scfjob,
                         input_type=scf_it,
                         input_dft=functional,
                         ecut=ecut,
                         ecutrho=ecutrho,
                         conv_thr=conv_thr,
                         mixing_beta=mixing_beta,
                         nosym=nosym,
                         hubbard_u=hubbard_u,
                         start_mag=start_mag,
                         pseudos=dftpseudos,
                         system=sys,
                         use_folded=folded_dft)
    p2q = generate_pw2qmcpack(identifier='p2q',
                              path=dftpath,
                              job=p2qjob,
                              write_psir=False)
    if wfconvert:
        wfc = generate_wfconvert(identifier='wfc',
                                 path=dftpath,
                                 job=wfcjob,
                                 spline=False)
    #end if
    qmc = generate_qmcpack(identifier=qmcid,
                           path=qmcpath,
                           job=qmcjob,
                           block=block_qmc,
                           force_write=force_write,
                           skip_submit=skip_submit_qmc,
                           input_type='basic',
                           pseudos=qmcpseudos,
                           system=sys,
                           bconds=bconds,
                           remove_cell=remove_cell,
                           jastrows=jastrows,
                           meshfactor=meshfactor,
                           det_format=det_format,
                           precision=precision,
                           estimators=estimators,
                           corrections=corrections,
                           calculations=qmc_calcs)

    sims = obj(scf=scf, p2q=p2q, qmc=qmc)

    if dft_dependencies != None:
        scf.depends(*dft_dependencies)
    #end if
    p2q.depends(scf, 'orbitals')
    if wfconvert:
        sims.wfc = wfc
        wfc.depends(p2q, 'orbitals')
        qmc.depends(wfc, 'orbitals')
    else:
        qmc.depends(p2q, 'orbitals')
    #end if

    if structdep != None:
        qmc.depends(structdep)
    #end if
    if not perform_opt and opt is None and opt_dependencies != None:
        qmc.depends(*opt_dependencies)
    #end if

    if perform_opt:
        if wfconvert:
            orbdep = wfc
        else:
            orbdep = p2q
        #end if
        opt_sys = sys
        if opt_kpoint != None:
            kaxes = opt_sys.structure.kaxes.copy()

            k = generate_kpoint(opt_kpoint, kaxes, grids=not nscf)

            opt_kgrid = k.kgrid
            opt_kshift = k.kshift
            dftopt_kshift = k.dft_kgrid
            dftopt_kgrid = k.dft_kshift

            opt_sys = opt_sys.copy()
            opt_sys.structure.clear_kpoints()
            opt_sys.structure.add_kpoints([k.kpoint], [1.0])

            scfopt = generate_pwscf(identifier=scf_id,
                                    path=dftoptpath,
                                    job=scfjob,
                                    input_type=scf_it,
                                    input_dft=functional,
                                    ecut=ecut,
                                    conv_thr=conv_thr,
                                    nosym=nosym,
                                    hubbard_u=hubbard_u,
                                    start_mag=start_mag,
                                    pseudos=dftpseudos,
                                    system=opt_sys,
                                    kgrid=dftopt_kgrid,
                                    kshift=dftopt_kshift)
            p2qopt = generate_pw2qmcpack(identifier='p2q',
                                         path=dftoptpath,
                                         job=p2qjob,
                                         write_psir=False)
            if wfconvert:
                wfcopt = generate_wfconvert(identifier='wfc',
                                            path=dftoptpath,
                                            job=wfcjob,
                                            spline=False)
            #end if
            if dft_dependencies != None:
                scfopt.depends(*dft_dependencies)
            #end if
            p2qopt.depends(scfopt, 'orbitals')
            sims.set(scfopt=scfopt, p2qopt=p2qopt)
            if wfconvert:
                sims.wfcopt = wfcopt
                wfcopt.depends(p2qopt, 'orbitals')
                orbdep = wfcopt
            else:
                orbdep = p2qopt
            #end if
        #end if
        optjob.set_processes()
        opt = generate_qmcpack(identifier='opt',
                               path=optpath,
                               job=optjob,
                               block=block_opt,
                               skip_submit=skip_submit_opt,
                               force_write=force_write,
                               input_type='opt_jastrow',
                               pseudos=qmcpseudos,
                               system=opt_sys,
                               bconds=bconds,
                               remove_cell=remove_cell,
                               jastrows=jastrows,
                               meshfactor=meshfactor,
                               det_format=det_format,
                               precision=precision,
                               timestep=vmc_timestep,
                               nonlocalpp=nonlocalmoves,
                               corrections=[],
                               sample_factor=sample_factor,
                               opt_calcs=opt_calcs,
                               processes=optjob.processes,
                               threads=optjob.threads)
        opt.depends(orbdep, 'orbitals')
        if structdep != None:
            opt.depends(structdep)
        #end if
        if opt_dependencies != None:
            opt.depends(*opt_dependencies)
        #end if
        if kinetic_E and opt_kpoint != None:
            p2copt = generate_pw2casino(identifier='p2c',
                                        path=dftoptpath,
                                        job=p2cjob)
            p2copt.depends(scfopt, 'orbitals')
            sims.p2copt = p2copt
        #end if
    #end if
    if opt is not None:
        sims.opt = opt
        qmc.depends(opt, 'jastrow')
    #end if

    if kinetic_E:
        p2c = generate_pw2casino(identifier='p2c', path=dftpath, job=p2cjob)
        p2c.depends(scf, 'orbitals')
        sims.p2c = p2c
    #end if

    if return_list:
        order = [
            'scfopt', 'p2copt', 'p2qopt', 'wfcopt', 'opt', 'scf', 'p2c', 'p2q',
            'wfc', 'qmc'
        ]
        simlist = []
        for simid in order:
            if simid in sims:
                simlist.append(sims[simid])
                del sims[simid]
            #end if
        #end for
        return simlist
    else:
        return sims
コード例 #7
0
def twist_averaged_qmc(identifier = '',
                       system     = None,
                       pseudos    = None,
                       functional = None,
                       jastrows   = 'generateJ12',
                       meshfactor = 1.0,
                       ecut       = 200,
                       conv_thr   = 1e-8,
                       kgrid      = None,
                       kshift     = None,
                       kinetic_E  = True,
                       shared_orb = True,
                       perform_opt= False,
                       opt        = None,
                       opt_calcs  = None,
                       opt_kpoint = (0,0,0),
                       block_opt  = False,
                       qmc_calcs  = None,
                       force_write= False,
                       block_qmc  = False,
                       basepath   = '',
                       directory  = 'twist_average',
                       dftdir     = 'dft',
                       optdir     = 'opt',
                       qmcdir     = 'qmc',
                       dftjob     = None,
                       p2cjob     = None,
                       p2qjob     = None,
                       wfcjob     = None,
                       optjob     = None,
                       qmcjob     = None):
    error('do not use this function (twist_averaged_qmc) unless you update it!')
    if p2cjob is None:
        p2cjob = Job(cores=1)
    #end if
    if p2qjob is None:
        p2qjob = Job(cores=1)
    #end if
    if wfcjob is None:
        wfcjob = Job(cores=1)
    #end if

    sims = []
    
    if system is None:
        error('system is a required input to basic_qmc')
    #end if
    if pseudos is None:
        error('pseudos is a required input to basic_qmc')
    #end if
    if identifier!='':
        directory = directory+'_'+identifier
        qmcid = identifier
    else:
        qmcid = 'qmc'
    #end if

    dftpseudos,qmcpseudos = sort_pseudos(pseudos)

    structure = system.structure
    if kgrid!=None and kshift!=None:
        system = system.copy()
        structure = system.structure
        structure.clear_kpoints()
        structure.add_kmesh(kgrid,kshift)
    #end if
    if shared_orb:
        kpoints = ['shared_orb']
    else:
        kpoints = structure.kpoints
    #end if

    optpath = os.path.join(basepath,directory,optdir)
    qmcpath = os.path.join(basepath,directory,qmcdir)

    if perform_opt and opt is None:
        optsims = optimization(
            identifier = identifier,
            system     = system,
            pseudos    = pseudos,
            functional = functional,
            jastrows   = jastrows,
            meshfactor = meshfactor,
            ecut       = ecut,
            conv_thr   = conv_thr,
            kinetic_E  = kinetic_E,
            block_qmc  = block_opt,
            force_write= force_write,
            opt_calcs  = opt_calcs,
            opt_kpoint = opt_kpoint,
            basepath   = os.path.join(basepath,directory),
            dftjob     = dftjob,
            p2cjob     = p2cjob,
            p2qjob     = p2qjob,
            wfcjob     = wfcjob,
            optjob     = optjob       
            )
        opt = optsims[-1]
        sims.extend(optsims)
    #end if

    n=0
    qmcs = []
    for kpoint in kpoints:
        if shared_orb:
            sys = system
            idext = ''
        else:
            sys = system.copy()
            sys.structure.kpoints = array([kpoint])
            idext = '_'+str(n).zfill(3)
        #end if

        dftpath = os.path.join(basepath,directory,dftdir+idext)

        if sys.folded_system!=None:
            dftsys = sys.folded_system
        else:
            dftsys = sys
        #end if


        scf = generate_pwscf(
            identifier = 'scf',
            path       = dftpath,
            job        = dftjob,
            input_type = 'scf',
            input_dft  = functional,
            ecut       = ecut,
            conv_thr   = conv_thr,
            pseudos    = dftpseudos,
            system     = dftsys
            )
        p2q = generate_pw2qmcpack(
            identifier = 'p2q',
            path       = dftpath,
            job        = p2qjob,
            write_psir = False
            )
        wfc = generate_wfconvert(
            identifier = 'wfc',
            path       = dftpath,
            job        = wfcjob,
            spline     = False
            )
        qmc = generate_qmcpack(
            identifier = qmcid+'_twist'+idext,
            path       = qmcpath,
            job        = qmcjob,
            block      = block_qmc,
            force_write= force_write,
            input_type = 'basic',
            pseudos    = qmcpseudos,
            system     = sys,
            jastrows   = jastrows,
            meshfactor = meshfactor,
            calculations = qmc_calcs
            )
        
        qmcs.append(qmc)

        p2q.depends(scf,'orbitals')
        wfc.depends(p2q,'orbitals')
        qmc.depends(wfc,'orbitals')
        if opt is not None:
            qmc.depends(opt,'jastrow')
        #end if
        sims += [scf,p2q,wfc]

        if kinetic_E:
            p2c = generate_pw2casino(
                identifier = 'p2c',
                path       = dftpath,
                job        = p2cjob
                )
            p2c.depends(scf,'orbitals')
            sims.append(p2c)
        #end if

        n+=1
    #end for

    if shared_orb:
        sims.extend(qmcs)
    else:
        taqmc = BundledQmcpack(
            identifier = identifier,
            path       = qmcpath,
            job        = qmcjob,
            block      = block_qmc,
            force_write= force_write,
            app_name   = 'qmcapp_complex',
            sims       = qmcs,
            system     = system
        )        
        sims.append(taqmc)
        for qmc in qmcs:
            qmc.block = True
        #end for
    #end if

    return sims
コード例 #8
0
def optimization(identifier = '',
                 system     = None,
                 pseudos    = None,
                 functional = None,
                 jastrows   = 'generateJ12',
                 meshfactor = 1.0,
                 ecut       = 200,
                 conv_thr   = 1e-8,
                 kinetic_E  = True,
                 block_qmc  = False,
                 force_write= False,
                 opt_calcs  = None,
                 opt_kpoint = None,
                 basepath   = '',
                 directory  = 'optimization',
                 dftdir     = 'dft',
                 optdir     = 'opt',
                 dftjob     = None,
                 p2cjob     = None,
                 p2qjob     = None,
                 wfcjob     = None,
                 optjob     = None):
    error('do not use this function (optimization) unless you update it!')
    if p2cjob is None:
        p2cjob = Job(cores=1)
    #end if
    if p2qjob is None:
        p2qjob = Job(cores=1)
    #end if
    if wfcjob is None:
        wfcjob = Job(cores=1)
    #end if
    if system is None:
        error('system is a required input to optimization')
    #end if
    if pseudos is None:
        error('pseudos is a required input to optimization')
    #end if
    if identifier!='':
        directory = directory+'_'+identifier
        qmcid = identifier
    else:
        qmcid = 'qmc'
    #end if

    dftpath = os.path.join(basepath,directory,dftdir)
    optpath = os.path.join(basepath,directory,optdir)

    dftpseudos,qmcpseudos = sort_pseudos(pseudos)

    sys = system.copy()
    if opt_kpoint!=None:
        sys.structure.kpoints = array([array(opt_kpoint)])
    #end if
    optjob.set_processes()

    if sys.folded_system!=None:
        dftsys = sys.folded_system
    else:
        dftsys = sys
    #end if

    scf = generate_pwscf(
        identifier = 'scf',
        path       = dftpath,
        job        = dftjob,
        input_type = 'scf',
        input_dft  = functional,
        ecut       = ecut,
        conv_thr   = conv_thr,
        pseudos    = dftpseudos,
        system     = dftsys
        )
    p2q = generate_pw2qmcpack(
        identifier = 'p2q',
        path       = dftpath,
        job        = p2qjob,
        write_psir = False
        )
    wfc = generate_wfconvert(
        identifier = 'wfc',
        path       = dftpath,
        job        = wfcjob,
        spline     = False
        )
    opt = generate_qmcpack(
        identifier = 'opt',
        path       = optpath,
        job        = optjob,
        block      = block_qmc,
        force_write= force_write,
        input_type = 'opt_jastrow',
        pseudos    = qmcpseudos,
        system     = sys,
        jastrows   = jastrows,
        meshfactor = meshfactor,
        opt_calcs  = opt_calcs,
        processes  = optjob.processes,
        threads    = optjob.threads
        )
    p2q.depends(scf,'orbitals')
    wfc.depends(p2q,'orbitals')
    opt.depends(wfc,'orbitals')

    if kinetic_E:
        p2c = generate_pw2casino(
            identifier = 'p2c',
            path       = dftpath,
            job        = p2cjob
            )
        p2c.depends(scf,'orbitals')
        sims = [scf,p2c,p2q,wfc,opt]        
    else:
        sims = [scf,p2q,wfc,opt]
    #end if

    return sims
コード例 #9
0
def sqd_qmc(identifier       = '',
            system           = None,
            filling          = None,
            updown           = None,
            down             = None,
            up               = None,
            grid_type        = 'log',
            ri               = 1e-6,
            rf               = 400,
            npts             = 10001,
            max_iter         = 1000,
            etot_tol         = 1e-8,
            eig_tol          = 1e-12,
            mix_ratio        = 0.7,            
            jastrows         = 'generateJ12',
            sqd_jastrow      = True,
            sqd_jastrow_qmc  = False,
            vmc_timestep     = 0.5,
            perform_opt      = False,
            opt              = None,
            opt_calcs        = None,
            sample_factor    = 1.0,
            block_opt        = False,
            skip_submit_opt  = False,
            qmc_calcs        = None,
            estimators       = None,
            block_qmc        = False,
            force_write      = False,
            skip_submit_qmc  = False,
            basepath         = '',
            directory        = 'qmc_sqd',
            hfdir            = 'hf',
            optdir           = 'opt',
            qmcdir           = 'qmc',
            hfjob            = None,
            optjob           = None,
            qmcjob           = None,
            opt_dependencies = None,
            return_list      = True):
    if system is None:
        error('system is a required input to sqd_qmc')
    #end if
    if identifier!='':
        directory = directory+'_'+identifier
        qmcid = identifier
    else:
        qmcid = 'qmc'
    #end if
    hfid = 'hf'

    hfpath = os.path.join(basepath,directory,hfdir)
    optpath = os.path.join(basepath,directory,optdir)
    qmcpath = os.path.join(basepath,directory,qmcdir)

    sys = system.copy()


    #add vmc timestep and nonlocalmoves to qmc_calcs, if requested
    if qmc_calcs!=None and vmc_timestep!=None:
        for calc in qmc_calcs:
            if isinstance(calc,loop):
                calc = calc.qmc
            #end if
            if isinstance(calc,vmc) or isinstance(calc,linear) or isinstance(calc,cslinear) and not 'timestep' in calc:
                calc.timestep = vmc_timestep
            #end if
        #end for
    #end if



    hf = generate_sqd(
        identifier = hfid,
        path       = hfpath,
        job        = hfjob,
        system     = sys,
        filling    = filling,
        updown     = updown,
        up         = up,
        down       = down,
        grid_type  = grid_type  ,
        ri         = ri         ,
        rf         = rf         ,
        npts       = npts       ,
        max_iter   = max_iter   ,
        etot_tol   = etot_tol   ,
        eig_tol    = eig_tol    ,
        mix_ratio  = mix_ratio  
        )
    qmc = generate_qmcpack(
        identifier = qmcid,
        path       = qmcpath,
        job        = qmcjob,
        block      = block_qmc,
        force_write= force_write,
        skip_submit= skip_submit_qmc,
        input_type = 'basic',
        system     = sys,
        jastrows   = jastrows,
        estimators = estimators,
        calculations = qmc_calcs
        )
    qmc.depends(hf,'orbitals')
    if sqd_jastrow_qmc:
        qmc.depends(hf,'jastrow')
    #end if

    sims = obj(
        hf = hf,
        qmc = qmc
        )

    if perform_opt:
        opt_sys = sys
        optjob.set_processes()
        opt = generate_qmcpack(
            identifier = 'opt',
            path       = optpath,
            job        = optjob,
            block      = block_opt,
            skip_submit= skip_submit_opt,
            force_write= force_write,
            input_type = 'opt_jastrow',
            system     = opt_sys,
            jastrows   = jastrows,
            timestep   = vmc_timestep,
            sample_factor = sample_factor,
            opt_calcs  = opt_calcs,
            processes  = optjob.processes,
            threads    = optjob.threads
            )
    #end if
    if opt is not None:
        if sqd_jastrow:
            opt.depends(hf,'jastrow')
        #end if
        opt.depends(hf,'orbitals')
        if opt_dependencies!=None:
            opt.depends(*opt_dependencies)
        #end if
        sims.opt = opt
        qmc.depends(opt,'jastrow')
    #end if

    if return_list:
        order = ['hf','opt','qmc']
        simlist = []
        for simid in order:
            if simid in sims:
                simlist.append(sims[simid])
                del sims[simid]
            #end if
        #end for
        return simlist
    else:
        return sims
コード例 #10
0
def basic_qmc(identifier       = '',
              system           = None,
              pseudos          = None,
              functional       = None,
              folded_dft       = True,
              ecut             = 200,
              ecutrho          = None,
              conv_thr         = 1e-8,
              mixing_beta      = .7,
              nosym            = True,
              nscf             = False,
              hubbard_u        = None,
              start_mag        = None,
              kinetic_E        = False, 
              wfconvert        = False,
              bconds           = None,
              jastrows         = 'generateJ12',
              meshfactor       = 1.0,
              det_format       = 'new',
              precision        = 'float',
              vmc_timestep     = None,
              nonlocalmoves    = None,
              perform_opt      = False,
              opt              = None,
              opt_calcs        = None,
              opt_kpoint       = None,
              sample_factor    = 1.0,
              block_opt        = False,
              skip_submit_opt  = False,
              qmc_calcs        = None,
              estimators       = None,
              corrections      = None,
              block_qmc        = False,
              force_write      = False,
              skip_submit_qmc  = False,
              basepath         = '',
              directory        = 'qmc_calc',
              dftdir           = 'scf',
              dftoptdir        = 'scfopt',
              optdir           = 'opt',
              qmcdir           = 'qmc',
              scfjob           = None,
              p2cjob           = None,
              p2qjob           = None,
              wfcjob           = None,
              optjob           = None,
              qmcjob           = None,
              dft_dependencies = None,
              opt_dependencies = None,
              remove_cell      = False,
              return_list      = True):

    if p2cjob is None:
        p2cjob = Job(cores=1)
    #end if
    if p2qjob is None:
        p2qjob = Job(cores=1)
    #end if
    if wfcjob is None:
        wfcjob = Job(cores=1)
    #end if
    if system is None:
        error('system is a required input to basic_qmc')
    #end if
    if pseudos is None:
        error('pseudos is a required input to basic_qmc')
    #end if
    if identifier!='':
        directory = directory+'_'+identifier
        qmcid = identifier
    else:
        qmcid = 'qmc'
    #end if

    dftpath = os.path.join(basepath,directory,dftdir)
    dftoptpath = os.path.join(basepath,directory,dftoptdir)
    optpath = os.path.join(basepath,directory,optdir)
    qmcpath = os.path.join(basepath,directory,qmcdir)

    dftpseudos,qmcpseudos = sort_pseudos(pseudos)

    sys = system.copy()

    structdep = None
    if dft_dependencies!=None:
        for dep in dft_dependencies:
            if dep[1]=='structure':
                structdep = dep
            #end if
        #end for
    #end if

    #add vmc timestep and nonlocalmoves to qmc_calcs, if requested
    if qmc_calcs!=None:
        for calc in qmc_calcs:
            if isinstance(calc,loop):
                calc = calc.qmc
            #end if
            if isinstance(calc,vmc) or isinstance(calc,linear) or isinstance(calc,cslinear):
                if vmc_timestep!=None and not 'timestep' in calc:
                    calc.timestep = vmc_timestep
                #end if
                if nonlocalmoves!=None:
                    calc.nonlocalpp = nonlocalmoves
                #end if
            elif isinstance(calc,dmc):
                if nonlocalmoves!=None:
                    calc.nonlocalmoves = nonlocalmoves
                #end if
            #end if
        #end for
    #end if

                
    if not nscf:
        scf_id = 'scf'
        scf_it = 'scf'
    else:
        scf_id = 'nscf'
        scf_it = 'nscf'
    #end if

    scf = generate_pwscf(
        identifier   = scf_id,
        path         = dftpath,
        job          = scfjob,
        input_type   = scf_it,
        input_dft    = functional,
        ecut         = ecut,
        ecutrho      = ecutrho,
        conv_thr     = conv_thr,
        mixing_beta  = mixing_beta,
        nosym        = nosym,
        hubbard_u    = hubbard_u,
        start_mag    = start_mag,
        pseudos      = dftpseudos,
        system       = sys,
        use_folded   = folded_dft
        )
    p2q = generate_pw2qmcpack(
        identifier   = 'p2q',
        path         = dftpath,
        job          = p2qjob,
        write_psir   = False
        )
    if wfconvert:
        wfc = generate_wfconvert(
            identifier   = 'wfc',
            path         = dftpath,
            job          = wfcjob,
            spline       = False
            )
    #end if
    qmc = generate_qmcpack(
        identifier   = qmcid,
        path         = qmcpath,
        job          = qmcjob,
        block        = block_qmc,
        force_write  = force_write,
        skip_submit  = skip_submit_qmc,
        input_type   = 'basic',
        pseudos      = qmcpseudos,
        system       = sys,
        bconds       = bconds,
        remove_cell  = remove_cell,
        jastrows     = jastrows,
        meshfactor   = meshfactor,
        det_format   = det_format,
        precision    = precision,
        estimators   = estimators,
        corrections  = corrections,
        calculations = qmc_calcs
        )

    sims = obj(
        scf = scf,
        p2q = p2q,
        qmc = qmc
        )

    if dft_dependencies!=None:
        scf.depends(*dft_dependencies)
    #end if
    p2q.depends(scf,'orbitals')
    if wfconvert:
        sims.wfc = wfc
        wfc.depends(p2q,'orbitals')
        qmc.depends(wfc,'orbitals')
    else:
        qmc.depends(p2q,'orbitals')
    #end if

    if structdep!=None:
        qmc.depends(structdep)
    #end if
    if not perform_opt and opt is None and opt_dependencies!=None:
        qmc.depends(*opt_dependencies)
    #end if

    if perform_opt:
        if wfconvert:
            orbdep = wfc
        else:
            orbdep = p2q
        #end if
        opt_sys = sys
        if opt_kpoint!=None:
            kaxes = opt_sys.structure.kaxes.copy()

            k = generate_kpoint(opt_kpoint,kaxes,grids=not nscf)

            opt_kgrid     = k.kgrid
            opt_kshift    = k.kshift
            dftopt_kshift = k.dft_kgrid
            dftopt_kgrid  = k.dft_kshift

            opt_sys = opt_sys.copy()
            opt_sys.structure.clear_kpoints()
            opt_sys.structure.add_kpoints([k.kpoint],[1.0])

            scfopt = generate_pwscf(
                identifier = scf_id,
                path       = dftoptpath,
                job        = scfjob,
                input_type = scf_it,
                input_dft  = functional,
                ecut       = ecut,
                conv_thr   = conv_thr,
                nosym      = nosym,
                hubbard_u  = hubbard_u,
                start_mag  = start_mag,
                pseudos    = dftpseudos,
                system     = opt_sys,
                kgrid      = dftopt_kgrid,
                kshift     = dftopt_kshift
                )
            p2qopt = generate_pw2qmcpack(
                identifier = 'p2q',
                path       = dftoptpath,
                job        = p2qjob,
                write_psir = False
                )
            if wfconvert:
                wfcopt = generate_wfconvert(
                    identifier = 'wfc',
                    path       = dftoptpath,
                    job        = wfcjob,
                    spline     = False
                    )
            #end if
            if dft_dependencies!=None:
                scfopt.depends(*dft_dependencies)
            #end if
            p2qopt.depends(scfopt,'orbitals')
            sims.set(
                scfopt = scfopt,
                p2qopt = p2qopt
                )
            if wfconvert:
                sims.wfcopt = wfcopt
                wfcopt.depends(p2qopt,'orbitals')
                orbdep = wfcopt
            else:
                orbdep = p2qopt
            #end if
        #end if
        optjob.set_processes()
        opt = generate_qmcpack(
            identifier = 'opt',
            path       = optpath,
            job        = optjob,
            block      = block_opt,
            skip_submit= skip_submit_opt,
            force_write= force_write,
            input_type = 'opt_jastrow',
            pseudos    = qmcpseudos,
            system     = opt_sys,
            bconds     = bconds,
            remove_cell= remove_cell,
            jastrows   = jastrows,
            meshfactor = meshfactor,
            det_format = det_format,
            precision  = precision,
            timestep   = vmc_timestep,
            nonlocalpp = nonlocalmoves,
            corrections= [],
            sample_factor = sample_factor,
            opt_calcs  = opt_calcs,
            processes  = optjob.processes,
            threads    = optjob.threads
            )
        opt.depends(orbdep,'orbitals')
        if structdep!=None:
            opt.depends(structdep)
        #end if
        if opt_dependencies!=None:
            opt.depends(*opt_dependencies)
        #end if
        if kinetic_E and opt_kpoint!=None:
            p2copt = generate_pw2casino(
                identifier = 'p2c',
                path       = dftoptpath,
                job        = p2cjob
                )
            p2copt.depends(scfopt,'orbitals')
            sims.p2copt = p2copt
        #end if
    #end if
    if opt is not None:
        sims.opt = opt
        qmc.depends(opt,'jastrow')
    #end if

    if kinetic_E:
        p2c = generate_pw2casino(
            identifier = 'p2c',
            path       = dftpath,
            job        = p2cjob
            )
        p2c.depends(scf,'orbitals')
        sims.p2c = p2c
    #end if

    if return_list:
        order = ['scfopt','p2copt','p2qopt','wfcopt','opt','scf','p2c','p2q','wfc','qmc']
        simlist = []
        for simid in order:
            if simid in sims:
                simlist.append(sims[simid])
                del sims[simid]
            #end if
        #end for
        return simlist
    else:
        return sims