How to use the generic.obj function in generic

To help you get started, we’ve selected a few generic examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github QMCPACK / qmcpack / nexus / lib / fileio.py View on Github external
line = lines[i].strip().lower()
                            while not line.startswith('end_bandgrid'):
                                if line.startswith('band'):
                                    band_index = int(line.split(':')[1].strip())
                                    bands[band_index] = []
                                else:
                                    bands[band_index].extend(line.split())
                                #end if
                                i+=1
                                line = lines[i].strip().lower()
                            #end while
                            for bi,bv in bands.iteritems():
                                bands[bi] = array(bv,dtype=float)
                                bands[bi].shape = tuple(grid)
                            #end for
                            band[grid_identifier] = obj(
                                grid   = grid,
                                corner = corner,
                                cell   = cell,
                                bands  = bands
                                )
                        #end if
                        i+=1
                    #end while
                else:
                    self.error('invalid keyword encountered: {0}'.format(keyword))
                #end if
            #end if
            i+=1
        #end while
github QMCPACK / qmcpack / nexus / lib / pwscf_analyzer.py View on Github external
i_occ = j
                        #end if
                    #end while
                    seigs = ''
                    for j in range(i+1,i_occ):
                        seigs+=lines[j]
                    #end for
                    seigs = seigs.strip()
                    eigs = array(seigs.split(),dtype=float)

                    soccs = ''
                    for j in range(i_occ+1,i_occ+1+(i_occ-i)-2):
                        soccs+= lines[j]
                    #end for
                    occs   = array(soccs.split(),dtype=float)
                    bk = obj(
                        index           = index,
                        kpoint_2pi_alat = kpoints_2pi_alat[index],
                        kpoint_rel      = kpoints_rel[index],
                        eigs            = eigs,
                        occs            = occs,
                        pol             = 'none',
                        )
                    band_channel = bands.up
                    if polarized:                  
                        if up_spin:
                            bk.pol = 'up'
                        elif not up_spin:
                            bk.pol = 'down'
                            band_channel = bands.down
                        #end if
                    else:
github QMCPACK / qmcpack / nexus / lib / vasp_input.py View on Github external
#end if
#end def assign_bool_array


#utility functions to convert from VASP internal objects to 
#nexus objects:
def vasp_to_nexus_elem(elem,elem_count):
    syselem=[]
    for x,count in zip(elem,elem_count):
        syselem+=[x for i in xrange(0,count)]
    #end for
    return array(syselem)
#end def vasp_to_nexus_elem


read_value_functions = obj(
    ints        = read_int,
    reals       = read_real,
    bools       = read_bool,
    strings     = read_string,
    int_arrays  = read_int_array,
    real_arrays = read_real_array,
    bool_arrays = read_bool_array
    )

write_value_functions = obj(
    ints        = write_int,
    reals       = write_real,
    bools       = write_bool,
    strings     = write_string,
    int_arrays  = write_int_array,
    real_arrays = write_real_array,
github QMCPACK / qmcpack / nexus / source / matter / periodic_table.py View on Github external
e[90].boiling_point=4790
	e[92].boiling_point=3818
	e[93].boiling_point=3902
	e[94].boiling_point=3232
	e[95].boiling_point=2607

        for i in range(1,nelements+1):
            e[i].create_var_dict()
        #end for

        #for i in range(len(e)):
        #    e[i].create_string_representation()
        ##end for


        isotope_masses  =  obj(
            H  = {1:1.00782503207,  2:2.0141017778,  3:3.0160492777},  
            He = {3:3.0160293191,  4:4.00260325415},  
            Li = {6:6.015122795,  7:7.01600455},  
            Be = {9:9.0121822},  
            B  = {10:10.0129370,  11:11.0093054},  
            C  = {12:12.0000000,  13:13.0033548378,  14:14.003241989},  
            N  = {14:14.0030740048,  15:15.0001088982},  
            O  = {16:15.99491461956,  17:16.99913170,  18:17.9991610},  
            F  = {19:18.99840322},  
            Ne = {20:19.9924401754,  21:20.99384668,  22:21.991385114},  
            Na = {23:22.9897692809},  
            Mg = {24:23.985041700,  25:24.98583692,  26:25.982592929},  
            Al = {27:26.98153863},  
            Si = {28:27.9769265325,  29:28.976494700,  30:29.97377017},  
            P  = {31:30.97376163},  
            S  = {32:31.97207100,  33:32.97145876,  34:33.96786690,  36:35.96708076},
github QMCPACK / qmcpack / nexus / lib / basisset.py View on Github external
def prim_widths(self):
        if self.contracted():
            self.error('cannot find primitive gaussian widths because basis is contracted')
        #end if
        lbasis = self.lbasis()
        gwidth = obj()
        for l,lbas in lbasis.iteritems():
            w = []
            for n in range(len(lbas)):
                w.append(1./sqrt(2.*lbas[n].terms[0].expon))
            #end for
            gwidth[l] = array(w,dtype=float)
        #end for
        return gwidth
    #end def prim_widths
github QMCPACK / qmcpack / nexus / lib / legacy / qmcpack_pp_validation.py View on Github external
ylabel    = 'PW kinetic energy',
            yunit     = 'Ha'
            ),
        Ekin_vmc = obj(
            data_type = 'stat',
            title     = 'VMC kinetic energy vs bond length',
            ylabel    = 'VMC kinetic energy',
            yunit     = 'Ha'
            ),
        Evmc_noJ = obj(
            data_type = 'stat',
            title     = 'Jastrowless VMC energy vs bond length',
            ylabel    = 'Jastrowless VMC energy',
            yunit     = 'Ha'
            ),
        Evmc = obj(
            data_type = 'stat',
            title     = 'VMC energy vs bond length',
            ylabel    = 'VMC energy',
            yunit     = 'Ha'
            ),
        Edmc = obj(
            data_type = 'stat',
            title     = 'DMC energy vs bond length',
            ylabel    = 'DMC energy',
            yunit     = 'Ha'
            )
        )


    def make_sims(self,v):
        sims = obj()
github QMCPACK / qmcpack / nexus / lib / vasp_input.py View on Github external
#end for
    return array(syselem)
#end def vasp_to_nexus_elem


read_value_functions = obj(
    ints        = read_int,
    reals       = read_real,
    bools       = read_bool,
    strings     = read_string,
    int_arrays  = read_int_array,
    real_arrays = read_real_array,
    bool_arrays = read_bool_array
    )

write_value_functions = obj(
    ints        = write_int,
    reals       = write_real,
    bools       = write_bool,
    strings     = write_string,
    int_arrays  = write_int_array,
    real_arrays = write_real_array,
    bool_arrays = write_bool_array
    )

assign_value_functions = obj(
    ints        = int,
    reals       = float,
    bools       = assign_bool,
    strings     = assign_string,
    int_arrays  = assign_int_array,
    real_arrays = assign_real_array,
github QMCPACK / qmcpack / nexus / lib / machines.py View on Github external
if job.subfile==None:
            self.error('submission file not specified for job')
        elif not os.path.exists(job.subfile):
            self.error('job submission file was not written prior to submission\n  submission file: '+os.path.join(job.directory,job.subfile))
        #end if
        command = self.sub_command(job)
        if nexus_core.generate_only:
            self.log(pad+'Would have executed:  '+command)
            job.status = job.states.running
            process = obj()
            process.job = job
            self.processes[job.internal_id] = process
        else:
            self.log(pad+'Executing:  '+command)
            job.status = job.states.running
            process = obj()
            process.job = job
            out,err = Popen(command,shell=True,stdout=PIPE,stderr=PIPE,close_fds=True).communicate()
            output=out+'\n'+err
            pid = self.read_process_id(output)
            if pid is None:
                self.error('process id could not be determined from submission output\n  output:\n'+output)
            else:
                self.log(pad+'  pid: {0}'.format(pid))
            #end if
            #pid = 'fakepid_'+str(job.internal_id)
            job.system_id = pid
            self.processes[pid] = process
        #end if
        self.leave()
    #end def submit_job
github QMCPACK / qmcpack / project_suite / source / simulation / qmc / qmcpack / qmcpack.py View on Github external
def twist_average(self,twistnums):
        br = obj()
        br.quantity = 'twistnum'
        br.values   = list(twistnums)
        self.bundle_request = br
        self.app_name = 'qmcapp_complex'
        #print 'twist_average'
github QMCPACK / qmcpack / nexus / lib / qmcpack_quantity_analyzers.py View on Github external
# 5) consider using cross-correlations w/ excluded elements to reduce variance

        ds = DMSettings(self.run_info.request.dm_settings)
        diagonal  = ds.diagonal 
        jackknife = ds.jackknife and not diagonal
        save_data = ds.save_data
        occ_tol   = ds.occ_tol  
        coup_tol  = ds.coup_tol 
        stat_tol  = ds.stat_tol 

        nbe = QAanalyzer.method_info.nblocks_exclude
        self.info.nblocks_exclude = nbe
        has_nmat = 'number_matrix' in self.data
        has_emat = 'energy_matrix' in self.data
        species = self.data.number_matrix.keys()
        species_sizes = obj()
        ps = self.run_info.input.get('particleset')
        for s in species:
            species_sizes[s] = ps.e.groups[s].size
        #end for
        mnames = []
        if has_nmat:
            mnames.append('number_matrix')
            if has_emat:
                mnames.append('energy_matrix')
            #end if
        #end if

        for species_name in species:
            for matrix_name in mnames:
                if not matrix_name in self:
                    self[matrix_name] = obj()