def setUp(self): domain = dm.domain(np.array([0, 0]), np.array([1, 1])) inDomain = lambda x, y: 0 < x < 1 and 0 < y < 1 onBoundary = lambda x, y: abs(x) < np.spacing(1) or abs(x-1) < np.spacing(1) \ or abs(y-1) < np.spacing(1) or abs(y) < np.spacing(1) getBoundaryValue = lambda x, y: 0 diri = dr.dirichlet_bc(inDomain, onBoundary, getBoundaryValue, domain) self.solver = poisson.poisson_solver( lambda x, y: 32 * x * (1 - x) + 32 * y * (1 - y), diri)
def setUp(self): domain = dm.domain(np.array([-1, -1]), np.array([1, 1])) inDomain = lambda x, y: x**2 + y**2 < 1 onBoundary = lambda x, y: abs(x**2 + y**2 - 1) < np.spacing(1) getBoundaryValue = lambda x, y: 1 getNearestPoint = [get_x_by_y, get_y_by_x] diri = dr.dirichlet_bc(inDomain, onBoundary, getBoundaryValue, domain, getNearestPoint) self.solver = fdm.fdm_solver(None, lambda x, y: 16 * (x**2 + y**2), diri)
def setUp(self): domain = dm.domain(np.array([-1, -1]), np.array([1, 1])) d = ddx.ddx(0.1) self.expression = expr.diff_operator_expression([d]) inDomain = lambda x, y: abs(x) < 1 and abs(y) < 1 onBoundary = lambda x, y: abs(x-1) < np.spacing(1) or abs(x+1) < np.spacing(1) \ or abs(y-1) < np.spacing(1) or abs(y+1) < np.spacing(1) getBoundaryValue = lambda x, y: 1 self.diri = dr.dirichlet_bc(inDomain, onBoundary, getBoundaryValue, domain) self.diri2 = dr.dirichlet_bc(inDomain, onBoundary, getBoundaryValue, domain, (lambda x, y: 1, lambda x, y: 2)) self.solver = fdm.fdm_solver(self.expression, lambda x, y: 1, self.diri) self.solver2 = fdm.fdm_solver(self.expression, lambda x, y: 1, self.diri2) domain_s = dm.domain(np.array([0, 0]), np.array([1, 1])) inDomain_s = lambda x, y: 0 < x < 1 and 0 < y < 1 onBoundary_s = lambda x, y: abs(x-1) < np.spacing(1) or abs(x) < np.spacing(1) \ or abs(y-1) < np.spacing(1) or abs(y) < np.spacing(1) getBoundaryValue_s = lambda x, y: 1/(1+x) + 1/(1+y) f_s = lambda x, y: 2/(1+x)**3 + 2/(1+y)**3 self.dirichlet = dr.dirichlet_bc(inDomain_s, onBoundary_s, getBoundaryValue_s, domain_s) self.real_solver = fdm.fdm_solver([], f_s, self.dirichlet)
def setUp(self): td_domain = dm.domain(np.array([0, 0]), np.array([1, 1])) td_inDomain = lambda x, y: 0 < x < 1 and 0 < y < 1 td_onBoundary = lambda x, y: abs(x-1) < np.spacing(1) or abs(x) < np.spacing(1) \ or abs(y) < np.spacing(1) def td_getBV(x, y): if abs(x) < np.spacing(1) or abs(x-1) < np.spacing(1): return 0 else: #return math.sin(math.pi*x) #return 6*math.sin(math.pi*x) + 3*math.cos(2*math.pi*x) - 3 return 6*x * math.sin(5*math.pi*x) f_s = lambda x, y: 0 dirichlet = dr.dirichlet_bc(td_inDomain, td_onBoundary, td_getBV, td_domain) self.solver = fdm.fdm_solver([], f_s, dirichlet)
def test_init(self): a = dr.dirichlet_bc(self.inDomain, self.onBoundary, self.getBoundaryValue, self.domain) assert (a.domain.lower_left_coord == np.array([-1, -1])).all()