From f79ceb91ffe9b6ca96c412bee09330ee150796e0 Mon Sep 17 00:00:00 2001 From: Balavarun5 Date: Mon, 18 Sep 2017 14:24:41 +0530 Subject: [PATCH] Edited the documentation. Examples need to be added. --- README.md | 13 +- code/app/lagrange.py | 261 +++++++++++++++++++++------------ code/app/params.py | 55 +++---- code/app/wave_equation.py | 101 +++++++------ code/main.py | 4 +- code/unit_test/test_waveEqn.py | 47 +----- 6 files changed, 267 insertions(+), 214 deletions(-) diff --git a/README.md b/README.md index a8d8527..d67649f 100644 --- a/README.md +++ b/README.md @@ -13,13 +13,23 @@ cd DG_Maxwell * Arrayfire * Numpy * Matplotlib +* tqdm +* pytest ## Usage: ``` cd DG_Maxwell/code python3 main.py ``` +* The parameters of the simulation are stored in global_variables.py in + the app folder, These can be changed accordingly. + +* The images of the wave are stored in the folder 1D_wave_images folder. +* To stitch the images in the folder and obtain a video of the simulation, + use the command in the terminal - + `ffmpeg -f image2 -i %04d.png -vcodec mpeg4 -mbd rd -trellis 2 -cmp 2 -g 300 -pass 1 -r 25 -b 18000000 movie.mp4` + ## Authors * **Balavarun P** - [GitHub Profile](https://github.com/Balavarun5) @@ -27,4 +37,5 @@ python3 main.py * **Mani Chandra** - [GitHub Profile](https://github.com/mchandra) ## Note for developers: -* Use spaces for indentation. +* Use tab spaces for indentation. + diff --git a/code/app/lagrange.py b/code/app/lagrange.py index 9b24c53..454c87c 100644 --- a/code/app/lagrange.py +++ b/code/app/lagrange.py @@ -23,7 +23,7 @@ def LGL_points(N): Returns ------- lgl : arrayfire.Array [N 1 1 1] - An array consisting of the Lagrange-Gauss-Lobatto Nodes. + The Lagrange-Gauss-Lobatto Nodes. Reference --------- @@ -53,14 +53,14 @@ def lobatto_weights(n, x): Index for which lobatto weight function x : arrayfire.Array [N 1 1 1] - 1D array of points where weight function is to be calculated. + Points where weight function is to be calculated. Returns ------- - gauss_lobatto_weights : arrayfire.Array - An array of lobatto weight functions for - the given :math: `x` points and index. + gauss_lobatto_weights : numpy.ndarray [N 1 1 1] + Lobatto weight for the given :math: `x` + points and index `i`. Reference --------- Gauss-Lobatto weights Wikipedia link- @@ -72,10 +72,32 @@ def lobatto_weights(n, x): return gauss_lobatto_weights -def gauss_nodes(N): +def gauss_nodes(n): ''' + Calculates :math: `N` Gaussian nodes used for Integration by + Gaussia quadrature. + + Gaussian node :math: `x_i` is the `i^{th}` root of + + :math: `P_n(\\xi)` + Where :math: `P_{n}(\\xi)` are the Legendre polynomials. + + Parameters + ---------- + n : int + The number of Gaussian nodes required. + + Returns + ------- + gauss_nodes : numpy.ndarray + The Gauss nodes :math: `x_i`. + + Reference + --------- + A Wikipedia article about the Gauss-Legendre quadrature + `https://goo.gl/9gqLpe` ''' - legendre = sp.legendre(N) + legendre = sp.legendre(n) gauss_nodes = legendre.r gauss_nodes.sort() @@ -84,16 +106,22 @@ def gauss_nodes(N): def gaussian_weights(N, i): ''' - Returns the gaussian weights for :math: `N` Gaussian Nodes at index - :math: `i`. + Returns the gaussian weights :math:`w_i` for :math: `N` Gaussian Nodes + at index :math: `i`. They are given by + + :math: `w_i = \\frac{2}{(1 - x_i^2) P'n(x_i)}` + + Where :math:`x_i` are the Gaussian nodes and :math: `P_{n}(\\xi)` + are the Legendre polynomials. + Parameters ---------- - N : int - Number of Gaussian nodes for which the weight is t be calculated. + N : int + Number of Gaussian nodes for which the weight is t be calculated. - i : int - Index for which the Gaussian weight is required. + i : int + Index for which the Gaussian weight is required. Returns ------- @@ -103,15 +131,16 @@ def gaussian_weights(N, i): ''' gaussian_nodes = gauss_nodes(N) - gaussian_weight = 2 / ((1 - (gaussian_nodes[i]) ** 2) * (np.polyder(sp.legendre(N))(gaussian_nodes[i])) ** 2) + gaussian_weight = 2 / ((1 - (gaussian_nodes[i]) ** 2) *\ + (np.polyder(sp.legendre(N))(gaussian_nodes[i])) ** 2) return gaussian_weight def lagrange_polynomials(x): ''' - A function to get the coefficients of the Lagrange basis polynomials for - a given set of x nodes. + A function to get the analytical form and thr coefficients of + Lagrange basis polynomials evaluated using x nodes. It calculates the Lagrange basis polynomials using the formula: :math:: @@ -119,17 +148,19 @@ def lagrange_polynomials(x): Parameters ---------- - x : numpy.array - An array consisting of the :math: `x` nodes using which the + x : numpy.array [N_LGL 1 1 1] + Contains the :math: `x` nodes using which the lagrange basis functions need to be evaluated. Returns ------- lagrange_basis_poly : list - A list of size `x.shape[0]` containing the analytical - form of the Lagrange basis polynomials in numpy.poly1d - form. This list is used in Integrate() function which - requires the analytical form of the integrand. + A list of size `x.shape[0]` containing the + analytical form of the Lagrange basis polynomials + in numpy.poly1d form. This list is used in + Integrate() function which requires the analytical + form of the integrand. + lagrange_basis_coeffs : numpy.ndarray A :math: `N \\times N` matrix containing the coefficients of the Lagrange basis polynomials such @@ -152,47 +183,38 @@ def lagrange_polynomials(x): return lagrange_basis_poly, lagrange_basis_coeffs -def lagrange_basis(i, x): + +def lagrange_function_value(lagrange_coeff_array): ''' - Calculates the value of the :math: `i^{th}` Lagrange basis (calculated - using the :math:`\\xi_{LGL}` points) at the :math: `x` coordinates. - + Funtion to calculate the value of lagrange basis functions over LGL + nodes. + Parameters ---------- - - i : int - The Lagrange basis which is to be calculated. - - x : arrayfire.Array - The coordinates at which the `i^{th}` Lagrange polynomial is to be - calculated. + lagrange_coeff_array : arrayfire.Array[N_LGL N_LGL 1 1] + Contains the coefficients of the + Lagrange basis polynomials Returns ------- + L_i : arrayfire.Array [N 1 1 1] + The value of lagrange basis functions calculated over the LGL + nodes. + + Examples + -------- + lagrange_function_value(4) gives the value of the four + Lagrange basis functions evaluated over 4 LGL points + arranged in a 2D array where Lagrange polynomials + evaluated at the same LGL point are in the same column. - l_xi_j : arrayfire.Array - Array of values of the :math: `i^{th}` Lagrange basis - calculated at the given :math: `x` coordinates. - ''' - x_tile = af.transpose(af.tile(x, 1, params.N_LGL)) - power = utils.linspace((params.N_LGL-1), 0, params.N_LGL) - power_tile = af.tile(power, 1, x.shape[0]) - x_pow = af.arith.pow(x_tile, power_tile) - l_xi_j = af.blas.matmul(params.lBasisArray[i], x_pow) + Also the value lagrange basis functions at LGL points has the property, - return l_xi_j - - -def lagrange_basis_function(lagrange_coeff_array): - ''' - Funtion to calculate the value of lagrange basis functions over LGL - nodes. + L_i(xi_k) = 0 for i != k + = 1 for i = k + + It follows then that lagrange_function_value returns an identity matrix. - Returns - ------- - L_i : arrayfire.Array [N 1 1 1] - The value of lagrange basis functions calculated over the LGL - nodes. ''' xi_tile = af.transpose(af.tile(params.xi_LGL, 1, params.N_LGL)) power = af.flip(af.range(params.N_LGL)) @@ -203,36 +225,22 @@ def lagrange_basis_function(lagrange_coeff_array): return L_i - -def dLp_xi_LGL(lagrange_coeff_array): - ''' - Function to calculate :math: `\\frac{d L_p(\\xi_{LGL})}{d\\xi}` - as a 2D array of :math: `L_i' (\\xi_{LGL})`. Where i varies along rows - and the nodes vary along the columns. - - Returns - ------- - dLp_xi : arrayfire.Array [N N 1 1] - A 2D array :math: `L_i (\\xi_p)`, where i varies - along dimension 1 and p varies along second dimension. - ''' - differentiation_coeffs = (af.transpose(af.flip(af.tile\ - (af.range(params.N_LGL), 1, params.N_LGL))) - * lagrange_coeff_array)[:, :-1] - - nodes_tile = af.transpose(af.tile(params.xi_LGL, 1, params.N_LGL - 1)) - power_tile = af.flip(af.tile(af.range(params.N_LGL - 1), 1, params.N_LGL)) - nodes_power_tile = af.pow(nodes_tile, power_tile) - - dLp_xi = af.blas.matmul(differentiation_coeffs, nodes_power_tile) - - return dLp_xi - def product_lagrange_poly(x): ''' Calculates the product of Lagrange basis polynomials in 'np.poly1d' in a 2D array. This analytical form of the product of the Lagrange basis is used in the calculation of A matrix using the Integrate() function. + + Parameters + ---------- + x : arrayfire.Array[N_LGL 1 1 1] + Contains N_LGL Gauss-Lobatto nodes. + + Returns + ------- + poly1d_product_list : list [N_LGL ** 2] + Contains the poly1d form of the product of the Lagrange + basis polynomials. ''' poly1d_list = lagrange_polynomials(x)[0] @@ -249,8 +257,8 @@ def product_lagrange_poly(x): def Integrate(integrand, N_quad, scheme): ''' - Integrates an analytical form of the integrand and integrates it using either - gaussian or lobatto quadrature. + Integrates an analytical form of the integrand and integrates it using + either gaussian or lobatto quadrature. Parameters ---------- @@ -258,8 +266,9 @@ def Integrate(integrand, N_quad, scheme): The analytical form of the integrand in numpy.poly1d form N_quad : int - The number of quadrature points to be used for Integration using - either Gaussian or Lobatto quadrature. + The number of quadrature points to be used for Integration + using either Gaussian or Lobatto quadrature. + scheme : string Specifies the method of integration to be used. Can take values 'gauss_quadrature' and 'lobatto_quadrature'. @@ -267,8 +276,8 @@ def Integrate(integrand, N_quad, scheme): Returns ------- Integral : numpy.float64 - The value o the definite integration performed using the specified - quadrature method. + The value of the definite integration performed using the + specified quadrature method. ''' if (scheme == 'gauss_quadrature'): gaussian_nodes = gauss_nodes(N_quad) @@ -289,17 +298,87 @@ def Integrate(integrand, N_quad, scheme): return Integral -def wave_equation_lagrange_basis(u, element_no): +def wave_equation_lagrange_basis_single_element(u, element_no): ''' - Calculates the wave equation for a single element using the amplitude of the wave at - the mapped LGL points. - [TODO] - Explain math. + Calculates the function which describes the amplitude of the wave in + a particular element. + + Using the value of the amplitude at the LGL points, A function which + describes this behaviour is obtained by expressing it as a linear + combination of the Lagrange basis polynomials. + + :math: ` f(x) = '\\sigma_i a_i L_i(\\xi)` + + Where the coefficients a_i are the value of the function at the + LGL points. + + Parameters + ---------- + u : arrayfire.Array [N_LGL N_Elements 1 1] + The amplitude of the wave at the LGL points for a + single element. + + element_no : int + The element for which the analytical form of the wave equation + is required. + + Returns + ------- + wave_equation_element : numpy.poly1d + The analytical form of the function which describes + the amplitude locally. ''' - amplitude_at_element_LGL = u[:, element_no] + amplitude_at_element_LGL = u[:, element_no] lagrange_basis_polynomials = params.lagrange_poly1d_list wave_equation_element = np.poly1d([0]) + for i in range(0, params.N_LGL): - wave_equation_element += af.sum(amplitude_at_element_LGL[i]) * lagrange_basis_polynomials[i] + wave_equation_element += af.sum(amplitude_at_element_LGL[i])\ + * lagrange_basis_polynomials[i] return wave_equation_element + +def wave_equation_lagrange(u): + ''' + Calculates the local wave equation in the Lagrange basis space + for all elements using wave_equation_lagrange_basis_single_element function. + + Parameters + ---------- + u : arrayfire.Array [N_LGL N_Elements 1 1] + Contains the amplitude of the wave at the LGL points for all elements. + + Returns + ------- + wave_equation_lagrange_basis : list [N_Elements] + Contains the local approximation of the wave + function in the form of a list + ''' + wave_equation_lagrange_basis = [] + + for i in range(0, params.N_Elements): + element_wave_equation = wave_equation_lagrange_basis_single_element(u, i) + + wave_equation_lagrange_basis.append(element_wave_equation) + + return wave_equation_lagrange_basis + +def differential_lagrange_poly1d(): + ''' + Calculates the differential of the analytical form of the Lagrange basis + polynomials. + + Returns + ------- + diff_lagrange_poly1d : list [N_LGL] + Contains the differential of the Lagrange basis + polynomials in numpy.poly1d form. + ''' + diff_lagrange_poly1d = [] + + for i in range (0, params.N_LGL): + test_diff = np.poly1d.deriv(params.lagrange_poly1d_list[i]) + diff_lagrange_poly1d.append(test_diff) + + return diff_lagrange_poly1d diff --git a/code/app/params.py b/code/app/params.py index 39031c1..c434fed 100644 --- a/code/app/params.py +++ b/code/app/params.py @@ -37,12 +37,37 @@ # Array of the lobatto weights used during integration. lobatto_weights = af.np_to_af_array(lagrange.lobatto_weights(N_LGL, xi_LGL)) + +# The number of Gaussian nodes for Gauss quadrature +N_Gauss = 10 + +# N_Gauss number of Gauss nodes. +gauss_points = lagrange.gauss_nodes(N_Gauss) + +# The Gaussian weights. +gauss_weights = af.np_to_af_array(np.zeros([N_Gauss])) + +for i in range(0, N_Gauss): + gauss_weights[i] = lagrange.gaussian_weights(N_Gauss, i) + + +# A list of the Lagrange polynomials in poly1d form. +lagrange_poly1d_list = lagrange.lagrange_polynomials(xi_LGL)[0] + +# List of the product of the Lagrange basis polynomials. Used in +# the calculation of A matrix. +poly1d_product_list = lagrange.product_lagrange_poly(xi_LGL) + +# list containing the poly1d forms of the differential of Lagrange +# basis polynomials. +differential_lagrange_polynomial = lagrange.differential_lagrange_poly1d() + + # An array containing the coefficients of the lagrange basis polynomials. lagrange_coeffs = af.np_to_af_array(lagrange.lagrange_polynomials(xi_LGL)[1]) # Refer corresponding functions. -dLp_xi = lagrange.dLp_xi_LGL(lagrange_coeffs) -lagrange_basis_value = lagrange.lagrange_basis_function(lagrange_coeffs) +lagrange_basis_value = lagrange.lagrange_function_value(lagrange_coeffs) # Obtaining an array consisting of the LGL points mapped onto the elements. @@ -58,7 +83,8 @@ af.sum(x_nodes[1]), N_Elements + 1) element_array = af.transpose(af.interop.np_to_af_array(np_element_array)) -element_LGL = wave_equation.mapping_xi_to_x(af.transpose(element_array), xi_LGL) +element_LGL = wave_equation.mapping_xi_to_x(af.transpose(element_array),\ + xi_LGL) # The minimum distance between 2 mapped LGL points. @@ -76,26 +102,3 @@ u = af.constant(0, N_LGL, N_Elements, time.shape[0],\ dtype = af.Dtype.f64) u[:, :, 0] = u_init - - - - - -lagrange_poly1d_list = lagrange.lagrange_polynomials(xi_LGL)[0] - -poly1d_product_list = lagrange.product_lagrange_poly(xi_LGL) - - - -N_Gauss = 10 - -gauss_points = lagrange.gauss_nodes(N_Gauss) -gauss_weights = af.np_to_af_array(np.zeros([N_Gauss])) - -for i in range(0, N_Gauss): - gauss_weights[i] = lagrange.gaussian_weights(N_Gauss, i) - -differential_lagrange_polynomial = [] -for i in range (0, N_LGL): - test_diff = np.poly1d.deriv(lagrange_poly1d_list[i]) - differential_lagrange_polynomial.append(test_diff) diff --git a/code/app/wave_equation.py b/code/app/wave_equation.py index d26616d..fc02e4c 100644 --- a/code/app/wave_equation.py +++ b/code/app/wave_equation.py @@ -75,21 +75,21 @@ def mapping_xi_to_x(x_nodes, xi): def dx_dxi_numerical(x_nodes, xi): ''' - Differential :math: `\\frac{dx}{d \\xi}` calculated by central differential - method about xi using the mapping_xi_to_x function. + Differential :math: `\\frac{dx}{d \\xi}` calculated by central + differential method about xi using the mapping_xi_to_x function. Parameters ---------- - x_nodes : arrayfire.Array - Contains the nodes of elements + x_nodes : arrayfire.Array [N_Elements 1 1 1] + Contains the nodes of elements. xi : float Value of :math: `\\xi` Returns ------- - dx_dxi : arrayfire.Array + dx_dxi : arrayfire.Array [N_Elements 1 1 1] :math:`\\frac{dx}{d \\xi}`. ''' dxi = 1e-7 @@ -107,12 +107,12 @@ def dx_dxi_analytical(x_nodes, xi): :math: `\\frac{x_1 - x_0}{2}` Parameters ---------- - x_nodes : arrayfire.Array - An array containing the nodes of an element. - + x_nodes : arrayfire.Array [N_Elements 1 1 1] + Contains the nodes of elements. + Returns ------- - analytical_dx_dxi : arrayfire.Array + analytical_dx_dxi : arrayfire.Array [N_Elements 1 1 1] The analytical solution of :math: `\\frac{dx}{d\\xi}` for an element. @@ -134,10 +134,9 @@ def A_matrix(): `https://goo.gl/Cw6tnw` Returns ------- - A_matrix : arrayfire.Array + A_matrix : arrayfire.Array [N_LGL N_LGL 1 1] The value of integral of product of lagrange basis functions - obtained by LGL points, using Gauss-Lobatto quadrature method - using :math: `N_LGL` points. + obtained by LGL points, using the Integrate() function ''' A_matrix = np.zeros([params.N_LGL, params.N_LGL]) @@ -145,7 +144,7 @@ def A_matrix(): for j in range(params.N_LGL): A_matrix[i][j] = lagrange.Integrate(\ params.poly1d_product_list[params.N_LGL * i + j],\ - 9, 'lobatto_quadrature') + params.N_LGL + 1, 'lobatto_quadrature') dx_dxi = af.mean(dx_dxi_numerical((params.element_mesh_nodes[0 : 2]),\ params.xi_LGL)) @@ -166,58 +165,48 @@ def flux_x(u): Parameters ---------- - u : arrayfire.Array - A 1-D array which contains the value of wave function. - + u : list [N_Elements] + The analytical form of the wave equation for each element arranged in + a list of numpy.poly1d polynomials. Returns ------- - flux : arrayfire.Array - The value of the flux for given u. + flux : list [N_Elements] + The analytical value of the flux for each element arranged in a list + of numpy.poly1d polynomials. ''' flux = params.c * u return flux -def wave_equation_lagrange_polynomials(u): - ''' - ''' - wave_equation_in_lagrange_basis = [] - - for i in range(0, params.N_Elements): - element_wave_equation = lagrange.wave_equation_lagrange_basis(u, i) - wave_equation_in_lagrange_basis.append(element_wave_equation) - - return wave_equation_in_lagrange_basis - - def volume_integral_flux(u_n): ''' Calculates the volume integral of flux in the wave equation. :math:`\\int_{-1}^1 f(u) \\frac{d L_p}{d\\xi} d\\xi` This will give N values of flux integral as p varies from 0 to N - 1. - This integral is carried out over an element with LGL nodes mapped onto it. + This integral is carried out using the analytical form of the integrand + This integrand is the used in the Integrate() function. Parameters ---------- u : arrayfire.Array [N_LGL N_Elements 1 1] - A 2D array containing the value of the wave function at - the mapped LGL nodes in all the elements. - + Amplitude of the wave at the mapped LGL nodes of each element. + Returns ------- flux_integral : arrayfire.Array [N_LGL N_Elements 1 1] - A 1-D array of the value of the flux integral calculated - for various lagrange basis functions. + Value of the volume integral flux. It contains the integral + of all N_LGL * N_Element integrands. ''' - wave_equation_in_lagrange_polynomials = wave_equation_lagrange_polynomials(u_n) + analytical_form_flux = flux_x(lagrange.wave_equation_lagrange(u_n)) differential_lagrange_poly = params.differential_lagrange_polynomial - flux_integral = np.zeros([params.N_LGL, params.N_Elements]) + flux_integral = np.zeros([params.N_LGL, params.N_Elements]) for i in range(params.N_LGL): for j in range(params.N_Elements): - integrand = wave_equation_in_lagrange_polynomials[j] * differential_lagrange_poly[i] - flux_integral[i][j] = lagrange.Integrate(integrand, 9, 'gauss_quadrature') + integrand = analytical_form_flux[j] * differential_lagrange_poly[i] + flux_integral[i][j] = lagrange.Integrate(integrand, params.N_LGL,\ + 'gauss_quadrature') flux_integral = af.np_to_af_array(flux_integral) @@ -229,13 +218,17 @@ def lax_friedrichs_flux(u_n): A function which calculates the lax-friedrichs_flux :math:`f_i` using. :math:`f_i = \\frac{F(u^{i + 1}_0) + F(u^i_{N_{LGL} - 1})}{2} - \frac {\Delta x}{2\Delta t} (u^{i + 1}_0 - u^i_{N_{LGL} - 1})` - + + The algorithm used is explained in the link given below + `https://goo.gl/sNsXXK` + Parameters ---------- u_n : arrayfire.Array [N_LGL N_Elements 1 1] - A 2D array consisting of the amplitude of the wave at the LGL nodes - at each element. + Amplitude of the wave at the mapped LGL nodes of each element. + ''' + u_iplus1_0 = af.shift(u_n[0, :], 0, -1) u_i_N_LGL = u_n[-1, :] @@ -259,15 +252,14 @@ def surface_term(u_n): Parameters ---------- u_n : arrayfire.Array [N_LGL N_Elements 1 1] - A 2D array consisting of the amplitude of the wave at the LGL nodes - at each element. - + Amplitude of the wave at the mapped LGL nodes of each element. + Returns ------- surface_term : arrayfire.Array [N_LGL N_Elements 1 1] The surface term represented in the form of an array, - :math:`L_p (1) f_i - L_p (-1) f_{i - 1}`, where p varies from - zero to :math:`N_{LGL}` and i from zero to + :math:`L_p (1) f_i - L_p (-1) f_{i - 1}`, where p varies + from zero to :math:`N_{LGL}` and i from zero to :math:`N_{Elements}`. p varies along the rows and i along columns. @@ -295,11 +287,18 @@ def b_vector(u_n): Parameters ---------- u_n : arrayfire.Array [N_LGL N_Elements 1 1] - A 2D array consisting of the amplitude of the wave at the - LGL nodes at each element. + Amplitude of the wave at the mapped LGL nodes of each element. + Returns ------- - b_vector_array : arrayfire.Array + b_vector_array : arrayfire.Array [N_LGL N_Elements 1 1] + Contains the b vector(of shape [N_LGL 1 1 1]) + for each element. + + Reference + --------- + A report for the b-vector can be found here + `https://goo.gl/sNsXXK` ''' volume_integral = volume_integral_flux(u_n) diff --git a/code/main.py b/code/main.py index 68d0905..889ef44 100644 --- a/code/main.py +++ b/code/main.py @@ -11,4 +11,6 @@ if __name__ == '__main__': - wave_equation.time_evolution() + #print(lagrange.product_lagrange_poly(params.xi_LGL)) + wave_equation.time_evolution() + print(params.lagrange_basis_value) diff --git a/code/unit_test/test_waveEqn.py b/code/unit_test/test_waveEqn.py index 9b58c4f..e3962b7 100644 --- a/code/unit_test/test_waveEqn.py +++ b/code/unit_test/test_waveEqn.py @@ -1,4 +1,5 @@ #! /usr/bin/env python3 + import math import numpy as np @@ -11,7 +12,7 @@ from app import wave_equation from utils import utils -# This test uses the initial paramters N_LGL = 8, N_Elements = 10 +# This test uses the initial paramters N_LGL = 8, N_Elements = 10 and c = 1. def test_mapping_xi_to_x(): ''' @@ -147,48 +148,6 @@ def test_lagrange_coeffs(): assert af.sum(af.abs(basis_array_analytical - params.lagrange_coeffs)) < threshold - -def test_dLp_xi(): - ''' - Test function to check the dLp_xi calculated in params module with a - numerically obtained one. - - Refrence - -------- - The link to the sage worksheet where the calculations were carried out. - `https://goo.gl/Xxp3PT` - ''' - threshold = 4e-11 - - reference_d_Lp_xi = af.np_to_af_array(np.array([\ - [-14.0000000000226,-3.20991570302344,0.792476681323880,-0.372150435728984,\ - 0.243330712724289,-0.203284568901545,0.219957514771985, -0.500000000000000], - - [18.9375986071129, 3.31499272476776e-11, -2.80647579473469,1.07894468878725\ - ,-0.661157350899271,0.537039586158262, -0.573565414940005,1.29768738831567], - - [-7.56928981931106, 4.54358506455201, -6.49524878326702e-12, \ - -2.37818723350641, 1.13535801687865, -0.845022556506714, 0.869448098330221,\ - -1.94165942553537], - - [4.29790816425547,-2.11206121431525,2.87551740597844,-1.18896004153157e-11,\ - -2.38892435916370, 1.37278583181113, -1.29423205091574, 2.81018898925442], - - [-2.81018898925442, 1.29423205091574, -1.37278583181113, 2.38892435916370, \ - 1.18892673484083e-11,-2.87551740597844, 2.11206121431525,-4.29790816425547], - - [1.94165942553537, -0.869448098330221, 0.845022556506714,-1.13535801687865,\ - 2.37818723350641, 6.49524878326702e-12,-4.54358506455201,7.56928981931106],\ - - [-1.29768738831567, 0.573565414940005,-0.537039586158262,0.661157350899271,\ - -1.07894468878725,2.80647579473469,-3.31498162253752e-11,-18.9375986071129], - - [0.500000000000000,-0.219957514771985,0.203284568901545,-0.243330712724289,\ - 0.372150435728984, -0.792476681323880, 3.20991570302344, 14.0000000000226] - ])) - - assert af.max(reference_d_Lp_xi - params.dLp_xi) < threshold - def test_A_matrix(): ''' Test function to check the A matrix obtained from wave_equation module with @@ -247,7 +206,7 @@ def test_volume_integral_flux(): given below. `https://goo.gl/5Mub8M` ''' - threshold = 4e-8 + threshold = 8e-9 params.c = 1 referenceFluxIntegral = af.transpose(af.interop.np_to_af_array(np.array([