Beispiel #1
0
    def make_variations(self):
        source = self.source
        source_info = self.source_info
        build_order = self.build_order
        variable_order = self.variable_order
        build_delimiter = self.build_delimiter
        variable_delimiter = self.variable_delimiter

        boset = set(build_order)
        voset = set(variable_order)

        invalid = boset - self.build_vars
        if len(invalid) > 0:
            self.error(
                'variables provided in build_order are invalid\n  invalid entries: '
                + str(list(invalid)) + '\b  valid options are: ' +
                str(list(self.build_vars)))
        #end if

        #assume template input file source for now
        qpinput, wf_h5file, pp_files, system, source_path = self.source_info.tuple(
            'input', 'wf_h5file', 'pp_files', 'system', 'path')

        #get the current date and time
        now = datetime.now()
        date_time = datetime.strftime(now, '%y%m%d_%H%M%S')

        errors = False

        for variation in self.variations:
            error = False
            vars = set(variation.keys())
            build_vars = vars & self.build_vars
            job_vars = vars & self.job_vars
            inflag_vars = vars & self.inflag_vars
            input_vars = vars - build_vars - job_vars - inflag_vars

            invars = inflag_vars | input_vars

            if build_vars < boset:
                self.error(
                    'not enough build variables in variation\n  build variables required: '
                    + str(build_order),
                    exit=False,
                    trace=False)
                error = True
            #end if
            if invars < voset:
                self.error(
                    'not enough input variables in variation\n  input variables required: '
                    + str(variable_order),
                    exit=False,
                    trace=False)
                error = True
            #end if

            # determine the build directory
            build_list = []
            build_dir = ''
            for var in build_order:
                if var in variation:
                    val = variation[var]
                    build_list.append(val)
                    if var == 'revision' and isinstance(val, int):
                        val = 'r' + str(val)
                    #end if
                    build_dir += str(val) + build_delimiter
                else:
                    self.error('variable ' + str(var) +
                               ' in build_order is not in variation',
                               exit=False,
                               trace=False)
                    error = True
                #end if
            #end for
            if len(build_list) > 0:
                build_dir = build_dir[:-len(build_delimiter)]
            #end if

            # determine the input var directory
            var_list = []
            var_dir = ''
            for var in variable_order:
                if var in variation:
                    val = variation[var]
                    var_list.append(val)
                    var_dir += '{0}-{1}{2}'.format(var, val,
                                                   variable_delimiter)
                else:
                    self.error('variable ' + str(var) +
                               ' in variable_order is not in variation',
                               exit=False,
                               trace=False)
                    error = True
                #end if
            #end for
            if len(var_list) > 0:
                var_dir = var_dir[:-len(variable_delimiter)]
            #end if

            if error:
                self.error('  variation provided:\n' + str(variation),
                           exit=False,
                           trace=False)
            #end if

            # make the job object
            jin = variation.obj(*job_vars)
            if len(inflag_vars) > 0:
                inflags = ''
                for var in inflag_vars:
                    val = variation[var]
                    if val:
                        inflags += ' --' + var
                    #end if
                #end for
                jin.app_flags = inflags
            #end if
            job = Job(**jin)

            # set the simulation path
            path = os.path.join(self.name, self.machine, var_dir,
                                build_dir + build_delimiter + date_time)

            # fill out the template input file
            #  assume simple and unique find and replace variations for now
            input = qpinput.copy()
            assignments = variation.obj(*input_vars)
            input.assign(**assignments)

            #  add the relative path location of the wavefunction file
            runpath = os.path.join(nexus_core.local_directory, nexus_core.runs,
                                   path)

            wftmp = os.path.join(source_path, wf_h5file)
            wfpath = os.path.relpath(wftmp, runpath)

            ds = input.get('determinantset')
            if ds != None:
                ds.href = wfpath
            #end if

            # check that the build exists
            app_loc = os.path.join(self.build_path, build_dir, self.app_loc)
            if not os.path.exists(app_loc) and not nexus_core.generate_only:
                print '    Error: no qmcapp at ' + app_loc
                error = True
            #end if
            job.app_name = app_loc

            # locate pp files
            files = []
            if pp_files != None:
                files = list(pp_files)
            #end if

            # make the simulation object
            qmc = Qmcpack(identifier='qmc',
                          path=path,
                          job=job,
                          system=system,
                          input=input,
                          files=files)
            self.sims[tuple(var_list + build_list)] = qmc

            # add it to the global simulation list
            self.simulations.append(qmc)

            errors = errors or error
        #end for

        if errors:
            self.error('errors encountered, see above')
Beispiel #2
0
    kshift=(0, 0, 0),
    net_charge=0,
    net_spin=0,
    C=4  # one line like this for each atomic species
)

my_bconds = 'ppp'  #  ppp/nnn for periodic/open BC's in QMC
#  if nnn, center atoms about (a1+a2+a3)/2

sims = []

# scf run to generate orbitals
scf = generate_pwscf(
    identifier='scf',
    path=my_project_name,
    job=Job(nodes=32, hours=2, app=pwscf),
    input_type='scf',
    system=my_system,
    pseudos=my_dft_pps,
    input_dft='lda',
    ecut=200,  # PW energy cutoff in Ry
    conv_thr=1e-8,
    mixing_beta=.7,
    nosym=True,
    wf_collect=True)
sims.append(scf)

# conversion step to create h5 file with orbitals
p2q = generate_pw2qmcpack(identifier='p2q',
                          path=my_project_name,
                          job=Job(cores=1, hours=2, app=pw2qmcpack),
    def make_variations(self):
        source      = self.source
        source_info = self.source_info
        build_order = self.build_order
        variable_order = self.variable_order
        build_delimiter = self.build_delimiter
        variable_delimiter = self.variable_delimiter

        boset = set(build_order)
        voset = set(variable_order)

        invalid = boset - self.build_vars
        if len(invalid)>0:
            self.error('variables provided in build_order are invalid\n  invalid entries: '+str(list(invalid))+'\b  valid options are: '+str(list(self.build_vars)))
        #end if

        #assume template input file source for now
        qpinput,wf_h5file,pp_files,system,source_path = self.source_info.tuple('input','wf_h5file','pp_files','system','path')

        #get the current date and time
        now = datetime.now()
        date_time = datetime.strftime(now,'%y%m%d_%H%M%S')


        errors = False

        for variation in self.variations:
            error = False
            vars = set(variation.keys())
            build_vars  = vars & self.build_vars
            job_vars    = vars & self.job_vars
            inflag_vars = vars & self.inflag_vars
            input_vars  = vars-build_vars-job_vars-inflag_vars

            invars = inflag_vars | input_vars

            if build_vars<boset:
                self.error('not enough build variables in variation\n  build variables required: '+str(build_order),exit=False,trace=False)
                error = True
            #end if
            if invars<voset:
                self.error('not enough input variables in variation\n  input variables required: '+str(variable_order),exit=False,trace=False)
                error = True
            #end if

            # determine the build directory
            build_list = []
            build_dir  = ''
            for var in build_order:
                if var in variation:
                    val = variation[var]
                    build_list.append(val)
                    if var=='revision' and isinstance(val,int):
                        val = 'r'+str(val)
                    #end if
                    build_dir += str(val)+build_delimiter
                else:
                    self.error('variable '+str(var)+' in build_order is not in variation',exit=False,trace=False)
                    error = True
                #end if
            #end for
            if len(build_list)>0:
                build_dir = build_dir[:-len(build_delimiter)]
            #end if

            # determine the input var directory
            var_list = []
            var_dir  = ''
            for var in variable_order:
                if var in variation:
                    val = variation[var]
                    var_list.append(val)
                    var_dir += '{0}-{1}{2}'.format(var,val,variable_delimiter)
                else:
                    self.error('variable '+str(var)+' in variable_order is not in variation',exit=False,trace=False)
                    error = True
                #end if
            #end for
            if len(var_list)>0:
                var_dir = var_dir[:-len(variable_delimiter)]
            #end if

            if error:
                self.error('  variation provided:\n'+str(variation),exit=False,trace=False)
            #end if

            # make the job object 
            jin = variation.obj(*job_vars)
            if len(inflag_vars)>0:
                inflags = ''
                for var in inflag_vars:
                    val = variation[var]
                    if val:
                        inflags+=' --'+var
                    #end if
                #end for
                jin.app_flags = inflags
            #end if
            job = Job(**jin)

            # set the simulation path
            path = os.path.join(self.name,self.machine,var_dir,build_dir+build_delimiter+date_time)

            # fill out the template input file
            #  assume simple and unique find and replace variations for now
            input = qpinput.copy()
            assignments = variation.obj(*input_vars)
            input.assign(**assignments)

            #  add the relative path location of the wavefunction file
            runpath = os.path.join(Pobj.local_directory,Pobj.runs,path)

            wftmp  = os.path.join(source_path,wf_h5file)
            wfpath = os.path.relpath(wftmp,runpath)

            ds = input.get('determinantset')
            if ds!=None:
                ds.href = wfpath
            #end if

            # check that the build exists
            app_loc = os.path.join(self.build_path,build_dir,self.app_loc)
            if not os.path.exists(app_loc) and not self.generate_only:
                print '    Error: no qmcapp at '+app_loc
                error = True
            #end if
            job.app_name = app_loc

            # locate pp files
            files = []
            if pp_files!=None:
                files = list(pp_files)
            #end if

            # make the simulation object
            qmc = Qmcpack(
                identifier = 'qmc',
                path       = path,
                job        = job,
                system     = system,
                input      = input,
                files      = files 
                )
            self.sims[tuple(var_list+build_list)] = qmc

            # add it to the global simulation list
            self.simulations.append(qmc)

            errors = errors or error
        #end for

        if errors:
            self.error('errors encountered, see above')
Beispiel #4
0
supercell_kgrids = [
    (1, 1, 1),  #   1 k-point
    (2, 2, 2),  #   8 k-points
    (4, 4, 4),  #  64 k-points
    (6, 6, 6)
]  # 216 k-points

# describe the relaxation calculations
# and link them together into a simulation cascade
relaxations = []  # list of relax simulation objects
for kgrid in supercell_kgrids:  # loop over supercell kgrids
    relax = generate_pwscf(  # make each relax simulation
        identifier='relax',  # file prefix
        # run directory
        path='relax/kgrid_{0}{1}{2}'.format(*kgrid),
        job=Job(cores=16),  # will run with mpirun -np 16
        input_type='relax',  # this is a relax calculation
        input_dft='pbe',  # PBE functional
        ecut=50,  # 50 Ry planewave cutoff
        conv_thr=1e-6,  # convergence threshold
        kgrid=kgrid,  # supercell k-point grid
        kshift=(1, 1, 1),  # grid centered at supercell L point
        pseudos=['Ge.pbe-kjpaw.UPF'],  # PBE pseudopotential
        system=T_system  # the interstitial system
    )
    # link together the simulation cascade
    #   current relax gets structure from previous
    if len(relaxations) > 0:  #   if it exists
        relax.depends(relaxations[-1], 'structure')
    #end if
    relaxations.append(relax)  # add relax simulation to the list
Beispiel #5
0
    net_spin=0,  # net spin in units of e-spin
    C=4  # C has 4 valence electrons
)

#generate the simulations for the qmc workflow
qsims = basic_qmc(
    # subdirectory of runs
    directory='c20_test',
    # description of the physical system
    system=c20,
    pseudos=[
        'C.BFD.upf',  # pwscf PP file
        'C.BFD.xml'
    ],  # qmcpack PP file
    # job parameters
    scfjob=Job(cores=16),  # cores to run scf 
    optjob=Job(
        cores=16,  # cores for optimization 
        app_name='qmcapp'),  # use real-valued qmcpack
    qmcjob=Job(
        cores=16,  # cores for qmc
        app_name='qmcapp'),  # use real-valued qmcpack
    # dft parameters (pwscf)
    functional='lda',  # dft functional
    ecut=150,  # planewave energy cutoff (Ry)
    conv_thr=1e-6,  # scf convergence threshold (Ry)
    mixing_beta=.7,  # charge mixing factor
    # qmc wavefunction parameters (qmcpack)
    bconds='nnn',  # open boundary conditions
    meshfactor=1.0,  # bspline grid spacing, larger is finer
    jastrows=[
Beispiel #6
0
    kshift=(.5, .5, .5),  # and shift
    C=4  # C has 4 valence electrons
)

#generate the simulations for the qmc workflow
qsims = standard_qmc(
    # subdirectory of runs
    directory='graphene_test',
    # description of the physical system
    system=graphene,
    pseudos=[
        'C.BFD.upf',  # pwscf PP file
        'C.BFD.xml'
    ],  # qmcpack PP file
    # job parameters
    scfjob=Job(cores=16),  # cores to run scf 
    nscfjob=Job(cores=16),  # cores to run non-scf 
    optjob=Job(cores=16),  # cores for optimization 
    qmcjob=Job(cores=16),  # cores for qmc
    # dft parameters (pwscf)
    functional='lda',  # dft functional
    ecut=150,  # planewave energy cutoff (Ry)
    conv_thr=1e-6,  # scf convergence threshold (Ry)
    mixing_beta=.7,  # charge mixing factor
    scf_kgrid=(8, 8, 8),  # MP grid of primitive cell
    scf_kshift=(1, 1, 1),  #  to converge charge density
    # qmc wavefunction parameters (qmcpack)
    meshfactor=1.0,  # bspline grid spacing, larger is finer
    jastrows=[
        dict(
            type='J1',  # 1-body