Пример #1
0
    def test_weak_form(self,real_operator,complex_operator):

        blocked_operator = BlockedBoundaryOperator(3,2)
        blocked_operator[0,0] = real_operator
        with pytest.raises(ValueError):
            weak_form = blocked_operator.weak_form()
        blocked_operator[1,1] = complex_operator
        blocked_operator[2,0] = real_operator
        weak_form = blocked_operator.weak_form()

        assert weak_form.ndims == (3,2)
Пример #2
0
    def test_weak_form(self, real_operator, complex_operator):

        blocked_operator = BlockedBoundaryOperator(3, 2)
        blocked_operator[0, 0] = real_operator
        with pytest.raises(ValueError):
            weak_form = blocked_operator.weak_form()
        blocked_operator[1, 1] = complex_operator
        blocked_operator[2, 0] = real_operator
        weak_form = blocked_operator.weak_form()

        assert weak_form.ndims == (3, 2)
Пример #3
0
    def test_add_blocked_boundary_operator(self,real_operator,complex_operator):

        blocked_operator = BlockedBoundaryOperator(2,2)
        blocked_operator[0,0] = real_operator
        blocked_operator[1,0] = complex_operator
        blocked_operator[1,1] = real_operator

        result = blocked_operator+blocked_operator

        expected = 2*blocked_operator.weak_form().as_matrix()
        actual = result.weak_form().as_matrix()

        assert np.linalg.norm(expected-actual)<_eps
Пример #4
0
    def test_add_blocked_boundary_operator(self, real_operator,
                                           complex_operator):

        blocked_operator = BlockedBoundaryOperator(2, 2)
        blocked_operator[0, 0] = real_operator
        blocked_operator[1, 0] = complex_operator
        blocked_operator[1, 1] = real_operator

        result = blocked_operator + blocked_operator

        expected = 2 * blocked_operator.weak_form().as_matrix()
        actual = result.weak_form().as_matrix()

        assert np.linalg.norm(expected - actual) < _eps
Пример #5
0
    def test_result_type(self, real_operator, complex_operator):

        blocked_operator = BlockedBoundaryOperator(3, 2)
        blocked_operator[0, 0] = real_operator
        assert blocked_operator.result_type == 'float64'

        blocked_operator[1, 1] = complex_operator
        assert blocked_operator.result_type == 'complex128'
Пример #6
0
    def test_assign_operators(self, real_operator, complex_operator):

        blocked_operator = BlockedBoundaryOperator(3, 2)

        blocked_operator[0, 0] = real_operator
        assert blocked_operator.domain_spaces[0] is not None
        assert blocked_operator.range_spaces[0] is not None
        assert blocked_operator.dual_to_range_spaces[0] is not None
        assert blocked_operator.domain_spaces[1] is None
Пример #7
0
    def test_apply_grid_function(self, real_operator, complex_operator, space):

        blocked_operator = BlockedBoundaryOperator(2, 2)
        blocked_operator[0, 0] = real_operator
        blocked_operator[1, 0] = complex_operator
        blocked_operator[1, 1] = real_operator

        g = GridFunction(space=space,
                         coefficients=np.ones(space.global_dof_count))
        g_vec = [g, 2 * g]
        res = blocked_operator * g_vec
        actual = res[1].coefficients
        expected = (2 * real_operator * g + complex_operator * g).coefficients

        assert np.linalg.norm(actual - expected) < _eps
Пример #8
0
    def test_basis_type(self):

        blocked_operator = BlockedBoundaryOperator(3, 2)
        assert blocked_operator.basis_type == 'float64'
Пример #9
0
    def test_initialization(self):

        blocked_operator = BlockedBoundaryOperator(3, 2)