Simulating square loop antenna

How to use openEMS. Discussion on examples, tutorials etc

Moderator: thorsten

sjgallagher2
Posts: 4
Joined: Tue 22 Jun 2021, 15:36

Simulating square loop antenna

I'm trying to simulate a square loop antenna to learn about OpenEMS, and while I've had some success with certain simulations, I'm not sure why my current simulation isn't running.

I have a loop which is modeled and imported as .stl. I manually meshed to avoid long computation times, though I experimented with SmoothMeshLine(), and I obtained the following (including the mesh and the debug PEC option output) :
squareloop2.png (9.71 KiB) Viewed 906 times
squareloop.png (9.89 KiB) Viewed 906 times
Screenshot 2021-06-22 094449.png (20.18 KiB) Viewed 906 times
I don't see any warnings when I run, but plotting the far field analysis produces NaN or 0 values. Here's the Octave source:

Code: Select all

``````# Ground Plate - Large Antenna

# Clean up
close all
clear
clc

# Initialize FDTD environment
unit = 1e-3; # Use this to convert to mm
FDTD = InitFDTD('NrTS',2000);

# Sinusoidal excitation
f0 = (1640e6/1)*unit; # Scaled
lambda = 3e8/f0
#FDTD = SetGaussExcite(FDTD,f0,0.5*f0);
FDTD = SetSinusExcite(FDTD,f0);

# Boundary conditions are perfect magnetic conductor (xmin, xmax),
# perfect electric conductor (ymin, ymax), and absorptive surface (zmin, zmax)
FDTD = SetBoundaryCond(FDTD,{'MUR' 'MUR' 'MUR' 'MUR' 'MUR' 'MUR'});

# Initialize geometry
CSX = InitCSX();

# Define simple grid
step=lambda/20;
# Define key meshing coordinates (in mm)
x_lines1 = [-lambda:step:-25,-23, -22.8:0.2:-22.4,-22:2:-2,-1.2:0.2:0.2];
x_lines = [x_lines1,0,-x_lines1];
y_lines = [lambda:-step:1, 1,0.2,0,-0.2,-1,-2:-2:-44,-45:-0.2:-46, -46:-step:-lambda];
mesh.x = x_lines
mesh.y = y_lines
mesh.z = -lambda:step:lambda;

SimBox = 2*[lambda lambda lambda]; # For NF2FF box
CSX = DefineRectGrid(CSX, 1, mesh);

CSX = AddMetal(CSX, 'ground_RX'); # Declare PEC
CSX = ImportSTL(CSX, 'ground_RX',1,'C:/[...]/SquareLoop.stl'); # Import geometry NOTE: to reproduce, add absolute path here

start = [-1.2 0 0];
stop = [1.2 0 0];
R = 50;
[CSX  port] = AddLumpedPort(CSX,1,1,R,start,stop,[1 0 0],true);

# Add Near-Field-to-Far-Field box for antenna pattern
SimBox = SimBox-step*4.0
[CSX, nf2ff] = CreateNF2FFBox(CSX, 'nf2ff',-SimBox/2,SimBox/2);

# Write FDTD and CSX structure to xml file
mkdir('tmp');
WriteOpenEMS('tmp/tmp.xml',FDTD,CSX);

# View the geometry generated
CSXGeomPlot('tmp/tmp.xml');

# Run the simulation
#RunOpenEMS('tmp','tmp.xml','--debug-PEC --no-simulation');
RunOpenEMS('tmp','tmp.xml','');

# Calculate near-field to far-field
theta_range = [0:2:180];
phi_range = [-180:2:180];
nf2ff = CalcNF2FF(nf2ff,'tmp',f0,theta_range*pi/180,phi_range*pi/180);
figure;
plotFF3D(nf2ff,'logscale',-20);
xlabel(gca(),"X");
ylabel(gca(),"Y");
zlabel(gca(),"Z");
hold on;
plot3(gca(),[1.5,0],[0,0],[0,0],'r');
plot3(gca(),[0,0],[1.5,0],[0,0],'g');
plot3(gca(),[0,0],[0,0],[1.5,0],'b');

# Save as vtk
E_far_normalized = nf2ff.E_norm{1} / max(nf2ff.E_norm{1}(:)) * nf2ff.Dmax;
DumpFF2VTK(['tmp/3D_Pattern.vtk'],E_far_normalized,theta_range,phi_range,'scale',1e-3);``````
I've had successful results already, but the new manual meshing is the thing causing my issues. What can I do to get the simulation to run properly? The simulation output is reproduced below (I ran it with 2000 time steps for brevity, I usually run around 20,000-50,000 max):

Code: Select all

``````invoking AppCSXCAD, exit to continue script...
VTKPrimitives::AddCube: Warning, can't draw a Point Box... skipping
args = "tmp.xml"
----------------------------------------------------------------------
| openEMS 64bit -- version v0.0.35-67-ga013077
| (C) 2010-2018 Thorsten Liebig <thorsten.liebig@gmx.de>  GPL license
----------------------------------------------------------------------
Used external libraries:
hdf5   -- Version: 1.8.12
compiled against: HDF5 library version: 1.8.12
tinyxml -- compiled against: 2.6.2
fparser
boost  -- compiled against: 1_60
vtk -- Version: 8.2.0
compiled against: 8.2.0

Create FDTD operator (compressed SSE + multi-threading)
Create a steady state detection using a period of 6.09756e-07 s
Operartor::CalcECOperator: Decreasing timestep by 0% to 1.93573e-10 (1.93628e-10) to match periodic signal
FDTD simulation size: 81x67x41 --> 222507 FDTD cells
FDTD timestep is: 1.93573e-10 s; Nyquist rate: 1575 timesteps @1.64e+06 Hz
openEMS::SetupFDTD: Warning, the timestep seems to be very small --> long simulation. Check your mesh!?
Excitation signal period is: 3150 timesteps (6.09756e-07s)
Max. number of timesteps: 2000 ( --> 0.31746 * Excitation signal period)
openEMS::SetupFDTD: Warning, max. number of timesteps is smaller than three times the excitation signal period.
You may want to choose a higher number of max. timesteps...
Create FDTD engine (compressed SSE + multi-threading)
Running FDTD engine... this may take a while... grab a cup of coffee?!?
[@        4s] Timestep:         1965 || Speed:   99.4 MC/s (2.238e-03 s/TS) || SteadyState:   0.00 dB
Time for 2000 iterations with 222507.00 cells : 4.47 sec
Speed: 99.52 MCells/s
----------------------------------------------------------------------
| nf2ff, near-field to far-field transformation for openEMS
| (C) 2012-2014 Thorsten Liebig <thorsten.liebig@gmx.de>  GPL license
----------------------------------------------------------------------
error: set: "ytick" must be finite
error: called from
colorbar at line 321 column 12
plotFF3D at line 79 column 5
ground_small_antenna at line 78 column 1``````

sjgallagher2
Posts: 4
Joined: Tue 22 Jun 2021, 15:36

Re: Simulating square loop antenna

Almost forgot to attach to .stl file with the geometry! Here it is, attached as a .txt (change the extension after downloading to .stl):
SquareLoop.txt