Author Topic: Getting into OpenEMS  (Read 1438 times)

0 Members and 1 Guest are viewing this topic.

Offline PerArduaTopic starter

  • Regular Contributor
  • *
  • Posts: 58
  • Country: gb
Getting into OpenEMS
« on: November 25, 2024, 10:09:21 pm »
I'm trying to get into OpenEMS as a tool for analysing the behaviour of microwave components. I think I understand the general workflow (setup in octave, view structures in AppCSXCAD, send data to OpenEMS, and process results in octave), as well as some of the general principles around FDTD, but only at a surface level.

I'm trying to simulate the following structure - a bad interdigital filter with no GND connections. My code seems to produce the correct structure, but when OpenEMS starts I get a message saying that all of the primitives are unused (except for the substrate).

Code: [Select]
close all
clear
clc

CSX = InitCSX();

% Define materials

CSX = AddMaterial(CSX, 'substrate'); % Substrate material
CSX = SetMaterialProperty(CSX, 'substrate', 'Epsilon', 4.2);
CSX = AddMetal(CSX, 'feed1');
CSX = AddMetal(CSX, 'res1');
CSX = AddMetal(CSX, 'res2');
CSX = AddMetal(CSX, 'res3');
CSX = AddMetal(CSX, 'res4');
CSX = AddMetal(CSX, 'res5');
CSX = AddMetal(CSX, 'feed2');
CSX = AddMetal(CSX, 'gnd');

%Define geometry

CSX = AddBox(CSX, 'substrate', 0, [0 0 0], [67.62 49.4 -1.5]);
CSX = AddBox(CSX, 'feed1', 0, [0 11.125 0], [6.75 14.075 0]);
CSX = AddBox(CSX, 'res1', 0, [6.75 10 0], [9.7 39.4 0]);
CSX = AddBox(CSX, 'res2', 0, [18.2 10 0], [21.15 39.3 0]);
CSX = AddBox(CSX, 'res3', 0, [32.75 10 0], [35.7 39.3 0]);
CSX = AddBox(CSX, 'res4', 0, [47.3 10 0], [50.25 39.3 0]);
CSX = AddBox(CSX, 'res5', 0, [58.75 10 0], [61.7 39.4 0]);
CSX = AddBox(CSX, 'feed2', 0, [61.7 11.125 0], [67.62 14.075 0]);
CSX = AddBox(CSX, 'gnd', 0, [0 0 -1.5], [67.62 49.4 -1.5]);

% Add ports

[CSX port{1}] = AddLumpedPort(CSX, 1, 1, 50, [0 11.125 0], [0 14.075 -1.5], [0 0 1], true);
[CSX port{2}] = AddLumpedPort(CSX, 1, 2, 50, [67.62 11.125 0], [67.62 14.075 -1.5], [0 0 1], false);


% Slice

mesh = DetectEdges(CSX);


% Extend mesh

mesh.x = [mesh.x -30 97.62]; % Two YZ planes at X = -25 and X = 25
mesh.y = [mesh.y -30 79.4]; % Two XZ planes at Y = -25 and Y = 25
mesh.z = [mesh.z -30 30]; % Two XY planes at Z = -15 and X = 15


% Smooth mesh
mesh = SmoothMesh(mesh, 0.5, 1.25); % (mesh, max_res, ratio)


% Set FDTD parameters:

F0 = 1.4*10^9; % Centre frequency
FC = 300*10^9; % Corner frequency
FDTD = InitFDTD('EndCriteria', 10^-3);
FDTD = SetGaussExcite(FDTD, F0, FC);
FDTD = SetBoundaryCond(FDTD, {'MUR','MUR','MUR','MUR','MUR','MUR'});

CSX = DefineRectGrid(CSX, 1/1000, mesh);


% Save data file that can be used by OpenEMS and AppCSXCAD

mkdir('temp');
WriteOpenEMS('temp/test.xml', FDTD, CSX);


% Display 3D model

CSXGeomPlot('temp/test.xml');

% Run OpenEMS

RunOpenEMS('temp', 'test.xml');


I have tried to follow this tutorial (youtube.com/watch?v=SPlrcp-gCKk), as well as any documentation I can find online - but the OpenEMS documentation seems a bit sparse, and without a background in the underlying theory I am a bit lost.

I did read the FAQs (https://wiki.openems.de/index.php/Frequently_Asked_Questions.html), but as far as I can see none of the reasons it suggests unused primatives are met here - the structure is within the meshed area, the primatives are all of the same priority, and I assigned a primative to each property.

Any ideas as to where I am going wrong?

Additionally, if anyone is aware of any useful resources to try and learn more about the various options available in OpenEMS, I'd be grateful.
« Last Edit: November 25, 2024, 10:38:04 pm by PerArdua »
 

Offline szoftveres

  • Regular Contributor
  • *
  • Posts: 147
  • Country: us
Re: Getting into OpenEMS
« Reply #1 on: November 26, 2024, 03:05:46 am »
I started out from a working official example (https://github.com/thliebig/openEMS/blob/master/matlab/Tutorials/Simple_Patch_Antenna.m) and modified it incrementally until I got what I wanted to simulate - writing one from scratch would have given me no way to detect any mistake I made along the way.

Also, one metal is sufficient for all features, eg:
Code: [Select]
CSX = AddMetal(CSX, 'copper');
 
The following users thanked this post: PerArdua

Offline selcuk

  • Frequent Contributor
  • **
  • Posts: 259
  • Country: tr
Re: Getting into OpenEMS
« Reply #2 on: November 26, 2024, 12:38:41 pm »
All of them are vanishing into the substrate since they have the same priority value. When two objects intersect, the one with the higher priority exists in that intersection and the other one is assumed to be not there.

https://wiki.openems.de/index.php/File:Priorities2.png.html

You may use like this:

Code: [Select]
CSX = AddBox(CSX, 'substrate', 0, [0 0 0], [67.62 49.4 -1.5]);
CSX = AddBox(CSX, 'feed1', 9, [0 11.125 0], [6.75 14.075 0]);
CSX = AddBox(CSX, 'res1', 10, [6.75 10 0], [9.7 39.4 0]);
CSX = AddBox(CSX, 'res2', 10, [18.2 10 0], [21.15 39.3 0]);
CSX = AddBox(CSX, 'res3', 10, [32.75 10 0], [35.7 39.3 0]);
CSX = AddBox(CSX, 'res4', 10, [47.3 10 0], [50.25 39.3 0]);
CSX = AddBox(CSX, 'res5', 10, [58.75 10 0], [61.7 39.4 0]);
CSX = AddBox(CSX, 'feed2', 9, [61.7 11.125 0], [67.62 14.075 0]);
CSX = AddBox(CSX, 'gnd', 5, [0 0 -1.5], [67.62 49.4 -1.5]);
 
The following users thanked this post: PerArdua, szoftveres

Offline PerArduaTopic starter

  • Regular Contributor
  • *
  • Posts: 58
  • Country: gb
Re: Getting into OpenEMS
« Reply #3 on: November 29, 2024, 05:58:18 pm »
Thank you both - I got the simulation to work - only took 9 hours... :D And I did spot that I was trying a 600 GHz bandwidth instead of 600 MHz  :palm:

If I might ask, why is it that the geometry in the YouTube tutorial doesn't throw up this error, when all of his boxes are the same priority and his 'signal' and 'ground' sit on the same plane as his 'substrate' boundaries?

If you go to 26 mins in exactly, you can see the three boxes, each with 0th priority.
« Last Edit: November 29, 2024, 06:31:11 pm by PerArdua »
 

Offline selcuk

  • Frequent Contributor
  • **
  • Posts: 259
  • Country: tr
Re: Getting into OpenEMS
« Reply #4 on: December 01, 2024, 01:09:45 pm »
I guess there is a difference between software versions in handling equal priorities. This is not clearly defined so I usually try to assign a different priority to each element to make sure the simulation runs as intended.

An example block:

Code: [Select]
% object priorities
ant_prio = 20 ; % antenna
tr_prio = 19 ; % transmission line
via_prio = 18 ; % via
gnd_prio = 17 ; % ground copper
sh_prio = 16 ; % shield
port_prio = 15 ; % port
mask_prio = 10 ; % solder mask
sub_prio = 9 ; % substrate
air_prio = 8 ; % air
enc_prio = 7 ; % enclosure
 
The following users thanked this post: PerArdua


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf