📜 ⬆️ ⬇️

OpenEMS modeling basics

In the last part it was described how to install and configure open-source electromagnetic simulator openEMS . Now you can go to the simulation. How to produce EMW modeling using openEMS and Octave will be discussed in this article.

We will simulate the process of electromagnetic wave propagation (EMW) between two parallel metal plates.

The configuration of the object is shown in the figure. A rectangular source of EMW is assumed, from which EMW spreads in both directions.
')


Under the cut line-by-line analysis of the script for modeling such an object.

As mentioned in the previous section, all openEMS simulations are Octave / Matlab scripts. Run Octave / Matlab and enter the following commands. First, we initialize the space. We create a special FDTD object that describes the finite difference space in the time domain:
FDTD = InitFDTD('NrTS',100,'EndCriteria',0,'OverSampling',50); 


The function parameters are 100 time calculation points from zero. The time calculation step is selected automatically based on the Nyquist frequency and the frequency of the source of the EMW. Try to set a different number of points, for example 1000.

Now we set the source of the EMW frequency of 10 MHz. Here the function parameters are clear from the name.

 FDTD = SetSinusExcite(FDTD,10e6); 


For any simulation of EMW, boundary conditions are needed. The boundary conditions describe the properties of the material, which is limited to spaces in the direction of each of the three axes of coordinates X, Y, Z. The order of the boundary conditions in the parameters of the function is the following X +, X-, Y +, Y-, Z +, Z- We have a space along the Y axis in the positive direction limited by an ideal conducting surface (PEC - Perfect Electric Conductor), in a negative direction along the Y - also conductive surface. PMC is perfect
magnetic conductor. MUR is an absolutely absorbing dielectric. It approximately corresponds to the material of the walls of the anechoic chamber.

 FDTD = SetBoundaryCond(FDTD,{'PMC' 'PMC' 'PEC' 'PEC' 'MUR' 'MUR'}); 


A special multilayer material (PML_x) is also available for boundary conditions. It can have from 6 to 20 layers (for example PML_8, PML_10). This material also acts as an absorbing dielectric.

After the boundary conditions are specified, we initialize the CSX space in which the geometry of our system will be specified.
 CSX = InitCSX(); 


Now you need to create a grid. Calculation of propagation of EMW will be performed inside the space bounded by the grid. First, we set the grid dimension by coordinates (X * Y * Z = 20x20 * 40 meters).
 mesh.x = -10:10; mesh.y = -10:10; mesh.z = -10:30; 


Now we create the actual grid in rectangular coordinates using the function
DefineRectGrid () and apply it to the geometry (the grid step is 1 meter):

 CSX = DefineRectGrid(CSX,1,mesh); 


Next, create a source of EMW. We set the amplitude of the electromagnetic wave and the direction of the vector of the electromagnetic wave. To do this, use the AddExcitation function.

 CSX = AddExcitation(CSX,'excitation',0,[0 1 0]); 


The first and second parameters of the function are the name of the CSX-space and the name of the source of EMW, respectively. The third parameter of the function is the field type. The following types are available:

The difference between hard and soft excitation is that with hard excitation, the amplitude of the electromagnetic wave at a given point in space is set to a forced value, and with soft excitation, the superposition of the fields is calculated, that is, the electromagnetic wave is superimposed on the fields present at that point.

The fourth parameter is a vector whose components set the amplitude of the electromagnetic wave in three directions X, Y, Z.

Thus, we set the excitation by an electric field with an amplitude of 1 V / m in the direction of the Y axis.

Now we create a platform (AddBox) with which the EMW will be distributed. This site is actually the source of EMW.
 CSX = AddBox(CSX,'excitation',0,[-10 -10 0],[10 10 0]); 


This completes the description of the geometry. After we have described the geometry, we need to create a section in which we will observe the propagation of EMW. This is done using the AddDump () and AddBox () functions.

 CSX = AddDump(CSX,'Et'); CSX = AddBox(CSX,'Et',0,[-10 0 -10],[10 0 30]); 


Now we prepare a temporary directory for storing the results of calculations and view the geometry with the help of CSXCAD.

 mkdir('tmp'); WriteOpenEMS('/tmp/tmp.xml',FDTD,CSX); CSXGeomPlot('/tmp/tmp.xml'); invoking AppCSXCAD, exit to continue script... QCSXCAD - disabling editing 


Everything, model of our structure is ready. You can run the simulator. If everything is normal, then we will see the following report:
 RunOpenEMS('tmp','/tmp/tmp.xml',''); ---------------------------------------------------------------------- | openEMS 64bit -- version v0.0.32-14-g63adb58 | (C) 2010-2013 Thorsten Liebig <thorsten.liebig@gmx.de> GPL license ---------------------------------------------------------------------- Used external libraries: CSXCAD -- Version: v0.5.2-15-gcb5b3cf hdf5 -- Version: 1.8.13 compiled against: HDF5 library version: 1.8.13 tinyxml -- compiled against: 2.6.2 fparser boost -- compiled against: 1_54 vtk -- Version: 5.10.1 compiled against: 5.10.1 Create FDTD operator (compressed SSE + multi-threading) FDTD simulation size: 21x21x41 --> 18081 FDTD cells FDTD timestep is: 1.92583e-09 s; Nyquist rate: 25 timesteps @1.03851e+07 Hz Excitation signal length is: 100 timesteps (1.92583e-07s) Max. number of timesteps: 100 ( --> 1 * Excitation signal length) Create FDTD engine (compressed SSE + multi-threading) Running FDTD engine... this may take a while... grab a cup of coffee?!? Time for 100 iterations with 18081 cells : 0.1624 sec Speed: 11.1336 MCells/s 


The simulation is complete and you can see the result. Run Paraview. Then select File-> Open and go to the temporary directory where the simulation results are stored. They open the file Et_.vtr. This file contains information about the result of the calculation of the propagation of EMW in time. This is what you need to open, the path to the file you will have is different:



Now we see in the Paraview window a plane, which is a section in which we look at the amplitude of the EMW.



To visualize the amplitude of EMW, select the E-field from the Coloring drop-down list (the default is SolidColor) and then display the color legend (click Show). Now we see the amplitude of the electromagnetic wave at time t = 0. At the initial moment of time, the amplitude of the EMW is also zero in the whole space, so the entire plane will be painted in one color. To see the distribution of EMW, you need to set the time different from zero and press the Rescale button. Now on the plane the amplitude distribution of EMW is displayed.



You can also start the animation and view the process of propagation of EMW in time. As expected, the EME extends in both directions from the source plane.

As a result, we modeled in the time domain the process of propagation of EME in a certain region of space. In conclusion, the entire Octave / Matlab script:

 FDTD = InitFDTD('NrTS',1000,'EndCriteria',0,'OverSampling',1); FDTD = SetSinusExcite(FDTD,10e6); FDTD = SetBoundaryCond(FDTD,{'PMC' 'PMC' 'PEC' 'PEC' 'MUR' 'MUR'}); CSX = InitCSX(); mesh.x = -10:10; mesh.y = -10:10; mesh.z = -10:30; CSX = DefineRectGrid(CSX,1,mesh); CSX = AddExcitation(CSX,'excitation',0,[0 1 0]); CSX = AddBox(CSX,'excitation',0,[-10 -10 0],[10 10 0]); CSX = AddDump(CSX,'Et'); CSX = AddBox(CSX,'Et',0,[-10 0 -10],[10 0 30]); mkdir('tmp'); WriteOpenEMS('/tmp/tmp.xml',FDTD,CSX); CSXGeomPlot('/tmp/tmp.xml'); RunOpenEMS('tmp','/tmp/tmp.xml',''); 


Link to the previous openEMS article: habrahabr.ru/post/255317

OpenEMS project website: openems.de

Source: https://habr.com/ru/post/258489/


All Articles