Beispiel #1
0
def build_triangularz(lp):
    """

    Parameters
    ----------
    lp

    Returns
    -------

    """
    NH = lp['NH']
    NV = lp['NV']
    shape = lp['shape']
    eta = lp['eta']
    theta = lp['theta']
    check = lp['check']
    if lp['cutz_method'] == 'random':
        xy, NL, KL, BL, LVUC, LV, UC, lattice_exten = \
            generate_triangular_lattice(shape, NH, NV, eta, theta, check=check)
        NL, KL, BL = \
            le.cut_bonds_z_random(xy, NL, KL, BL, lp['target_z'], bulk_determination='Endpts', check=check)
    elif lp['cutz_method'] == 'highest':
        xy, NL, KL, BL, LVUC, LV, UC, lattice_exten = \
            generate_triangular_lattice(shape, NH + 5, NV + 5, eta, theta, check=check)
        NL, KL, BL = le.cut_bonds_z_highest(xy, NL, KL, BL, lp['target_z'], check=check)
        # Now crop out correctly coordinated region
        shapedict = {shape: [NH, NV]}
        keep = blf.argcrop_lattice_to_polygon(shapedict, xy, check=check)
        xy, NL, KL, BL = le.remove_pts(keep, xy, BL, NN='min')
        LVUC = LVUC[keep]
    else:
        raise RuntimeError('Must specify cutz_method argument when Lattice topology == triangularz.')

    # Remove any points with no bonds
    keep = KL.any(axis=1)
    xy, NL, KL, BL = le.remove_pts(keep, xy, BL, NN='min')
    LVUC = LVUC[keep]

    print 'len(xy) = ', len(xy)
    z = le.compute_bulk_z(xy, NL, KL, BL)
    print 'FOUND z = ', z
    print('Defining lattice_exten...')
    lattice_exten = 'triangularz_' + shape + '_zmethod' + lp['cutz_method'] + '_z' + '{0:0.03f}'.format(z)
    PVxydict = {}
    PVx = []
    PVy = []
    BBox = blf.auto_polygon(shape, lp['NH'], lp['NV'], eps=0.00)
    LL = (np.max(xy[:, 0]) - np.min(xy[:, 0]), np.max(xy[:, 1]) - np.min(xy[:, 1]))
    return xy, NL, KL, BL, PVxydict, PVx, PVy, LL, LVUC, LV, UC, BBox, lattice_exten
Beispiel #2
0
def build_hyperuniform_annulus(lp):
    """Build an annular sample of hyperuniform centroid network structure.

    Parameters
    ----------
    lp : dict
        lattice parameters dictionary. Uses lp['alph'] to determine the fraction of the system that is cut from the
        center

    Returns
    -------
    xy, NL, KL, BL, PVxydict, PVx, PVy, LVUC, BBox, LL, LV, UC, lattice_exten
    """
    xy, NL, KL, BL, PVxydict, PVx, PVy, LL, LVUC, LV, UC, BBox, lattice_exten = build_hyperuniform(
        lp)
    # Cut out the center and all particles more than radius away from center.
    radius = min(np.max(xy[:, 0]), np.max(xy[:, 1]))
    rad_inner = radius * lp['alph']
    dist = np.sqrt(xy[:, 0]**2 + xy[:, 1]**2)
    keep = np.logical_and(dist > rad_inner, dist < radius)
    # PVxydict and PV should really not be necessary here, since the network is not periodic
    if PVxydict:
        print 'PVxydict = ', PVxydict
        raise RuntimeError(
            'Annulus function is not designed for periodic BCs -- what are you doing?'
        )
    else:
        xy, NL, KL, BL = le.remove_pts(
            keep, xy, BL, check=lp['check'])  # , PVxydict=PVxydict, PV=PV)

    lattice_exten += '_alph' + sf.float2pstr(lp['alph'])
    return xy, NL, KL, BL, PVxydict, PVx, PVy, LVUC, BBox, LL, LV, UC, lattice_exten
Beispiel #3
0
def generate_cairo_tiling(lp):
    """

    Parameters
    ----------
    lp : dict
        lattice parameters dict with keys: shape, NH, NV, aratio, delta, phi, check

    Returns
    -------

    """
    print 'creating cairo tiling...'
    lp_tmp = copy.deepcopy(lp)
    lp_tmp['eta'] = 0.
    lp_tmp['NH'] += 5
    lp_tmp['NV'] += 5
    xyA, NLA, KLA, BLA, LVUCA, LVA, UCA, PVxydictA, PVxA, PVyA, lattice_exten = \
        generate_flattened_honeycomb_lattice(lp_tmp)

    xyleft = xyA[xyA[:, 0] < np.min(xyA[:, 0]) + 1e-4]
    farleft = np.argmin(xyleft[:, 1])
    xyA -= xyleft[farleft]

    if lp['check']:
        le.display_lattice_2D(xyA, BLA)

    xyB = np.dstack((xyA[:, 1], xyA[:, 0]))[0] + np.array([3., 1.])
    BLB = (np.abs(BLA) + len(xyA)) * (np.minimum(np.sign(BLA[:, 0]), np.sign(BLA[:, 1]))).reshape(len(BLA), 1)
    LVUC = 'none'
    LV = LVA
    UC = 'none'

    xy = np.vstack((xyA, xyB))
    BL = np.vstack((BLA, BLB))
    keep = np.logical_and(np.logical_and(xy[:, 0] > 10, xy[:, 1] > 10),
                          np.logical_and(xy[:, 1] < np.max(xyA[:, 1]), xy[:, 0] < np.max(xyB[:, 0])))
    xy, NL, KL, BL = le.remove_pts(keep, xy, BL)

    # Find all crossing line segs, replace with a particle connected to each particle involved

    # todo: make periodic BCs work (currently aren't realistically used)
    PVxydict = copy.deepcopy(PVxydictA)
    for key in PVxydictA:
        PVxydict[(key[1], key[0])] = np.array([PVxydictA[key][1], PVxydictA[key][0]])
    PVxB = copy.deepcopy(PVyA)
    PVyB = copy.deepcopy(PVxA)
    PVx = np.vstack((PVxA, PVxB))
    PVy = np.vstack((PVyA, PVyB))

    lattice_exten = 'cairo_' + lattice_exten[19:]
    return xy, NL, KL, BL, LVUC, LV, UC, PVxydict, PVx, PVy, lattice_exten
Beispiel #4
0
def setup_penrose_for_periodic(lp):
    """Creating a rhombus-shaped penroserhombTri quasicrystalline lattice, with arrangement of particles such that
    a periodic tiling nearly matches a true quasicrystal lattice."""
    if lp['NH'] < 160 and lp['NV'] < 160:
        Num_sub = int(np.ceil(np.log2(lp['NH']) + 2))
    else:
        Num_sub = int(np.ceil(np.log2(lp['NH']) + 3))
    xy, NL, KL, BL, TRI, lattice_exten = generate_penrose_rhombic_tiling(Num_sub, check=False)

    # Find a lower left sixfold particle

    sixfold = np.where(np.sum(KL, axis=1) > 5)[0]
    # print 'sixfold = ', sixfold
    # print 'sum = ', xy[sixfold, 0] + xy[sixfold, 1]
    lowerleft = np.argmin(xy[sixfold, 0] + xy[sixfold, 1])
    indx = sixfold[lowerleft]
    ll = (np.abs(xy[:, 0] - xy[indx, 0]) ** 2 + np.abs(xy[:, 1] - xy[indx, 1]) ** 2).argmin()

    # Find a matching sixfold particle along vertical line from this location closest to NV away
    vertical = np.where(np.abs(xy[:, 0] - xy[ll, 0]) < 1e-5)[0]
    ul = vertical[np.argmin(np.abs(xy[vertical, 1] - xy[ll, 1] - lp['NV']))]

    # Find a matching sixfold particle along sloped horizontal line from this location closest to NH away
    rotll = xy - xy[ll, :]
    ang = np.pi * 0.5 - 2 * np.pi * 0.2
    xyrot = np.dstack((rotll[:, 0] * np.cos(ang) + rotll[:, 1] * np.sin(ang),
                       -rotll[:, 0] * np.sin(ang) + rotll[:, 1] * np.cos(ang)))[0]
    horiz = np.where(np.abs(xyrot[:, 1]) < 1e-1)[0]
    # print 'horiz = ', horiz
    # plt.scatter(xy[:, 0], xy[:, 1])
    # plt.scatter(xy[horiz, 0], xy[horiz, 1], c='r')
    # plt.scatter(xy[ll, 0], xy[ll, 1], c='g')
    # plt.show()
    # plt.plot(xyrot[horiz, 0], np.abs(xyrot[horiz, 0] - lp['NH']), 'b.-')
    # plt.show()
    lr = horiz[np.argmin(np.abs(xyrot[horiz, 0] - lp['NH']))]

    # Is there a matching particle along vertical line from this location closest to NV away from lr?
    vertical = np.where(np.abs(xy[:, 0] - xy[lr, 0]) < 1e-2)[0]
    ur = vertical[np.argmin(np.abs(xy[vertical, 1] - xy[lr, 1] - lp['NV']))]

    if lp['check']:
        print 'idx = ', ll
        print 'ul = ', ul
        print 'lr = ', lr
        print 'ur = ', ur
        le.movie_plot_2D(xy, BL, bs=0.0 * BL[:, 0], colormap='BlueBlackRed', colorz=True,
                         title='Output during periodic identification',
                         show=False)  # PVx=PVx, PVy=PVy, PVxydict=PVxydict,
        plt.plot([xy[ll, 0], xy[ul, 0], xy[lr, 0], xy[ur, 0]], [xy[ll, 1], xy[ul, 1], xy[lr, 1], xy[ur, 1]], 'ro')
        plt.show()

    vertd = xy[ul, 1] - xy[ll, 1]
    horzd = xy[lr, 0] - xy[ll, 0]
    horvd = xy[lr, 1] - xy[ll, 1]
    midpt = np.mean(np.array([xy[ll], xy[ul], xy[ul] + np.array([horzd, horvd]), xy[lr]]), axis=0)
    xy -= midpt
    PV = np.array([[horzd, horvd], [0., vertd]])
    polygon = 0.5 * np.array([[-PV[0, 0], (-PV[1, 1] - PV[0, 1])],
                              [PV[0, 0], (-PV[1, 1] + PV[0, 1])],
                              [PV[0, 0], (PV[1, 1] + PV[0, 1])],
                              [-PV[0, 0], (PV[1, 1] - PV[0, 1])]])
    if lp['check']:
        le.movie_plot_2D(xy, BL, bs=0.0 * BL[:, 0], colormap='BlueBlackRed', colorz=True,
                         title='point set before cropping', show=False)
        plt.plot(polygon[:, 0], polygon[:, 1], 'r.-')
        plt.show()
        plt.clf()

    BBox = copy.deepcopy(polygon)
    eps = 1e-4
    polygon += np.array([-eps, -eps])
    bpath = mplpath.Path(polygon)
    keep = bpath.contains_points(xy)
    xy, NL, KL, BL = le.remove_pts(keep, xy, BL, NN='min', check=lp['check'])

    return xy, NL, KL, BL, PV, BBox, polygon, lattice_exten
Beispiel #5
0
def build_lattice(lattice):
    """Build the lattice based on the values stored in the lp dictionary attribute of supplied lattice instance.

    Returns
    -------
    lattice : lattice_class lattice instance
        The instance of the lattice class, with the following attributes populated:
        lattice.xy = xy
        lattice.NL = NL
        lattice.KL = KL
        lattice.BL = BL
        lattice.PVx = PVx
        lattice.PVy = PVy
        lattice.PVxydict = PVxydict
        lattice.PV = PV
        lattice.lp['BBox'] : #vertices x 2 float array
            BBox is the polygon used to crop the lattice or defining the extent of the lattice; could be hexagonal, for instance.
        lattice.lp['LL'] : tuple of 2 floats
            LL are the linear extent in each dimension of the lattice. For ex:
            ( np.max(xy[:,0])-np.min(xy[:,0]), np.max(xy[:,1])-np.min(xy[:,1]) )
        lattice.lp['LV'] = LV
        lattice.lp['UC'] = UC
        lattice.lp['lattice_exten'] : str
            A string specifier for the lattice built
        lattice.lp['slit_exten'] = slit_exten
    """
    # Define some shortcut variables
    lattice_type = lattice.lp['LatticeTop']
    shape = lattice.lp['shape']
    NH = lattice.lp['NH']
    NV = lattice.lp['NV']
    lp = lattice.lp
    networkdir = lattice.lp['rootdir'] + 'networks/'
    check = lattice.lp['check']
    if lattice_type == 'hexagonal':
        from build_hexagonal import build_hexagonal
        xy, NL, KL, BL, PVxydict, PVx, PVy, PV, LL, LVUC, LV, UC, BBox, lattice_exten = build_hexagonal(
            lp)
    elif lattice_type == 'hexmeanfield':
        from build_hexagonal import build_hexmeanfield
        xy, NL, KL, BL, PVxydict, PVx, PVy, PV, LL, LVUC, LV, UC, BBox, lattice_exten = build_hexmeanfield(
            lp)
    elif lattice_type == 'hexmeanfield3gyro':
        from build_hexagonal import build_hexmeanfield3gyro
        xy, NL, KL, BL, PVxydict, PVx, PVy, PV, LL, LVUC, LV, UC, BBox, lattice_exten = build_hexmeanfield3gyro(
            lp)
    elif 'selregion' in lattice_type:
        # amorphregion_isocent or amorphregion_kagome_isocent, for ex
        # Example usage: python ./build/make_lattice.py -LT selregion_randorg_gammakick1p60_cent -spreadt 0.8 -NP 225
        #  python ./build/make_lattice.py -LT selregion_iscentroid -N 30
        #  python ./build/make_lattice.py -LT selregion_hyperuniform -N 80
        from lepm.build.build_select_region import build_select_region
        xy, NL, KL, BL, PVx, PVy, PVxydict, LVUC, BBox, LL, LV, UC, lattice_exten, lp = build_select_region(
            lp)
    elif lattice_type == 'frame1dhex':
        from build_hexagonal import build_frame1dhex
        # keep only the boundary of the lattice, eliminate the bulk
        xy, NL, KL, BL, PVxydict, PVx, PVy, LL, LVUC, LV, UC, BBox, lattice_exten = build_frame1dhex(
            lp)
    elif lattice_type == 'square':
        import lepm.build.build_square as bs
        print '\nCreating square lattice...'
        xy, NL, KL, BL, lattice_exten = bs.generate_square_lattice(
            shape, NH, NV, lp['eta'], lp['theta'])
        print 'lattice_exten = ', lattice_exten
        PVx = []
        PVy = []
        PVxydict = {}
        LL = (NH + 1, NV + 1)
        LVUC = 'none'
        UC = 'none'
        LV = 'none'
        BBox = np.array([[-LL[0] * 0.5, -LL[1] * 0.5],
                         [LL[0] * 0.5,
                          -LL[1] * 0.5], [LL[0] * 0.5, LL[1] * 0.5],
                         [-LL[0] * 0.5, LL[1] * 0.5]])
    elif lattice_type == 'triangular':
        import lepm.build.build_triangular as bt
        xy, NL, KL, BL, PVxydict, PVx, PVy, LL, LVUC, LV, UC, BBox, lattice_exten = bt.build_triangular_lattice(
            lp)
    elif lattice_type == 'linear':
        from lepm.build.build_linear_lattices import build_zigzag_lattice
        xy, NL, KL, BL, PVxydict, PVx, PVy, LL, LVUC, LV, UC, BBox, lattice_exten = build_zigzag_lattice(
            lp)
        lp['NV'] = 1
    elif lattice_type == 'deformed_kagome':
        from lepm.build.build_kagome import generate_deformed_kagome
        xy, NL, KL, BL, PVxydict, PVx, PVy, PV, LL, LVUC, LV, UC, BBox, lattice_exten = generate_deformed_kagome(
            lp)
    elif lattice_type == 'deformed_martini':
        from lepm.build.build_martini import build_deformed_martini
        xy, NL, KL, BL, PVxydict, PVx, PVy, LL, LVUC, LV, UC, BBox, lattice_exten = build_deformed_martini(
            lp)
    elif lattice_type == 'twisted_kagome':
        from lepm.build.build_kagome import build_twisted_kagome
        xy, NL, KL, BL, PVxydict, PVx, PVy, LL, LVUC, LV, UC, BBox, lattice_exten = build_twisted_kagome(
            lp)
    elif lattice_type == 'hyperuniform':
        from lepm.build.build_hyperuniform import build_hyperuniform
        xy, NL, KL, BL, PVxydict, PVx, PVy, LL, LVUC, LV, UC, BBox, lattice_exten = build_hyperuniform(
            lp)
    elif lattice_type == 'hyperuniform_annulus':
        from lepm.build.build_hyperuniform import build_hyperuniform_annulus
        xy, NL, KL, BL, PVxydict, PVx, PVy, LL, LVUC, LV, UC, BBox, lattice_exten = build_hyperuniform_annulus(
            lp)
        lp['shape'] = 'annulus'
    elif lattice_type == 'isostatic':
        from lepm.build.build_jammed import build_isostatic
        # Manually tune coordination of jammed packing (lets you tune through isostatic point)
        xy, NL, KL, BL, PVxydict, PVx, PVy, LL, LVUC, LV, UC, BBox, lattice_exten = build_isostatic(
            lp)
    elif lattice_type == 'jammed':
        from lepm.build.build_jammed import build_jammed
        xy, NL, KL, BL, PVxydict, PVx, PVy, LL, LVUC, LV, UC, BBox, lattice_exten = build_jammed(
            lp)
    elif lattice_type == 'triangularz':
        from lepm.build.build_triangular import build_triangularz
        xy, NL, KL, BL, PVxydict, PVx, PVy, LL, LVUC, LV, UC, BBox, lattice_exten = build_triangularz(
            lp)
    elif lattice_type == 'hucentroid':
        from lepm.build.build_hucentroid import build_hucentroid
        xy, NL, KL, BL, PVxydict, PVx, PVy, LL, LVUC, LV, UC, BBox, lattice_exten = build_hucentroid(
            lp)
    elif lattice_type == 'hucentroid_annulus':
        from lepm.build.build_hucentroid import build_hucentroid_annulus
        xy, NL, KL, BL, PVxydict, PVx, PVy, LL, LVUC, LV, UC, BBox, lattice_exten = build_hucentroid_annulus(
            lp)
        lp['shape'] = 'annulus'
    elif lattice_type == 'huvoronoi':
        from lepm.build.build_voronoized import build_huvoronoi
        xy, NL, KL, BL, PVx, PVy, PVxydict, LL, BBox, lattice_exten = build_huvoronoi(
            lp)
        LVUC = 'none'
        LV = 'none'
        UC = 'none'
    elif lattice_type == 'kagome_hucent':
        from lepm.build.build_hucentroid import build_kagome_hucent
        xy, NL, KL, BL, PVxydict, PVx, PVy, LL, LVUC, LV, UC, BBox, lattice_exten = build_kagome_hucent(
            lp)
    elif lattice_type == 'kagome_hucent_annulus':
        from lepm.build.build_hucentroid import build_kagome_hucent_annulus
        xy, NL, KL, BL, PVxydict, PVx, PVy, LL, LVUC, LV, UC, BBox, lattice_exten = build_kagome_hucent_annulus(
            lp)
        lp['shape'] = 'annulus'
    elif lattice_type == 'kagome_huvor':
        from lepm.build.build_voronoized import build_kagome_huvor
        print('Loading hyperuniform to build lattice...')
        xy, NL, KL, BL, PVx, PVy, PVxydict, LL, BBox, lattice_exten = build_kagome_huvor(
            lp)
        LV, LVUC, UC = 'none', 'none', 'none'
    elif lattice_type == 'iscentroid':
        from lepm.build.build_iscentroid import build_iscentroid
        print('Loading isostatic to build lattice...')
        xy, NL, KL, BL, PVx, PVy, PVxydict, LVUC, BBox, LL, LV, UC, lattice_exten = build_iscentroid(
            lp)
    elif lattice_type == 'kagome_isocent':
        from lepm.build.build_iscentroid import build_kagome_isocent
        xy, NL, KL, BL, PVx, PVy, PVxydict, LVUC, BBox, LL, LV, UC, lattice_exten = build_kagome_isocent(
            lp)
    elif lattice_type == 'overcoordinated1':
        from lepm.build.build_overcoordinated import generate_overcoordinated1_lattice
        xy, NL, KL, BL, SBL, LV, UC, LVUC, lattice_exten = generate_overcoordinated1_lattice(
            NH, NV)
        PVxydict = {}
        PVx = []
        PVy = []
        if lp['check']:
            le.display_lattice_2D(xy, BL)
    elif lattice_type == 'circlebonds':
        from lepm.build.build_linear_lattices import generate_circle_lattice
        xy, NL, KL, BL, LV, UC, LVUC, lattice_exten = generate_circle_lattice(
            NH)
        PVxydict = {}
        PVx = []
        PVy = []
        lp['NV'] = 1
        minx = np.min(xy[:, 0])
        maxx = np.max(xy[:, 0])
        miny = np.min(xy[:, 1])
        maxy = np.max(xy[:, 1])
        BBox = np.array([[minx, miny], [minx, maxy], [maxx, maxy],
                         [maxx, miny]])
        LL = (maxx - minx, maxy - miny)
    elif lattice_type == 'dislocatedRand':
        from lepm.build.build_dislocatedlattice import build_dislocated_lattice
        xy, NL, KL, BL, PVx, PVy, PVxydict, LL, BBox, lattice_exten = build_dislocated_lattice(
            lp)
    elif lattice_type == 'dislocated':
        if lp['dislocation_xy'] != 'none':
            dislocX = lp['dislocation_xy'].split('/')[0]
            dislocY = lp['dislocation_xy'].split('/')[1]
            dislocxy_exten = '_dislocxy_' + dislocX + '_' + dislocY
            pt = np.array([[float(dislocX), float(dislocY)]])
        else:
            pt = np.array([[0., 0.]])
            dislocxy_exten = ''
        if lp['Bvec'] == 'random':
            Bvecs = 'W'
        else:
            Bvecs = lp['Bvec']
        xy, NL, KL, BL, lattice_exten = generate_dislocated_hexagonal_lattice(
            shape, NH, NV, pt, Bvecs=Bvecs, check=lp['check'])
        lattice_exten += dislocxy_exten
        PVx = []
        PVy = []
        PVxydict = {}
        LL = (np.max(xy[:, 0]) - np.min(xy[:, 0]),
              np.max(xy[:, 1]) - np.min(xy[:, 1]))
        BBox = np.array([[np.min(xy[:, 0]), np.min(xy[:, 1])],
                         [np.max(xy[:, 0]), np.min(xy[:, 1])],
                         [np.max(xy[:, 0]), np.max(xy[:, 1])],
                         [np.min(xy[:, 0]), np.max(xy[:, 1])]])
        LV = 'none'
        UC = 'none'
        LVUC = 'none'
    elif lattice_type == 'penroserhombTri':
        if lp['periodicBC']:
            from lepm.build.build_quasicrystal import generate_periodic_penrose_rhombic
            xy, NL, KL, BL, PVxydict, BBox, PV, lattice_exten = generate_periodic_penrose_rhombic(
                lp)
            LL = (PV[0, 0], PV[1, 1])
            PVx, PVy = le.PVxydict2PVxPVy(PVxydict, NL)
        else:
            from lepm.build.build_quasicrystal import generate_penrose_rhombic_lattice
            xy, NL, KL, BL, lattice_exten, Num_sub = generate_penrose_rhombic_lattice(
                shape, NH, NV, check=lp['check'])
            LL = (np.max(xy[:, 0]) - np.min(xy[:, 0]),
                  np.max(xy[:, 1]) - np.min(xy[:, 1]))
            BBox = blf.auto_polygon(shape, NH, NV, eps=0.00)
            PVx = []
            PVy = []
            PVxydict = {}

        LVUC = 'none'
        LV = 'none'
        UC = 'none'
    elif lattice_type == 'penroserhombTricent':
        from lepm.build.build_quasicrystal import generate_penrose_rhombic_centroid_lattice
        xy, NL, KL, BL, PVxydict, PV, LL, BBox, lattice_exten = generate_penrose_rhombic_centroid_lattice(
            lp)
        # deepcopy PVxydict to generate new pointers
        PVxydict = copy.deepcopy(PVxydict)
        if lp['periodicBC']:
            PVx, PVy = le.PVxydict2PVxPVy(PVxydict, NL)
        else:
            PVx, PVy = [], []

        # Rescale so that median bond length is unity
        bL = le.bond_length_list(xy, BL, NL=NL, KL=KL, PVx=PVx, PVy=PVy)
        scale = 1. / np.median(bL)
        xy *= scale
        PV *= scale
        print 'PV = ', PV
        BBox *= scale
        LL = (LL[0] * scale, LL[1] * scale)

        print 'after updating other things: PVxydict = ', PVxydict
        if lp['periodicBC']:
            PVx *= scale
            PVy *= scale
            PVxydict.update(
                (key, val * scale) for key, val in PVxydict.items())
        else:
            PVx = []
            PVy = []

        LVUC = 'none'
        LV = 'none'
        UC = 'none'
    elif lattice_type == 'kagome_penroserhombTricent':
        from build.build_quasicrystal import generate_penrose_rhombic_centroid_lattice
        xy, NL, KL, BL, lattice_exten = generate_penrose_rhombic_centroid_lattice(
            shape, NH + 5, NV + 5, check=lp['check'])

        # Decorate lattice as kagome
        print('Decorating lattice as kagome...')
        xy, BL, PVxydict = blf.decorate_as_kagome(xy, BL)
        lattice_exten = 'kagome_' + lattice_exten

        xy, NL, KL, BL = blf.mask_with_polygon(shape,
                                               NH,
                                               NV,
                                               xy,
                                               BL,
                                               eps=0.00,
                                               check=False)

        # Rescale so that median bond length is unity
        bL = le.bond_length_list(xy, BL)
        xy *= 1. / np.median(bL)

        minx = np.min(xy[:, 0])
        miny = np.min(xy[:, 1])
        maxx = np.max(xy[:, 0])
        maxy = np.max(xy[:, 1])
        BBox = np.array([[minx, miny], [minx, maxy], [maxx, maxy],
                         [maxx, miny]])
        LL = (np.max(xy[:, 0]) - np.min(xy[:, 0]),
              np.max(xy[:, 1]) - np.min(xy[:, 1]))
        PVx = []
        PVy = []
        PVxydict = {}
        LVUC = 'none'
        LV = 'none'
        UC = 'none'
    elif lattice_type == 'random':
        xx = np.random.uniform(low=-NH * 0.5 - 10,
                               high=NH * 0.5 + 10,
                               size=(NH + 20) * (NV + 20))
        yy = np.random.uniform(low=-NV * 0.5 - 10,
                               high=NV * 0.5 + 10,
                               size=(NH + 20) * (NV + 20))
        xy = np.dstack((xx, yy))[0]
        Dtri = Delaunay(xy)
        TRI = Dtri.vertices
        BL = le.Tri2BL(TRI)
        NL, KL = le.BL2NLandKL(BL, NN='min')

        # Crop to polygon (instead of trimming boundaries)
        # NL, KL, BL, TRI = le.delaunay_cut_unnatural_boundary(xy, NL, KL, BL, TRI, thres=lp['trimbound_thres'])
        shapedict = {shape: [NH, NV]}
        keep = blf.argcrop_lattice_to_polygon(shapedict, xy, check=check)
        xy, NL, KL, BL = le.remove_pts(keep, xy, BL, NN='min')

        lattice_exten = lattice_type + '_square_thres' + sf.float2pstr(
            lp['trimbound_thres'])
        polygon = blf.auto_polygon(shape, NH, NV, eps=0.00)
        BBox = polygon
        LL = (np.max(BBox[:, 0]) - np.min(BBox[:, 0]),
              np.max(BBox[:, 1]) - np.min(BBox[:, 1]))
        PVx = []
        PVy = []
        PVxydict = {}
        LVUC = 'none'
        LV = 'none'
        UC = 'none'
    elif lattice_type == 'randomcent':
        from lepm.build.build_random import build_randomcent
        xy, NL, KL, BL, PVxydict, PVx, PVy, LL, LVUC, LV, UC, BBox, lattice_exten = build_randomcent(
            lp)
    elif lattice_type == 'kagome_randomcent':
        from lepm.build.build_random import build_kagome_randomcent
        xy, NL, KL, BL, PVxydict, PVx, PVy, LL, LVUC, LV, UC, BBox, lattice_exten = build_kagome_randomcent(
            lp)
    elif lattice_type == 'randomspreadcent':
        from lepm.build.build_randomspread import build_randomspreadcent
        xy, NL, KL, BL, PVxydict, PVx, PVy, LL, LVUC, LV, UC, BBox, lattice_exten = build_randomspreadcent(
            lp)
    elif lattice_type == 'kagome_randomspread':
        from lepm.build.build_randomspread import build_kagome_randomspread
        xy, NL, KL, BL, PVxydict, PVx, PVy, LL, LVUC, LV, UC, BBox, lattice_exten = build_kagome_randomspread(
            lp)
    elif 'randorg_gammakick' in lattice_type and 'kaghi' not in lattice_type:
        # lattice_type is like 'randorg_gamma0p20_cent' and uses Hexner pointsets
        # NH is width, NV is height, NP_load is total number of points. This is different than other conventions.
        from build_randorg_gamma import build_randorg_gamma_spread
        xy, NL, KL, BL, PVxydict, PVx, PVy, LL, LVUC, LV, UC, BBox, lattice_exten = build_randorg_gamma_spread(
            lp)
    elif 'randorg_gamma' in lattice_type and 'kaghi' not in lattice_type:
        # lattice_type is like 'randorg_gamma0p20_cent' and uses Hexner pointsets
        from build_randorg_gamma import build_randorg_gamma_spread_hexner
        xy, NL, KL, BL, PVxydict, PVx, PVy, LL, LVUC, LV, UC, BBox, lattice_exten = \
            build_randorg_gamma_spread_hexner(lp)
    elif 'random_organization' in lattice_type:
        try:
            if isinstance(lp['relax_timesteps'], str):
                relax_tag = lp['relax_timesteps']
            else:
                relax_tag = '{0:02d}'.format(lp['relax_timesteps'])
        except:
            raise RuntimeError(
                'lattice parameters dictionary lp needs key relax_timesteps')

        points = np.loadtxt(
            networkdir +
            'random_organization_source/random_organization/random/' +
            'random_kick_' + relax_tag + 'relax/out_d' +
            '{0:02d}'.format(int(lp['conf'])) + '_xy.txt')
        points -= np.mean(points, axis=0)
        xytmp, trash1, trash2, trash3 = blf.mask_with_polygon(shape,
                                                              NH,
                                                              NV,
                                                              points, [],
                                                              eps=0.00)

        xy, NL, KL, BL = le.delaunay_centroid_lattice_from_pts(xytmp,
                                                               polygon='auto',
                                                               check=check)
        polygon = blf.auto_polygon(shape, NH, NV, eps=0.00)

        if check:
            le.display_lattice_2D(xy, BL)

        # Rescale so that median bond length is unity
        bL = le.bond_length_list(xy, BL, NL=NL, KL=KL, PVx=PVx, PVy=PVy)
        xy *= 1. / np.median(bL)
        polygon *= 1. / np.median(bL)

        lattice_exten = lattice_type + '_relax' + relax_tag + '_' + shape + '_d' + \
                        '{0:02d}'.format(int(lp['loadlattice_number']))
        LL = (np.max(xy[:, 0]) - np.min(xy[:, 0]),
              np.max(xy[:, 1]) - np.min(xy[:, 1]))
        PVxydict = {}
        PVx = []
        PVy = []
        BBox = polygon
    elif lattice_type == 'flattenedhexagonal':
        from lepm.build.build_hexagonal import generate_flattened_honeycomb_lattice
        xy, NL, KL, BL, LVUC, LV, UC, PVxydict, PVx, PVy, lattice_exten = \
            generate_flattened_honeycomb_lattice(shape, NH, NV, lp['aratio'], lp['delta'], lp['phi'], eta=0., rot=0.,
                                                 periodicBC=False, check=check)
    elif lattice_type == 'cairo':
        from lepm.build.build_cairo import build_cairo
        xy, NL, KL, BL, PVxydict, PVx, PVy, LL, LVUC, LV, UC, BBox, lattice_exten = build_cairo(
            lp)
    elif lattice_type == 'kagper_hucent':
        from lepm.build.build_hucentroid import build_kagper_hucent
        xy, NL, KL, BL, PVx, PVy, PVxydict, LVUC, BBox, LL, LV, UC, lattice_exten, lp = build_kagper_hucent(
            lp)
    elif lattice_type == 'hex_kagframe':
        from lepm.build.build_kagcentframe import build_hex_kagframe
        # Use lp['alph'] to determine the beginning of the kagomized frame, surrounding hexagonal lattice
        xy, NL, KL, BL, PVx, PVy, PVxydict, LVUC, BBox, LL, LV, UC, lattice_exten, lp = build_hex_kagframe(
            lp)
    elif lattice_type == 'hex_kagcframe':
        from lepm.build.build_kagcentframe import build_hex_kagcframe
        # Use lp['alph'] to determine the beginning of the kagomized frame, surrounding hexagonal lattice
        # as circlular annulus
        xy, NL, KL, BL, PVx, PVy, PVxydict, LVUC, BBox, LL, LV, UC, lattice_exten, lp = build_hex_kagcframe(
            lp)
    elif lattice_type in ['hucent_kagframe', 'hucent_kagcframe']:
        from lepm.build.build_kagcentframe import build_hucent_kagframe
        # Use lp['alph'] to determine the beginning of the kagomized frame, surrounding hucentroid decoration
        xy, NL, KL, BL, PVx, PVy, PVxydict, LVUC, BBox, LL, LV, UC, lattice_exten, lp = build_hucent_kagframe(
            lp)
    elif lattice_type == 'kaghu_centframe':
        from lepm.build.build_kagcentframe import build_kaghu_centframe
        # Use lp['alph'] to determine the beginning of the centroid frame, surrounding kagomized decoration
        xy, NL, KL, BL, PVx, PVy, PVxydict, LVUC, BBox, LL, LV, UC, lattice_exten, lp = build_kaghu_centframe(
            lp)
    elif lattice_type in ['isocent_kagframe', 'isocent_kagcframe']:
        from lepm.build.build_kagcentframe import build_isocent_kagframe
        # Use lp['alph'] to determine the beginning of the kagomized frame, surrounding hucentroid decoration
        xy, NL, KL, BL, PVx, PVy, PVxydict, LVUC, BBox, LL, LV, UC, lattice_exten, lp = build_isocent_kagframe(
            lp)
    elif lattice_type == 'kagsplit_hex':
        from lepm.build.build_kagome import build_kagsplit_hex
        # Use lp['alph'] to determine what fraction (on the right) is kagomized
        xy, NL, KL, BL, PVx, PVy, PVxydict, LVUC, BBox, LL, LV, UC, lattice_exten, lp = build_kagsplit_hex(
            lp)
    elif lattice_type == 'kagper_hex':
        from lepm.build.build_kagome import build_kagper_hex
        # Use lp['alph'] to determine what fraction of the radius/width (in the center) is kagomized
        xy, NL, KL, BL, PVx, PVy, PVxydict, LVUC, BBox, LL, LV, UC, lattice_exten, lp = build_kagper_hex(
            lp)
    elif lattice_type == 'hex_kagperframe':
        from lepm.build.build_kagcentframe import build_hex_kagperframe
        # Use lp['alph'] to determine what fraction of the radius/width (in the center) is partially kagomized
        xy, NL, KL, BL, PVx, PVy, PVxydict, LVUC, BBox, LL, LV, UC, lattice_exten, lp = build_hex_kagperframe(
            lp)
    elif lattice_type == 'kagome':
        from lepm.build.build_kagome import build_kagome
        # lets you make a square kagome
        xy, NL, KL, BL, PVx, PVy, PVxydict, PV, LVUC, BBox, LL, LV, UC, lattice_exten, lp = build_kagome(
            lp)
    elif 'uofc' in lattice_type:
        from lepm.build.build_kagcent_words import build_uofc
        # ['uofc_hucent', 'uofc_kaglow_hucent', 'uofc_kaghi_hucent', 'uofc_kaglow_isocent']:
        xy, NL, KL, BL, PVx, PVy, PVxydict, LVUC, BBox, LL, LV, UC, lattice_exten, lp = build_uofc(
            lp)
    elif 'chicago' in lattice_type:
        from lepm.build.build_kagcent_words import build_chicago
        xy, NL, KL, BL, PVx, PVy, PVxydict, LVUC, BBox, LL, LV, UC, lattice_exten, lp = build_chicago(
            lp)
    elif 'chern' in lattice_type:
        from lepm.build.build_kagcent_words import build_kagcentchern
        xy, NL, KL, BL, PVx, PVy, PVxydict, LVUC, BBox, LL, LV, UC, lattice_exten, lp = build_kagcentchern(
            lp)
    elif 'csmf' in lattice_type:
        from lepm.build.build_kagcent_words import build_kagcentcsmf
        xy, NL, KL, BL, PVx, PVy, PVxydict, LVUC, BBox, LL, LV, UC, lattice_exten, lp = build_kagcentcsmf(
            lp)
    elif 'thanks' in lattice_type:
        # example:
        # python ./build/make_lattice.py -LT kaghi_isocent_thanks -skip_gyroDOS -NH 300 -NV 70 -thres 5.5 -skip_polygons
        from lepm.build.build_kagcent_words import build_kagcentthanks
        xy, NL, KL, BL, PVx, PVy, PVxydict, LVUC, BBox, LL, LV, UC, lattice_exten, lp = build_kagcentthanks(
            lp)
    elif 'curvys' in lattice_type:
        # for lattice_type in ['kaghi_isocent_curvys', 'kaglow_isocent_curvys',
        #                      'kaghi_hucent_curvys', 'kaglow_hucent_curvys', kaghi_randorg_gammakick1p60_cent_curvys',
        #                      'kaghi_randorg_gammakick0p50_cent_curvys', ... ]
        # example usage:
        # python ./build/make_lattice.py -LT kaghi_isocent_curvys -NH 100 -NV 70 -thres 5.5 -skip_polygons -skip_gyroDOS
        from lepm.build.build_kagcent_words import build_kagcentcurvys
        xy, NL, KL, BL, PVx, PVy, PVxydict, LVUC, BBox, LL, LV, UC, lattice_exten, lp = build_kagcentcurvys(
            lp)
    elif 'hexannulus' in lattice_type:
        from lepm.build.build_conformal import build_hexannulus
        xy, NL, KL, BL, lattice_exten, lp = build_hexannulus(lp)
        LL = (np.max(xy[:, 0]) - np.min(xy[:, 0]),
              np.max(xy[:, 1]) - np.min(xy[:, 1]))
        PVxydict = {}
        PVx = []
        PVy = []
        UC = np.array([0, 0])
        LV = 'none'
        LVUC = 'none'
        minx = np.min(xy[:, 0])
        miny = np.min(xy[:, 1])
        maxx = np.max(xy[:, 0])
        maxy = np.max(xy[:, 1])
        BBox = np.array([[minx, miny], [minx, maxy], [maxx, maxy],
                         [maxx, miny]])
    elif 'accordion' in lattice_type:
        # accordionhex accordiony accordionkagy
        # Example usage:
        # python ./build/make_lattice.py -LT accordionkag -alph 0.9 -intparam 2 -N 6 -skip_polygons -skip_gyroDOS
        # nzag controlled by lp['intparam'], and the rotation of the kagome element is controlled by lp['alph']
        if lattice_type == 'accordionhex':
            from lepm.build.build_hexagonal import build_accordionhex
            xy, NL, KL, BL, PVx, PVy, PVxydict, LVUC, BBox, LL, LV, UC, lattice_exten, lp, xyvx = build_accordionhex(
                lp)
        elif lattice_type == 'accordionkag':
            from lepm.build.build_kagome import build_accordionkag
            xy, NL, KL, BL, PVx, PVy, PVxydict, PV, LVUC, BBox, LL, LV, UC, lattice_exten, lp = build_accordionkag(
                lp)
        elif lattice_type == 'accordionkag_hucent':
            from lepm.build.build_hucentroid import build_accordionkag_hucent
            xy, NL, KL, BL, PVxydict, PVx, PVy, LL, LVUC, LV, UC, BBox, lattice_exten = \
                build_accordionkag_hucent(lp)
        elif lattice_type == 'accordionkag_isocent':
            from lepm.build.build_iscentroid import build_accordionkag_isocent
            xy, NL, KL, BL, PVxydict, PVx, PVy, LL, LVUC, LV, UC, BBox, lattice_exten = \
                build_accordionkag_isocent(lp)
    elif 'spindle' in lattice_type:
        if lattice_type == 'spindle':
            from lepm.build.build_spindle import build_spindle
            xy, NL, KL, BL, PVxydict, PVx, PVy, PV, LL, LVUC, LV, UC, BBox, lattice_exten = build_spindle(
                lp)
    elif lattice_type == 'stackedrhombic':
        from lepm.build.build_rhombic import build_stacked_rhombic
        xy, NL, KL, BL, PVxydict, PVx, PVy, PV, LL, LVUC, LV, UC, BBox, lattice_exten = build_stacked_rhombic(
            lp)
    elif 'junction' in lattice_type:
        # accordionhex accordiony accordionkagy
        if lattice_type == 'hexjunction':
            from lepm.build.build_hexagonal import build_hexjunction
            xy, NL, KL, BL, PVx, PVy, PVxydict, LVUC, BBox, LL, LV, UC, lattice_exten, lp, xyvx = build_hexjunction(
                lp)
        elif lattice_type == 'kagjunction':
            from lepm.build.build_kagome import build_kagjunction
            xy, NL, KL, BL, PVx, PVy, PVxydict, LVUC, BBox, LL, LV, UC, lattice_exten, lp = build_kagjunction(
                lp)

    ###########

    # For reference: this is how to change z
    # le.cut_bonds_z(BL,lp['target_z'])
    # ##cut N bonds for z
    # N2cut = int(round((z_start-target_z)*len(BL)/z_start))
    # allrows = range(len(BL))
    # inds = random.sample(allrows, N2cut)
    # keep = np.setdiff1d(allrows,inds)
    # bnd_z = BL[keep]

    # Cut slit
    if lp['make_slit']:
        print('Cuting notch or slit...')
        L = max(xy[:, 0]) - min(xy[:, 0])
        cutL = L * lp['cutLfrac']
        x0 = -L * 0. + cutL * 0.5 - 1.  # 0.25*L+0.5
        BL, xy = blf.cut_slit(BL, xy, cutL + 1e-3, x0, y0=0.2)
        slit_exten = '_cutL' + str(cutL / L) + 'L_x0_' + str(x0)

        print('Rebuilding NL,KL...')
        NP = len(xy)
        if latticetop == 'deformed_kagome':
            nn = 4
        elif lattice_type == 'linear':
            if NP == 1:
                nn = 0
            else:
                nn = 2
        else:
            nn = 'min'

        NL, KL = le.BL2NLandKL(BL, NP=NP, NN=nn)

        # remake BL too
        BL = le.NL2BL(NL, KL)
    else:
        slit_exten = ''
        NP = len(xy)

    if lp['check']:
        print 'make_lattice: Showing lattice before saving...'
        # print 'PVx = ', PVx
        # print 'PVy = ', PVy
        le.display_lattice_2D(xy, BL, PVxydict=PVxydict)
    ################

    lattice.xy = xy
    lattice.NL = NL
    lattice.KL = KL
    lattice.BL = BL
    lattice.PVx = PVx
    lattice.PVy = PVy
    lattice.PVxydict = PVxydict
    lattice.LVUC = LVUC
    lattice.lp = lp
    lattice.lp['BBox'] = BBox
    lattice.lp['LL'] = LL
    lattice.lp['LV'] = LV
    lattice.lp['UC'] = UC
    lattice.lp['lattice_exten'] = lattice_exten
    lattice.lp['slit_exten'] = slit_exten
    lattice.lp['Nparticles'] = NP
    return lattice
Beispiel #6
0
def build_hexannulus_filled_defects(lp):
    """Build a U(1) symmetric honeycomb lattice within an annulus. The inner radius is given by alpha
    At some cutoff radius, decrease the number of particles in each new row. Also, place a particle at the center.
    Instead of lp['alph'] determining the inner radius cutoff as a fraction of the system size,
    lp['alph'] as the cutoff radius for when to decrease the number of particles in each row.
    Remove lp['Ndefects'] at each row within a radius of lp['alph'] * system_size.

    Parameters
    ----------
    lp : dict

    """
    N = lp['NH']
    shape = 'circle'
    theta = np.linspace(0, 2. * np.pi, N + 1)
    theta = theta[:-1]
    # The radius, given the length of a side is:
    # radius = s/(2 * sin(2 pi/ n)), where n is number of sides, s is length of each side
    # We set the length of a side to be 1 (the rest length of each bond)
    Rout = 1. / (2. * np.sin(np.pi / float(N)))
    if lp['alph'] < 1e-5 or lp['alph'] > 1:
        raise RuntimeError('lp param alph must be > 0 and less than 1')
    Rinner = lp['alph'] * Rout

    # Make the first row
    xtmp = Rout * np.cos(theta)
    ytmp = Rout * np.sin(theta)
    xy = np.dstack([xtmp, ytmp])[0]
    if lp['check']:
        plt.plot(xy[:, 0], xy[:, 1], 'b.')
        for ii in range(len(xy)):
            plt.text(xy[ii, 0] + 0.2 * np.random.rand(1)[0],
                     xy[ii, 1] + 0.2 * np.random.rand(1)[0], str(ii))
        plt.title('First row')
        plt.show()

    # rotate by delta(theta)/2 and shrink xy so that outer bond lengths are all equal to unity
    # Here we have all bond lengths of the outer particles == 1, so that the inner radius is determined by
    #
    #           o z1
    #        /  |
    #      /    |
    # z2  o     |       |z2 - z0| = |z2 - z1| --> if z2 = r2 e^{i theta/2}, and z1 = r1 e^{i theta}, and z0 = r1,
    #       \   |                                 then r2 = r1 cos[theta/2] - sqrt[s**2 - r1**2 + r1**2 cos[theta/2]**2]
    #         \ |                                   or r2 = r1 cos[theta/2] + sqrt[s**2 - r1**2 + r1**2 cos[theta/2]**2]
    #           o z0                              Choose the smaller radius (the first one).
    #                                             s is the sidelength, initially == 1
    #                                             iterate sidelength: s = R*2*sin(2pi/N)
    #                                                --> see for ex, http://www.mathopenref.com/polygonradius.html
    dt = np.diff(theta)
    if (dt - dt[0] < 1e-12).all():
        dt = dt[0]
    else:
        print 'dt = ', dt
        raise RuntimeError('Not all thetas are evenly spaced')
    RR = Rout
    ss = 1.
    Rnext = RR * np.cos(dt * 0.5) - np.sqrt(ss**2 - RR**2 +
                                            RR**2 * np.cos(dt * 0.5)**2)
    rlist = [RR]

    # Continue adding more rows
    kk = 0
    while Rnext > Rinner:
        print 'Adding Rnext = ', Rnext
        print 'with bond length connecting to last row = ', ss
        # Add to xy
        if np.mod(kk, 2) == 0:
            xtmp = Rnext * np.cos(theta + dt * 0.5)
            ytmp = Rnext * np.sin(theta + dt * 0.5)
        else:
            xtmp = Rnext * np.cos(theta)
            ytmp = Rnext * np.sin(theta)
        xyadd = np.dstack([xtmp, ytmp])[0]
        xy = np.vstack((xy, xyadd))
        rlist.append(Rnext)

        if lp['check']:
            plt.plot(xy[:, 0], xy[:, 1], 'b.')
            for ii in range(len(xy)):
                plt.text(xy[ii, 0] + 0.2 * np.random.rand(1)[0],
                         xy[ii, 1] + 0.2 * np.random.rand(1)[0], str(ii))
            plt.title('next row')
            plt.show()

        RR = Rnext
        ss = RR * np.sin(2. * np.pi / N)
        print 'next sidelength = ', ss
        Rnext = RR * np.cos(dt * 0.5) - np.sqrt(ss**2 - RR**2 +
                                                RR**2 * np.cos(dt * 0.5)**2)
        kk += 1

    Rfinal = RR
    # Get NV from the number of rows laid down.
    NVtri = len(rlist)
    lp['NV'] = NVtri - 2

    print('Triangulating points...\n')
    tri = Delaunay(xy)
    TRItmp = tri.vertices

    print('Computing bond list...\n')
    BL = le.Tri2BL(TRItmp)
    # bL = le.bond_length_list(xy,BL)
    thres = 1.1  # cut off everything longer than a diagonal
    print('thres = ' + str(thres))
    print('Trimming bond list...\n')
    BLtrim = le.cut_bonds(BL, xy, thres)
    print('Trimmed ' + str(len(BL) - len(BLtrim)) + ' bonds.')

    xy, NL, KL, BL = le.voronoi_lattice_from_pts(xy, NN=3, kill_outliers=True)

    # Remove any bonds that cross the inner circle
    tmpt = np.linspace(0, 2. * np.pi, 2000)
    innercircle = Rinner * np.dstack((np.cos(tmpt), np.sin(tmpt)))[0]
    # cycle the inner circle by one
    ic_roll = np.dstack((np.roll(innercircle[:, 0],
                                 -1), np.roll(innercircle[:, 1], -1)))[0]
    ic = np.hstack((innercircle, ic_roll))
    bondsegs = np.hstack((xy[BL[:, 0]], xy[BL[:, 1]]))
    does_intersect = linsegs.linesegs_intersect_linesegs(bondsegs,
                                                         ic,
                                                         thres=1e-6)
    keep = np.ones(len(BL[:, 0]), dtype=bool)
    keep[does_intersect] = False
    BL = BL[keep]

    # Remove any points that ended up inside the inner radius (this should not be necessary)
    inpoly = le.inds_in_polygon(xy, innercircle)
    keep = np.setdiff1d(np.arange(len(xy)), inpoly)
    print 'keep = ', keep
    print 'len(xy) = ', len(xy)
    xy, NL, KL, BL = le.remove_pts(keep, xy, BL, NN='min', check=lp['check'])

    # Randomize if eta > 0 specified
    eta = lp['eta']
    if eta == 0:
        xypts = xy
        eta_exten = ''
    else:
        print 'Randomizing lattice by eta=', eta
        jitter = eta * np.random.rand(np.shape(xy)[0], np.shape(xy)[1])
        xypts = np.dstack(
            (xy[:, 0] + jitter[:, 0], xy[:, 1] + jitter[:, 1]))[0]
        eta_exten = '_eta{0:.3f}'.format(eta).replace('.', 'p')

    # Naming
    exten = '_circle_delta0p667_phi0p000_alph{0:0.2f}'.format(
        lp['alph']).replace('.', 'p') + eta_exten

    lattice_exten = 'hexannulus' + exten
    print 'lattice_exten = ', lattice_exten

    if lp['check']:
        le.display_lattice_2D(xy,
                              BL,
                              NL=NL,
                              KL=KL,
                              title='output from build_hexannulus()',
                              close=False)
        for ii in range(len(xy)):
            plt.text(xy[ii, 0] + 0.2 * np.random.rand(1)[0],
                     xy[ii, 1] + 0.2 * np.random.rand(1)[0], str(ii))
        plt.show()

    # Scale up xy
    BM = le.BL2BM(xy, NL, BL, KL=KL, PVx=None, PVy=None)
    bL = le.BM2bL(NL, BM, BL)
    scale = 1. / np.median(bL)
    xy *= scale
    return xy, NL, KL, BL, lattice_exten, lp
Beispiel #7
0
def build_kagome_randomcent(lp):
    """Build uniformly random point set, and construct voronoized network from that.

    lp : dict
        lattice parameters dictionary
    """
    NH = lp['NH']
    NV = lp['NV']
    LL = (NH, NV)
    if lp['periodicBC']:
        xx = np.random.uniform(low=-NH * 0.5, high=NH * 0.5, size=NH * NV)
        yy = np.random.uniform(low=-NV * 0.5, high=NV * 0.5, size=NH * NV)
        xy = np.dstack((xx, yy))[0]
        xy, NL, KL, BL, PVxydict = \
            kagomecentroid_periodic_network_from_pts(xy, LL, BBox='auto', check=lp['check'])
        PVx, PVy = le.PVxydict2PVxPVy(PVxydict, NL)

        # check that all points are inside BBox
        shapedict = {lp['shape']: [NH, NV]}
        keep = argcrop_lattice_to_polygon(shapedict, xy, check=lp['check'])
        if len(np.where(keep)[0]) != len(xy):
            raise RuntimeError('Some points were spuriously outside the allowed BBox.')
        polygon = auto_polygon(lp['shape'], NH, NV, eps=0.00)
        perstr = '_periodic'
    else:
        xx = np.random.uniform(low=-NH * 0.5 - 10, high=NH * 0.5 + 10, size=(NH + 20) * (NV + 20))
        yy = np.random.uniform(low=-NV * 0.5 - 10, high=NV * 0.5 + 10, size=(NH + 20) * (NV + 20))
        xy = np.dstack((xx, yy))[0]

        xy, NL, KL, BL = kagomecentroid_lattice_from_pts(xy, polygon=None, trimbound=False, check=lp['check'])

        # Crop to polygon
        shapedict = {lp['shape']: [NH, NV]}
        keep = argcrop_lattice_to_polygon(shapedict, xy, check=lp['check'])
        xy, NL, KL, BL = le.remove_pts(keep, xy, BL, NN='min')
        polygon = auto_polygon(lp['shape'], NH, NV, eps=0.00)
        PVxydict = {}
        PVx = []
        PVy = []
        perstr = ''

    # If the meshfn going to overwrite a previous realization?
    mfok = le.meshfn_is_used(le.build_meshfn(lp)[0])
    print 'mfok = ', mfok
    while mfok:
        lp['conf'] += 1
        mfok = le.meshfn_is_used(le.build_meshfn(lp)[0])

    lattice_exten = lp['LatticeTop'] + '_' + lp['shape'] + perstr + '_r' + '{0:02d}'.format(int(lp['conf']))

    # Rescale so that median bond length is unity
    bL = le.bond_length_list(xy, BL, NL=NL, KL=KL, PVx=PVx, PVy=PVy)
    scale = 1. / np.median(bL)
    xy *= scale
    polygon *= scale
    LL = (LL[0] * scale, LL[1] * scale)
    if lp['periodicBC']:
        PVx *= scale
        PVy *= scale
        PVxydict.update((key, val * scale) for key, val in PVxydict.items())
    LVUC = 'none'
    LV = 'none'
    UC = 'none'
    BBox = polygon
    PVx, PVy = le.PVxydict2PVxPVy(PVxydict, NL)

    return xy, NL, KL, BL, PVxydict, PVx, PVy, LL, LVUC, LV, UC, BBox, lattice_exten
Beispiel #8
0
def build_isostatic(lp):
    """Build a network by manually tuning coordination of jammed packing (lets you tune through isostatic point)

    Parameters
    ----------
    lp

    Returns
    -------

    """
    # Manually tune coordination of jammed packing (lets you tune through isostatic point)
    networkdir = lp['rootdir'] + 'networks/'
    print(
        'Loading isostatic: get jammed point set to build lattice with new bonds...'
    )
    number = '{0:03d}'.format(int(lp['conf']))
    if lp['source'] == 'hexner':
        # Use Daniel Hexner - supplied networks
        points, BL, LLv, numberstr, sizestr, lp = load_hexner_jammed(
            lp, BL_load=False)
        LL = (LLv, LLv)
        print 'LL = ', LL
        sourcestr = '_hexner'
    else:
        zindex = '{0:03d}'.format(int(lp['loadlattice_z']))
        points = np.loadtxt(networkdir + 'isostatic_source/isostatic_homog_z' +
                            zindex + '_conf' + number + '_nodes.txt')
    points -= np.mean(points, axis=0)

    # DO initial cropping to speed up triangulation
    keep1 = np.logical_and(
        abs(points[:, 0]) < lp['NH'] * 0.5 + 8,
        abs(points[:, 1]) < lp['NV'] * 0.5 + 8)
    xy = points[keep1]
    if lp['periodicBC']:
        xy, NL, KL, BL, PVxydict = \
            le.delaunay_rect_periodic_network_from_pts(xy, LL, target_z=lp['target_z'],
                                                       zmethod=lp['cutz_method'], check=check)
        PVx, PVy = le.PVxydict2PVxPVy(PVxydict, NL)
        periodicstr = '_periodic'
    else:
        xy, NL, KL, BL, BM = le.delaunay_lattice_from_pts(
            xy,
            trimbound=False,
            target_z=lp['target_z'],
            zmethod=lp['cutz_method'],
            check=check)

        # if lp['cutz_method'] == 'random':
        #     NL, KL, BL = le.cut_bonds_z_random(xy, NL, KL, BL, lp['target_z'],  bulk_determination='Endpts')
        # elif lp['cutz_method'] == 'highest':
        #     NL, KL, BL = le.cut_bonds_z_highest(xy, NL, KL, BL, lp['target_z'], check=check)
        # elif lp['cutz_method'] == 'none':
        #     pass

        print('Trimming lattice to be NH x NV...')
        keep = np.logical_and(
            abs(xy[:, 0]) < lp['NH'] * 0.5,
            abs(xy[:, 1]) < lp['NV'] * 0.5)
        xy, NL, KL, BL = le.remove_pts(keep,
                                       xy,
                                       BL,
                                       NN='min',
                                       check=lp['check'])
        PVxydict = {}
        PVx = []
        PVy = []
        periodicstr = ''

    le.movie_plot_2D(xy,
                     BL,
                     bs=0.0 * BL[:, 0],
                     PVx=PVx,
                     PVy=PVy,
                     PVxydict=PVxydict,
                     colormap='BlueBlackRed',
                     title='Output during isostatic build',
                     show=True)
    plt.close('all')

    # Calculate coordination number
    z = le.compute_bulk_z(copy.deepcopy(xy), copy.deepcopy(NL),
                          copy.deepcopy(KL), copy.deepcopy(BL))
    print 'FOUND z = ', z
    lattice_exten = 'isostatic_' + lp['shape'] + periodicstr + sourcestr + '_z' + '{0:0.03f}'.format(z) + '_conf' + \
                    numberstr + '_zmethod' + lp['cutz_method']
    BBox = np.array([[-LL[0] * 0.5, -LL[1] * 0.5], [LL[0] * 0.5, -LL[1] * 0.5],
                     [LL[0] * 0.5, LL[1] * 0.5], [-LL[0] * 0.5, LL[1] * 0.5]])
    LV = 'none'
    UC = 'none'
    LVUC = 'none'
    plt.close('all')
    return xy, NL, KL, BL, PVx, PVy, PVxydict, LVUC, BBox, LL, LV, UC, lattice_exten, lp
Beispiel #9
0
def build_jammed(lp):
    """Use bonds from jammed packing --> already near isostatic, but can't tune above it, only below.

    Parameters
    ----------
    lp

    Returns
    -------

    """
    # Use bonds from jammed packing --> already near isostatic, but can't tune above it, only below.
    shape = lp['shape']
    nh = lp['NH']
    nv = lp['NV']
    networkdir = dio.ensure_dir(lp['rootdir']) + 'networks/'

    print('Loading isostatic file to build jammed lattice...')
    # Now load
    use_hexner = (lp['source'] == 'hexner')
    if use_hexner:
        print 'lp[periodicBC] = ', lp['periodicBC']
        points, BL, LLv, numberstr, sizestr, lp = load_hexner_jammed(
            lp, BL_load=True)
        sourcestr = '_hexner'
    else:
        # Use Stephan Ulrich's lattices
        if lp['periodicBC']:
            RuntimeError('Not sure if Stephan Ulrich lattices are periodic!')
        zindex = '{0:03d}'.format(int(lp['loadlattice_z']))
        number = '{0:03d}'.format(int(lp['conf']))
        points = np.loadtxt(networkdir + 'isostatic_source/isostatic_homog_z' +
                            zindex + '_conf' + number + '_nodes.txt')
        BL = np.loadtxt(networkdir + 'isostatic_source/isostatic_homog_z' +
                        zindex + '_conf' + number + '_bonds.txt',
                        usecols=(0, 1),
                        dtype=int)
        sourcestr = '_ulrich_homog'
        print 'BL[100] = ', BL[100]
        # Loaded BL uses indexing starting at 1, not 0
        BL -= 1
        print 'BL[100] = ', BL[100]
        numberstr = number[1:]

    if check:
        le.display_lattice_2D(points,
                              np.abs(BL),
                              title='points and bonds loaded, before pruning')
    xy = points - np.mean(points, axis=0)
    NL, KL = le.BL2NLandKL(BL, NN='min')

    # Remove any points with no bonds
    print 'Removing points without any bonds...'
    keep = KL.any(axis=1)
    xy, NL, KL, BL = le.remove_pts(keep, xy, BL, NN='min')
    print 'len(xy) = ', len(xy)

    if check:
        le.display_lattice_2D(
            xy,
            np.abs(BL),
            title='Before tuning z (down) and before fixing PBCs')

    if lp['cutz_method'] == 'random':
        NL, KL, BL = le.cut_bonds_z_random(xy,
                                           NL,
                                           KL,
                                           BL,
                                           lp['target_z'],
                                           bulk_determination='Endpts')
    elif lp['cutz_method'] == 'highest':
        NL, KL, BL = le.cut_bonds_z_highest(xy,
                                            NL,
                                            KL,
                                            BL,
                                            lp['target_z'],
                                            check=check)
    elif lp['cutz_method'] == 'none':
        pass

    if lp['periodicBC'] or lp['NP_load'] > 0:
        print 'Building periodicBC PVs...'
        lp['periodicBC'] = True
        LL = (LLv, LLv)
        polygon = 0.5 * np.array([[-LLv, -LLv], [LLv, -LLv], [LLv, LLv],
                                  [-LLv, LLv]])
        BBox = polygon
        PV = np.array([[LLv, 0.0], [LLv, LLv], [LLv, -LLv], [0.0, 0.0],
                       [0.0, LLv], [0.0, -LLv], [-LLv, 0.0], [-LLv, LLv],
                       [-LLv, -LLv]])
        PVxydict = le.BL2PVxydict(BL, xy, PV)
        PVx, PVy = le.PVxydict2PVxPVy(PVxydict, NL)

        if lp['check']:
            le.display_lattice_2D(xy,
                                  BL,
                                  NL=NL,
                                  KL=KL,
                                  PVx=PVx,
                                  PVy=PVy,
                                  title='Checking periodic BCs',
                                  close=False,
                                  colorz=False)
            for ii in range(len(xy)):
                plt.text(xy[ii, 0] + 0.1, xy[ii, 1], str(ii))
            plt.plot(xy[:, 0], xy[:, 1], 'go')
            plt.show()
    else:
        polygon = blf.auto_polygon(shape, nh, nv, eps=0.00)
        BBox = polygon
        print('Trimming lattice to be NH x NV...')
        keep = np.logical_and(
            abs(xy[:, 0]) < nh * 0.5,
            abs(xy[:, 1]) < nv * 0.5)
        print "Check that if lp['NP_load'] !=0 then len(keep) == len(xy):", len(
            keep) == len(xy)
        xy, NL, KL, BL = le.remove_pts(keep, xy, BL, NN='min')
        LL = (nh, nv)
        PVx = []
        PVy = []
        PVxydict = {}

    z = le.compute_bulk_z(xy, NL, KL, BL)
    print 'FOUND z = ', z

    if lp['periodicBC']:
        periodicBCstr = '_periodicBC'
    else:
        periodicBCstr = ''

    print('Defining lattice_exten...')
    lattice_exten = 'jammed_' + shape + sourcestr + periodicBCstr + '_z' + '{0:0.03f}'.format(z) + '_conf' + \
                    numberstr + '_zmethod' + lp['cutz_method']
    LV = 'none'
    UC = 'none'
    LVUC = 'none'
    return xy, NL, KL, BL, PVx, PVy, PVxydict, LVUC, BBox, LL, LV, UC, lattice_exten, lp
def calc_boundary_inner(mglat, check=False):
    """

    Parameters
    ----------
    mglat: MagneticGyroLattice instance
    check: bool

    Returns
    -------
    boundary_inner : M x 1 int array
        the idices of mglat.xy that mark the boundary of mglat.xy_inner
    """
    # First check if there is an outer boundary to be ignored
    if len(mglat.outer_indices) == 0:
        # All particles are inner particles
        boundary_inner = mglat.lattice.get_boundary()
    else:
        # First remove the outer boundary
        print 'mgfns: removing outer boundary for tmp lattice'
        xytmp, NLtmp, KLtmp, BLtmp = le.remove_pts(
            mglat.inner_indices,
            mglat.xy,
            mglat.lattice.BL,
            NN='min',
            check=check,
            PVxydict=mglat.lattice.PVxydict,
            PV=mglat.lattice.PV)
        if mglat.lattice.PV is not None:
            PVxydict_tmp = le.BL2PVxydict(BLtmp, xytmp, mglat.lattice.PV)
            PVxtmp, PVytmp = le.PVxydict2PVxPVy(PVxydict_tmp,
                                                NLtmp,
                                                KLtmp,
                                                check=check)
        if mglat.lp['periodic_strip']:
            # Special case: if the entire strip is a boundary, then get
            boundary = le.extract_1d_boundaries(xytmp,
                                                NLtmp,
                                                KLtmp,
                                                BLtmp,
                                                PVxtmp,
                                                PVytmp,
                                                check=check)
        elif mglat.lp['periodicBC']:
            boundary = None
            raise RuntimeError(
                'periodic boundary conditions and not periodic strip, yet outer_indices are nonempty'
            )
        elif 'annulus' in mglat.lp['LatticeTop'] or mglat.lp[
                'shape'] == 'annulus':
            print 'here'
            outer_boundary = le.extract_boundary(xytmp,
                                                 NLtmp,
                                                 KLtmp,
                                                 BLtmp,
                                                 check=check)
            inner_boundary = le.extract_inner_boundary(xytmp,
                                                       NLtmp,
                                                       KLtmp,
                                                       BLtmp,
                                                       check=check)
            boundary = (outer_boundary, inner_boundary)
        else:
            boundary = le.extract_boundary(xytmp,
                                           NLtmp,
                                           KLtmp,
                                           BLtmp,
                                           check=check)

        # Now determine which particles are the same as xytmp[boundary]
        boundary_inner = dh.match_points(mglat.xy, xytmp[boundary])

        if check:
            print 'mgfns: boundary_inner = ', boundary_inner
            import matplotlib.pyplot as plt
            plt.plot(mglat.xy[:, 0], mglat.xy[:, 1], 'b.')
            plt.plot(xytmp[boundary, 0], xytmp[boundary, 1], 'go')
            plt.plot(mglat.xy[boundary_inner, 0], mglat.xy[boundary_inner, 1],
                     'r.')
            plt.show()

        return boundary_inner
Beispiel #11
0
def build_select_region(lp):
    """

    Parameters
    ----------
    lp

    Returns
    -------

    """
    lpnew = copy.deepcopy(lp)
    lpnew['LatticeTop'] = lp['LatticeTop'].split('selregion_')[-1]
    lpnew['check'] = False
    print 'lpnew[LatticeTop] = ', lpnew['LatticeTop']
    lattice = lattice_class.Lattice(lpnew)
    print '\nBuilding lattice...'
    lattice.build()
    # xy, NL, KL, BL, PVx, PVy, PVxydict, LVUC, BBox, LL, LV, UC, lattice_exten = build_kagome_isocent(lp)
    xy = lattice.xy
    NL = lattice.NL
    KL = lattice.KL
    BL = lattice.BL
    PVx = lattice.PVx
    PVy = lattice.PVy
    PVxydict = lattice.PVxydict
    try:
        LVUC = lattice.lp['LVUC']
        LV = lattice.lp['LV']
        UC = lattice.lp['UC']
    except:
        LVUC = 'none'
        LV = 'none'
        UC = 'none'

    LL = lattice.lp['LL']
    old_lattice_exten = lattice.lp['lattice_exten']

    # Display lattice
    ax = le.display_lattice_2D(xy,
                               BL,
                               NL=NL,
                               KL=KL,
                               PVxydict=PVxydict,
                               PVx=PVx,
                               PVy=PVy,
                               title='Choose roi polygon',
                               xlimv=None,
                               ylimv=None,
                               colorz=True,
                               ptcolor=None,
                               ptsize=10,
                               close=False,
                               colorpoly=False,
                               viewmethod=False,
                               labelinds=False,
                               colormap='BlueBlackRed',
                               bgcolor='#FFFFFF',
                               axis_off=False,
                               linewidth=0.0,
                               edgecolors=None,
                               check=False)

    # let user draw ROI
    roi = roipoly(ax=ax, roicolor='r')

    print 'roi = ', roi
    print 'x = ', roi.allxpoints
    print 'y = ', roi.allypoints
    roi = np.dstack((roi.allxpoints, roi.allypoints))[0]
    inpoly = dh.inds_in_polygon(xy, roi)
    print 'inpoly = ', inpoly
    if lp['check']:
        plt.plot(xy[inpoly, 0], xy[inpoly, 1], 'b.')
        plt.show()

    xy, NL, KL, BL = le.remove_pts(inpoly, xy, BL, check=lp['check'])
    if lp['periodicBC']:
        PV = le.PVxydict2PV(PVxydict)
        PVxydict = le.BL2PVxydict(BL, xy, PV)
        # If cropping the points has cut off all periodic BCs, update lp to reflect this
        if len(PVxydict) == 0:
            lp['periodicBC'] = False

    if LVUC is not None and LVUC is not 'none':
        LVUC = LVUC[inpoly]

    BBox = roi
    lattice_exten = 'selregion_' + old_lattice_exten + '_NP{0:06d}'.format(
        len(xy))
    xy -= np.mean(xy, axis=0)
    if lp['check']:
        ax = le.display_lattice_2D(xy,
                                   BL,
                                   NL=NL,
                                   KL=KL,
                                   PVxydict=PVxydict,
                                   PVx=PVx,
                                   PVy=PVy,
                                   title='Cropped network',
                                   xlimv=None,
                                   ylimv=None,
                                   colorz=True,
                                   ptcolor=None,
                                   ptsize=10,
                                   close=False,
                                   colorpoly=False,
                                   viewmethod=False,
                                   labelinds=False,
                                   colormap='BlueBlackRed',
                                   bgcolor='#FFFFFF',
                                   axis_off=False,
                                   linewidth=0.0,
                                   edgecolors=None,
                                   check=False)

    return xy, NL, KL, BL, PVx, PVy, PVxydict, LVUC, BBox, LL, LV, UC, lattice_exten, lp
Beispiel #12
0
def build_hyperuniform(lp):
    """Build a network from a triangulated hyperuniform pointset

    Parameters
    ----------
    lp

    Returns
    -------

    """
    networkdir = dio.prepdir(lp['rootdir']) + 'networks/'
    NH = lp['NH']
    NV = lp['NV']
    shape = lp['shape']
    if lp['NP_load'] == 0:
        points = np.loadtxt(networkdir +
                            'hyperuniform_source/hyperuniform_N400/out_d' +
                            str(int(lp['conf'])) + '_xy.txt')
        points -= np.mean(points, axis=0) + lp['origin']
        # make lattice larger than final cut
        keep = np.logical_and(
            abs(points[:, 0]) < NH * 1.5 + 8,
            abs(points[:, 1]) < NV * 1.5 + 8)
        xy = points[keep]
        xytri, NL, KL, BL, BM = le.delaunay_lattice_from_pts(
            xy, trimbound=False, target_z=lp['target_z'])
        # Crop lattice down to size
        polygon = blf.auto_polygon(shape, NH, NV, eps=0.00)
        BBox = polygon
        print('Trimming lattice to be NH x NV...')
        keep = np.logical_and(
            abs(xy[:, 0]) < NH * 0.5,
            abs(xy[:, 1]) < NV * 0.5)
        print "Check that if lp['NP_load'] !=0 then len(keep) == len(xy):", len(
            keep) == len(xy)
        xy, NL, KL, BL = le.remove_pts(keep, xytri, BL, NN='min')
        # make string from origin values
        print 'lp[origin] = ', lp['origin']
        print 'type(lp[origin]) = ', type(lp['origin'])
        if (np.abs(lp['origin']) < 1e-7).all():
            originstr = ''
        else:
            originstr = '_originX' + '{0:0.2f}'.format(lp['origin'][0]).replace('.', 'p') + \
                        'Y' + '{0:0.2f}'.format(lp['origin'][1]).replace('.', 'p')
        periodicstr = ''
        LL = (NH, NV)
        BBox = 0.5 * np.array([[-LL[0], -LL[1]], [LL[0], -LL[1]],
                               [LL[0], LL[1]], [-LL[0], LL[1]]],
                              dtype=float)
        PVx = []
        PVy = []
        PVxydict = {}
    else:
        # Unlike in the jammed case, we can't load a periodic bond list! We must make it.
        lp['periodicBC'] = True
        sizestr = '{0:03d}'.format(lp['NP_load'])
        points = np.loadtxt(networkdir + 'hyperuniform_source/hyperuniform_N' + sizestr + '/out_d' + \
                            str(int(lp['conf'])) + '_xy.txt')
        points -= np.mean(points, axis=0)
        # Ensuring that origin param is centered (since using entire lattice)
        lp['origin'] = np.array([0.0, 0.0])
        LL = (lp['NP_load'], lp['NP_load'])
        polygon = 0.5 * np.array([[-LL[0], -LL[1]], [LL[0], -LL[1]],
                                  [LL[0], LL[1]], [-LL[0], LL[1]]])
        BBox = polygon
        xy, NL, KL, BL, PVxydict = le.delaunay_rect_periodic_network_from_pts(
            points,
            LL,
            BBox='auto',
            check=lp['check'],
            zmethod=lp['cutz_method'],
            target_z=lp['target_z'])
        print 'Building periodicBC PVs...'
        PVx, PVy = le.PVxydict2PVxPVy(PVxydict, NL)
        originstr = ''
        periodicstr = '_periodic'

        if lp['check']:
            le.display_lattice_2D(xy,
                                  BL,
                                  NL=NL,
                                  KL=KL,
                                  PVx=PVx,
                                  PVy=PVy,
                                  title='Checking periodic BCs',
                                  close=False,
                                  colorz=False)
            for ii in range(len(xy)):
                plt.text(xy[ii, 0] + 0.1, xy[ii, 1], str(ii))
            plt.plot(xy[:, 0], xy[:, 1], 'go')
            plt.show()

    lattice_exten = 'hyperuniform_' + shape + periodicstr + '_d' + '{0:02d}'.format(int(lp['conf'])) + \
                    '_z{0:0.3f}'.format(lp['target_z']) + originstr
    LV = 'none'
    UC = 'none'
    LVUC = 'none'
    return xy, NL, KL, BL, PVxydict, PVx, PVy, LL, LVUC, LV, UC, BBox, lattice_exten