示例#1
0
def _init_ORB_grid(data, grid_par=-6, over_s=7):
    u"""Initializes ORBKIT's grid and returns necessary data for visualization.

    **Parameters:**
      data : dict
    QCinfo instance representing the molecule.
      grid_par : int
    Parameter controlling grid. If positive or zero, it specifies number of points; otherwise it specifies the resolution in inverse atomic units.
      over_s : int|float
    Oversizing, to be tuned

    **Returns**
      X, Y, Z
    Meshgrid (as returned by numpy.mgrid) for positioning the voxels.
    """

    from orbkit import grid

    ## Reinitialization of the grid
    grid.is_initialized = False

    ## Spacing/Number of points
    if grid_par > 0:
        grid.N_ = [grid_par] * 3
    elif grid_par == 0:
        grid.N_ = [80] * 3
    else:
        grid.delta_ = [1.0 / (-grid_par)] * 3

    grid.max_ = np.amax(data.geo_spec, axis=0) + over_s
    grid.min_ = np.amin(data.geo_spec, axis=0) - over_s

    grid.adjust_to_geo(data, extend=over_s, step=grid.delta_[0])
    grid.init(force=True)

    ## The meshgrid MUST be generated in this manner,
    ## in order to be maximally consistent with ORBKIT
    ## which uses numpy.arange to generate its grid
    ## (i.e. start:stop+step:step)
    X, Y, Z = np.mgrid[grid.min_[0]:grid.max_[0] +
                       grid.delta_[0]:grid.delta_[0],
                       grid.min_[1]:grid.max_[1] +
                       grid.delta_[1]:grid.delta_[1],
                       grid.min_[2]:grid.max_[2] +
                       grid.delta_[2]:grid.delta_[2]]
    ## NOTICE: numpy.arange does not return consistent results if step is a float,
    ## specifically if (stop - start)/step overflows, resulting in
    ## arange(start, stop, step)[-1] > stop

    return X, Y, Z
示例#2
0
def _alt_init_ORB_grid(data, N, D):
	from orbkit import grid

	grid.N_ = np.array(N)
	grid.delta_ = np.array(D)

	T = grid.N_*grid.delta_
	P = np.mean(data.geo_spec, axis=0)

	grid.min_ = P - T/2
	grid.max_ = P + T/2

	grid.init()

	X, Y, Z = np.mgrid[grid.min_[0] : grid.max_[0] + grid.delta_[0] : grid.delta_[0],
                           grid.min_[1] : grid.max_[1] + grid.delta_[1] : grid.delta_[1],
                           grid.min_[2] : grid.max_[2] + grid.delta_[2] : grid.delta_[2]]

	return X, Y, Z