MomentGauge.Sampler.SamplerUtility#

Module Contents#

Functions#

Gauss_Legendre_Quadrature(a, b, n)

Generate the Legender Quadrature points and corresponding weights for 1D integral

Gauss_Legendre_Quadrature_2D(a_x, b_x, n_x, a_y, b_y, n_y)

Generate the Legender Quadrature points and corresponding weights for 2D integral

Gauss_Legendre_Quadrature_2D_Block(a_x, b_x, n_x, B_x, ...)

Block-wise the Legender Quadrature points and corresponding weights for 2D integral.

MomentGauge.Sampler.SamplerUtility.Gauss_Legendre_Quadrature(a, b, n)#

Generate the Legender Quadrature points and corresponding weights for 1D integral

\begin{equation} \int_{a}^b \phi(x) d x \approx \sum_{i=i}^n w_i \phi(x_i), \end{equation}
Parameters:
  • a (float) – lower integration limit

  • b (float) – upper integration limit, float

  • n (int) – the order of Gauss Legendre quadrature

Returns:

A tuple containing

x: array of shape (n) - the quadrature points \(x_i\)

w: array of shape (n) - the quadrature weights \(w_i\)

Return type:

Tuple

MomentGauge.Sampler.SamplerUtility.Gauss_Legendre_Quadrature_2D(a_x, b_x, n_x, a_y, b_y, n_y)#

Generate the Legender Quadrature points and corresponding weights for 2D integral

\begin{equation} \int_{a_y}^{b_y} \int_{a_x}^{b_x} \phi(x,y) d x dy \approx \sum_{i=1,j=1}^{n_x,n_y} w_{ij} \phi( \mathbf{x}_{ij}), \end{equation}
Parameters:
  • a_x (float) – lower integration limit in x dimension

  • b_x (float) – upper integration limit in x dimension

  • n_x (int) – the order of Gauss Legendre quadrature in x dimension

  • a_y (float) – lower integration limit in y dimension

  • b_y (float) – upper integration limit in y dimension

  • n_y (int) – the order of Gauss Legendre quadrature in y dimension

Returns:

A tuple containing

x: array of shape (n_x, n_y, 2) - the quadrature points, x[i,j,:] is the 2D i-jth quadrature points \(\mathbf{x}_{ij}\)

w: array of shape (n_x, n_y) - the quadrature weights w[i,j] is the quadrature weight \(w_{ij}\)

Return type:

Tuple

MomentGauge.Sampler.SamplerUtility.Gauss_Legendre_Quadrature_2D_Block(a_x, b_x, n_x, B_x, a_y, b_y, n_y, B_y)#

Block-wise the Legender Quadrature points and corresponding weights for 2D integral.

The integration domain is a square \((a_x, b_x)\times(a_y, b_y)\) that is splitted into (b_x*b_y) blocks, in which each block are integrated with 2D Gauss Legendre quadratures as in Sampler.SamplerUtility.Gauss_Legendre_Quadrature_2D().

Specifically, the interval \((a_x, b_x)\) is divided into \(B_x\) piecies: \(\{(a_{x,l_x},a_{x,l_x+1})\ |\ l_x = 1,\cdots,B_x; a_{x,1} = a_x, a_{x,B_x+1} = b_x\}\).

The interval \((b_x, b_y)\) is divided into \(B_y\) piecies: \(\{(a_{y,l_y},a_{y,l_y+1})\ |\ l_y = 1,\cdots,B_y; a_{y,1} = a_y, a_{y,B_y+1} = b_y\}\).

\begin{equation} \begin{split} \int_{a_y}^{b_y} \int_{a_x}^{b_x} \phi(x,y) d x dy &= \sum_{l_x=1,l_y=1}^{B_x,B_y} \int_{a_{y,l_y}}^{a_{y,l_y+1}} \int_{a_{x,l_x}}^{a_{x,l_x+1}} \phi(x,y) d x dy \\ & \approx \sum_{l_x=1,l_y=1,i=1,j=1}^{B_x,B_y,n_x,n_y} w_{l_xl_yij} \phi( \mathbf{x}_{l_xl_yij}), \end{split} \end{equation}
Parameters:
  • a_x (float) – lower integration limit in x dimension

  • b_x (float) – upper integration limit in x dimension

  • n_x (int) – the order of Gauss Legendre quadrature in x dimension

  • B_x (int) – how many blocks are splitted in the x dimension

  • a_y (float) – lower integration limit in y dimension

  • b_y (float) – upper integration limit in y dimension

  • n_y (int) – the order of Gauss Legendre quadrature in y dimension

  • B_y (int) – how many blocks are splitted in the y dimension

Returns:

A tuple containing

x: array of shape (B_x,B_y,n_x, n_y, 2) - the quadrature points, x[l_x,l_y,i,j,:] is the i-jth 2D quadrature points \(\mathbf{x}_{l_xl_yij}\) in the l_x-l_yth block

w: array of shape (B_x,B_y,n_x, n_y) - the quadrature weights w[l_x,l_y,i,j] is the i-jth quadrature weight \(w_{l_xl_yij}\) in the l_x-l_yth block

Return type:

Tuple