diff options
| author | eug-vs <eugene@eug-vs.xyz> | 2022-05-26 14:52:10 +0400 | 
|---|---|---|
| committer | eug-vs <eugene@eug-vs.xyz> | 2022-05-26 15:10:17 +0400 | 
| commit | 559ca0a5dae0b8f31f02f8d053898ff56e6c4144 (patch) | |
| tree | 318081c68218200ec0912f2d715c96429d8d6acf /src | |
| parent | 011f7ae73560b690aa1af58d445e1cf0afdf7103 (diff) | |
| download | CFD-SIMPLE-progress.tar.gz | |
feat: add outflow boundary condition, full pprogress
Diffstat (limited to 'src')
| -rw-r--r-- | src/simple.py | 25 | 
1 files changed, 14 insertions, 11 deletions
| diff --git a/src/simple.py b/src/simple.py index 8523db8..0b5436a 100644 --- a/src/simple.py +++ b/src/simple.py @@ -92,13 +92,13 @@ class SIMPLE:      def correct_pressure(self):          self.p_prime = np.zeros(shape=self.p.shape, dtype=float) -        for i in range(1, self.p.shape[0] - 1): -            for j in range(1, self.p.shape[1] - 1): +        for i in range(self.p.shape[0]): +            for j in range(self.p.shape[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+1] * self.step) -                    a_W = 0 if j == 1 else self.assert_positive(-self.d_e[i][j] * self.step) +                    a_W = 0 if j == 0 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_S = 0 if i == 0 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 * ( @@ -106,13 +106,14 @@ class SIMPLE:                          (self.v_star[i+1][j] - self.v_star[i][j])                      ) -                    self.p_prime[i][j] = ( -                        (a_E * self.p_prime[i][j+1] if a_E > 0 else 0) + -                        (a_W * self.p_prime[i][j-1] if a_W > 0 else 0) + -                        (a_N * self.p_prime[i+1][j] if a_N > 0 else 0) + -                        (a_S * self.p_prime[i-1][j] if a_S > 0 else 0) + -                        self.b[i][j] -                    ) / a_P +                    if a_P != 0: +                        self.p_prime[i][j] = ( +                            (a_E * self.p_prime[i][j+1] if a_E > 0 else 0) + +                            (a_W * self.p_prime[i][j-1] if a_W > 0 else 0) + +                            (a_N * self.p_prime[i+1][j] if a_N > 0 else 0) + +                            (a_S * self.p_prime[i-1][j] if a_S > 0 else 0) + +                            self.b[i][j] +                        ) / a_P          self.p = self.p_star + self.p_prime * self.alpha_p          self.p_star = self.p @@ -140,6 +141,7 @@ class SIMPLE:          self.u_star[:self.bfs_shape[0], self.bfs_shape[1]] = self.u_star[:self.bfs_shape[0], self.bfs_shape[1] - 1]          self.p_star[:self.bfs_shape[0], :self.bfs_shape[1]] = 0 +        self.u_star[:, -1] = self.u_star[:, -2]          self.correct_pressure()          self.correct_velocities() @@ -155,6 +157,7 @@ class SIMPLE:          self.u[:self.bfs_shape[0], self.bfs_shape[1]] = self.u[:self.bfs_shape[0], self.bfs_shape[1] - 1]          self.p[:self.bfs_shape[0], :self.bfs_shape[1]] = 0 +        self.u[:, -1] = self.u[:, -2]      def avg_error(self):          return np.absolute(self.b).sum() | 
