本文整理汇总了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;未经允许,请勿转载。 |
请发表评论