Exemple #1
0
    def right_b(coeff=0.25, mu=7):
        xs = np.linspace(f1x2[-1], f2x2[-1], mu)
        f3x = np.sin(np.linspace(0, np.pi * (mu - 1), mu) + np.pi / 2)

        xr = np.linspace(c, L, RN)
        fxr1 = spectral.chebEval(cf1x * L2, xr, a=-L, b=L)
        fxr2 = spectral.chebEval(cf2x * L2, xr, a=-L, b=L)
        x131 = np.hstack((x[:-1], xr))
        st1 = np.hstack((f2x[:-1], fxr2))
        st2 = np.hstack((f1x[:-1], fxr1))
        meh1 = sp_int.interp1d(x131, st1, kind='linear')
        meh2 = sp_int.interp1d(x131, st2, kind='linear')

        s5, a5 = points1((c + f3x * coeff)[1:-1],
                         meh1(c + f3x * coeff)[1:-1], xs[1:-1], s4)
        s6, a6 = points1((c + f3x * coeff)[1:-1],
                         meh2(c + f3x * coeff)[1:-1], xs[1:-1], s5)
        ix9 = line1(np.squeeze([[a2[-1]] + a5 + [a4[-1]]]), 9 * M)
        ix10 = line1(np.squeeze([[a1[-1]] + a6 + [a3[-1]]]), 10 * M)
        ix11 = []
        for i in range(mu - 2):
            ix11.append(line1([a5[i], a6[i]], 11 * M + i))
        ix11 = np.atleast_1d(np.squeeze(ix11))
        bsurfsr.append(surface1([ix10[0], -ix11[0], -ix9[0], -ix7[-1]], 5 * M))
        for i in range(1, mu - 2):
            bsurfsr.append(
                surface1([ix10[i], -ix11[i], -ix9[i], ix11[i - 1]], 5 * M + i))
        bsurfsr.append(
            surface1([ix10[-1], ix8[-1], -ix9[-1], ix11[-1]], 5 * M + i + 1))
        arr1 = np.atleast_1d(np.squeeze([ix6[-1], ix4[-1], *-ix9, -ix2[-1]]))
        arr2 = np.atleast_1d(np.squeeze([ix5[-1], ix3[-1], *-ix10, -ix1[-1]]))
        bsurfsr.append(surface1(arr1, 7 * M))
        bsurfsr.append(surface1(arr2, 7 * M + 1))
        return s5, s6, [ix9, ix10]
Exemple #2
0
    def left_b(s5, s6, coeff=0.25, mu=7):
        # mu = 7
        xs = np.linspace(f1x2[-1], f2x2[-1], mu)
        f3x = np.sin(np.linspace(0, np.pi*(mu - 1), mu) + np.pi/2)

        xl = np.linspace(-L, b, LN)
        fxl1 = spectral.chebEval(cf1x*L2, xl, a=-L, b=L)
        fxl2 = spectral.chebEval(cf2x*L2, xl, a=-L, b=L)
        # print(np.hstack((xl, x[1:])).size)
        x131 = np.hstack((xl, x[1:]))
        st1 = np.hstack((fxl2, f2x[1:]))
        st2 = np.hstack((fxl1, f1x[1:]))
        # print(x131)
        meh1 = sp_int.interp1d(x131, st1, kind='linear')
        meh2 = sp_int.interp1d(x131, st2, kind='linear')

        s7, a7 = points1((b + f3x*coeff)[1:-1],  meh1(b + f3x*coeff)[1:-1], xs[1:-1], s6)
        s8, a8 = points1((b + f3x * coeff)[1:-1], meh2(b + f3x*coeff)[1:-1], xs[1:-1], s7)
        ix12 = line1(np.squeeze([[a2[0]] + a7 + [a4[0]]]), 12 * M)
        ix13 = line1(np.squeeze([[a1[0]] + a8 + [a3[0]]]), 13 * M)
        ix14 = []
        for i in range(mu - 2):
            ix14.append(line1([a7[i], a8[i]], 14*M + i))
        ix14 = np.atleast_1d(np.squeeze(ix14))
        bsurfsl.append(surface1([ix13[0], -ix14[0], -ix12[0], -ix7[0]], 6*M))
        for i in range(1, mu - 2):
            bsurfsl.append(surface1([ix13[i], -ix14[i], -ix12[i], ix14[i - 1]], 6*M + i))
        bsurfsl.append(surface1([ix13[-1], ix8[0], -ix12[-1], ix14[-1]], 6 * M + i + 1))
        arr1 = np.atleast_1d(np.squeeze([ix6[0], -ix4[0], *-ix12, ix2[0]]))
        arr2 = np.atleast_1d(np.squeeze([ix5[0], -ix3[0], *-ix13, ix1[0]]))
        bsurfsl.append(surface1(arr1, 8*M))
        bsurfsl.append(surface1(arr2, 8*M + 1))
        return s8, [ix12, ix13]
Exemple #3
0
def new_center(S, I, Is, c=0.1, N=3, n=100, L=10, L2=1, L3=1, xs=1):
    # L += c
    #    L2 += c
    #    L3 += c
    x2, f1x2, f2x2 = img.imr('img2.png', n)
    x, f1x, f2x = img.imr('img.png', n)
    x *= L
    x2 *= L

    X = x.copy()
    cf1x = spectral.chebTransform(f1x)
    cf2x = spectral.chebTransform(f2x)

    cf1x2 = spectral.chebTransform(f1x2)
    cf2x2 = spectral.chebTransform(f2x2)
    # N = 3
    M = 1000
    # n = N
    # x = np.linspace(-L, L, N)
    # x = spectral.chebNodes(N, -L, L)
    x = xs
    f1x = spectral.chebEval(cf1x, x, a=-L, b=L) - c
    f2x = spectral.chebEval(cf2x, x, a=-L, b=L) + c

    f1x2 = spectral.chebEval(cf1x2, x, a=-L, b=L) - c
    f2x2 = spectral.chebEval(cf2x2, x, a=-L, b=L) + c

    f1x[-1] -= 10 * c
    f1x[0] -= 1 * c
    x[-1] += c / 2
    x[0] -= c / 2
    f1x *= L2
    f2x *= L2
    f1x2 *= L3
    f2x2 *= L3

    surfs = []

    s1, a1 = points1(x, f1x, f1x2, S)
    s2, a2 = points1(x, f2x, f1x2, s1, s=1, e=1)

    s3, a3 = points1(x, f1x, f2x2, s2)
    s4, a4 = points1(x, f2x, f2x2, s3, s=1, e=1)
    #
    ix1 = line1(a1, (1 + I) * M)
    ix2 = line1(a2, (2 + I) * M)
    #
    ix3 = line1(a3, (3 + I) * M)
    ix4 = line1(a4, (4 + I) * M)

    ix5 = []
    ix6 = []
    ix8 = []
    ix7 = []
    # # #

    ix5.append(line1([a1[0], a3[0]], (I + 5) * M))
    ix7.append(line1([a1[0], a2[0]], (I + 7) * M))
    ix8.append(line1([a3[0], a4[0]], (I + 8) * M))
    for i in range(len(a1) - 1):
        if i < (len(a1) - 2):
            ix5.append(line1([a1[i + 1], a3[i + 1]], (I + 5) * M + i + 1))
            ix6.append(line1([a2[i], a4[i]], (I + 6) * M + i))
            ix7.append(line1([a1[i + 1], a2[i]], (I + 7) * M + i + 1))
            ix8.append(line1([a3[i + 1], a4[i]], (I + 8) * M + i + 1))
        else:
            ix5.append(line1([a1[i + 1], a3[i + 1]], (I + 5) * M + i + 1))
            ix7.append(line1([a1[i + 1], a2[i - 1]], (I + 7) * M + i + 1))
            ix8.append(line1([a3[i + 1], a4[i - 1]], (I + 8) * M + i + 1))

    ix5 = np.atleast_1d(np.squeeze(np.array(ix5)))
    ix6 = np.atleast_1d(np.squeeze(np.array(ix6)))
    ix7 = np.atleast_1d(np.squeeze(np.array(ix7)))
    ix8 = np.atleast_1d(np.squeeze(np.array(ix8)))
    for i in range(len(a1)):
        if i < len(a1) - 2 and i > 0:
            # upper
            surfs.append(
                surface1([ix1[i - 1], ix5[i], -ix3[i - 1], -ix5[i - 1]],
                         (1 + Is) * M + i))
            # lower
            surfs.append(
                surface1([ix2[i - 1], ix6[i], -ix4[i - 1], -ix6[i - 1]],
                         (2 + Is) * M + i))
            # left
            surfs.append(
                surface1([ix1[i], ix7[i + 1], -ix2[i - 1], -ix7[i]],
                         (3 + Is) * M + i))
            # right
            surfs.append(
                surface1([ix3[i], ix8[i + 1], -ix4[i - 1], -ix8[i]],
                         (4 + Is) * M + i))
        elif i == len(a1) - 2:

            surfs.append(
                surface1([ix1[i - 1], ix5[i], -ix3[i - 1], -ix5[i - 1]],
                         (1 + Is) * M + i))
            surfs.append(
                surface1([ix1[i], ix5[i + 1], -ix3[i], -ix5[i]],
                         (1 + Is) * M + i + 1))

            surfs.append(
                surface1([ix1[i], ix7[i + 1], -ix7[i]], (3 + Is) * M + i))
            surfs.append(
                surface1([ix3[i], ix8[i + 1], -ix8[i]], (4 + Is) * M + i))
            surfs.append(
                surface1([ix5[i + 1], ix8[i + 1], -ix6[i - 1], -ix7[i + 1]],
                         (2 + Is) * M + i))
        elif i == 0:
            surfs.append(
                surface1([ix1[i], ix7[i + 1], -ix7[i]], (3 + Is) * M + i))
            surfs.append(
                surface1([ix3[i], ix8[i + 1], -ix8[i]], (4 + Is) * M + i))
            surfs.append(
                surface1([ix5[i], ix8[i], -ix6[i], -ix7[i]], (2 + Is) * M + i))

    return s8, [a1, a2, a3, a4], [[ix7[0], ix8[0]], [ix7[-1], ix8[-1]]], surfs
Exemple #4
0
def center(b=-0.7,
           c=0.7,
           N=3,
           LN=7,
           RN=7,
           n=100,
           L=10,
           L2=1,
           L3=1,
           coeff=0.007,
           mu=13):
    b *= L
    c *= L
    x2, f1x2, f2x2 = img.imr('img2.png', n)
    x, f1x, f2x = img.imr('img.png', n)
    x *= L
    x2 *= L
    cf1x = spectral.chebTransform(f1x)
    cf2x = spectral.chebTransform(f2x)

    cf1x2 = spectral.chebTransform(f1x2)
    cf2x2 = spectral.chebTransform(f2x2)
    # N = 3
    M = 1000
    x = np.linspace(b, c, N)
    f1x = spectral.chebEval(cf1x, x, a=-L, b=L)
    f2x = spectral.chebEval(cf2x, x, a=-L, b=L)

    f1x2 = spectral.chebEval(cf1x2, x, a=-L, b=L)
    f2x2 = spectral.chebEval(cf2x2, x, a=-L, b=L)
    f1x *= L2
    f2x *= L2
    f1x2 *= L3
    f2x2 *= L3
    surfs = []
    bsurfs = []

    s1, a1 = points1(x, f1x, f1x2, 1)
    s2, a2 = points1(x, f2x, f1x2, s1)

    s3, a3 = points1(x, f1x, f2x2, s2)
    s4, a4 = points1(x, f2x, f2x2, s3)
    #
    ix1 = line1(a1, 1 * M)
    ix2 = line1(a2, 2 * M)
    #
    ix3 = line1(a3, 3 * M)
    ix4 = line1(a4, 4 * M)

    ix5 = []
    ix6 = []
    ix8 = []
    ix7 = []
    # # #
    for i in range(len(a1)):
        if i < len(a1) - 1 and i != 0:
            ix5.append(line1([a1[i], a3[i]], 5 * M + i))
            ix6.append(line1([a2[i], a4[i]], 6 * M + i))
            ix7.append(line1([a1[i], a2[i]], 7 * M + i))
            ix8.append(line1([a3[i], a4[i]], 8 * M + i))
        else:
            ix7.append(line1([a1[i], a2[i]], 7 * M + i))
            ix8.append(line1([a3[i], a4[i]], 8 * M + i))

    ix5 = np.atleast_1d(np.squeeze(np.array(ix5)))
    ix6 = np.atleast_1d(np.squeeze(np.array(ix6)))
    ix7 = np.atleast_1d(np.squeeze(np.array(ix7)))
    ix8 = np.atleast_1d(np.squeeze(np.array(ix8)))

    for i in range(len(a1) - 1):
        if i < len(a1) - 2 and i > 0:
            # upper
            surfs.append(
                surface1([ix1[i], ix5[i], -ix3[i], -ix5[i - 1]], 1 * M + i))
            # lower
            surfs.append(
                surface1([ix2[i], ix6[i], -ix4[i], -ix6[i - 1]], 2 * M + i))
            # left
            surfs.append(
                surface1([ix1[i], ix7[i + 1], -ix2[i], -ix7[i]], 3 * M + i))
            # right
            surfs.append(
                surface1([ix3[i], ix8[i + 1], -ix4[i], -ix8[i]], 4 * M + i))
        elif i == len(a1) - 2:
            surfs.append(
                surface1([ix1[i], ix7[i + 1], -ix2[i], -ix7[i]], 3 * M + i))
            surfs.append(
                surface1([ix3[i], ix8[i + 1], -ix4[i], -ix8[i]], 4 * M + i))
        elif i == 0:
            surfs.append(
                surface1([ix1[i], ix7[i + 1], -ix2[i], -ix7[i]], 3 * M + i))
            surfs.append(
                surface1([ix3[i], ix8[i + 1], -ix4[i], -ix8[i]], 4 * M + i))

    bsurfsl = []
    bsurfsr = []

    def right_b(coeff=0.25, mu=7):
        xs = np.linspace(f1x2[-1], f2x2[-1], mu)
        f3x = np.sin(np.linspace(0, np.pi * (mu - 1), mu) + np.pi / 2)

        xr = np.linspace(c, L, RN)
        fxr1 = spectral.chebEval(cf1x * L2, xr, a=-L, b=L)
        fxr2 = spectral.chebEval(cf2x * L2, xr, a=-L, b=L)
        x131 = np.hstack((x[:-1], xr))
        st1 = np.hstack((f2x[:-1], fxr2))
        st2 = np.hstack((f1x[:-1], fxr1))
        meh1 = sp_int.interp1d(x131, st1, kind='linear')
        meh2 = sp_int.interp1d(x131, st2, kind='linear')

        s5, a5 = points1((c + f3x * coeff)[1:-1],
                         meh1(c + f3x * coeff)[1:-1], xs[1:-1], s4)
        s6, a6 = points1((c + f3x * coeff)[1:-1],
                         meh2(c + f3x * coeff)[1:-1], xs[1:-1], s5)
        ix9 = line1(np.squeeze([[a2[-1]] + a5 + [a4[-1]]]), 9 * M)
        ix10 = line1(np.squeeze([[a1[-1]] + a6 + [a3[-1]]]), 10 * M)
        ix11 = []
        for i in range(mu - 2):
            ix11.append(line1([a5[i], a6[i]], 11 * M + i))
        ix11 = np.atleast_1d(np.squeeze(ix11))
        bsurfsr.append(surface1([ix10[0], -ix11[0], -ix9[0], -ix7[-1]], 5 * M))
        for i in range(1, mu - 2):
            bsurfsr.append(
                surface1([ix10[i], -ix11[i], -ix9[i], ix11[i - 1]], 5 * M + i))
        bsurfsr.append(
            surface1([ix10[-1], ix8[-1], -ix9[-1], ix11[-1]], 5 * M + i + 1))
        arr1 = np.atleast_1d(np.squeeze([ix6[-1], ix4[-1], *-ix9, -ix2[-1]]))
        arr2 = np.atleast_1d(np.squeeze([ix5[-1], ix3[-1], *-ix10, -ix1[-1]]))
        bsurfsr.append(surface1(arr1, 7 * M))
        bsurfsr.append(surface1(arr2, 7 * M + 1))
        return s5, s6, [ix9, ix10]

    def left_b(s5, s6, coeff=0.25, mu=7):
        # mu = 7
        xs = np.linspace(f1x2[-1], f2x2[-1], mu)
        f3x = np.sin(np.linspace(0, np.pi * (mu - 1), mu) + np.pi / 2)

        xl = np.linspace(-L, b, LN)
        fxl1 = spectral.chebEval(cf1x * L2, xl, a=-L, b=L)
        fxl2 = spectral.chebEval(cf2x * L2, xl, a=-L, b=L)
        # print(np.hstack((xl, x[1:])).size)
        x131 = np.hstack((xl, x[1:]))
        st1 = np.hstack((fxl2, f2x[1:]))
        st2 = np.hstack((fxl1, f1x[1:]))
        # print(x131)
        meh1 = sp_int.interp1d(x131, st1, kind='linear')
        meh2 = sp_int.interp1d(x131, st2, kind='linear')

        s7, a7 = points1((b + f3x * coeff)[1:-1],
                         meh1(b + f3x * coeff)[1:-1], xs[1:-1], s6)
        s8, a8 = points1((b + f3x * coeff)[1:-1],
                         meh2(b + f3x * coeff)[1:-1], xs[1:-1], s7)
        ix12 = line1(np.squeeze([[a2[0]] + a7 + [a4[0]]]), 12 * M)
        ix13 = line1(np.squeeze([[a1[0]] + a8 + [a3[0]]]), 13 * M)
        ix14 = []
        for i in range(mu - 2):
            ix14.append(line1([a7[i], a8[i]], 14 * M + i))
        ix14 = np.atleast_1d(np.squeeze(ix14))
        bsurfsl.append(surface1([ix13[0], -ix14[0], -ix12[0], -ix7[0]], 6 * M))
        for i in range(1, mu - 2):
            bsurfsl.append(
                surface1([ix13[i], -ix14[i], -ix12[i], ix14[i - 1]],
                         6 * M + i))
        bsurfsl.append(
            surface1([ix13[-1], ix8[0], -ix12[-1], ix14[-1]], 6 * M + i + 1))
        arr1 = np.atleast_1d(np.squeeze([ix6[0], -ix4[0], *-ix12, ix2[0]]))
        arr2 = np.atleast_1d(np.squeeze([ix5[0], -ix3[0], *-ix13, ix1[0]]))
        bsurfsl.append(surface1(arr1, 8 * M))
        bsurfsl.append(surface1(arr2, 8 * M + 1))
        return s8, [ix12, ix13]

    s5, s6, rxs = right_b(coeff, mu)
    s8, lxs = left_b(s6, s6, coeff, mu)
    return s8, lxs, rxs, [a1, a2, a3,
                          a4], [[ix7[0], ix8[0]],
                                [ix7[-1], ix8[-1]]], surfs, bsurfsl, bsurfsr, x
Exemple #5
0
def left(S, I, Is, xs, As, Bs, b=-0.7, N=3, n=100, L=10, L2=1, L3=1):
    b *= L
    x2, f1x2, f2x2 = img.imr('img2.png', n)
    x, f1x, f2x = img.imr('img.png', n)
    x *= L
    x2 *= L
    cf1x = spectral.chebTransform(f1x)
    cf2x = spectral.chebTransform(f2x)

    cf1x2 = spectral.chebTransform(f1x2)
    cf2x2 = spectral.chebTransform(f2x2)
    M = 1000
    x = np.linspace(x[0], b, N)
    f1x = spectral.chebEval(cf1x, x, a=-L, b=L)

    f2x = spectral.chebEval(cf2x, x, a=-L, b=L)

    f1x2 = spectral.chebEval(cf1x2, x, a=-L, b=L)
    f2x2 = spectral.chebEval(cf2x2, x, a=-L, b=L)

    f1x *= L2
    f2x *= L2
    f1x2 *= L3
    f2x2 *= L3

    s1, a1 = points1(x, f1x, f1x2, S, e=1)
    s2, a2 = points1(x, f2x, f1x2, s1, e=1, s=1)

    s3, a3 = points1(x, f1x, f2x2, s2, e=1)
    s4, a4 = points1(x, f2x, f2x2, s3, e=1, s=1)
    #
    ix1 = line1(a1 + [As[0][0]], (I + 1) * M)
    ix2 = line1([a1[0]] + a2 + [As[1][0]], (I + 2) * M)
    #
    ix3 = line1(a3 + [As[2][0]], (I + 3) * M)
    ix4 = line1([a3[0]] + a4 + [As[3][0]], (I + 4) * M)

    ix5 = []
    ix6 = []
    ix8 = []
    ix7 = []
    # # #
    ix5.append(line1([a1[0], a3[0]], (I + 5) * M))
    for i in range(len(a1)):
        if i < len(a1) - 1:
            ix5.append(line1([a1[i + 1], a3[i + 1]], (I + 5) * M + i + 1))
            ix6.append(line1([a2[i], a4[i]], (I + 6) * M + i))
            ix7.append(line1([a1[i + 1], a2[i]], (I + 7) * M + i))
            ix8.append(line1([a3[i + 1], a4[i]], (I + 8) * M + i))

    ix5 = np.atleast_1d(np.squeeze(np.array(ix5)))
    ix6 = np.atleast_1d(np.squeeze(np.array(ix6)))
    ix7 = np.atleast_1d(np.squeeze(np.array(ix7)))
    ix8 = np.atleast_1d(np.squeeze(np.array(ix8)))

    surfs = []
    for i in range(len(a1)):
        if i == 0:
            surfs.append(
                surface1([ix1[i], ix5[i + 1], -ix3[i], -ix5[i]],
                         (1 + Is) * M + i))
            surfs.append(
                surface1([ix2[i], ix6[i], -ix4[i], -ix5[i]], (2 + Is) * M + i))
            #
            surfs.append(surface1([ix1[i], ix7[i], -ix2[i]], (3 + Is) * M + i))
            surfs.append(surface1([ix3[i], ix8[i], -ix4[i]], (4 + Is) * M + i))
        elif i == len(a1) - 1:
            arr1 = np.atleast_1d(np.squeeze([ix1[i], *xs[1], -ix3[i],
                                             -ix5[i]]))
            arr2 = np.atleast_1d(
                np.squeeze([ix2[i], *xs[0], -ix4[i], -ix6[i - 1]]))

            surfs.append(surface1(arr1, (Is + 1) * M + i))
            surfs.append(surface1(arr2, (Is + 2) * M + i))
            surfs.append(
                surface1([ix1[i], Bs[0], -ix2[i], -ix7[i - 1]],
                         (3 + Is) * M + i))
            surfs.append(
                surface1([ix3[i], Bs[1], -ix4[i], -ix8[i - 1]],
                         (4 + Is) * M + i))
        else:
            # upper
            surfs.append(
                surface1([ix1[i], ix5[i + 1], -ix3[i], -ix5[i]],
                         (1 + Is) * M + i))
            # lower
            surfs.append(
                surface1([ix2[i], ix6[i], -ix4[i], -ix6[i - 1]],
                         (2 + Is) * M + i))
            # left
            surfs.append(
                surface1([ix1[i], ix7[i], -ix2[i], -ix7[i - 1]],
                         (3 + Is) * M + i))
            # right
            surfs.append(
                surface1([ix3[i], ix8[i], -ix4[i], -ix8[i - 1]],
                         (4 + Is) * M + i))
    return s4, surfs, x
Exemple #6
0
def right(S, I, Is, xs, As, Bs, c=0.7, N=3, n=100, L=10, L2=1, L3=1):
    c *= L
    x2, f1x2, f2x2 = img.imr('img2.png', n)
    x, f1x, f2x = img.imr('img.png', n)
    x *= L
    x2 *= L
    cf1x = spectral.chebTransform(f1x)
    cf2x = spectral.chebTransform(f2x)

    cf1x2 = spectral.chebTransform(f1x2)
    cf2x2 = spectral.chebTransform(f2x2)
    M = 1000
    x = np.linspace(c, x[-1], N)
    f1x = spectral.chebEval(cf1x, x, a=-L, b=L)

    f2x = spectral.chebEval(cf2x, x, a=-L, b=L)
    f1x2 = spectral.chebEval(cf1x2, x, a=-L, b=L)
    f2x2 = spectral.chebEval(cf2x2, x, a=-L, b=L)
    f1x *= L2
    f2x *= L2
    f1x2 *= L3
    f2x2 *= L3

    s1, a1 = points1(x, f1x, f1x2, S, s=1)
    s2, a2 = points1(x, f2x, f1x2, s1, s=1, e=1)

    s3, a3 = points1(x, f1x, f2x2, s2, s=1)
    s4, a4 = points1(x, f2x, f2x2, s3, s=1, e=1)
    # #

    ix1 = line1([As[0][-1]] + a1, (I + 1) * M)
    ix2 = line1([As[1][-1]] + a2 + [a1[-1]], (I + 2) * M)
    # #
    ix3 = line1([As[2][-1]] + a3, (I + 3) * M)
    ix4 = line1([As[3][-1]] + a4 + [a3[-1]], (I + 4) * M)
    #
    ix5 = []
    ix6 = []
    ix8 = []
    ix7 = []
    for i in range(len(a1)):
        if i < len(a1) - 1:
            ix5.append(line1([a1[i], a3[i]], (I + 5) * M + i))
            ix6.append(line1([a2[i], a4[i]], (I + 6) * M + i))
            ix7.append(line1([a1[i], a2[i]], (I + 7) * M + i))
            ix8.append(line1([a3[i], a4[i]], (I + 8) * M + i))
        else:
            # if i == len(a1) - 2:
            ix5.append(line1([a1[i], a3[i]], (I + 5) * M + i))
        #     ix5.append(line1([a1[i], a3[i]], (I + 6) * M + i))
        #     ix7.append(line1([a1[i], a2[i]], (I + 7) * M + i))
        #     ix8.append(line1([a3[i], a4[i]], (I + 8) * M + i))
    #
    #
    #
    #     #
    ix5 = np.atleast_1d(np.squeeze(np.array(ix5)))
    ix6 = np.atleast_1d(np.squeeze(np.array(ix6)))
    ix7 = np.atleast_1d(np.squeeze(np.array(ix7)))
    ix8 = np.atleast_1d(np.squeeze(np.array(ix8)))

    meh = []
    for i in range(len(a1)):
        if i == 0:
            arr1 = np.atleast_1d(
                np.squeeze([ix1[i], *(-xs[1]), -ix3[i], ix5[i]]))

            arr2 = np.atleast_1d(
                np.squeeze([ix2[i], *(-xs[0]), -ix4[i], ix6[i]]))
            meh.append(surface1(arr1, (Is + 1) * M + i))
            meh.append(surface1(arr2, (Is + 2) * M + i))

            meh.append(
                surface1([ix1[i], ix7[i], -ix2[i], -Bs[0]], (Is + 3) * M + i))
            meh.append(
                surface1([ix3[i], ix8[i], -ix4[i], -Bs[1]], (Is + 4) * M + i))
        elif i == len(a1) - 1:
            meh.append(
                surface1([ix1[i], ix5[i], -ix3[i], -ix5[i - 1]],
                         (Is + 1) * M + i))
            meh.append(
                surface1([ix2[i], ix5[i], -ix4[i], -ix6[i - 1]],
                         (Is + 2) * M + i))
            # #
            meh.append(
                surface1([ix1[i], -ix2[i], -ix7[i - 1]], (Is + 3) * M + i))
            meh.append(
                surface1([ix3[i], -ix4[i], -ix8[i - 1]], (Is + 4) * M + i))
        else:
            # upper
            meh.append(
                surface1([ix1[i], ix5[i], -ix3[i], -ix5[i - 1]],
                         (Is + 1) * M + i))
            # lower
            meh.append(
                surface1([ix2[i], ix6[i], -ix4[i], -ix6[i - 1]],
                         (Is + 2) * M + i))
            # #left
            meh.append(
                surface1([ix1[i], ix7[i], -ix2[i], -ix7[i - 1]],
                         (Is + 3) * M + i))
            # right
            meh.append(
                surface1([ix3[i], ix8[i], -ix4[i], -ix8[i - 1]],
                         (Is + 4) * M + i))
    return s4, meh, x
Exemple #7
0
def left(S, I, Is, xs, As, Bs, b=-0.7, N=3, n=100):
    # n = 100
    L = 10
    b *= L
    lxs = xs[0]
    uxs = xs[1]
    x2, f1x2, f2x2 = img.imr('img2.png', n)
    x, f1x, f2x = img.imr('img.png', n)
    x *= L
    x2 *= L
    cf1x = spectral.chebTransform(f1x)
    cf2x = spectral.chebTransform(f2x)

    cf1x2 = spectral.chebTransform(f1x2)
    cf2x2 = spectral.chebTransform(f2x2)
    # N = 7
    M = 1000
    n = N
    x = np.linspace(x[0], b, N)
    f1x = spectral.chebEval(cf1x, x, a=-L, b=L)

    f2x = spectral.chebEval(cf2x, x, a=-L, b=L)

    f1x2 = spectral.chebEval(cf1x2, x, a=-L, b=L)
    f2x2 = spectral.chebEval(cf2x2, x, a=-L, b=L)
    # plt.plot(x, f1x)
    # plt.show()
    L2 = 1
    f1x *= L2
    f2x *= L2

    def points1(fx, z, I, s=0, e=0):
        ind = []
        for i in range(s, fx.size - e):
            file.write('Point(' + str(I + i) + ') = {' +
                       ", ".join(map(str, (list([x[i], z[i], fx[i], 1])))) +
                       '};')
            file.write('\n')
            file.write('//+' + '\n')
            ind.append(I + i)
        return fx.size + I, ind

    def line1(ind, I):
        ind1 = []
        for i in range(len(ind) - 1):
            file.write('Line(' + str(I + i) + ') = {' + str(ind[i]) + ',' +
                       str(ind[i + 1]) + '};')
            file.write('\n')
            file.write('//+' + '\n')
            ind1.append(I + i)
        return np.array(ind1)

    def surface1(ix, I):
        file.write('Curve Loop(' + str(I) + ') = {' + ', '.join(map(str, ix)) +
                   '};')
        file.write('\n')
        file.write('//+' + '\n')
        file.write('Plane Surface(' + str(I) + ') = {' + str(I) + '};')
        file.write('\n')
        file.write('//+' + '\n')
        return str(I)

    s1, a1 = points1(f1x, f1x2, S, e=1)
    s2, a2 = points1(f2x, f1x2, s1, e=1, s=1)

    s3, a3 = points1(f1x, f2x2, s2, e=1)
    s4, a4 = points1(f2x, f2x2, s3, e=1, s=1)
    #
    ix1 = line1(a1 + [As[0][0]], (I + 1) * M)
    ix2 = line1([a1[0]] + a2 + [As[1][0]], (I + 2) * M)
    #
    ix3 = line1(a3 + [As[2][0]], (I + 3) * M)
    ix4 = line1([a3[0]] + a4 + [As[3][0]], (I + 4) * M)

    ix5 = []
    ix6 = []
    ix8 = []
    ix7 = []
    # # #
    ix5.append(line1([a1[0], a3[0]], (I + 5) * M))
    for i in range(len(a1)):
        if i < len(a1) - 1:
            ix5.append(line1([a1[i + 1], a3[i + 1]], (I + 5) * M + i + 1))
            ix6.append(line1([a2[i], a4[i]], (I + 6) * M + i))
            ix7.append(line1([a1[i + 1], a2[i]], (I + 7) * M + i))
            ix8.append(line1([a3[i + 1], a4[i]], (I + 8) * M + i))
        # if i == len(a1) - 2:
        #     ix5.append(line1([a1[i], a3[i]], (I + 5) * M + i))
        #     ix5.append(line1([a1[i + 1], a3[i + 1]], (I + 6) * M + i + 1))
        #     ix7.append(line1([a1[i], a2[i - 1]], (I + 7) * M + i))
        #     ix8.append(line1([a3[i], a4[i - 1]], (I + 8) * M + i))

        #
    ix5 = np.atleast_1d(np.squeeze(np.array(ix5)))
    ix6 = np.atleast_1d(np.squeeze(np.array(ix6)))
    ix7 = np.atleast_1d(np.squeeze(np.array(ix7)))
    ix8 = np.atleast_1d(np.squeeze(np.array(ix8)))
    #
    # print(ix1)
    # print(ix5)
    # print(ix3)
    surfs = []
    for i in range(len(a1)):
        if i == 0:
            surfs.append(
                surface1([ix1[i], ix5[i + 1], -ix3[i], -ix5[i]],
                         (1 + Is) * M + i))
            surfs.append(
                surface1([ix2[i], ix6[i], -ix4[i], -ix5[i]], (2 + Is) * M + i))
            #
            surfs.append(surface1([ix1[i], ix7[i], -ix2[i]], (3 + Is) * M + i))
            surfs.append(surface1([ix3[i], ix8[i], -ix4[i]], (4 + Is) * M + i))
        elif i == len(a1) - 1:
            arr1 = np.atleast_1d(np.squeeze([ix1[i], *xs[1], -ix3[i],
                                             -ix5[i]]))
            arr2 = np.atleast_1d(
                np.squeeze([ix2[i], *xs[0], -ix4[i], -ix6[i - 1]]))

            surfs.append(surface1(arr1, (Is + 1) * M + i))
            surfs.append(surface1(arr2, (Is + 2) * M + i))
            surfs.append(
                surface1([ix1[i], Bs[0], -ix2[i], -ix7[i - 1]],
                         (3 + Is) * M + i))
            surfs.append(
                surface1([ix3[i], Bs[1], -ix4[i], -ix8[i - 1]],
                         (4 + Is) * M + i))
        else:
            #upper
            surfs.append(
                surface1([ix1[i], ix5[i + 1], -ix3[i], -ix5[i]],
                         (1 + Is) * M + i))
            #lower
            surfs.append(
                surface1([ix2[i], ix6[i], -ix4[i], -ix6[i - 1]],
                         (2 + Is) * M + i))
            #left
            surfs.append(
                surface1([ix1[i], ix7[i], -ix2[i], -ix7[i - 1]],
                         (3 + Is) * M + i))
            #right
            surfs.append(
                surface1([ix3[i], ix8[i], -ix4[i], -ix8[i - 1]],
                         (4 + Is) * M + i))
    return surfs
Exemple #8
0
def right(S, I, Is, xs, As, Bs, c=0.7, N=3, n=100):
    surfs = []
    # n = 100
    L = 10
    c *= L
    x2, f1x2, f2x2 = img.imr('img2.png', n)
    x, f1x, f2x = img.imr('img.png', n)
    x *= L
    x2 *= L
    cf1x = spectral.chebTransform(f1x)
    cf2x = spectral.chebTransform(f2x)

    cf1x2 = spectral.chebTransform(f1x2)
    cf2x2 = spectral.chebTransform(f2x2)
    # N = 3
    M = 1000
    n = N
    x = np.linspace(c, x[-1], N)
    f1x = spectral.chebEval(cf1x, x, a=-L, b=L)
    f2x = spectral.chebEval(cf2x, x, a=-L, b=L)

    f1x2 = spectral.chebEval(cf1x2, x, a=-L, b=L)
    f2x2 = spectral.chebEval(cf2x2, x, a=-L, b=L)
    # plt.plot(x, f1x)
    # plt.show()
    L2 = 1
    f1x *= L2
    f2x *= L2

    def points1(fx, z, I, s=0, e=0):
        ind = []
        for i in range(s, fx.size - e):
            file.write('Point(' + str(I + i) + ') = {' +
                       ", ".join(map(str, (list([x[i], z[i], fx[i], 1])))) +
                       '};')
            file.write('\n')
            file.write('//+' + '\n')
            ind.append(I + i)
        return fx.size + I, ind

    def line1(ind, I):
        ind1 = []
        for i in range(len(ind) - 1):
            file.write('Line(' + str(I + i) + ') = {' + str(ind[i]) + ',' +
                       str(ind[i + 1]) + '};')
            file.write('\n')
            file.write('//+' + '\n')
            ind1.append(I + i)
        return np.array(ind1)

    def surface1(ix, I):
        file.write('Curve Loop(' + str(I) + ') = {' + ', '.join(map(str, ix)) +
                   '};')
        file.write('\n')
        file.write('//+' + '\n')
        file.write('Plane Surface(' + str(I) + ') = {' + str(I) + '};')
        file.write('\n')
        file.write('//+' + '\n')
        return str(I)

    def volume(planes, I):
        file.write('Surface Loop(' + str(I) + ') = {' +
                   ', '.join(map(str, planes)) + '};')
        file.write('\n')
        file.write('//+' + '\n')
        file.write('Volume(' + str(I) + ') = {' + str(I) + '};')
        file.write('\n')
        file.write('//+' + '\n')

    s1, a1 = points1(f1x, f1x2, S, s=1)
    s2, a2 = points1(f2x, f1x2, s1, s=1, e=1)

    s3, a3 = points1(f1x, f2x2, s2, s=1)
    s4, a4 = points1(f2x, f2x2, s3, s=1, e=1)
    # #

    ix1 = line1([As[0][-1]] + a1, (I + 1) * M)
    ix2 = line1([As[1][-1]] + a2 + [a1[-1]], (I + 2) * M)
    # #
    ix3 = line1([As[2][-1]] + a3, (I + 3) * M)
    ix4 = line1([As[3][-1]] + a4 + [a3[-1]], (I + 4) * M)
    #
    ix5 = []
    ix6 = []
    ix8 = []
    ix7 = []
    # # # #

    for i in range(len(a1)):
        if i < len(a1) - 1:
            ix5.append(line1([a1[i], a3[i]], (I + 5) * M + i))
            ix6.append(line1([a2[i], a4[i]], (I + 6) * M + i))
            ix7.append(line1([a1[i], a2[i]], (I + 7) * M + i))
            ix8.append(line1([a3[i], a4[i]], (I + 8) * M + i))
        else:
            # if i == len(a1) - 2:
            ix5.append(line1([a1[i], a3[i]], (I + 5) * M + i))
        #     ix5.append(line1([a1[i], a3[i]], (I + 6) * M + i))
        #     ix7.append(line1([a1[i], a2[i]], (I + 7) * M + i))
        #     ix8.append(line1([a3[i], a4[i]], (I + 8) * M + i))
    #
    #
    #
    #     #
    ix5 = np.atleast_1d(np.squeeze(np.array(ix5)))
    ix6 = np.atleast_1d(np.squeeze(np.array(ix6)))
    ix7 = np.atleast_1d(np.squeeze(np.array(ix7)))
    ix8 = np.atleast_1d(np.squeeze(np.array(ix8)))

    meh = []
    for i in range(len(a1)):
        if i == 0:
            arr1 = np.atleast_1d(
                np.squeeze([ix1[i], *(-xs[1]), -ix3[i], ix5[i]]))

            arr2 = np.atleast_1d(
                np.squeeze([ix2[i], *(-xs[0]), -ix4[i], ix6[i]]))
            meh.append(surface1(arr1, (Is + 1) * M + i))
            meh.append(surface1(arr2, (Is + 2) * M + i))

            meh.append(
                surface1([ix1[i], ix7[i], -ix2[i], -Bs[0]], (Is + 3) * M + i))
            meh.append(
                surface1([ix3[i], ix8[i], -ix4[i], -Bs[1]], (Is + 4) * M + i))
        elif i == len(a1) - 1:
            meh.append(
                surface1([ix1[i], ix5[i], -ix3[i], -ix5[i - 1]],
                         (Is + 1) * M + i))
            meh.append(
                surface1([ix2[i], ix5[i], -ix4[i], -ix6[i - 1]],
                         (Is + 2) * M + i))
            # #
            meh.append(
                surface1([ix1[i], -ix2[i], -ix7[i - 1]], (Is + 3) * M + i))
            meh.append(
                surface1([ix3[i], -ix4[i], -ix8[i - 1]], (Is + 4) * M + i))
        else:
            #upper
            meh.append(
                surface1([ix1[i], ix5[i], -ix3[i], -ix5[i - 1]],
                         (Is + 1) * M + i))
            #lower
            meh.append(
                surface1([ix2[i], ix6[i], -ix4[i], -ix6[i - 1]],
                         (Is + 2) * M + i))
            # #left
            meh.append(
                surface1([ix1[i], ix7[i], -ix2[i], -ix7[i - 1]],
                         (Is + 3) * M + i))
            #right
            meh.append(
                surface1([ix3[i], ix8[i], -ix4[i], -ix8[i - 1]],
                         (Is + 4) * M + i))
    # volume(meh, 1)
    return s4, meh
Exemple #9
0
def main():
    n = 20
    L = 10

    x2, f1x2, f2x2 = img.imr('img2.png', n)
    x, f1x, f2x = img.imr('img.png', n)
    x *= L
    x2 *= L
    cf1x = spectral.chebTransform(f1x)
    cf2x = spectral.chebTransform(f2x)

    cf1x2 = spectral.chebTransform(f1x2)
    cf2x2 = spectral.chebTransform(f2x2)
    N = 15
    M = 1000
    n = N
    x = np.linspace(x[0], x[-1], N)
    f1x = spectral.chebEval(cf1x, x, a=-L, b=L)
    f2x = spectral.chebEval(cf2x, x, a=-L, b=L)

    f1x2 = spectral.chebEval(cf1x2, x, a=-L, b=L)
    f2x2 = spectral.chebEval(cf2x2, x, a=-L, b=L)
    # plt.plot(x, f1x)
    # plt.show()
    L2 = 1
    f1x *= L2
    f2x *= L2

    def points1(fx, z, I, s=0, e=0):
        ind = []
        for i in range(s, fx.size - e):
            file.write('Point(' + str(I + i) + ') = {' +
                       ", ".join(map(str, (list([x[i], z[i], fx[i], 1])))) +
                       '};')
            file.write('\n')
            file.write('//+' + '\n')
            ind.append(I + i)
        return fx.size + I, ind

    def line1(ind, I):
        ind1 = []
        for i in range(len(ind) - 1):
            file.write('Line(' + str(I + i) + ') = {' + str(ind[i]) + ',' +
                       str(ind[i + 1]) + '};')
            file.write('\n')
            file.write('//+' + '\n')
            ind1.append(I + i)
        return np.array(ind1)

    def surface1(ix, I):
        file.write('Curve Loop(' + str(I) + ') = {' + ', '.join(map(str, ix)) +
                   '};')
        file.write('\n')
        file.write('//+' + '\n')
        file.write('Plane Surface(' + str(I) + ') = {' + str(I) + '};')
        file.write('\n')
        file.write('//+' + '\n')

    s1, a1 = points1(f1x, f1x2, 1)
    a = 1
    s2, a2 = points1(f2x, f1x2, s1, s=1, e=1)

    s3, a3 = points1(f1x, f2x2, s2)
    s4, a4 = points1(f2x, f2x2, s3, s=1, e=1)
    #
    ix1 = line1(a1, 1 * M)
    ix2 = line1([a1[0]] + a2 + [a1[-1]], 2 * M)
    #
    ix3 = line1(a3, 3 * M)
    ix4 = line1([a3[0]] + a4 + [a3[-1]], 4 * M)

    ix5 = []
    ix6 = []
    ix8 = []
    ix7 = []
    # # #
    for i in range(len(a1) - 1):
        if i < len(a1) - 2:
            ix5.append(line1([a1[i], a3[i]], 5 * M + i))
            ix6.append(line1([a2[i], a4[i]], 6 * M + i))
            if i != 0:
                ix7.append(line1([a1[i], a2[i - 1]], 7 * M + i))
                ix8.append(line1([a3[i], a4[i - 1]], 8 * M + i))
        if i == len(a1) - 2:
            ix5.append(line1([a1[i], a3[i]], 5 * M + i))
            ix5.append(line1([a1[i + 1], a3[i + 1]], 5 * M + i + 1))
            ix7.append(line1([a1[i], a2[i - 1]], 7 * M + i))
            ix8.append(line1([a3[i], a4[i - 1]], 8 * M + i))

        #
    ix5 = np.atleast_1d(np.squeeze(np.array(ix5)))
    ix6 = np.atleast_1d(np.squeeze(np.array(ix6)))
    ix7 = np.atleast_1d(np.squeeze(np.array(ix7)))
    ix8 = np.atleast_1d(np.squeeze(np.array(ix8)))

    for i in range(len(a1) - 1):
        if i == 0:
            surface1([ix1[i], ix5[i + 1], -ix3[i], -ix5[i]], 1 * M + i)
            surface1([ix2[i], ix6[i], -ix4[i], -ix5[i]], 2 * M + i)

            surface1([ix1[i], ix7[i], -ix2[i]], 3 * M + i)
            surface1([ix3[i], ix8[i], -ix4[i]], 4 * M + i)
        elif i == len(a1) - 2:
            # print('hey')
            surface1([ix1[i], ix5[i + 1], -ix3[i], -ix5[i]], 1 * M + i)
            surface1([ix2[i], ix5[i + 1], -ix4[i], -ix6[i - 1]], 2 * M + i)
            #
            surface1([ix1[i], -ix2[i], -ix7[i - 1]], 3 * M + i)
            surface1([ix3[i], -ix4[i], -ix8[i - 1]], 4 * M + i)
        else:
            #upper
            surface1([ix1[i], ix5[i + 1], -ix3[i], -ix5[i]], 1 * M + i)
            #lower
            surface1([ix2[i], ix6[i], -ix4[i], -ix6[i - 1]], 2 * M + i)
            #left
            surface1([ix1[i], ix7[i], -ix2[i], -ix7[i - 1]], 3 * M + i)
            #right
            surface1([ix3[i], ix8[i], -ix4[i], -ix8[i - 1]], 4 * M + i)
Exemple #10
0
def center(b=-0.7, c=0.7, N=3, LN=7, RN=7, n=100):
    # n = 100
    L = 10
    b *= L
    c *= L
    x2, f1x2, f2x2 = img.imr('img2.png', n)
    x, f1x, f2x = img.imr('img.png', n)
    x *= L
    x2 *= L
    X = x.copy()
    cf1x = spectral.chebTransform(f1x)
    cf2x = spectral.chebTransform(f2x)

    cf1x2 = spectral.chebTransform(f1x2)
    cf2x2 = spectral.chebTransform(f2x2)
    # N = 3
    M = 1000
    n = N
    x = np.linspace(b, c, N)
    f1x = spectral.chebEval(cf1x, x, a=-L, b=L)
    f2x = spectral.chebEval(cf2x, x, a=-L, b=L)

    f1x2 = spectral.chebEval(cf1x2, x, a=-L, b=L)
    f2x2 = spectral.chebEval(cf2x2, x, a=-L, b=L)
    L2 = 1
    f1x *= L2
    f2x *= L2
    surfs = []
    bsurfs = []

    def points1(x, fx, z, I, s=0, e=0):
        ind = []
        for i in range(s, fx.size - e):
            file.write('Point(' + str(I + i) + ') = {' +
                       ", ".join(map(str, (list([x[i], z[i], fx[i], 1])))) +
                       '};')
            file.write('\n')
            file.write('//+' + '\n')
            ind.append(I + i)
        return fx.size + I, ind

    def line1(ind, I):
        ind1 = []
        for i in range(len(ind) - 1):
            file.write('Line(' + str(I + i) + ') = {' + str(ind[i]) + ',' +
                       str(ind[i + 1]) + '};')
            file.write('\n')
            file.write('//+' + '\n')
            ind1.append(I + i)
        return np.array(ind1)

    def surface1(ix, I):
        file.write('Curve Loop(' + str(I) + ') = {' + ', '.join(map(str, ix)) +
                   '};')
        file.write('\n')
        file.write('//+' + '\n')
        file.write('Plane Surface(' + str(I) + ') = {' + str(I) + '};')
        file.write('\n')
        file.write('//+' + '\n')
        return str(I)

    s1, a1 = points1(x, f1x, f1x2, 1)
    s2, a2 = points1(x, f2x, f1x2, s1)

    s3, a3 = points1(x, f1x, f2x2, s2)
    s4, a4 = points1(x, f2x, f2x2, s3)
    #
    ix1 = line1(a1, 1 * M)
    ix2 = line1(a2, 2 * M)
    #
    ix3 = line1(a3, 3 * M)
    ix4 = line1(a4, 4 * M)

    ix5 = []
    ix6 = []
    ix8 = []
    ix7 = []
    # # #
    for i in range(len(a1)):
        if i < len(a1) - 1 and i != 0:
            ix5.append(line1([a1[i], a3[i]], 5 * M + i))
            ix6.append(line1([a2[i], a4[i]], 6 * M + i))
            ix7.append(line1([a1[i], a2[i]], 7 * M + i))
            ix8.append(line1([a3[i], a4[i]], 8 * M + i))
        else:
            ix7.append(line1([a1[i], a2[i]], 7 * M + i))
            ix8.append(line1([a3[i], a4[i]], 8 * M + i))
        # elif i == 0:
        #     ix5.append(line1([a1[i], a3[i]], 5 * M + i))
        #     ix6.append(line1([a2[i], a4[i]], 6 * M + i))

    ix5 = np.atleast_1d(np.squeeze(np.array(ix5)))
    ix6 = np.atleast_1d(np.squeeze(np.array(ix6)))
    ix7 = np.atleast_1d(np.squeeze(np.array(ix7)))
    ix8 = np.atleast_1d(np.squeeze(np.array(ix8)))
    # print(ix1)
    # print(ix5)
    # print(ix3)
    # print(ix5)
    for i in range(len(a1) - 1):
        if i < len(a1) - 2 and i > 0:
            # upper
            surfs.append(
                surface1([ix1[i], ix5[i], -ix3[i], -ix5[i - 1]], 1 * M + i))
            # lower
            surfs.append(
                surface1([ix2[i], ix6[i], -ix4[i], -ix6[i - 1]], 2 * M + i))
            #left
            surfs.append(
                surface1([ix1[i], ix7[i + 1], -ix2[i], -ix7[i]], 3 * M + i))
            #right
            surfs.append(
                surface1([ix3[i], ix8[i + 1], -ix4[i], -ix8[i]], 4 * M + i))
        elif i == len(a1) - 2:
            surfs.append(
                surface1([ix1[i], ix7[i + 1], -ix2[i], -ix7[i]], 3 * M + i))
            surfs.append(
                surface1([ix3[i], ix8[i + 1], -ix4[i], -ix8[i]], 4 * M + i))
        elif i == 0:
            surfs.append(
                surface1([ix1[i], ix7[i + 1], -ix2[i], -ix7[i]], 3 * M + i))
            surfs.append(
                surface1([ix3[i], ix8[i + 1], -ix4[i], -ix8[i]], 4 * M + i))

    bsurfsl = []
    bsurfsr = []

    def right_b(coeff=0.25, mu=7):
        xs = np.linspace(f1x2[-1], f2x2[-1], mu)
        f3x = np.sin(np.linspace(0, np.pi * (mu - 1), mu) + np.pi / 2)

        xr = np.linspace(c, L, RN)
        fxr1 = spectral.chebEval(cf1x, xr, a=-L, b=L)
        fxr2 = spectral.chebEval(cf2x, xr, a=-L, b=L)
        # print(np.hstack((xl, x[1:])).size)
        x131 = np.hstack((x[:-1], xr))
        st1 = np.hstack((f2x[:-1], fxr2))
        st2 = np.hstack((f1x[:-1], fxr1))
        # print(x131)
        meh1 = sp_int.interp1d(x131, st1, kind='linear')
        meh2 = sp_int.interp1d(x131, st2, kind='linear')

        s5, a5 = points1((c + f3x * coeff)[1:-1],
                         meh1(c + f3x * coeff)[1:-1], xs[1:-1], s4)
        s6, a6 = points1((c + f3x * coeff)[1:-1],
                         meh2(c + f3x * coeff)[1:-1], xs[1:-1], s5)
        ix9 = line1(np.squeeze([[a2[-1]] + a5 + [a4[-1]]]), 9 * M)
        ix10 = line1(np.squeeze([[a1[-1]] + a6 + [a3[-1]]]), 10 * M)
        ix11 = []
        for i in range(mu - 2):
            ix11.append(line1([a5[i], a6[i]], 11 * M + i))
        ix11 = np.atleast_1d(np.squeeze(ix11))
        bsurfsr.append(surface1([ix10[0], -ix11[0], -ix9[0], -ix7[-1]], 5 * M))
        for i in range(1, mu - 2):
            bsurfsr.append(
                surface1([ix10[i], -ix11[i], -ix9[i], ix11[i - 1]], 5 * M + i))
        bsurfsr.append(
            surface1([ix10[-1], ix8[-1], -ix9[-1], ix11[-1]], 5 * M + i + 1))
        arr1 = np.atleast_1d(np.squeeze([ix6[-1], ix4[-1], *-ix9, -ix2[-1]]))
        arr2 = np.atleast_1d(np.squeeze([ix5[-1], ix3[-1], *-ix10, -ix1[-1]]))
        bsurfsr.append(surface1(arr1, 7 * M))
        bsurfsr.append(surface1(arr2, 7 * M + 1))
        return s5, s6, [ix9, ix10]

    def left_b(s5, s6, coeff=0.25, mu=7):
        # mu = 7
        xs = np.linspace(f1x2[-1], f2x2[-1], mu)
        f3x = np.sin(np.linspace(0, np.pi * (mu - 1), mu) + np.pi / 2)

        xl = np.linspace(-L, b, LN)
        fxl1 = spectral.chebEval(cf1x, xl, a=-L, b=L)
        fxl2 = spectral.chebEval(cf2x, xl, a=-L, b=L)
        # print(np.hstack((xl, x[1:])).size)
        x131 = np.hstack((xl, x[1:]))
        st1 = np.hstack((fxl2, f2x[1:]))
        st2 = np.hstack((fxl1, f1x[1:]))
        # print(x131)
        meh1 = sp_int.interp1d(x131, st1, kind='linear')
        meh2 = sp_int.interp1d(x131, st2, kind='linear')

        s7, a7 = points1((b + f3x * coeff)[1:-1],
                         meh1(b + f3x * coeff)[1:-1], xs[1:-1], s6)
        s8, a8 = points1((b + f3x * coeff)[1:-1],
                         meh2(b + f3x * coeff)[1:-1], xs[1:-1], s7)
        ix12 = line1(np.squeeze([[a2[0]] + a7 + [a4[0]]]), 12 * M)
        ix13 = line1(np.squeeze([[a1[0]] + a8 + [a3[0]]]), 13 * M)
        ix14 = []
        for i in range(mu - 2):
            ix14.append(line1([a7[i], a8[i]], 14 * M + i))
        ix14 = np.atleast_1d(np.squeeze(ix14))
        bsurfsl.append(surface1([ix13[0], -ix14[0], -ix12[0], -ix7[0]], 6 * M))
        for i in range(1, mu - 2):
            bsurfsl.append(
                surface1([ix13[i], -ix14[i], -ix12[i], ix14[i - 1]],
                         6 * M + i))
        bsurfsl.append(
            surface1([ix13[-1], ix8[0], -ix12[-1], ix14[-1]], 6 * M + i + 1))
        arr1 = np.atleast_1d(np.squeeze([ix6[0], -ix4[0], *-ix12, ix2[0]]))
        arr2 = np.atleast_1d(np.squeeze([ix5[0], -ix3[0], *-ix13, ix1[0]]))
        bsurfsl.append(surface1(arr1, 8 * M))
        bsurfsl.append(surface1(arr2, 8 * M + 1))
        return s8, [ix12, ix13]

    s5, s6, rxs = right_b(.07, 13)
    s8, lxs = left_b(s6, s6, 0.07, 13)
    return s8, lxs, rxs, [a1, a2, a3, a4], [[ix7[0], ix8[0]],
                                            [ix7[-1],
                                             ix8[-1]]], surfs, bsurfsl, bsurfsr