Ejemplo n.º 1
0
def get_pwscf_sim(type='scf'):
    from nexus_base import nexus_core
    from machines import job
    from pwscf import Pwscf,generate_pwscf

    nexus_core.runs = ''

    sim = None

    if type=='scf':
        sim = generate_pwscf(
            identifier   = 'scf',
            path         = 'scf',
            job          = job(machine='ws1',cores=1),
            input_type   = 'generic',
            calculation  = 'scf',
            input_dft    = 'lda', 
            ecutwfc      = 200,   
            conv_thr     = 1e-8, 
            nosym        = True,
            wf_collect   = True,
            system       = get_system(),
            pseudos      = ['C.BFD.upf'], 
            nogamma      = True,
            )
    else:
        failed()
    #end if

    assert(sim is not None)
    assert(isinstance(sim,Pwscf))

    return sim
Ejemplo n.º 2
0
def test_minimal_init():
    from machines import job
    from pwscf import Pwscf,generate_pwscf

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

    assert(isinstance(sim,Pwscf))

    clear_all_sims()
Ejemplo n.º 3
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
Ejemplo n.º 4
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
Ejemplo n.º 5
0
def standard_qmc(identifier='',
                 scf_kgrid=None,
                 scf_kshift=(1, 1, 1),
                 system=None,
                 pseudos=None,
                 folded_dft=True,
                 functional=None,
                 ecut=200,
                 ecutrho=None,
                 conv_thr=1e-8,
                 mixing_beta=.7,
                 nosym=False,
                 nscf_nosym=True,
                 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',
                 scfdir='scf',
                 nscfdir='nscf',
                 nscfoptdir='nscfopt',
                 optdir='opt',
                 qmcdir='qmc',
                 scfjob=None,
                 nscfjob=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 standard_qmc')
    #end if
    if pseudos is None:
        error('pseudos is a required input to standard_qmc')
    #end if
    if scf_kgrid is None:
        error('scf_kgrid is a required input to standard_qmc')
    #end if

    scfpath = os.path.join(basepath, directory, scfdir)
    dftpseudos, qmcpseudos = sort_pseudos(pseudos)
    sys = system.copy()

    scf = generate_pwscf(identifier='scf',
                         path=scfpath,
                         job=scfjob,
                         input_type='scf',
                         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,
                         kgrid=scf_kgrid,
                         kshift=scf_kshift,
                         wf_collect=False,
                         use_folded=folded_dft)

    if dft_dependencies is None:
        dft_dependencies = []
    else:
        scf.depends(*dft_dependencies)
        dft_dependencies = list(dft_dependencies)
    #end if
    dft_dependencies.append((scf, 'charge_density'))

    sims = basic_qmc(nscf=True,
                     identifier=identifier,
                     system=system,
                     pseudos=pseudos,
                     folded_dft=folded_dft,
                     functional=functional,
                     jastrows=jastrows,
                     meshfactor=meshfactor,
                     det_format=det_format,
                     precision=precision,
                     ecut=ecut,
                     ecutrho=ecutrho,
                     conv_thr=conv_thr,
                     mixing_beta=mixing_beta,
                     nosym=nscf_nosym,
                     hubbard_u=hubbard_u,
                     start_mag=start_mag,
                     kinetic_E=kinetic_E,
                     wfconvert=wfconvert,
                     bconds=bconds,
                     vmc_timestep=vmc_timestep,
                     nonlocalmoves=nonlocalmoves,
                     perform_opt=perform_opt,
                     opt=opt,
                     opt_calcs=opt_calcs,
                     opt_kpoint=opt_kpoint,
                     sample_factor=sample_factor,
                     block_opt=block_opt,
                     skip_submit_opt=skip_submit_opt,
                     qmc_calcs=qmc_calcs,
                     estimators=estimators,
                     corrections=corrections,
                     block_qmc=block_qmc,
                     force_write=force_write,
                     skip_submit_qmc=skip_submit_qmc,
                     basepath=basepath,
                     directory=directory,
                     dftdir=nscfdir,
                     dftoptdir=nscfoptdir,
                     optdir=optdir,
                     qmcdir=qmcdir,
                     scfjob=nscfjob,
                     p2cjob=p2cjob,
                     p2qjob=p2qjob,
                     wfcjob=wfcjob,
                     optjob=optjob,
                     qmcjob=qmcjob,
                     dft_dependencies=dft_dependencies,
                     opt_dependencies=opt_dependencies,
                     remove_cell=remove_cell,
                     return_list=return_list)

    if return_list:
        sims = [scf] + sims
    else:
        if 'scf' in sims:
            sims.nscf = sims.scf
            del sims.scf
        #end if
        if 'scfopt' in sims:
            sims.nscfopt = sims.scfopt
            del sims.scfopt
        #end if
        sims.scf = scf
    #end if

    return sims
Ejemplo n.º 6
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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 9
0
def standard_qmc(identifier      = '',
                 scf_kgrid       = None,
                 scf_kshift      = (1,1,1),
                 system          = None,
                 pseudos         = None,
                 folded_dft      = True,
                 functional      = None,
                 ecut            = 200,
                 ecutrho         = None,
                 conv_thr        = 1e-8,
                 mixing_beta     = .7,
                 nosym           = False,
                 nscf_nosym      = True,
                 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',
                 scfdir          = 'scf',
                 nscfdir         = 'nscf',
                 nscfoptdir      = 'nscfopt',
                 optdir          = 'opt',
                 qmcdir          = 'qmc',
                 scfjob          = None,
                 nscfjob         = 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 standard_qmc')
    #end if
    if pseudos is None:
        error('pseudos is a required input to standard_qmc')
    #end if
    if scf_kgrid is None:
        error('scf_kgrid is a required input to standard_qmc')
    #end if


    scfpath = os.path.join(basepath,directory,scfdir)
    dftpseudos,qmcpseudos = sort_pseudos(pseudos)
    sys = system.copy()    

    scf = generate_pwscf(
        identifier = 'scf',
        path       = scfpath,
        job        = scfjob,
        input_type = 'scf',
        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,
        kgrid      = scf_kgrid,
        kshift     = scf_kshift,
        wf_collect = False,
        use_folded = folded_dft
        )
    

    if dft_dependencies is None:
        dft_dependencies = []
    else:
        scf.depends(*dft_dependencies)
        dft_dependencies = list(dft_dependencies)
    #end if
    dft_dependencies.append((scf,'charge_density'))


    sims = basic_qmc(
        nscf             = True            ,   
        identifier       = identifier      ,   
        system           = system          ,   
        pseudos          = pseudos         ,   
        folded_dft       = folded_dft      ,
        functional       = functional      ,   
        jastrows         = jastrows        ,   
        meshfactor       = meshfactor      ,   
        det_format       = det_format      ,
        precision        = precision       ,
        ecut             = ecut            ,   
        ecutrho          = ecutrho         ,   
        conv_thr         = conv_thr        ,   
        mixing_beta      = mixing_beta     ,   
        nosym            = nscf_nosym      ,    
        hubbard_u        = hubbard_u       ,
        start_mag        = start_mag       ,
        kinetic_E        = kinetic_E       ,
        wfconvert        = wfconvert       ,
        bconds           = bconds          ,
        vmc_timestep     = vmc_timestep    ,
        nonlocalmoves    = nonlocalmoves   ,
        perform_opt      = perform_opt     ,   
        opt              = opt             ,   
        opt_calcs        = opt_calcs       ,   
        opt_kpoint       = opt_kpoint      ,   
        sample_factor    = sample_factor   ,   
        block_opt        = block_opt       ,   
        skip_submit_opt  = skip_submit_opt ,
        qmc_calcs        = qmc_calcs       ,   
        estimators       = estimators      ,
        corrections      = corrections     ,
        block_qmc        = block_qmc       ,   
        force_write      = force_write     ,   
        skip_submit_qmc  = skip_submit_qmc ,   
        basepath         = basepath        ,   
        directory        = directory       ,   
        dftdir           = nscfdir         ,   
        dftoptdir        = nscfoptdir      ,   
        optdir           = optdir          ,   
        qmcdir           = qmcdir          ,   
        scfjob           = nscfjob         ,   
        p2cjob           = p2cjob          ,   
        p2qjob           = p2qjob          ,   
        wfcjob           = wfcjob          ,   
        optjob           = optjob          ,   
        qmcjob           = qmcjob          ,   
        dft_dependencies = dft_dependencies,
        opt_dependencies = opt_dependencies,
        remove_cell      = remove_cell,
        return_list      = return_list         
        )

    if return_list:
        sims = [scf]+sims
    else:
        if 'scf' in sims:
            sims.nscf = sims.scf
            del sims.scf
        #end if
        if 'scfopt' in sims:
            sims.nscfopt = sims.scfopt
            del sims.scfopt
        #end if
        sims.scf = scf
    #end if

    return sims
Ejemplo n.º 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
Ejemplo n.º 11
0
#! /usr/bin/env python
from casino_python import settings, System
from pwscf import generate_pwscf
from analyze_results import results

settings(
    rootdir="./",
    pspdir="./Psps",
    pspname="OPT",
    pspcutoffs="psp.txt",
    #pspcutoffs=280
    machinename="cruller",
)

generic = System(name="Co",
                 structdir="./Structs",
                 source="icsd",
                 supercells=[1, 2, 3, 4],
                 folded=True,
                 real_or_complex='Complex',
                 mindistance=12)

sims = []
scf = generate_pwscf(system=generic, input_dft='lda')

#print generic.structures["radius.1"].kgrid
Ejemplo n.º 12
0
vmc_old = None
for scell in [1, 2]:
    generic = System(name="Li",
                     structdir="./Structs",
                     source="icsd",
                     supercell_size=scell,
                     folded=True,
                     real_or_complex='Complex',
                     mindistance=16
                     #real_or_complex='Real'
                     )
    scf = generate_pwscf(
        system=generic,
        input_dft='lda',
        job=Job(nodes=2,
                time=12,
                name='dft',
                app='/home/apps/espresso-5.0.3/bin/pw.x -pw2casino'))
    psi = pw2casino(dft=scf)
    vmc = generate_casino(dft=scf,
                          psi=psi,
                          qmc='vmc_opt',
                          qmc_prev=None,
                          job=Job(nodes=8, time=12, name='vmc', app='casino'))
    vmc_old = vmc
    dmc = generate_casino(dft=scf,
                          psi=psi,
                          qmc='vmc_dmc',
                          qmc_prev=vmc,
                          job=Job(nodes=80, time=12, name='vmc', app='casino'))