wave_equation¶
-
dg_maxwell.wave_equation.A_matrix()[source]¶ Calculates A matrix whose elements \(A_{p i}\) are given by \(A_{pi} = \int^1_{-1} L_p(\xi)L_i(\xi) \frac{dx}{d\xi}\)
The integrals are computed using the integrate() function. Since elements are taken to be of equal size, \(\frac {dx}{d\xi}\) is same everywhere
Returns: 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 the integrate() function
-
dg_maxwell.wave_equation.RK4_timestepping(A_inverse, u, delta_t)[source]¶ Implementing the Runge-Kutta (RK4) method to evolve the wave.
Parameters: A_inverse : arrayfire.Array[N_LGL N_LGL M 1]
The inverse of the A matrix for \(M\) differential equations.
u : arrayfire.Array[N_LGL N_Elements M 1]
u at the mapped LGL points
delta_t : float64
The time-step by which u is to be evolved.
Returns: delta_u : arrayfire.Array [N_LGL N_Elements 1 1]
The change in u at the mapped LGL points.
-
dg_maxwell.wave_equation.b_vector(u_n)[source]¶ Calculates the b vector for N_Elements number of elements.
Parameters: u_n : arrayfire.Array [N_LGL N_Elements 1 1]
Amplitude of the wave at the mapped LGL nodes of each element.
Returns: 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.
See: Report for the b-vector can be found here
-
dg_maxwell.wave_equation.dx_dxi_analytical(x_nodes, xi)[source]¶ The analytical result for \(\frac{dx}{d \xi}\) for a 1D element is \(\frac{x_1 - x_0}{2}\)
Parameters: x_nodes : arrayfire.Array [2 N_Elements 1 1]
Contains the nodes of elements.
xi : arrayfire.Array [N_LGL 1 1 1]
Values of \(\xi\).
Returns: analytical_dx_dxi : arrayfire.Array [N_Elements 1 1 1]
The analytical solution of \(\frac{dx}{d\xi}\) for an element.
-
dg_maxwell.wave_equation.dx_dxi_numerical(x_nodes, xi)[source]¶ Differential \(\frac{dx}{d \xi}\) calculated by central differential method about xi using the mapping_xi_to_x function.
Parameters: x_nodes : arrayfire.Array [N_Elements 1 1 1]
Contains the nodes of elements.
xi : arrayfire.Array [N_LGL 1 1 1]
Values of \(\xi\)
Returns: dx_dxi : arrayfire.Array [N_Elements 1 1 1]
\(\frac{dx}{d \xi}\).
-
dg_maxwell.wave_equation.flux_x(u)[source]¶ A function which returns the value of flux for a given wave function u. \(f(u) = c u^k\)
Parameters: u : list [N_Elements]
The analytical form of the wave equation for each element arranged in a list of numpy.poly1d polynomials.
Returns: flux : list [N_Elements]
The analytical value of the flux for each element arranged in a list of numpy.poly1d polynomials.
-
dg_maxwell.wave_equation.lax_friedrichs_flux(u_n)[source]¶ Calculates the lax-friedrichs_flux \(f_i\) using.
\[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 this document
Parameters: u_n : arrayfire.Array [N_LGL N_Elements M 1]
Amplitude of the wave at the mapped LGL nodes of each element. This code will work for \(M\) multiple
u_n.Returns: boundary_flux : arrayfire.Array [1 N_Elements 1 1]
Contains the value of the flux at the boundary elements. Periodic boundary conditions are used.
-
dg_maxwell.wave_equation.mapping_xi_to_x(x_nodes, xi)[source]¶ Maps points in \(\xi\) space to \(x\) space using the formula \(x = \frac{1 - \xi}{2} x_0 + \frac{1 + \xi}{2} x_1\)
Parameters: x_nodes : arrayfire.Array [2 1 1 1]
Element nodes.
xi : arrayfire.Array [N 1 1 1]
Value of \(\xi\) coordinate for which the corresponding \(x\) coordinate is to be found.
Returns: x : arrayfire.Array
\(x\) value in the element corresponding to \(\xi\).
-
dg_maxwell.wave_equation.surface_term(u_n)[source]¶ Calculates the surface term, \(L_p(1) f_i - L_p(-1) f_{i - 1}\) using the lax_friedrichs_flux function and lagrange_basis_value from params module.
Parameters: u_n : arrayfire.Array [N_LGL N_Elements M 1]
Amplitude of the wave at the mapped LGL nodes of each element. This code will work for multiple \(M\)
u_nReturns: surface_term : arrayfire.Array [N_LGL N_Elements M 1]
The surface term represented in the form of an array, \(L_p (1) f_i - L_p (-1) f_{i - 1}\), where p varies from zero to \(N_{LGL}\) and i from zero to \(N_{Elements}\). p varies along the rows and i along columns.
See: PDF describing the algorithm to obtain the surface term.
-
dg_maxwell.wave_equation.time_evolution(u=None)[source]¶ Solves the wave equation
\[u^{t_n + 1} = b(t_n) \times A\]iterated over time.shape[0] time steps t_n
Second order time stepping is used. It increases the accuracy of the wave evolution.
The second order time-stepping would be U^{n + 1/2} = U^n + dt / 2 (A^{-1} B(U^n)) U^{n + 1} = U^n + dt (A^{-1} B(U^{n + 1/2}))
Returns: None
-
dg_maxwell.wave_equation.upwind_flux(u_n)[source]¶ Finds the upwind flux of all the element edges present inside a domain.
Parameters: u_n : arrayfire.Array [N_LGL N_Elements M 1]
Amplitude of the wave at the mapped LGL nodes of each element. This code will work for \(M\) multiple
u_n.Returns: flux_x : arrayfire.Array [1 N_Elements 1 1]
Contains the value of the flux at the boundary elements. Periodic boundary conditions are used.
-
dg_maxwell.wave_equation.upwind_flux_maxwell_eq(u_n)[source]¶ Finds the upwind flux of all the element edges present inside a domain for Mode \(1\) of Maxwell’s equations. Please refer to maxwell_equation_pbc_1d.pdf for the derivation of the modes.
Parameters: u_n : arrayfire.Array [N_LGL N_Elements M 1]
Amplitude of the wave at the mapped LGL nodes of each element. This code will work for \(M\) multiple
u_n.Returns: flux_x : arrayfire.Array [1 N_Elements 1 1]
Contains the value of the flux at the boundary elements. Periodic boundary conditions are used.
-
dg_maxwell.wave_equation.volume_integral_flux(u_n)[source]¶ Calculates the volume integral of flux in the wave equation.
\(\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 using the analytical form of the integrand obtained as a linear combination of Lagrange basis polynomials.
This integrand is the used in the integrate() function.
Calculation of volume integral flux using N_LGL Lobatto quadrature points can be vectorized and is much faster.
Parameters: u : arrayfire.Array [N_LGL N_Elements M 1]
Amplitude of the wave at the mapped LGL nodes of each element. This function can computer flux for \(M\) \(u\).
Returns: flux_integral : arrayfire.Array [N_LGL N_Elements M 1]
Value of the volume integral flux. It contains the integral of all N_LGL * N_Element integrands.