Cem

openEMS (a free FDTD solver)

Structure Import Toolchain DXF - STL - CSX

One way import objects to openEMS is by using DXF Files.
The 2D DXF Files will be converted to 3D objects using FreeCad and exported in the STL-Mesh Format.
The STL file will be imported in openEMS and the object coordinates will be extracted.
The object coordinates will be used to create the mesh.

Here comes a Step-by-Step tutorial.

Import DXF to FreeCad

  1. Open Freecad in the "Draft" workbench
  2. Enable the DXF import in Freecad if not available (see FreeCad help)
  3. Under Edit -> Preferences -> Import/Export -> DXF -> Import Settings: Draft Objects

The 2D object is now imported as line object with no planes.

  1. Select all line objects and convert to a "sketch" object. This creates one single sketch object including all lines
  2. Select the single sketch object and convert back to "draft" object. Now several draft objects exist. One object for each closed line structure.
  3. Select the new draft objects and change the parameter "MakeFace" to "true". Each object gets a face.
  4. Change to the "Part" workbench to create a 3D object.
  5. Now the objects can be extruded into one direction, e.g. 1mm in z-directtion.
  6. Select all object you want to export in the STL-format and export via File -> Export -> STL Mesh.

Import in openEMS

In openEMS the import via the function "stlread()" can be as follows

%get important coordinates from STL file
[ic_x ic_y ic_z] = DetectEdgesSTL('/home/hwe/13_freecadprj/Hairpinfilter/CoupledLineFilter_t_35um_hsub_1p5mm_er_6p15_shielded.stl');

% define conductor(oriented in x-direction
CSX = AddMaterial(CSX,'Copper');
CSX = SetMaterialProperty( CSX, 'Copper', 'Kappa', cond, 'Epsilon', 1, 'Mue', 1 );
CSX = ImportSTL(CSX, 'Copper',10, '/home/hwe/13_freecadprj/Hairpinfilter/CoupledLineFilter_t_35um_hsub_1p5mm_er_6p15_shielded.stl','Transform',{'Scale', 1});

%define dielectric layer
CSX = AddMaterial(CSX,'RO4360');
CSX = SetMaterialProperty( CSX, 'RO4360', 'Epsilon', er, 'Mue', 1, 'kappa',kappa );
CSX = AddBox(CSX,'RO4360',0,[ic_x(1) ic_y(1) 0],[ic_x(end) ic_y(end) hsub]);

%create a smooth mesh
%make sure the excitation ports are sitting on the grid by
%including them in the below gridline specifications
%the accuracy can be increased when applying the 1/3-2/3 rule to microstrip lines
mesh.x = SmoothMeshLines([ic_x], resolution/4); 
mesh_y_inner = SmoothMeshLines([ic_y(4:29)],resolution/4);
mesh.y = SmoothMeshLines([ic_y(1) mesh_y_inner ic_y(end)], resolution);
mesh.z = SmoothMeshLines([0 hsub hsub+thickness zbox], resolution);
CSX = DefineRectGrid(CSX, unit, mesh);

%define simple lumped port at input
start=[ic_x(2) ic_y(26) 0];
stop =[ic_x(2) ic_y(28) hsub];
[CSX port{1}] = AddLumpedPort(CSX, 99, 1, 50, start, stop, [0 0 1], true);

%define simple lumped port at output
start=[ic_x(end-1) ic_y(5) 0];
stop =[ic_x(end-1) ic_y(7) hsub];
[CSX port{2}] = AddLumpedPort(CSX, 99, 2, 50, start, stop, [0 0 1], false);
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License