コード例 #1
0
    def build_obstacle(g):

        y1 = int(np.shape(g)[0] / 10)
        y2 = int(9 * np.shape(g)[0] / 10)
        x_center = int(np.shape(g)[1] / 2)
        y_center = int(np.shape(g)[0] / 2)

        if x_center > y_center:
            r = int(np.shape(g)[0] / 5)
        else:
            r = int(np.shape(g)[1] / 5)

        g[y1:y2, 0:1] = 2
        g[y1:y2, nx - 1:nx] = 3
        g[y1:y2, 1:nx - 1] = 1

        for j in range(ny - 1):
            for i in range(nx - 1):
                a = np.abs(i - x_center)
                b = np.abs(j - y_center)
                c = np.sqrt(a**2 + b**2)

                if c < r:
                    g[j, i] = 0

        if data_check.existing_data():
            np.savetxt('dat/G_{}_{}_{}.dat'.format(geometry, nx, ny),
                       g,
                       fmt='%.1f')

        return g
コード例 #2
0
    def build_elbow(g):

        xmax = int(np.shape(g)[1] / 2 + np.shape(g)[1] / 5)
        x1 = int(np.shape(g)[1] / 2 - np.shape(g)[1] / 10)
        x2 = int(np.shape(g)[1] / 2 + np.shape(g)[1] / 5)
        ymax = int(np.shape(g)[0] / 2 + np.shape(g)[0] / 5)
        y1 = int(np.shape(g)[0] / 2 - np.shape(g)[0] / 10)
        y2 = int(np.shape(g)[0] / 2 + np.shape(g)[0] / 5)

        g[y1:y2, 0:1] = 2
        g[0:1, x1:x2] = 3
        g[y1:y2, 1:xmax] = 1
        g[1:ymax, x1:x2] = 1

        if data_check.existing_data():
            np.savetxt('dat/G_{}_{}_{}.dat'.format(geometry, nx, ny),
                       g,
                       fmt='%.1f')

        return g
コード例 #3
0
    def build_geometry(g, angle):

        alpha = np.tan(np.abs(angle))

        for i in range(nx):  # Parse the columns of G
            offset = int(i * alpha)
            g[1 + offset:-1 - offset, i] = 1

        # Flip the geometry if angle negative
        if angle > 0:
            g = np.fliplr(g)
        g[:, 0] *= 2  # Inlet
        g[:, -1] *= 3  # Outlet

        if data_check.existing_data():
            np.savetxt('dat/G_{}_{}_{}.dat'.format(geometry, nx, ny), g)

        else:
            pass

        return g
コード例 #4
0
#!/usr/bin/env python3

# Main program
import time
from parameters import recompute
import matrices
import plot
import data_check

t_init = time.time()
data_check.data_check()
matrices = matrices.Matrices()

if recompute or data_check.existing_data():
    data_check.domain_check()
    print('\nComputing new data...')
    matrices.make_data()
else:
    print('Running the program using existing data\n')

data = matrices.load_data()

plot = plot.Plot()

plot.plot_graphs("potential", data)
plot.plot_graphs("velocity", data)
plot.plot_graphs("streamlines", data)
plot.plot_graphs("pressure", data)

t_end = time.time()
print("\nProgram executed in {:.3f} seconds."