Пример #1
0
def _get_tmat_cell(cell, options):
    t_mat = np.array([frac2val(x) for x in options.t_mat.split()])
    t_mat = _get_matrix(t_mat)
    if t_mat is False:
        sys.stderr.write("Transformation matrix is not correctly set.\n")
        return False
    else:
        if options.is_verbose:
            print "Transform cell using transformation matrix:"
            print t_mat
        return reduce_points(t_mat, cell)
Пример #2
0
def _get_tmat_cell(cell, options):
    t_mat = np.array([frac2val(x) for x in options.t_mat.split()])
    t_mat = _get_matrix(t_mat)
    if t_mat is False:
        sys.stderr.write("Transformation matrix is not correctly set.\n")
        return False
    else:
        if options.is_verbose:
            print "Transform cell using transformation matrix:"
            print t_mat
        return reduce_points(t_mat, cell)
Пример #3
0
def get_supercell(cell, supercell_matrix, tolerance=1e-5):
    """
    Build supercell with supercell matrix as follows:
    1) Create supercell with surrounding simple lattice.
    2) Trim the surrounding supercell with the target lattice.

    """
    
    smat = np.array(supercell_matrix)
    frame = get_smallest_surrounding_lattice_multiplicities(smat)
    surrounding_cell = get_simple_supercell(frame, cell)
    if (np.diag(np.diagonal(smat)) == smat).all():
        return surrounding_cell

    transformation_matrix = np.array([smat[0] / float(frame[0]),
                                      smat[1] / float(frame[1]),
                                      smat[2] / float(frame[2])])
    supercell = reduce_points(transformation_matrix,
                              surrounding_cell,
                              tolerance)
    return supercell