# -*- coding: utf-8 -*-
"""
Numeric integration routines
----------------------------
Weights and coordinates for Gauss-Legendre quadrature [WGAUSS]_. The
values for triangles is presented in section 5.5 of Bathe book [BATHE]_.

References
----------
.. [WGAUSS] Wikipedia contributors. "Gaussian quadrature." Wikipedia,
   The Free Encyclopedia, 2 Nov.  2015. Web. 25 Dec. 2015.
   url: https://en.wikipedia.org/wiki/Gaussian_quadrature
.. [BATHE] Bathe, Klaus-Jürgen. Finite element procedures. Prentice Hall,
   Pearson Education, 2006.
"""
from itertools import product
import numpy as np


#%% General
def gauss_1d(npts):
    """Return Gauss points and weights for Gauss quadrature in 1D

    Parameters
    ----------
    npts : int
      Number of quadrature points.

    Returns
    -------
    wts : ndarray
      Weights for the Gauss-Legendre quadrature.
    pts : ndarray
      Points for the Gauss-Legendre quadrature.
    """
    if npts == 2:
        pts = [-0.577350269189625764, 0.577350269189625764]
        wts = [1.00000000000000000, 1.00000000000000000]
    elif npts == 3:
        pts = [-0.774596669241483377, 0, 0.774596669241483377]
        wts = [0.555555555555555556, 0.888888888888888889,
               0.555555555555555556]
    elif npts == 4:
        pts = [-0.861136311594052575, -0.339981043584856265,
               0.339981043584856265, 0.861136311594052575]
        wts = [0.347854845137453857, 0.652145154862546143,
               0.652145154862546143, 0.347854845137453857]
    elif npts == 5:
        pts = [-0.906179845938663993, -0.538469310105683091, 0,
               0.538469310105683091, 0.906179845938663993]
        wts = [0.236926885056189088, 0.478628670499366468,
               0.568888888888888889, 0.478628670499366468,
               0.236926885056189088]
    elif npts == 6:
        pts = [-0.932469514203152028, -0.661209386466264514,
               -0.238619186083196909, 0.238619186083196909,
               0.661209386466264514, 0.932469514203152028]
        wts = [0.171324492379170345, 0.360761573048138608,
               0.467913934572691047, 0.467913934572691047,
               0.360761573048138608, 0.171324492379170345]
    elif npts == 7:
        pts = [-0.949107912342758525, -0.741531185599394440,
               -0.405845151377397167, 0, 0.405845151377397167,
               0.741531185599394440, 0.949107912342758525]
        wts = [0.129484966168869693, 0.279705391489276668,
               0.381830050505118945, 0.417959183673469388,
               0.381830050505118945, 0.279705391489276668,
               0.129484966168869693]
    elif npts == 8:
        pts = [-0.960289856497536232, -0.796666477413626740,
               -0.525532409916328986, -0.183434642495649805,
               0.183434642495649805, 0.525532409916328986,
               0.796666477413626740, 0.960289856497536232]
        wts = [0.101228536290376259, 0.222381034453374471,
               0.313706645877887287, 0.362683783378361983,
               0.362683783378361983, 0.313706645877887287,
               0.222381034453374471, 0.101228536290376259]
    elif npts == 9:
        pts = [-0.968160239507626090, -0.836031107326635794,
               -0.613371432700590397, -0.324253423403808929, 0,
               0.324253423403808929, 0.613371432700590397,
               0.836031107326635794, 0.968160239507626090]
        wts = [0.0812743883615744120, 0.180648160694857404,
               0.260610696402935462, 0.312347077040002840,
               0.330239355001259763, 0.312347077040002840,
               0.260610696402935462, 0.180648160694857404,
               0.0812743883615744120]
    elif npts == 10:
        pts = [-0.973906528517171720, -0.865063366688984511,
               -0.679409568299024406, -0.433395394129247191,
               -0.148874338981631211, 0.148874338981631211,
               0.433395394129247191, 0.679409568299024406,
               0.865063366688984511, 0.973906528517171720]
        wts = [0.0666713443086881376, 0.149451349150580593,
               0.219086362515982044, 0.269266719309996355,
               0.295524224714752870, 0.295524224714752870,
               0.269266719309996355, 0.219086362515982044,
               0.149451349150580593, 0.0666713443086881376]
    else:
        msg = "The number of points should be in [2, 10]"
        raise ValueError(msg)

    return pts, wts


def gauss_nd(npts, ndim=2):
    """
    Return Gauss points and weights for Gauss quadrature in
    an ND hypercube.

    Parameters
    ----------
    npts : int
      Number of quadrature points.

    Returns
    -------
    nd_wts : ndarray
      Weights for the Gauss-Legendre quadrature.
    nd_pts : ndarray
      Points for the Gauss-Legendre quadrature.
    """
    pts, wts = gauss_1d(npts)
    nd_pts = np.array(list(product(pts, repeat=ndim)))
    nd_wts = product(wts, repeat=ndim)
    nd_wts = [np.prod(nd_wt) for nd_wt in nd_wts]
    return nd_pts, nd_wts


def gauss_tri(order=2):
    """
    Gauss points and weights for a triangle up to order 7

    Returns
    -------
    pts : ndarray
      Points for the Gauss-Legendre quadrature.
    wts : ndarray
      Weights for the Gauss-Legendre quadrature.

    References
    ----------
    .. [BATHE] Bathe, Klaus-Jürgen. Finite element procedures.
       Prentice Hall, Pearson Education, 2006.
    """
    if order == 1:
        pts = np.array([[0.3333333333333, 0.3333333333333]])
        wts = np.array([1.0])
    elif order == 2:
        pts = np.array([
            [0.1666666666667, 0.1666666666667],
            [0.6666666666667, 0.1666666666667],
            [0.1666666666667, 0.6666666666667]])
        wts = np.full([3], 0.333333333333)
    elif order in [3, 4, 5]:
        pts = np.array([
            [0.1012865073235, 0.1012865073235],
            [0.7974269853531, 0.1012865073235],
            [0.1012865073235, 0.7974269853531],
            [0.4701420641051, 0.0597158717898],
            [0.4701420641051, 0.4701420641051],
            [0.0597158717898, 0.4701420641051],
            [0.3333333333333, 0.3333333333333]])
        wts = np.array([
            0.1259391805448, 0.1259391805448, 0.1259391805448,
            0.1323941527885, 0.1323941527885, 0.1323941527885,
            0.225])
    elif order in [6, 7]:
        pts = np.array([
            [0.0651301029022, 0.0651301029022],
            [0.8697397941956, 0.0651301029022],
            [0.0651301029022, 0.8697397941956],
            [0.3128654960049, 0.0486903154253],
            [0.6384441885698, 0.3128654960049],
            [0.0486903154253, 0.6384441885698],
            [0.6384441885698, 0.0486903154253],
            [0.3128654960049, 0.6384441885698],
            [0.0486903154253, 0.3128654960049],
            [0.2603459660790, 0.2603459660790],
            [0.4793080678413, 0.2603459660790],
            [0.2603459660790, 0.4793080678413],
            [0.3333333333333, 0.3333333333333]])
        wts = np.array([
            0.0533472356088, 0.0533472356088, 0.0533472356088,
            0.0771137608903, 0.0771137608903, 0.0771137608903,
            0.0771137608903, 0.0771137608903, 0.0771137608903,
            0.1756152574332, 0.1756152574332, 0.1756152574332,
            -0.1495700444677])
    else:
        msg = "The order should be in [1, 7]"
        raise ValueError(msg)
    return pts, wts


def gauss_tet(order=3):
    """
    Gauss points and weights for a tetrahedron up to order 10

    Returns
    -------
    pts : ndarray
      Points for the Gauss-Legendre quadrature.
    wts : ndarray
      Weights for the Gauss-Legendre quadrature.

    References
    ----------
    .. [WITHE] Witherden, F. D., & Vincent, P. E. (2015).
       On the identification of symmetric quadrature rules
       for finite element methods. Computers & Mathematics with
       Applications, 69(10), 1232-1241.
    .. [SCHLO] Nico Schlömer, Nick R. Papior, Rasmus Zetter,
       Matthieu Ancellin, & Darius Arnold. (2020, May 5).
       nschloe/quadpy v0.14.11 (Version v0.14.11). Zenodo.
       http://doi.org/10.5281/zenodo.3786435

    """
    if order == 1:
        pts = np.array([[0.25, 0.25, 0.25]])
        wts = np.array([1.0])
    elif order == 2:
        pts = np.array([
            [0.1381966011250105, 0.1381966011250105, 0.5854101966249684],
            [0.1381966011250105, 0.5854101966249684, 0.1381966011250105],
            [0.5854101966249684, 0.1381966011250105, 0.1381966011250105],
            [0.1381966011250105, 0.1381966011250105, 0.1381966011250105]])
        wts = np.array([0.25, 0.25, 0.25, 0.25])
    elif order == 3:
        pts = np.array([
            [0.3281633025163817, 0.3281633025163817, 0.0155100924508549],
            [0.1080472498984286, 0.1080472498984286, 0.6758582503047142],
            [0.3281633025163817, 0.0155100924508549, 0.3281633025163817],
            [0.1080472498984286, 0.6758582503047142, 0.1080472498984286],
            [0.0155100924508549, 0.3281633025163817, 0.3281633025163817],
            [0.6758582503047142, 0.1080472498984286, 0.1080472498984286],
            [0.3281633025163817, 0.3281633025163817, 0.3281633025163817],
            [0.1080472498984286, 0.1080472498984286, 0.1080472498984286]])
        wts = np.array([
            0.1362178425370874, 0.1137821574629126, 0.1362178425370874,
            0.1137821574629126, 0.1362178425370874, 0.1137821574629126,
            0.1362178425370874, 0.1137821574629126])
    elif order in [4, 5]:
        pts = np.array([
            [0.3108859192633006, 0.3108859192633006, 0.0673422422100982],
            [0.0927352503108912, 0.0927352503108912, 0.7217942490673263],
            [0.3108859192633006, 0.0673422422100982, 0.3108859192633006],
            [0.0927352503108912, 0.7217942490673263, 0.0927352503108912],
            [0.0673422422100982, 0.3108859192633006, 0.3108859192633006],
            [0.7217942490673263, 0.0927352503108912, 0.0927352503108912],
            [0.3108859192633006, 0.3108859192633006, 0.3108859192633006],
            [0.0927352503108912, 0.0927352503108912, 0.0927352503108912],
            [0.0455037041256496, 0.4544962958743504, 0.4544962958743504],
            [0.4544962958743504, 0.0455037041256496, 0.4544962958743504],
            [0.0455037041256496, 0.0455037041256496, 0.4544962958743504],
            [0.4544962958743504, 0.4544962958743504, 0.0455037041256496],
            [0.0455037041256496, 0.4544962958743504, 0.0455037041256496],
            [0.4544962958743504, 0.0455037041256496, 0.0455037041256496]])
        wts = np.array([
            0.1126879257180159, 0.073493043116362 , 0.1126879257180159,
            0.073493043116362 , 0.1126879257180159, 0.073493043116362 ,
            0.1126879257180159, 0.073493043116362 , 0.0425460207770815,
            0.0425460207770815, 0.0425460207770815, 0.0425460207770815,
            0.0425460207770815, 0.0425460207770815])
    elif order == 6:
        pts = np.array([
            [0.0406739585346114, 0.0406739585346114, 0.8779781243961658],
            [0.3223378901422755, 0.3223378901422755, 0.0329863295731736],
            [0.214602871259152 , 0.214602871259152 , 0.356191386222544 ],
            [0.0406739585346114, 0.8779781243961658, 0.0406739585346114],
            [0.3223378901422755, 0.0329863295731736, 0.3223378901422755],
            [0.214602871259152 , 0.356191386222544 , 0.214602871259152 ],
            [0.8779781243961658, 0.0406739585346114, 0.0406739585346114],
            [0.0329863295731736, 0.3223378901422755, 0.3223378901422755],
            [0.356191386222544 , 0.214602871259152 , 0.214602871259152 ],
            [0.0406739585346114, 0.0406739585346114, 0.0406739585346114],
            [0.3223378901422755, 0.3223378901422755, 0.3223378901422755],
            [0.214602871259152 , 0.214602871259152 , 0.214602871259152 ],
            [0.0636610018750174, 0.6030056647916492, 0.2696723314583159],
            [0.6030056647916492, 0.0636610018750174, 0.2696723314583159],
            [0.0636610018750174, 0.0636610018750174, 0.2696723314583159],
            [0.6030056647916492, 0.2696723314583159, 0.0636610018750174],
            [0.0636610018750174, 0.2696723314583159, 0.0636610018750174],
            [0.2696723314583159, 0.0636610018750174, 0.0636610018750174],
            [0.0636610018750174, 0.2696723314583159, 0.6030056647916492],
            [0.2696723314583159, 0.0636610018750174, 0.6030056647916492],
            [0.0636610018750174, 0.0636610018750174, 0.6030056647916492],
            [0.2696723314583159, 0.6030056647916492, 0.0636610018750174],
            [0.0636610018750174, 0.6030056647916492, 0.0636610018750174],
            [0.6030056647916492, 0.0636610018750174, 0.0636610018750174]])
        wts = np.array([
            0.0100772110553206, 0.0553571815436547, 0.0399227502581675,
            0.0100772110553206, 0.0553571815436547, 0.0399227502581675,
            0.0100772110553206, 0.0553571815436547, 0.0399227502581675,
            0.0100772110553206, 0.0553571815436547, 0.0399227502581675,
            0.0482142857142857, 0.0482142857142857, 0.0482142857142857,
            0.0482142857142857, 0.0482142857142857, 0.0482142857142857,
            0.0482142857142857, 0.0482142857142857, 0.0482142857142857,
            0.0482142857142857, 0.0482142857142857, 0.0482142857142857])
    elif order == 7:
        pts = np.array([
            [0.25              , 0.25              , 0.25              ],
            [0.3157011497782028, 0.3157011497782028, 0.0528965506653916],
            [0.3157011497782028, 0.0528965506653916, 0.3157011497782028],
            [0.0528965506653916, 0.3157011497782028, 0.3157011497782028],
            [0.3157011497782028, 0.3157011497782028, 0.3157011497782028],
            [0.0504898225983964, 0.4495101774016036, 0.4495101774016036],
            [0.4495101774016036, 0.0504898225983964, 0.4495101774016036],
            [0.0504898225983964, 0.0504898225983964, 0.4495101774016036],
            [0.4495101774016036, 0.4495101774016036, 0.0504898225983964],
            [0.0504898225983964, 0.4495101774016036, 0.0504898225983964],
            [0.4495101774016036, 0.0504898225983964, 0.0504898225983964],
            [0.188833831026001 , 0.575171637587    , 0.0471607003609981],
            [0.0212654725414831, 0.8108302410985486, 0.1466388138184851],
            [0.575171637587    , 0.188833831026001 , 0.0471607003609981],
            [0.8108302410985486, 0.0212654725414831, 0.1466388138184851],
            [0.188833831026001 , 0.188833831026001 , 0.0471607003609981],
            [0.0212654725414831, 0.0212654725414831, 0.1466388138184851],
            [0.575171637587    , 0.0471607003609981, 0.188833831026001 ],
            [0.8108302410985486, 0.1466388138184851, 0.0212654725414831],
            [0.188833831026001 , 0.0471607003609981, 0.188833831026001 ],
            [0.0212654725414831, 0.1466388138184851, 0.0212654725414831],
            [0.0471607003609981, 0.188833831026001 , 0.188833831026001 ],
            [0.1466388138184851, 0.0212654725414831, 0.0212654725414831],
            [0.188833831026001 , 0.0471607003609981, 0.575171637587    ],
            [0.0212654725414831, 0.1466388138184851, 0.8108302410985486],
            [0.0471607003609981, 0.188833831026001 , 0.575171637587    ],
            [0.1466388138184851, 0.0212654725414831, 0.8108302410985486],
            [0.188833831026001 , 0.188833831026001 , 0.575171637587    ],
            [0.0212654725414831, 0.0212654725414831, 0.8108302410985486],
            [0.0471607003609981, 0.575171637587    , 0.188833831026001 ],
            [0.1466388138184851, 0.8108302410985486, 0.0212654725414831],
            [0.188833831026001 , 0.575171637587    , 0.188833831026001 ],
            [0.0212654725414831, 0.8108302410985486, 0.0212654725414831],
            [0.575171637587    , 0.188833831026001 , 0.188833831026001 ],
            [0.8108302410985486, 0.0212654725414831, 0.0212654725414831]])
        wts = np.array([
            0.0954852894641308, 0.042329581209967 , 0.042329581209967 ,
            0.042329581209967 , 0.042329581209967 , 0.0318969278328576,
            0.0318969278328576, 0.0318969278328576, 0.0318969278328576,
            0.0318969278328576, 0.0318969278328576, 0.0372071307283346,
            0.0081107708299033, 0.0372071307283346, 0.0081107708299033,
            0.0372071307283346, 0.0081107708299033, 0.0372071307283346,
            0.0081107708299033, 0.0372071307283346, 0.0081107708299033,
            0.0372071307283346, 0.0081107708299033, 0.0372071307283346,
            0.0081107708299033, 0.0372071307283346, 0.0081107708299033,
            0.0372071307283346, 0.0081107708299033, 0.0372071307283346,
            0.0081107708299033, 0.0372071307283346, 0.0081107708299033,
            0.0372071307283346, 0.0081107708299033])
    elif order == 8:
        pts = np.array([
            [0.1079527249622109, 0.1079527249622109, 0.6761418251133673],
            [0.1851094877825866, 0.1851094877825866, 0.4446715366522402],
            [0.0423165436847673, 0.0423165436847673, 0.8730503689456981],
            [0.314181709124039 , 0.314181709124039 , 0.0574548726278831],
            [0.1079527249622109, 0.6761418251133673, 0.1079527249622109],
            [0.1851094877825866, 0.4446715366522402, 0.1851094877825866],
            [0.0423165436847673, 0.8730503689456981, 0.0423165436847673],
            [0.314181709124039 , 0.0574548726278831, 0.314181709124039 ],
            [0.6761418251133673, 0.1079527249622109, 0.1079527249622109],
            [0.4446715366522402, 0.1851094877825866, 0.1851094877825866],
            [0.8730503689456981, 0.0423165436847673, 0.0423165436847673],
            [0.0574548726278831, 0.314181709124039 , 0.314181709124039 ],
            [0.1079527249622109, 0.1079527249622109, 0.1079527249622109],
            [0.1851094877825866, 0.1851094877825866, 0.1851094877825866],
            [0.0423165436847673, 0.0423165436847673, 0.0423165436847673],
            [0.314181709124039 , 0.314181709124039 , 0.314181709124039 ],
            [0.4355913285838302, 0.0644086714161698, 0.0644086714161698],
            [0.0644086714161698, 0.4355913285838302, 0.0644086714161698],
            [0.4355913285838302, 0.4355913285838302, 0.0644086714161698],
            [0.0644086714161698, 0.0644086714161698, 0.4355913285838302],
            [0.4355913285838302, 0.0644086714161698, 0.4355913285838302],
            [0.0644086714161698, 0.4355913285838302, 0.4355913285838302],
            [0.0214339301271306, 0.7174640634263083, 0.2396680763194305],
            [0.2041393338760291, 0.5837973783021444, 0.0079239539457974],
            [0.7174640634263083, 0.0214339301271306, 0.2396680763194305],
            [0.5837973783021444, 0.2041393338760291, 0.0079239539457974],
            [0.0214339301271306, 0.0214339301271306, 0.2396680763194305],
            [0.2041393338760291, 0.2041393338760291, 0.0079239539457974],
            [0.7174640634263083, 0.2396680763194305, 0.0214339301271306],
            [0.5837973783021444, 0.0079239539457974, 0.2041393338760291],
            [0.0214339301271306, 0.2396680763194305, 0.0214339301271306],
            [0.2041393338760291, 0.0079239539457974, 0.2041393338760291],
            [0.2396680763194305, 0.0214339301271306, 0.0214339301271306],
            [0.0079239539457974, 0.2041393338760291, 0.2041393338760291],
            [0.0214339301271306, 0.2396680763194305, 0.7174640634263083],
            [0.2041393338760291, 0.0079239539457974, 0.5837973783021444],
            [0.2396680763194305, 0.0214339301271306, 0.7174640634263083],
            [0.0079239539457974, 0.2041393338760291, 0.5837973783021444],
            [0.0214339301271306, 0.0214339301271306, 0.7174640634263083],
            [0.2041393338760291, 0.2041393338760291, 0.5837973783021444],
            [0.2396680763194305, 0.7174640634263083, 0.0214339301271306],
            [0.0079239539457974, 0.5837973783021444, 0.2041393338760291],
            [0.0214339301271306, 0.7174640634263083, 0.0214339301271306],
            [0.2041393338760291, 0.5837973783021444, 0.2041393338760291],
            [0.7174640634263083, 0.0214339301271306, 0.0214339301271306],
            [0.5837973783021444, 0.2041393338760291, 0.2041393338760291]])
        wts = np.array([
            0.0264266509084088, 0.0520317475637385, 0.0075252561535402,
            0.0417637828569349, 0.0264266509084088, 0.0520317475637385,
            0.0075252561535402, 0.0417637828569349, 0.0264266509084088,
            0.0520317475637385, 0.0075252561535402, 0.0417637828569349,
            0.0264266509084088, 0.0520317475637385, 0.0075252561535402,
            0.0417637828569349, 0.0362809302613088, 0.0362809302613088,
            0.0362809302613088, 0.0362809302613088, 0.0362809302613088,
            0.0362809302613088, 0.0071569028908444, 0.0154534861509603,
            0.0071569028908444, 0.0154534861509603, 0.0071569028908444,
            0.0154534861509603, 0.0071569028908444, 0.0154534861509603,
            0.0071569028908444, 0.0154534861509603, 0.0071569028908444,
            0.0154534861509603, 0.0071569028908444, 0.0154534861509603,
            0.0071569028908444, 0.0154534861509603, 0.0071569028908444,
            0.0154534861509603, 0.0071569028908444, 0.0154534861509603,
            0.0071569028908444, 0.0154534861509603, 0.0071569028908444,
            0.0154534861509603])
    elif order == 9:
        pts = np.array([
            [2.5000000000000000e-01, 2.5000000000000000e-01,
            2.5000000000000000e-01],
            [6.1981697552226933e-10, 6.1981697552226933e-10,
            9.9999999814054907e-01],
            [1.6077453539526160e-01, 1.6077453539526160e-01,
            5.1767639381421526e-01],
            [3.2227652182142102e-01, 3.2227652182142102e-01,
            3.3170434535736870e-02],
            [4.5108918345413578e-02, 4.5108918345413578e-02,
            8.6467324496375930e-01],
            [6.1981697552226933e-10, 9.9999999814054907e-01,
            6.1981697552226933e-10],
            [1.6077453539526160e-01, 5.1767639381421526e-01,
            1.6077453539526160e-01],
            [3.2227652182142102e-01, 3.3170434535736870e-02,
            3.2227652182142102e-01],
            [4.5108918345413578e-02, 8.6467324496375930e-01,
            4.5108918345413578e-02],
            [9.9999999814054907e-01, 6.1981697552226933e-10,
            6.1981697552226933e-10],
            [5.1767639381421526e-01, 1.6077453539526160e-01,
            1.6077453539526160e-01],
            [3.3170434535736870e-02, 3.2227652182142102e-01,
            3.2227652182142102e-01],
            [8.6467324496375930e-01, 4.5108918345413578e-02,
            4.5108918345413578e-02],
            [6.1981697552226933e-10, 6.1981697552226933e-10,
            6.1981697552226933e-10],
            [1.6077453539526160e-01, 1.6077453539526160e-01,
            1.6077453539526160e-01],
            [3.2227652182142102e-01, 3.2227652182142102e-01,
            3.2227652182142102e-01],
            [4.5108918345413578e-02, 4.5108918345413578e-02,
            4.5108918345413578e-02],
            [1.1229654600437609e-01, 3.8770345399562389e-01,
            3.8770345399562389e-01],
            [3.8770345399562389e-01, 1.1229654600437609e-01,
            3.8770345399562389e-01],
            [1.1229654600437609e-01, 1.1229654600437609e-01,
            3.8770345399562389e-01],
            [3.8770345399562389e-01, 3.8770345399562389e-01,
            1.1229654600437609e-01],
            [1.1229654600437609e-01, 3.8770345399562389e-01,
            1.1229654600437609e-01],
            [3.8770345399562389e-01, 1.1229654600437609e-01,
            1.1229654600437609e-01],
            [4.5887144875245922e-01, 2.5545792330413102e-03,
            7.9702523262040248e-02],
            [3.3775870685338598e-02, 7.1835032644207453e-01,
            2.1409793218724826e-01],
            [1.8364136980992790e-01, 3.4415910578175279e-02,
            5.9830134980196892e-01],
            [2.5545792330413102e-03, 4.5887144875245922e-01,
            7.9702523262040248e-02],
            [7.1835032644207453e-01, 3.3775870685338598e-02,
            2.1409793218724826e-01],
            [3.4415910578175279e-02, 1.8364136980992790e-01,
            5.9830134980196892e-01],
            [4.5887144875245922e-01, 4.5887144875245922e-01,
            7.9702523262040248e-02],
            [3.3775870685338598e-02, 3.3775870685338598e-02,
            2.1409793218724826e-01],
            [1.8364136980992790e-01, 1.8364136980992790e-01,
            5.9830134980196892e-01],
            [2.5545792330413102e-03, 7.9702523262040248e-02,
            4.5887144875245922e-01],
            [7.1835032644207453e-01, 2.1409793218724826e-01,
            3.3775870685338598e-02],
            [3.4415910578175279e-02, 5.9830134980196892e-01,
            1.8364136980992790e-01],
            [4.5887144875245922e-01, 7.9702523262040248e-02,
            4.5887144875245922e-01],
            [3.3775870685338598e-02, 2.1409793218724826e-01,
            3.3775870685338598e-02],
            [1.8364136980992790e-01, 5.9830134980196892e-01,
            1.8364136980992790e-01],
            [7.9702523262040248e-02, 4.5887144875245922e-01,
            4.5887144875245922e-01],
            [2.1409793218724826e-01, 3.3775870685338598e-02,
            3.3775870685338598e-02],
            [5.9830134980196892e-01, 1.8364136980992790e-01,
            1.8364136980992790e-01],
            [4.5887144875245922e-01, 7.9702523262040248e-02,
            2.5545792330413102e-03],
            [3.3775870685338598e-02, 2.1409793218724826e-01,
            7.1835032644207453e-01],
            [1.8364136980992790e-01, 5.9830134980196892e-01,
            3.4415910578175279e-02],
            [7.9702523262040248e-02, 4.5887144875245922e-01,
            2.5545792330413102e-03],
            [2.1409793218724826e-01, 3.3775870685338598e-02,
            7.1835032644207453e-01],
            [5.9830134980196892e-01, 1.8364136980992790e-01,
            3.4415910578175279e-02],
            [4.5887144875245922e-01, 4.5887144875245922e-01,
            2.5545792330413102e-03],
            [3.3775870685338598e-02, 3.3775870685338598e-02,
            7.1835032644207453e-01],
            [1.8364136980992790e-01, 1.8364136980992790e-01,
            3.4415910578175279e-02],
            [7.9702523262040248e-02, 2.5545792330413102e-03,
            4.5887144875245922e-01],
            [2.1409793218724826e-01, 7.1835032644207453e-01,
            3.3775870685338598e-02],
            [5.9830134980196892e-01, 3.4415910578175279e-02,
            1.8364136980992790e-01],
            [4.5887144875245922e-01, 2.5545792330413102e-03,
            4.5887144875245922e-01],
            [3.3775870685338598e-02, 7.1835032644207453e-01,
            3.3775870685338598e-02],
            [1.8364136980992790e-01, 3.4415910578175279e-02,
            1.8364136980992790e-01],
            [2.5545792330413102e-03, 4.5887144875245922e-01,
            4.5887144875245922e-01],
            [7.1835032644207453e-01, 3.3775870685338598e-02,
            3.3775870685338598e-02],
            [3.4415910578175279e-02, 1.8364136980992790e-01,
            1.8364136980992790e-01]])
        wts = np.array([
            5.801054891248025e-02, 6.431928175925639e-05,
            2.317333846242546e-02, 2.956291233542929e-02,
            8.063979979616182e-03, 6.431928175925639e-05,
            2.317333846242546e-02, 2.956291233542929e-02,
            8.063979979616182e-03, 6.431928175925639e-05,
            2.317333846242546e-02, 2.956291233542929e-02,
            8.063979979616182e-03, 6.431928175925639e-05,
            2.317333846242546e-02, 2.956291233542929e-02,
            8.063979979616182e-03, 3.813408010370246e-02,
            3.813408010370246e-02, 3.813408010370246e-02,
            3.813408010370246e-02, 3.813408010370246e-02,
            3.813408010370246e-02, 8.384422198298552e-03,
            1.023455935274533e-02, 2.052491596798814e-02,
            8.384422198298552e-03, 1.023455935274533e-02,
            2.052491596798814e-02, 8.384422198298552e-03,
            1.023455935274533e-02, 2.052491596798814e-02,
            8.384422198298552e-03, 1.023455935274533e-02,
            2.052491596798814e-02, 8.384422198298552e-03,
            1.023455935274533e-02, 2.052491596798814e-02,
            8.384422198298552e-03, 1.023455935274533e-02,
            2.052491596798814e-02, 8.384422198298552e-03,
            1.023455935274533e-02, 2.052491596798814e-02,
            8.384422198298552e-03, 1.023455935274533e-02,
            2.052491596798814e-02, 8.384422198298552e-03,
            1.023455935274533e-02, 2.052491596798814e-02,
            8.384422198298552e-03, 1.023455935274533e-02,
            2.052491596798814e-02, 8.384422198298552e-03,
            1.023455935274533e-02, 2.052491596798814e-02,
            8.384422198298552e-03, 1.023455935274533e-02,
            2.052491596798814e-02])
    elif order == 10:
        pts = np.array([
            [0.25              , 0.25              , 0.25              ],
            [0.3122500686951887, 0.3122500686951887, 0.063249793914434 ],
            [0.1143096538573461, 0.1143096538573461, 0.6570710384279617],
            [0.3122500686951887, 0.063249793914434 , 0.3122500686951887],
            [0.1143096538573461, 0.6570710384279617, 0.1143096538573461],
            [0.063249793914434 , 0.3122500686951887, 0.3122500686951887],
            [0.6570710384279617, 0.1143096538573461, 0.1143096538573461],
            [0.3122500686951887, 0.3122500686951887, 0.3122500686951887],
            [0.1143096538573461, 0.1143096538573461, 0.1143096538573461],
            [0.4104307392189654, 0.1654860256196111, 0.0136524959424581],
            [0.0061380088247907, 0.9429887673452049, 0.0447352150052138],
            [0.1210501811455894, 0.4771903799042804, 0.2807092578045408],
            [0.0327794682164426, 0.594256269480007 , 0.3401847940871078],
            [0.032485281564823 , 0.8011772846583444, 0.1338521522120095],
            [0.174979342183939 , 0.628071845475366 , 0.021969470156756 ],
            [0.1654860256196111, 0.4104307392189654, 0.0136524959424581],
            [0.9429887673452049, 0.0061380088247907, 0.0447352150052138],
            [0.4771903799042804, 0.1210501811455894, 0.2807092578045408],
            [0.594256269480007 , 0.0327794682164426, 0.3401847940871078],
            [0.8011772846583444, 0.032485281564823 , 0.1338521522120095],
            [0.628071845475366 , 0.174979342183939 , 0.021969470156756 ],
            [0.4104307392189654, 0.4104307392189654, 0.0136524959424581],
            [0.0061380088247907, 0.0061380088247907, 0.0447352150052138],
            [0.1210501811455894, 0.1210501811455894, 0.2807092578045408],
            [0.0327794682164426, 0.0327794682164426, 0.3401847940871078],
            [0.032485281564823 , 0.032485281564823 , 0.1338521522120095],
            [0.174979342183939 , 0.174979342183939 , 0.021969470156756 ],
            [0.1654860256196111, 0.0136524959424581, 0.4104307392189654],
            [0.9429887673452049, 0.0447352150052138, 0.0061380088247907],
            [0.4771903799042804, 0.2807092578045408, 0.1210501811455894],
            [0.594256269480007 , 0.3401847940871078, 0.0327794682164426],
            [0.8011772846583444, 0.1338521522120095, 0.032485281564823 ],
            [0.628071845475366 , 0.021969470156756 , 0.174979342183939 ],
            [0.4104307392189654, 0.0136524959424581, 0.4104307392189654],
            [0.0061380088247907, 0.0447352150052138, 0.0061380088247907],
            [0.1210501811455894, 0.2807092578045408, 0.1210501811455894],
            [0.0327794682164426, 0.3401847940871078, 0.0327794682164426],
            [0.032485281564823 , 0.1338521522120095, 0.032485281564823 ],
            [0.174979342183939 , 0.021969470156756 , 0.174979342183939 ],
            [0.0136524959424581, 0.4104307392189654, 0.4104307392189654],
            [0.0447352150052138, 0.0061380088247907, 0.0061380088247907],
            [0.2807092578045408, 0.1210501811455894, 0.1210501811455894],
            [0.3401847940871078, 0.0327794682164426, 0.0327794682164426],
            [0.1338521522120095, 0.032485281564823 , 0.032485281564823 ],
            [0.021969470156756 , 0.174979342183939 , 0.174979342183939 ],
            [0.4104307392189654, 0.0136524959424581, 0.1654860256196111],
            [0.0061380088247907, 0.0447352150052138, 0.9429887673452049],
            [0.1210501811455894, 0.2807092578045408, 0.4771903799042804],
            [0.0327794682164426, 0.3401847940871078, 0.594256269480007 ],
            [0.032485281564823 , 0.1338521522120095, 0.8011772846583444],
            [0.174979342183939 , 0.021969470156756 , 0.628071845475366 ],
            [0.0136524959424581, 0.4104307392189654, 0.1654860256196111],
            [0.0447352150052138, 0.0061380088247907, 0.9429887673452049],
            [0.2807092578045408, 0.1210501811455894, 0.4771903799042804],
            [0.3401847940871078, 0.0327794682164426, 0.594256269480007 ],
            [0.1338521522120095, 0.032485281564823 , 0.8011772846583444],
            [0.021969470156756 , 0.174979342183939 , 0.628071845475366 ],
            [0.4104307392189654, 0.4104307392189654, 0.1654860256196111],
            [0.0061380088247907, 0.0061380088247907, 0.9429887673452049],
            [0.1210501811455894, 0.1210501811455894, 0.4771903799042804],
            [0.0327794682164426, 0.0327794682164426, 0.594256269480007 ],
            [0.032485281564823 , 0.032485281564823 , 0.8011772846583444],
            [0.174979342183939 , 0.174979342183939 , 0.628071845475366 ],
            [0.0136524959424581, 0.1654860256196111, 0.4104307392189654],
            [0.0447352150052138, 0.9429887673452049, 0.0061380088247907],
            [0.2807092578045408, 0.4771903799042804, 0.1210501811455894],
            [0.3401847940871078, 0.594256269480007 , 0.0327794682164426],
            [0.1338521522120095, 0.8011772846583444, 0.032485281564823 ],
            [0.021969470156756 , 0.628071845475366 , 0.174979342183939 ],
            [0.4104307392189654, 0.1654860256196111, 0.4104307392189654],
            [0.0061380088247907, 0.9429887673452049, 0.0061380088247907],
            [0.1210501811455894, 0.4771903799042804, 0.1210501811455894],
            [0.0327794682164426, 0.594256269480007 , 0.0327794682164426],
            [0.032485281564823 , 0.8011772846583444, 0.032485281564823 ],
            [0.174979342183939 , 0.628071845475366 , 0.174979342183939 ],
            [0.1654860256196111, 0.4104307392189654, 0.4104307392189654],
            [0.9429887673452049, 0.0061380088247907, 0.0061380088247907],
            [0.4771903799042804, 0.1210501811455894, 0.1210501811455894],
            [0.594256269480007 , 0.0327794682164426, 0.0327794682164426],
            [0.8011772846583444, 0.032485281564823 , 0.032485281564823 ],
            [0.628071845475366 , 0.174979342183939 , 0.174979342183939 ]])
        wts = np.array([
            0.0473997735560207, 0.0269370599922687, 0.0098691597167934,
            0.0269370599922687, 0.0098691597167934, 0.0269370599922687,
            0.0098691597167934, 0.0269370599922687, 0.0098691597167934,
            0.0113938812201952, 0.0003619443443393, 0.0257397319804561,
            0.0101358716797558, 0.0065761472770359, 0.012907035798862 ,
            0.0113938812201952, 0.0003619443443393, 0.0257397319804561,
            0.0101358716797558, 0.0065761472770359, 0.012907035798862 ,
            0.0113938812201952, 0.0003619443443393, 0.0257397319804561,
            0.0101358716797558, 0.0065761472770359, 0.012907035798862 ,
            0.0113938812201952, 0.0003619443443393, 0.0257397319804561,
            0.0101358716797558, 0.0065761472770359, 0.012907035798862 ,
            0.0113938812201952, 0.0003619443443393, 0.0257397319804561,
            0.0101358716797558, 0.0065761472770359, 0.012907035798862 ,
            0.0113938812201952, 0.0003619443443393, 0.0257397319804561,
            0.0101358716797558, 0.0065761472770359, 0.012907035798862 ,
            0.0113938812201952, 0.0003619443443393, 0.0257397319804561,
            0.0101358716797558, 0.0065761472770359, 0.012907035798862 ,
            0.0113938812201952, 0.0003619443443393, 0.0257397319804561,
            0.0101358716797558, 0.0065761472770359, 0.012907035798862 ,
            0.0113938812201952, 0.0003619443443393, 0.0257397319804561,
            0.0101358716797558, 0.0065761472770359, 0.012907035798862 ,
            0.0113938812201952, 0.0003619443443393, 0.0257397319804561,
            0.0101358716797558, 0.0065761472770359, 0.012907035798862 ,
            0.0113938812201952, 0.0003619443443393, 0.0257397319804561,
            0.0101358716797558, 0.0065761472770359, 0.012907035798862 ,
            0.0113938812201952, 0.0003619443443393, 0.0257397319804561,
            0.0101358716797558, 0.0065761472770359, 0.012907035798862 ])
    else:
        msg = "The order should be in [1, 10]"
        raise ValueError(msg)
    return pts, wts
