Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from math import cos, sin, pow, pi
- from numpy import zeros, array
- class Solution:
- def __init__(self, n, x, y):
- self._n = n
- self._uright = zeros((n + 1, n + 1))
- self._u = zeros((n + 1, n + 1))
- self.CalcURight(x, y)
- #self._u.copy(list(self._uright))
- def CalcURight(self, x, y):
- for i in range(0, self._n + 1):
- for j in range(0, self._n + 1):
- self._uright[i][j] = sin(pi * x[i]) * sin(pi * y[j])
- def URight(self):
- return self._uright
- def CalcURelax(self, h, w, u, f):
- for i in range(1, self._n - 1):
- for j in range(1, self._n - 1):
- one = (pow(h, 2) * w * f[i][j]) / 4
- two = w / 4 * (self._u[i - 1][j] + self._u[i][j - 1] + self._u[i + 1][j] + self._u[i][j + 1])
- three = (1 - w) * self._u[i][j]
- self._u[i][j] = one + two + three
- def U(self):
- return self._u
Advertisement
Add Comment
Please, Sign In to add comment