Thanks Matthew,
I was able to identify and obtain the edge of interest, but I am having an issue defining the coefficients for the GridFunction.
For reference, I am trying to excite the middle edge of a rectangle sheet of length L, and width W. Once I identify the edge, I tried initializing a GridFunction
with a vector of coefficients, where it is a vector of zeros and a specific value at the edge index. I get an error when attempting to solve the LU decomposition:
ValueError: dimension mismatch
Here is the code:
#Constants
frequency = 500E6 #MHZ
vacuum_permittivity = 8.854187817E-12
vacuum_permeability = 4 * np.pi * 1E-7
w = 2 * np.pi * frequency
k = w * np.sqrt(vacuum_permittivity * vacuum_permeability)
wavelength = speed_of_light / frequency
#Rectangle Micro-strip
W = 0.003
L = 1
plate1 = np.array([[-L/2, W/2, 0], [0, W/2, 0], [0, -W/2, 0], [-L/2, -W/2, 0]])
plate2 = np.array([[0, W/2, 0], [0, -W/2, 0], [L/2, -W/2, 0], [L/2, W/2, 0]])
#Edges to Identify
edgeV1 = [0, -W/2, 0]
edgeV2 = [0, W/2, 0]
grid1 = bempp.api.shapes.shapes.screen(plate1, h=(1/10)*wavelength)
grid2 = bempp.api.shapes.shapes.screen(plate2, h=(1/10)*wavelength)
grid = bempp.api.grid.union([grid1, grid2])
#Get Edges
for i, e in enumerate(grid.edges.T):
if ((grid.vertices[:, e[0]] == edgeV1).all() or (grid.vertices[:, e[0]] == edgeV2).all()):
if ((grid.vertices[:, e[1]] == edgeV1).all() or (grid.vertices[:, e[1]] == edgeV2).all()):
edgeInd = i
#Basis Functions to represent problem
div_space = bempp.api.function_space(grid, "RWG", 0)
curl_space = bempp.api.function_space(grid, "SNC", 0)
#Set-up Appropriate Operators - EFIE
elec = bempp.api.operators.boundary.maxwell.electric_field(div_space, div_space, curl_space, k)
#Set-Up Coefficients
coefficients=np.zeros((grid.edges.shape[1],1))
coefficients[edgeInd, 0] = 1
trace_fun = bempp.api.GridFunction(div_space, coefficients= coefficients, dual_space=curl_space)
#Solve System
from bempp.api.linalg import lu
solved_system = lu(elec, trace_fun)
It’s a simple problem, and I thought including the code would help. I suspect that BEMPP is removing the perimeter edges of the rectangle, for continuity purposes, and thus reducing the size of the elec
matrix.
In this case, it may be re-numbering the edges. Is there a function that can tell me which edges will be removed, or which will remain? Such that I could re-locate the edge of interest, and initialize a GridFunction
with the appropriate sized vector of coefficients.
Best,
-Ricardo