diff options
author | eug-vs <eugene@eug-vs.xyz> | 2022-05-18 17:59:26 +0400 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2022-05-18 17:59:26 +0400 |
commit | 53630647e9404120d34ab99c91b3daccb6cc02b9 (patch) | |
tree | 199dc691e68b1c098107244053b9c08184d9aa08 | |
parent | 0b06a9026730b81df9da03085fa2acfab66101ee (diff) | |
download | CFD-SIMPLE-53630647e9404120d34ab99c91b3daccb6cc02b9.tar.gz |
feat: improve plotting and output
-rw-r--r-- | src/main.py | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/src/main.py b/src/main.py index 4df1526..5904fbb 100644 --- a/src/main.py +++ b/src/main.py @@ -4,8 +4,8 @@ import matplotlib.pyplot as plt PI = np.pi np.set_printoptions(precision=2, floatmode="maxprec", suppress=True) -figure, axes = plt.subplots() cb = None +plot = None Re = 200 @@ -166,28 +166,45 @@ while error > precision: p[i][j] = 0 # Continuity residual as error measure - error = 0 + new_error = 0 for i in range(N): for j in range(M): - error += abs(b[i][j]) + new_error += abs(b[i][j]) + new_error /= N * M + if abs(new_error - error) > 10 ** -12: + error = new_error + else: + print('Error decrease too small, you probably wont do better') + break # Plotting - print(error) + print(new_error) x, y = np.meshgrid( np.linspace(0, domain_size[1], shape[1]), np.linspace(0, domain_size[0], shape[0]), ) - if iteration % 100 == 0: - pcolormesh = axes.pcolormesh(x, y, p, cmap='PuBuGn') - if (cb): + if iteration % 5 == 0 or iteration == 1: + print(f'Plotting, iteration: {iteration}') + if cb: cb.remove() - cb = plt.colorbar(pcolormesh) - + if plot: + plot.remove() factor = np.sqrt(u ** 2 + v ** 2) u_normalized = u / factor v_normalized = v / factor - plt.quiver(x, y, u_normalized, v_normalized, scale=45) + + density = 2 + plot = plt.quiver( + x[::density, ::density], + y[::density, ::density], + u_normalized[::density, ::density], + v_normalized[::density, ::density], + p[::density, ::density], + scale=30, + cmap='inferno' + ) + cb = plt.colorbar() plt.pause(0.0001) |