summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreug-vs <eugene@eug-vs.xyz>2022-05-26 13:18:07 +0400
committereug-vs <eugene@eug-vs.xyz>2022-05-26 13:18:07 +0400
commit886b7e06bba685f54002e9e247ac37a7dd093970 (patch)
tree904905b8107bd9de114f8fdc1c09f40f93727b53
parent5881e6fbd2086028014519cd0e1ea0a01a3ca896 (diff)
downloadCFD-SIMPLE-886b7e06bba685f54002e9e247ac37a7dd093970.tar.gz
fix: pressure inversion
-rw-r--r--src/simple.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/simple.py b/src/simple.py
index 0e103ea..3318213 100644
--- a/src/simple.py
+++ b/src/simple.py
@@ -49,7 +49,7 @@ class SIMPLE:
a_S = self.assert_positive(+0.5 * v_S * self.step + self.nu)
a_e = 0.5 * self.step * (u_E - u_W + v_N - v_S) + 4 * self.nu
- A_e = -self.step
+ A_e = self.step
self.d_e[i][j] = A_e / a_e
@@ -57,7 +57,8 @@ class SIMPLE:
a_E * self.u[i][j + 1] +
a_W * self.u[i][j - 1] +
a_N * self.u[i + 1][j] +
- a_S * self.u[i - 1][j]
+ a_S * self.u[i - 1][j] +
+ 0#self.b[i][j - 1]
) / a_e + self.d_e[i][j] * (self.p_star[i][j - 1] - self.p_star[i][j]) # p - p_e
# Momentum along Y direction
@@ -76,7 +77,7 @@ class SIMPLE:
a_S = self.assert_positive(+0.5 * v_S * self.step + self.nu)
a_n = 0.5 * self.step * (u_E - u_W + v_N - v_S) + 4 * self.nu
- A_n = -self.step
+ A_n = self.step
self.d_n[i][j] = A_n / a_n
@@ -84,7 +85,8 @@ class SIMPLE:
a_E * self.v[i][j + 1] +
a_W * self.v[i][j - 1] +
a_N * self.v[i + 1][j] +
- a_S * self.v[i - 1][j]
+ a_S * self.v[i - 1][j] +
+ 0#self.b[i - 1][j]
) / a_n + self.d_n[i][j] * (self.p_star[i - 1][j] - self.p_star[i][j]) # p - p_n
def correct_pressure(self):
@@ -92,15 +94,15 @@ class SIMPLE:
for i in range(1, self.p.shape[0] - 1):
for j in range(1, self.p.shape[1] - 1):
if i >= self.bfs_shape[0] or j >= self.bfs_shape[1]:
- a_E = 0 if j == self.p.shape[1] - 1 else self.assert_positive(-self.d_e[i][j] * self.step)
- a_W = 0 if j == 1 else self.assert_positive(-self.d_e[i][j+1] * self.step)
+ a_E = 0 if j == self.p.shape[1] - 1 else self.assert_positive(-self.d_e[i][j+1] * self.step)
+ a_W = 0 if j == 1 else self.assert_positive(-self.d_e[i][j] * self.step)
a_N = 0 if i == self.p.shape[0] - 1 else self.assert_positive(-self.d_n[i+1][j] * self.step)
a_S = 0 if i == 1 else self.assert_positive(-self.d_n[i][j] * self.step)
a_P = a_E + a_W + a_N + a_S
self.b[i][j] = self.step * (
- -(self.u_star[i][j] - self.u_star[i][j+1])
- + (self.v_star[i+1][j] - self.v_star[i][j])
+ (self.u_star[i][j+1] - self.u_star[i][j]) +
+ (self.v_star[i+1][j] - self.v_star[i][j])
)
self.p_prime[i][j] = (