예제 #1
0
파일: bundle.py 프로젝트: jyamu/qmc
 def bundle_jobs(self):
     jobs = []
     time = Job.zero_time()
     cores = 0
     threads = self.sims[0].job.threads
     same_threads = True
     machine_names = set()
     for sim in self.sims:
         job = sim.job
         cores += job.cores
         same_threads = same_threads and threads == job.threads
         time = job.max_time(time)
         machine = job.get_machine()
         machine_names.add(machine.name)
         jobs.append(job)
     #end for
     if not same_threads:
         self.error(
             'bundling jobs with different numbers of threads is not yet supported'
         )
     #end if
     machine_names = list(machine_names)
     if len(machine_names) != 1:
         self.error('attempted to bundle jobs across these machines: ' +
                    str(machine_names) +
                    '\n  jobs may only be bundled on the same machine')
     #end if
     self.job = Job(bundled_jobs=jobs,
                    cores=cores,
                    threads=threads,
                    machine=machine_names[0],
                    **time)
예제 #2
0
 def process_machine_settings(self,mset):
     Job.restore_default_settings()
     ProjectManager.restore_default_settings()
     mid_set = set()
     if 'machine_info' in mset:
         machine_info = mset.machine_info
         if isinstance(machine_info,dict) or isinstance(machine_info,obj):
             for machine_name,minfo in machine_info.iteritems():
                 mname = machine_name.lower()
                 if Machine.exists(mname):
                     machine = Machine.get(mname)
                     machine.restore_default_settings()
                     machine.incorporate_user_info(minfo)
                     mid_set.add(id(machine))
                 else:
                     self.error('machine {0} is unknown\n  cannot set machine_info'.format(machine_name))
                 #end if
             #end for
         else:
             self.error('machine_info must be a dict or obj\n  you provided type '+machine_info.__class__.__name__)
         #end if
     #end if
     if 'machine' in mset:
         machine_name = mset.machine
         if not Machine.exists(machine_name):
             self.error('machine {0} is unknown'.format(machine_name))
         #end if
         Job.machine = machine_name
         machine = Machine.get(machine_name)
         ProjectManager.machine = machine
         if machine is not None and id(machine) not in mid_set:
             machine.restore_default_settings()
         #end if
         if 'account' in mset:
             account = mset.account
             if not isinstance(account,str):
                 self.error('account for {0} must be a string\n  you provided: {1}'.format(machine_name,account))
             #end if
             ProjectManager.machine.account = account
         #end if
         if 'machine_mode' in mset:
             machine_mode = mset.machine_mode
             if machine_mode in Machine.modes:
                 machine_mode = Machine.modes[machine_mode]
             #end if
             if machine_mode==Machine.modes.interactive:
                 if ProjectManager.machine==None:
                     ProjectManager.class_error('no machine specified for interactive mode')
                 #end if
                 if not isinstance(ProjectManager.machine,Supercomputer):
                     self.error('interactive mode is not supported for machine type '+ProjectManager.machine.__class__.__name__)
                 #end if
                 if not 'interactive_cores' in mset:
                     self.error('interactive mode requested, but interactive_cores not set')
                 #end if
                 ProjectManager.machine = ProjectManager.machine.interactive_representation(mset.interactive_cores)
                 Job.machine = ProjectManager.machine.name
예제 #3
0
 def bundle_jobs(self,relative=False):
     jobs = []
     job0 = self.sims[0].job
     time    = Job.zero_time()
     nodes   = 0
     cores   = 0
     thread_set = set()
     queue_set  = set()
     presub_set = set()
     machine_set = set()
     for sim in self.sims:
         job = sim.job
         nodes += job.nodes
         cores += job.cores
         time    = job.max_time(time)
         machine = job.get_machine()
         machine_set.add(machine.name)
         thread_set.add(job.threads)
         queue_set.add(job.queue)
         presub_set.add(job.presub)
         jobs.append(job)
     #end for
     if len(thread_set)>1:
         self.error('bundling jobs with different numbers of threads is not yet supported\nthread inputs provided: {0}'.format(sorted(thread_set),trace=False))
     #end if
     if len(queue_set)>1:
         self.error('bundling jobs with different queues is not allowed\nqueue inputs provided: {0}'.format(sorted(queue_set)),trace=False)
     #end if
     if len(presub_set)>1:
         ps = ''
         for psub in sorted(presub_set):
             ps+=psub+'\n\n'
         #end for
         self.error('bundling jobs with different pre-submission commands is not allowed\npresub inputs provided: \n{0}'.format(ps),trace=False)
     #end if
     if len(machine_set)>1:
         self.error('attempted to bundle jobs across these machines: {0}\n  jobs may only be bundled on the same machine'.format(sorted(machine_set)),trace=False)
     #end if
     threads = list(thread_set)[0]
     queue   = list(queue_set)[0]
     presub  = list(presub_set)[0]
     machine = list(machine_set)[0]
     self.job = Job(
         bundled_jobs = jobs,
         relative     = relative,
         queue        = queue,
         nodes        = nodes,
         cores        = cores,
         threads      = threads,
         machine      = machine,
         presub       = presub,
         **time
         )
예제 #4
0
    def __init__(self, system=None, job=None, **kwargs):

        assert isinstance(system, System)
        assert isinstance(job, Job)
        #Inputs
        self.system = system
        self.job=Job(name=job.name,cores=job.cores,time=job.time,app=job.app+' < input.qe > output.qe')
        self.kwargs = kwargs

        #Class derived parameters
        self.rundir = system.rundir + '/qe'
        self.inputfile = self.rundir + '/input.qe'
        self.outputfile = self.rundir + '/output.qe'
        self.complete = False

        #Prepare input parameters - new attr
        self.process_system_inputs()
        self.process_pwscf_inputs()

        #Check if calculation already finished
        self.complete=False
        self.running=False
        self.control_pwscf()

        # If complete, do nothing; else write input.qe
        if not self.running and not self.complete:
            self.write_pwscf_inputs()
            self.execute()

        if self.complete:
            print self.rundir + ' is already completed!'

        if self.running:
            print self.rundir + ' is already running!'
예제 #5
0
 def bundle_jobs(self, relative=False):
     jobs = []
     job0 = self.sims[0].job
     time = Job.zero_time()
     nodes = 0
     cores = 0
     threads = job0.threads
     queue = job0.queue
     same_threads = True
     same_queue = True
     machine_names = set()
     for sim in self.sims:
         job = sim.job
         nodes += job.nodes
         cores += job.cores
         same_threads = same_threads and threads == job.threads
         same_queue = same_queue and queue == job.queue
         time = job.max_time(time)
         machine = job.get_machine()
         machine_names.add(machine.name)
         jobs.append(job)
     #end for
     if not same_threads:
         self.error(
             'bundling jobs with different numbers of threads is not yet supported',
             trace=False)
     #end if
     if not same_queue:
         self.error('bundling jobs with different queues is not allowed',
                    trace=False)
     #end if
     machine_names = list(machine_names)
     if len(machine_names) != 1:
         self.error('attempted to bundle jobs across these machines: ' +
                    str(machine_names) +
                    '\n  jobs may only be bundled on the same machine',
                    trace=False)
     #end if
     self.job = Job(bundled_jobs=jobs,
                    relative=relative,
                    queue=queue,
                    nodes=nodes,
                    cores=cores,
                    threads=threads,
                    machine=machine_names[0],
                    **time)
예제 #6
0
 def bundle_jobs(self,relative=False):
     jobs = []
     job0 = self.sims[0].job
     time    = Job.zero_time()
     nodes   = 0
     cores   = 0
     threads = job0.threads
     queue   = job0.queue
     same_threads = True
     same_queue   = True
     machine_names = set()
     for sim in self.sims:
         job = sim.job
         nodes += job.nodes
         cores += job.cores
         same_threads = same_threads and threads==job.threads
         same_queue   = same_queue   and queue==job.queue
         time    = job.max_time(time)
         machine = job.get_machine()
         machine_names.add(machine.name)
         jobs.append(job)
     #end for
     if not same_threads:
         self.error('bundling jobs with different numbers of threads is not yet supported',trace=False)
     #end if
     if not same_queue:
         self.error('bundling jobs with different queues is not allowed',trace=False)
     #end if
     machine_names = list(machine_names)
     if len(machine_names)!=1:
         self.error('attempted to bundle jobs across these machines: '+str(machine_names)+'\n  jobs may only be bundled on the same machine',trace=False)
     #end if
     self.job = Job(
         bundled_jobs = jobs,
         relative     = relative,
         queue        = queue,
         nodes        = nodes,
         cores        = cores,
         threads      = threads,
         machine      = machine_names[0],
         **time
         )
예제 #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 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
예제 #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
예제 #11
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'))