當前位置: 首頁>>代碼示例>>Python>>正文


Python quadratures.GaussQuadratures類代碼示例

本文整理匯總了Python中pymor.tools.quadratures.GaussQuadratures的典型用法代碼示例。如果您正苦於以下問題:Python GaussQuadratures類的具體用法?Python GaussQuadratures怎麽用?Python GaussQuadratures使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了GaussQuadratures類的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

    def __init__(self):
        def tensor_points(P):
            PP0, PP1 = np.array(np.meshgrid(P, P))
            return np.array((PP0.ravel(), PP1.ravel())).T

        def tensor_weights(W):
            return np.dot(W[:, np.newaxis], W[np.newaxis, :]).ravel()
        self._quadrature_points = [tensor_points(GaussQuadratures.quadrature(npoints=p + 1)[0])
                                   for p in xrange(GaussQuadratures.maxpoints())]
        self._quadrature_weights = [tensor_weights(GaussQuadratures.quadrature(npoints=p + 1)[1])
                                    for p in xrange(GaussQuadratures.maxpoints())]
        self._quadrature_npoints = np.arange(1, GaussQuadratures.maxpoints() + 1) ** 2
        self._quadrature_orders = GaussQuadratures.orders
        self._quadrature_order_map = GaussQuadratures.order_map
開發者ID:maltedschumacher,項目名稱:pyMor,代碼行數:14,代碼來源:referenceelements.py

示例2: test_other_functions

 def test_other_functions(self):
     order = GaussQuadratures.orders[-1]
     for name, function, integral in FUNCTIONS:
         Q = GaussQuadratures.iter_quadrature(order)
         ret = sum([function(p) * w for (p, w) in Q])
         assert float_cmp(ret, integral), '{} integral wrong: {} vs {} (quadrature order {})'.format(
             name, integral, ret, order)
開發者ID:lucas-ca,項目名稱:pymor,代碼行數:7,代碼來源:tools.py

示例3: test_other_functions

 def test_other_functions(self):
     order = GaussQuadratures.orders[-1]
     for name, function, integral in FUNCTIONS:
         Q = GaussQuadratures.iter_quadrature(order)
         ret = sum([function(p) * w for (p, w) in Q])
         assert float_cmp(ret, integral), \
             f'{name} integral wrong: {integral} vs {ret} (quadrature order {order})'
開發者ID:pymor,項目名稱:pymor,代碼行數:7,代碼來源:tools.py

示例4: test_polynomials

 def test_polynomials(self):
     for n, function, _, integral in polynomials(GaussQuadratures.orders[-1]):
         name = 'x^{}'.format(n)
         for order in GaussQuadratures.orders:
             if n > order / 2:
                 continue
             Q = GaussQuadratures.iter_quadrature(order)
             ret = sum([function(p) * w for (p, w) in Q])
             assert float_cmp(ret, integral), '{} integral wrong: {} vs {} (quadrature order {})'.format(
                 name, integral, ret, order)
開發者ID:lucas-ca,項目名稱:pymor,代碼行數:10,代碼來源:tools.py

示例5: test_polynomials

 def test_polynomials(self):
     for n, function, _, integral in polynomials(GaussQuadratures.orders[-1]):
         name = f'x^{n}'
         for order in GaussQuadratures.orders:
             if n > order / 2:
                 continue
             Q = GaussQuadratures.iter_quadrature(order)
             ret = sum([function(p) * w for (p, w) in Q])
             assert float_cmp(ret, integral), \
                 f'{name} integral wrong: {integral} vs {ret} (quadrature order {order})'
開發者ID:pymor,項目名稱:pymor,代碼行數:10,代碼來源:tools.py

示例6: __init__

 def __init__(self, flux, flux_derivative, gausspoints=5, intervals=1):
     self.flux = flux
     self.flux_derivative = flux_derivative
     self.gausspoints = gausspoints
     self.intervals = intervals
     self.build_parameter_type(inherits=(flux, flux_derivative))
     points, weights = GaussQuadratures.quadrature(npoints=self.gausspoints)
     points = points / intervals
     points = ((np.arange(self.intervals, dtype=np.float)[:, np.newaxis] * (1 / intervals))
               + points[np.newaxis, :]).ravel()
     weights = np.tile(weights, intervals) * (1 / intervals)
     self.points = points
     self.weights = weights
開發者ID:JuliaBru,項目名稱:pymor,代碼行數:13,代碼來源:fv.py

示例7: quadrature

 def quadrature(self, order=None, npoints=None, quadrature_type='default'):
     if quadrature_type == 'default' or quadrature_type == 'gauss':
         P, W = GaussQuadratures.quadrature(order, npoints)
         return P[:, np.newaxis], W
     else:
         raise NotImplementedError('quadrature_type must be "default" or "gauss"')
開發者ID:tobiasleibner,項目名稱:pymor,代碼行數:6,代碼來源:referenceelements.py

示例8: test_points

 def test_points(self):
     for order in GaussQuadratures.orders:
         P, _ = GaussQuadratures.quadrature(order)
         assert float_cmp_all(P, np.sort(P))
         assert 0.0 < P[0]
         assert P[-1] < 1.0
開發者ID:lucas-ca,項目名稱:pymor,代碼行數:6,代碼來源:tools.py

示例9: test_weights

 def test_weights(self):
     for order in GaussQuadratures.orders:
         _, W = GaussQuadratures.quadrature(order)
         assert float_cmp(sum(W), 1)
開發者ID:lucas-ca,項目名稱:pymor,代碼行數:4,代碼來源:tools.py

示例10: test_points

 def test_points(self):
     for order in GaussQuadratures.orders:
         P, _ = GaussQuadratures.quadrature(order)
         np.testing.assert_array_equal(P, np.sort(P))
         self.assertLess(0.0, P[0])
         self.assertLess(P[-1], 1.0)
開發者ID:BarbaraV,項目名稱:pymor,代碼行數:6,代碼來源:tools.py

示例11: test_weights

 def test_weights(self):
     for order in GaussQuadratures.orders:
         _, W = GaussQuadratures.quadrature(order)
         self.assertAlmostEqual(sum(W), 1)
開發者ID:BarbaraV,項目名稱:pymor,代碼行數:4,代碼來源:tools.py


注:本文中的pymor.tools.quadratures.GaussQuadratures類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。