Ejemplo n.º 1
0
def test_Stencils():
    from Lattice import Lattice
    N = 30
    L = 1
    nr_dims = 2
    box_depth = 3
    lat = Lattice(N, L, nr_dims)
    lat.setup_boxes(box_depth)
    stencils = Stencils(lat)
    for idx in range(lat.nr_points):
        s = stencils.get_stencil(idx)

    for idx in range(lat.nr_points):
        if not lat.IsCloseToEdgeWithHigherSpacing(idx, 1, nr_dims):
            nr_points = len(lat.get_nearby_points(idx, 1))
        else:
            nr_points = len(lat.get_nearby_points(idx, 2))
        if len(s) != nr_points:
            print(len(s), "\n", nr_points, s)
Ejemplo n.º 2
0
def teststuff():
    for dim in [2, 3, 6]:
        N = 30
        L = 1
        box_depth = 3
        lat = Lattice(N, L, nr_dims=dim)
        lat.setup_boxes(box_depth)

        assert lat.nr_boxes == len(
            lat.Box_list
        ), f"Number of boxes doesn't correspond to length of Box_list, dim={dim}."
        assert len(
            lat.Box_list
        ) == box_depth**dim, f"Number of boxes doesn't corresponds to length of Box_list, dim={dim}"
        for i in range(box_depth**dim):
            box = lat.Box_list[i]
            if (box.corner_coord == np.ones(dim) * (box_depth - 1) // 2).all():
                assert box.a_local == 1, f"Central box doesn't have spacing 1, dim={dim}"
            else:
                assert box.a_local == 2, f"Non-central box doesn't have spacing 2, dim={dim}"
        nr_points = np.sum((N // (box_depth * lat.a_list))**dim, dtype=int)
        assert lat.nr_points == nr_points, f"Number of points {nr_points}, doesn't correspond to reported number of points, {lat.nr_points}, dim={dim}."
Ejemplo n.º 3
0
import numpy as np
import matplotlib.pyplot as plt
from Lattice import Lattice



if __name__ == "__main__":
    nr_dims = 2
    N = 33
    L = 1
    box_depth = 3

    lat = Lattice(N, L, nr_dims=nr_dims)
    lat.setup_boxes(box_depth)
    hash_list = np.zeros(lat.nr_points, dtype=int)
    idx_list = np.zeros(400, dtype=int)

    # for idx0 in range(lat.nr_points):
    #     hash = lat.get_stencil(idx0)
    #     hash_list[idx0] = hash

    #     idx_list[hash] = idx0


    # plt.hist(idx_list)
    # plt.show()

    for idx in range(lat.nr_points):
        coord = lat.coords[idx]
        plt.scatter(coord[0], coord[1], c="navy")
        for i in range(box_depth+1):