Example #1
0
def make_density_profiles(program, num_lebedev, r_low, r_high, steps,
                          atom_numbers, max_ion, do_work, do_random):
    # generate lebedev grid
    lebedev_xyz, lebedev_weights = get_grid(num_lebedev)

    # define radii
    rgrid = RLogIntGrid(r_low, r_high, steps)
    agrid = ALebedevIntGrid(num_lebedev, do_random)

    f_pro = file("densities.txt", "w")
    print >> f_pro, rgrid.get_description()
    charges = []

    # run over all directories, run cubegen, load cube data
    pb = log.pb("Density profiles", len(atom_numbers) * (2 * max_ion + 1))
    for number in atom_numbers:
        symbol = periodic[number].symbol
        for charge in xrange(-max_ion, max_ion + 1):
            charge_label = charge_to_label(charge)
            pb()
            dirname = os.path.join("%03i%s" % (number, symbol), charge_label,
                                   "gs")
            # get the grid
            if not os.path.isdir(dirname): continue
            if do_work:
                work = Work(dirname)
            else:
                work = Work()
            grid = AtomicGrid.from_prefix("grid", work)
            if grid is None:
                center = numpy.zeros(3, float)
                grid = AtomicGrid.from_parameters("grid", work, center, rgrid,
                                                  agrid)
            # compute densities
            program.compute_density(grid, dirname)
            # this is spherical averaging, i.e. integral/(4*pi)
            radrhos = agrid.integrate(grid.moldens) / (4 * numpy.pi)
            print >> f_pro, "%3i %+2i" % (number, charge),
            # leave out near zeros to save space and time
            print >> f_pro, " ".join("%22.16e" % rho for rho in radrhos
                                     if rho > 1e-100)
            check = rgrid.integrate(4 * numpy.pi * rgrid.rs * rgrid.rs *
                                    radrhos)
            charges.append((number, symbol, charge, check))

    pb()
    f_pro.close()

    counter = 0
    for number, symbol, charge, real_charge in charges:
        log("Total charge error: %3i %2s %+2i    % 10.5e" %
            (number, symbol, charge, -real_charge + number - charge))
        counter += 1
Example #2
0
def make_density_profiles(program, num_lebedev, r_low, r_high, steps, atom_numbers, max_ion, do_work, do_random):
    # generate lebedev grid
    lebedev_xyz, lebedev_weights = get_grid(num_lebedev)

    # define radii
    rgrid = RLogIntGrid(r_low, r_high, steps)
    agrid = ALebedevIntGrid(num_lebedev, do_random)

    f_pro = file("densities.txt", "w")
    print >> f_pro, rgrid.get_description()
    charges = []

    # run over all directories, run cubegen, load cube data
    pb = log.pb("Density profiles", len(atom_numbers)*(2*max_ion+1))
    for number in atom_numbers:
        symbol = periodic[number].symbol
        for charge in xrange(-max_ion, max_ion+1):
            charge_label = charge_to_label(charge)
            pb()
            dirname = os.path.join("%03i%s" % (number, symbol), charge_label, "gs")
            # get the grid
            if not os.path.isdir(dirname): continue
            if do_work:
                work = Work(dirname)
            else:
                work = Work()
            grid = AtomicGrid.from_prefix("grid", work)
            if grid is None:
                center = numpy.zeros(3,float)
                grid = AtomicGrid.from_parameters("grid", work, center, rgrid, agrid)
            # compute densities
            program.compute_density(grid, dirname)
            # this is spherical averaging, i.e. integral/(4*pi)
            radrhos = agrid.integrate(grid.moldens)/(4*numpy.pi)
            print >> f_pro, "%3i %+2i" % (number, charge),
            # leave out near zeros to save space and time
            print >> f_pro, " ".join("%22.16e" % rho for rho in radrhos if rho > 1e-100)
            check = rgrid.integrate(4*numpy.pi*rgrid.rs*rgrid.rs*radrhos)
            charges.append((number, symbol, charge, check))


    pb()
    f_pro.close()

    counter = 0
    for number, symbol, charge, real_charge in charges:
        log("Total charge error: %3i %2s %+2i    % 10.5e" % (number, symbol, charge, -real_charge+number-charge))
        counter += 1
Example #3
0
 def __init__(self, context, rgrid, extra_tag_attributes):
     # create angular grid object
     agrid = ALebedevIntGrid(context.options.lebedev, context.options.do_random)
     # check arguments
     extra_tag_attributes["rgrid"] = rgrid.get_description()
     extra_tag_attributes["agrid"] = agrid.get_description()
     context.check_tag(extra_tag_attributes)
     # assign attributes
     self.context = context
     self.rgrid = rgrid
     self.agrid = agrid
     self._done = set([])
     # clone attributes from context
     self.work = context.work
     self.output = context.output
     self.wavefn = context.wavefn
     self.molecule = context.wavefn.molecule