Coder Social home page Coder Social logo

thliebig / openems Goto Github PK

View Code? Open in Web Editor NEW
408.0 408.0 145.0 4.77 MB

openEMS is a free and open-source electromagnetic field solver using the EC-FDTD method.

Home Page: http://openEMS.de

License: GNU General Public License v3.0

MATLAB 34.90% CMake 1.10% C++ 56.05% Shell 0.04% Makefile 0.14% Python 5.74% C 0.36% Cython 1.67%

openems's People

Contributors

0xcoto avatar andypfau avatar awzhy0yqh81uoyvh avatar batchdrake avatar biergaizi avatar dac922 avatar detlefc avatar funkmaus avatar gammaxy1 avatar georgmichel avatar guitorri avatar khashabri avatar luzpaz avatar madscientist159 avatar mpinese avatar mrhighvoltage avatar oberstet avatar pkubaj avatar rdmitry avatar rubund avatar sibbi77 avatar stefanbruens avatar thasti avatar thliebig avatar tmolteno avatar tmpusr123 avatar yurivict avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

openems's Issues

Semi-Automatic & Fully-Automatic Correctness Tests Needed

Recently some developers are interested in exploring different ways to speedup the FDTD engine, examples include my #100 proposal and #105 patch, and @MircoController's experimental CUDA kernel at thliebig/openEMS-Project#36. To allow making significant changes to the FDTD kernel with confidence, there's a need for semi-automatic and fully-automatic correctness tests.

Also, when creating a package for a system, it's often customary to run the built-in tests that come within a project to ensure the program is running correctly. This is why FreeBSD developer @yurivict created Issue #78 on "please explain how to run tests." However, currently there is no test.

I'm seeing the possibility of using two types of checks:

  1. Comparison against analytical results: The easiest check is to create simulations for some structures with well-known analytical results, such as the cutoff frequency of waveguide, the characteristic impedance of transmission lines, or the radiation pattern of antennas. However, only simple structure can be compared with this method.
  2. Comparison against previous versions: Another type of check is comparing the result of a new result against the result of a known-good historical version. This allows the use of arbitrary simulations as checks without referring to analytical results.

The checks should eventually be fully-automatic, but for now a semi-automatic check is enough - for example, plot the S-parameter / radiation pattern of a device and the known-good result on the same chart on the screen. This allows developers to easily spot a deviation that indicates the existence of bugs. I think many examples from the Tutorial directory can already serve as tests. Eventually, tests should be fully automatic - each data point of the result would be automatically compared with a known-good reference. An error is generated if a deviation beyond reasonable tolerance is detected.

MaxTime isn't working

For example calling
InitFDTD('MaxTime', 5) and then RunOpenEMS won't give the expected results.
Looking at the source code it looks like m_maxTime is there but isn't used at all.

BUG: commit 'try to find optimal number of engine threads' has a process exiting issue or something.

Hi @thliebig, Beginning with commit 6673aef the following code taken from the tutorial hangs prior to exit. I suspect something isn't closing . It will exit normally if you comment out the FDTD.run(). So it is something that gets started in the .run() process. This bug is breaking for python scripts that use the openEMS class, call the .run() and need to return.

# -*- coding: utf-8 -*-
"""
 Simple Patch Antenna Tutorial

 Tested with
  - python 3.10
  - openEMS v0.0.34+

 (c) 2015-2023 Thorsten Liebig <[email protected]>

"""

### Import Libraries
import os, tempfile
from pylab import *

from CSXCAD  import ContinuousStructure
from openEMS import openEMS
from openEMS.physical_constants import *

### General parameter setup
Sim_Path = os.path.join(tempfile.gettempdir(), 'Simp_Patch')

post_proc_only = False

# patch width (resonant length) in x-direction
patch_width  = 32 #
# patch length in y-direction
patch_length = 40

#substrate setup
substrate_epsR   = 3.38
substrate_kappa  = 1e-3 * 2*pi*2.45e9 * EPS0*substrate_epsR
substrate_width  = 60
substrate_length = 60
substrate_thickness = 1.524
substrate_cells = 4

#setup feeding
feed_pos = -6 #feeding position in x-direction
feed_R = 50     #feed resistance

# size of the simulation box
SimBox = np.array([200, 200, 150])

# setup FDTD parameter & excitation function
f0 = 2e9 # center frequency
fc = 1e9 # 20 dB corner frequency

### FDTD setup
## * Limit the simulation to 30k timesteps
## * Define a reduced end criteria of -40dB
FDTD = openEMS(NrTS=30000, EndCriteria=1e-4)
FDTD.SetGaussExcite( f0, fc )
FDTD.SetBoundaryCond( ['MUR', 'MUR', 'MUR', 'MUR', 'MUR', 'MUR'] )


CSX = ContinuousStructure()
FDTD.SetCSX(CSX)
mesh = CSX.GetGrid()
mesh.SetDeltaUnit(1e-3)
mesh_res = C0/(f0+fc)/1e-3/20

### Generate properties, primitives and mesh-grid
#initialize the mesh with the "air-box" dimensions
mesh.AddLine('x', [-SimBox[0]/2, SimBox[0]/2])
mesh.AddLine('y', [-SimBox[1]/2, SimBox[1]/2]          )
mesh.AddLine('z', [-SimBox[2]/3, SimBox[2]*2/3]        )

# create patch
patch = CSX.AddMetal( 'patch' ) # create a perfect electric conductor (PEC)
start = [-patch_width/2, -patch_length/2, substrate_thickness]
stop  = [ patch_width/2 , patch_length/2, substrate_thickness]
patch.AddBox(priority=10, start=start, stop=stop) # add a box-primitive to the metal property 'patch'
FDTD.AddEdges2Grid(dirs='xy', properties=patch, metal_edge_res=mesh_res/2)

# create substrate
substrate = CSX.AddMaterial( 'substrate', epsilon=substrate_epsR, kappa=substrate_kappa)
start = [-substrate_width/2, -substrate_length/2, 0]
stop  = [ substrate_width/2,  substrate_length/2, substrate_thickness]
substrate.AddBox( priority=0, start=start, stop=stop )

# add extra cells to discretize the substrate thickness
mesh.AddLine('z', linspace(0,substrate_thickness,substrate_cells+1))

# create ground (same size as substrate)
gnd = CSX.AddMetal( 'gnd' ) # create a perfect electric conductor (PEC)
start[2]=0
stop[2] =0
gnd.AddBox(start, stop, priority=10)

FDTD.AddEdges2Grid(dirs='xy', properties=gnd)

# apply the excitation & resist as a current source
start = [feed_pos, 0, 0]
stop  = [feed_pos, 0, substrate_thickness]
port = FDTD.AddLumpedPort(1, feed_R, start, stop, 'z', 1.0, priority=5, edges2grid='xy')

mesh.SmoothMeshLines('all', mesh_res, 1.4)

# Add the nf2ff recording box
nf2ff = FDTD.CreateNF2FFBox()

### Run the simulation
if 0:  # debugging only
    CSX_file = os.path.join(Sim_Path, 'simp_patch.xml')
    if not os.path.exists(Sim_Path):
        os.mkdir(Sim_Path)
    CSX.Write2XML(CSX_file)
    from CSXCAD import AppCSXCAD_BIN
    os.system(AppCSXCAD_BIN + ' "{}"'.format(CSX_file))

if not post_proc_only:
    FDTD.Run(Sim_Path, verbose=3, cleanup=True)

Python/CSXCAD AddBox error

Hello!
I've got a problem with command CSX.AddBox in python wrapper... Compiler returns an error:
Traceback (most recent call last):
File "dipole.py", line 48, in <module>
box=CSX.AddBox(substrate, priority=0, start=start, stop=stop )
AttributeError: 'CSXCAD.CSXCAD.ContinuousStructure' object has no attribute 'AddBox'

All examples have the same error with "AddBox"

Feed resistance in AddMSLPort is incorrectly oriented

openEMS/matlab/AddMSLPort.m

Lines 259 to 261 in 0342eef

if (feed_R > 0) && ~isinf(feed_R)
CSX = AddLumpedElement( CSX, [PortNamePrefix 'port_resist_' int2str(portnr)], idx_height-1, 'R', feed_R );
CSX = AddBox( CSX, [PortNamePrefix 'port_resist_' int2str(portnr)], prio, ex_start, ex_stop );

This sets the direction of the feed resistance to idx_height-1. In the example of a microstrip line with propagation along the x-axis (=0), width measured along the y-axis (=1), and excitation oriented toward the z-axis (=2), idx_height is 2, so the resistance is oriented perpendicular to the line. If idx_height were 0, then this would pass -1 to AddLumpedElement and cause an error at some point.

Changing this to idx_prop would create a zero-length lumped element which is not allowed.

InitCSX.m is missing

The "matlab" folder is missing InitCSX.m which is required to run any of the Tutorial files.

openEMS.sh

Hi Thorsten!

What is the point of the openEMS.sh script?

#!/bin/bash

#clear LD_LIBRARY_PATH
export LD_LIBRARY_PATH=

#get path to openEMS
openEMS_PATH=`dirname $0`

#execute openEMS
exec $openEMS_PATH/openEMS $@

Since it does nothing else than just running the openEMS binary, I think we should remove it and make invoke_openEMS.m call the openEMS binary instead. May is there still a reason that I can't see?

Best regards,

how to calculate time interval ?

Hi, I came cross a problem. I want to know where time interval (i.e. dt) is defined or calculated in your code, because I think it is needed for calculation of f0 and fc.

munmap_chunk(): invalid pointer when running openEMS on Arch Linux

I followed the first tutorial but I can't get openEMS to run properly, it crashes with the error in the title. (or free(): invalid pointer)

I tried 3 times to get it to generate a debug build by hacking your updater thing but for some reason it doesn't work, di you have an official method to add debug symbols so this bug report is somewhat useful?

GNU gdb (GDB) 8.1.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Registered pretty printers for UE4 classes
Reading symbols from ./openEMS...(no debugging symbols found)...done.
(gdb) r
Starting program: /tmp/openems/bin/openEMS /tmp/tmp.xml
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
 ---------------------------------------------------------------------- 
 | openEMS 64bit -- version v0.0.35
 | (C) 2010-2016 Thorsten Liebig <[email protected]>  GPL license
 ---------------------------------------------------------------------- 
        Used external libraries:
                CSXCAD -- Version: v0.6.2
                hdf5   -- Version: 1.10.2
                          compiled against: HDF5 library version: 1.10.2
                tinyxml -- compiled against: 2.6.2
                fparser
                boost  -- compiled against: 1_67
                vtk -- Version: 6.3.0
                       compiled against: 6.3.0

munmap_chunk(): invalid pointer

Program received signal SIGABRT, Aborted.
0x00007ffff5e6fd7f in raise () from /usr/lib/libc.so.6
(gdb) 

h5readatt_octave.cc:3:10: fatal error: hdf5.h: No such file or directory

Hi,

I'm getting the following error when I try the Patch_Antenna_Array tutorial file:

----------------------------------------------------------------------
 | openEMS 64bit -- version v0.0.35-28-g6133dea
 | (C) 2010-2016 Thorsten Liebig <[email protected]>  GPL license
 ----------------------------------------------------------------------
        Used external libraries:
                CSXCAD -- Version: v0.6.2-80-g6ab8a3a
                hdf5   -- Version: 1.10.0
                          compiled against: HDF5 library version: 1.10.0-patch1
                tinyxml -- compiled against: 2.6.2
                fparser
                boost  -- compiled against: 1_62
                vtk -- Version: 6.3.0
                       compiled against: 6.3.0

--------

RunFDTD: Warning: Max. number of timesteps was reached before the end-criteria of -50dB was reached...
        You may want to choose a higher number of max. timesteps...
Time for 30000 iterations with 588744.00 cells : 306.45 sec
Speed: 57.63 MCells/s
 ----------------------------------------------------------------------
 | nf2ff, near-field to far-field transformation for openEMS
 | (C) 2012-2014 Thorsten Liebig <[email protected]>  GPL license
 ----------------------------------------------------------------------
calculating far field at phi=[0 90] deg...
warning: function "h5readatt_octave" not found, trying to run "setup"
warning: called from
    ReadHDF5Attribute at line 15 column 9
    ReadNF2FF at line 22 column 12
    CalcNF2FF at line 140 column 7
    Patch_Antenna_Array at line 228 column 7
setting up openEMS matlab/octave interface
compiling oct files
h5readatt_octave.cc:3:10: fatal error: hdf5.h: No such file or directory
 #include "hdf5.h"
          ^~~~~~~~
compilation terminated.
HDF5 library path found at: /usr/lib/x86_64-linux-gnu/hdf5/openmpi/libhdf5.so
/usr/lib/x86_64-linux-gnu/hdf5/serial
HDF5 include path found at: /usr/include/hdf5/openmpi/hdf5.h
/usr/include/hdf5/serial
warning: mkoctfile: building exited with failure status
error: 'h5readatt_octave' undefined near line 22 column 19
error: called from
    ReadHDF5Attribute at line 22 column 10
    ReadNF2FF at line 22 column 12
    CalcNF2FF at line 140 column 7
    Patch_Antenna_Array at line 228 column 7

Which seems to be telling me it cannot find hdf5.h, and yet it then says it found it in the openmpi and serial directories.

Any suggestions to how to proceed? I'm assuming that this is happening in the nf2ff octave interface - how can I replicate this without re-running the whole simulation?

Thanks again,

Matt

How to cluster?

Hi!

Is there any howto or tutorial on how to setup a cluster with openems?

openEMS folder in 'Program Files': openEMS binary exited with error-code 1

Hi,

as I'm knew to github I don't know if placing the issue here is right. Please redirect me to the correct location if posting it here is not right.
I followed the initial steps (documented in your wiki) using Matlab. When running the following command I got the following error:
Command
RunOpenEMS( '.', 'nonexistant.xml', '' )
Error
"openEMS binary exited with error-code 1"

After some digging it got clear that running the openEMS.exe Matlab failed due to a whitespace ' ' in the path directing to the exe-file. In my case it was 'Program Files' that had the whitespace included. Therefore Matlab was not able to run the exe.
Changing line 37 of 'invoke_openEMS.m' to the following solved the problem.

command = ['"' openEMS_bin '"' ' ' opts];

I don't know if this is the 'best' or 'cleanest' solution, but it worked for me.

Note to first-time users: As mentioned in the Wiki, you'll still get an error. But the error is due to not finding the .xml file which doesn't exist. However, the error-code will have the value -1 and not 1 as in the case of not being able to run the exe-file.

Best regards,
Lukas

libhdf5_serial.so.10 file not found error

Using an older Octave script on newer "i7" computer with Ubuntu 20.x.
Followed installation instructions. With minor updates, simulation finishes (adaptive to available processors -- nice!!)
Error output from nf2ff in z direction: (x and y ran without error)
error: ReadHDF5Attribute: /home/lawrence/opt/openEMS/share/openEMS/matlab/h5readatt_octave.oct: failed to load: libhdf5_serial.so.10: cannot open shared object file: No such file or directory
error: called from
ReadHDF5Attribute at line 22 column 10
ReadNF2FF at line 22 column 12
CalcNF2FF at line 140 column 7
Not urgent. All help deeply appreciated. Thanks

Meshing issue

Hello,
I am new on using openems. I want to make a PCB trace antenna simulate it and have s11, impedance and radiation pattern curve.
Here my code. I took IFA example to adapt to my antenna shape. I have meshing problems:

Meshing issues

close all
clear
clc

%% setup the simulation
physical_constants;
unit = 1e-3; % all length in mm

%
substrate.width = 10; % width of substrate
substrate.length = 10; % length of substrate
substrate.thickness = 0.8; % thickness of substrate
substrate.cells = 4; % use 4 cells for meshing substrate

ifa.h = 3; % height of short circuit stub
ifa.l = 8; % length of radiating element over2
ifa.w1 = 0.9; % width of short circuit stub
ifa.w2 = 0.3; % width of radiating element
ifa.wf = 0.4; % width of feed element
ifa.fp = 4; % position of feed element relative to short
% circuit stub
ifa.e = 3.3; % distance to edge

ifa.b = 6;
ifa.a = 1.2;
ifa.c = 0.3;
ifa.d = 0.3;

% substrate setup
substrate.epsR = 4.29;
substrate.kappa = 1e-3 * 2pi2.45e9 * EPS0*substrate.epsR;

%setup feeding
feed.R = 50; %feed resistance

%open AppCSXCAD and show ifa
show = 1;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% size of the simulation box
SimBox = [substrate.width2 substrate.length2 150];

%% setup FDTD parameter & excitation function
f0 = 2.5e9; % center frequency
fc = 1e9; % 20 dB corner frequency

FDTD = InitFDTD('NrTS', 60000 );
FDTD = SetGaussExcite( FDTD, f0, fc );
BC = {'MUR' 'MUR' 'MUR' 'MUR' 'MUR' 'MUR'}; % boundary conditions
FDTD = SetBoundaryCond( FDTD, BC );

%% setup CSXCAD geometry & mesh
CSX = InitCSX();

%initialize the mesh with the "air-box" dimensions
mesh.x = [-SimBox(1)/2 SimBox(1)/2];
mesh.y = [-SimBox(2)/2 SimBox(2)/2];
mesh.z = [-SimBox(3)/2 SimBox(3)/2];

%% create substrate
CSX = AddMaterial( CSX, 'substrate');
CSX = SetMaterialProperty( CSX, 'substrate', 'Epsilon',substrate.epsR, 'Kappa', substrate.kappa);
start = [-substrate.width/2 -substrate.length/2 0];
stop = [ substrate.width/2 substrate.length/2 substrate.thickness];
CSX = AddBox( CSX, 'substrate', 1, start, stop );
% add extra cells to discretize the substrate thickness
mesh.z = [linspace(0,substrate.thickness,substrate.cells+1) mesh.z];

%% create ground plane
CSX = AddMetal( CSX, 'groundplane' ); % create a perfect electric conductor (PEC)
start = [-substrate.width/2 -substrate.length/2 substrate.thickness];
stop = [ substrate.width/2 substrate.length/2-ifa.e substrate.thickness];
CSX = AddBox(CSX, 'groundplane', 10, start,stop);

%% create ifa
CSX = AddMetal( CSX, 'ifa' ); % create a perfect electric conductor (PEC)
tl = [0,substrate.length/2-ifa.e,substrate.thickness]; % translate

start = [-ifa.fp+ifa.c+ifa.c 0.5 0] + tl;
stop = start + [ifa.wf ifa.h-0.5 0];
CSX = AddBox( CSX, 'ifa', 10, start, stop); % feed element

start = [-ifa.fp 0 0] + tl;
stop = start + [-ifa.w1 ifa.h 0];
CSX = AddBox( CSX, 'ifa', 10, start, stop); % short circuit stub

start = [(-ifa.fp-ifa.w1) ifa.h 0] + tl;
stop = start + [ifa.l -ifa.w2 0];
CSX = AddBox( CSX, 'ifa', 10, start, stop); % radiating element1

start = [(-ifa.fp-ifa.w1+ifa.l) ifa.h 0] + tl;
stop = start + [-ifa.w2 -ifa.a 0];
CSX = AddBox( CSX, 'ifa', 10, start, stop); % radiating element2

start = [(-ifa.fp-ifa.w1+ifa.l) ifa.h-ifa.a 0] + tl;
stop = start + [-ifa.b ifa.w2 0];
CSX = AddBox( CSX, 'ifa', 10, start, stop); % radiating element3

start = [(-ifa.fp-ifa.w1+ifa.l-ifa.b+ifa.w2) ifa.h-ifa.a 0] + tl;
stop = start + [-ifa.w2 -ifa.a 0];
CSX = AddBox( CSX, 'ifa', 10, start, stop); % radiating element4

start = [(-ifa.fp-ifa.w1+ifa.l) (ifa.h-ifa.a+0.6) 0] + tl;
stop = start + [-ifa.b ifa.w2 0];
CSX = AddBox( CSX, 'ifa', 10, start, stop); % radiating element5

start = [(-ifa.fp-ifa.w1+ifa.l-ifa.b+ifa.w2+ifa.b) ifa.h-ifa.a 0] + tl;
stop = start + [-ifa.w2 -ifa.a 0];
CSX = AddBox( CSX, 'ifa', 10, start, stop); % radiating element6

start = [(-ifa.fp-ifa.w1+ifa.l) (ifa.h-ifa.a+2*0.6) 0] + tl;
stop = start + [-ifa.b ifa.w2 0];
CSX = AddBox( CSX, 'ifa', 10, start, stop); % radiating element7

ifa_mesh = DetectEdges(CSX, [], 'SetProperty','ifa');
mesh.x = [mesh.x SmoothMeshLines(ifa_mesh.x, 0.6)];
mesh.y = [mesh.y SmoothMeshLines(ifa_mesh.y, 0.6)];

%% apply the excitation & resist as a current source
start = [-ifa.fp+ifa.c+ifa.c 0 0] + tl;
stop = start + [ifa.wf 0.5 0];
[CSX port] = AddLumpedPort(CSX, 5 ,1 ,feed.R, start, stop, [0 1 0], true);

%% finalize the mesh
% generate a smooth mesh with max. cell size: lambda_min / 20
mesh = DetectEdges(CSX, mesh);
mesh = SmoothMesh(mesh, c0 / (f0+fc) / unit / 10);
CSX = DefineRectGrid(CSX, unit, mesh);

%% add a nf2ff calc box; size is 3 cells away from MUR boundary condition
start = [mesh.x(4) mesh.y(4) mesh.z(4)];
stop = [mesh.x(end-3) mesh.y(end-3) mesh.z(end-3)];
[CSX nf2ff] = CreateNF2FFBox(CSX, 'nf2ff', start, stop);

%% prepare simulation folder
Sim_Path = 'tmp_IFA';
Sim_CSX = 'IFA.xml';

try confirm_recursive_rmdir(false,'local'); end

[status, message, messageid] = rmdir( Sim_Path, 's' ); % clear previous directory
[status, message, messageid] = mkdir( Sim_Path ); % create empty simulation folder

%% write openEMS compatible xml-file
WriteOpenEMS( [Sim_Path '/' Sim_CSX], FDTD, CSX );

%% show the structure
if (show == 1)
CSXGeomPlot( [Sim_Path '/' Sim_CSX] );
end

Feature Request: Benchmarking Demos

For openEMS users, it would be insightful to know how different hardware and software configurations (CPU, memory, multi-threading, MPI clustering) affect simulation speed via a set of standard tests. However, the current demos provided in openEMS are meant for teaching purposes, not benchmarks. It would be useful to add some demos with longer runtime (e.g. 5 to 10 minutes) for benchmarking purposes, perhaps by using a smaller mesh than what's strictly necessary. Demos on the use of different boundary conditions (e.g. PEC vs PML) would also be helpful to show their performance impact.

where is the harminv.exe, i can not find it.

when i use the
[freq,decay,Q,amp,phase,err]=harminv( u, t(2)-t(1), 0, 1e9 );

matlab displays an error:

"D:\CODE _TEST\dashijie\paper\FDM\FDMC++\openEMS-master\matlab..\harminv.exe" -t 1.6683e-11 0-1000000000 < "C:\Users\liu\AppData\Local\Temp\tpfb124c08_746d_447d_be64_c652ab3f21fb"
exit status: 1
output: '"D:\CODE _TEST\dashijie\paper\FDM\FDMC++\openEMS-master\matlab..\harminv.exe"' Not an internal or external command, nor a runnable program or batch files.

Packaging Python interface for PyPI

I believe it would be very convenient for users if the openems and csxcad interfaces were available for installation on PyPI. The current installation process makes using these interfaces in external libraries difficult. Is this something that might be considered?

[proposed bug] Can't find openEMS binary if path has spaces on Windows

Hi,

First of all, thank you so much for your awesome work!

I'm encountering this issue where on my Windows PC, I'm getting the following error when running the helical antenna tutorial:

'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
args = "Helix_Ant.xml"
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
error: openEMS binary exited with error-code 1
error: called from
    invoke_openEMS at line 50 column 2
    RunOpenEMS at line 181 column 9
    Helical_Antenna at line 128 column 5

From the error message and the fact that I've had success running the tutorial on a different PC, in which I've put the openEMS folder in C (C:/openEMS), I'll say that the problem is the path--more specifically, it's the space in "Program Files" where I put the openEMS folder on this PC.

I've traced it back to matlab/private/invoke_openEMS.m line 34:
openEMS_bin = searchBinary('openEMS.exe', [dir filesep '..' filesep '..' filesep]);

I'd like to fix it myself, but I can't find the "searchBinary" function's definition anywhere in this repository or in Matlab's documentation. Could you please point me to where I can find more information about it?

Thank you!

Problem with FD values from probes

When the 'Frequency' option is provided to AddProbe, the resulting frequency domain data is close, but not identical to the conjugate complex of the data which is calculated via ReadUI afterwards. The sign of the exponent in ProcessIntegral::Process line 161 is nevertheless in agreement with the octave definition of the Fourier transform. The resulting positive phase drift from AddProbe is not in agreement with the assumed definition of the Fourier transform, i.e. int(f(t)_exp(-2_pi_omega_f*t), dt) is the forward transform.

Some spurious signal appears at the end of the simulation and increases in energy

Hi

I could not find the openEMS forum (which I remember I have seen earlier), so I am asking here.

I am simulating a microstrip connected to a coaxial cable. I am making a 2d field dump on top of board. Most of the simulation looks great, but near the end when it seems like the excitation has died out, some spurious signal suddenly appears at the connection between the microstrip and the coax. It builds up in energy and eventually fills the entire grid with "high" energy. I was wondering if you know why this happens, and how it can be prevented.

The code is attached below:

#!/usr/bin/env octave

pkg load openems
pkg load csxcad

close all
clear
clc

physical_constants;
unit = 1e-6; % specify everything in um
MSL_length = 50000;
MSL_width = 600;
substrate_thickness = 254;
substrate_epr = 3.66;
stub_length = 12e3;
f_max = 7e9;

FDTD = InitFDTD();
FDTD = SetGaussExcite( FDTD, f_max/2, f_max/2 );
BC   = {'PML_8' 'PML_8' 'MUR' 'MUR' 'MUR' 'MUR'};
FDTD = SetBoundaryCond( FDTD, BC );

CSX = InitCSX();
resolution = c0/(f_max*sqrt(substrate_epr))/unit /50; % resolution of lambda/50
mesh.x = SmoothMeshLines( [9000 11000] , resolution/4, 1.5 ,0 );
mesh.x = SmoothMeshLines( [-MSL_length 8000 mesh.x MSL_length], resolution, 1.5 ,0 );
mesh.y = SmoothMeshLines( [0:50:2300], resolution, 1.3, 0);
mesh.y = SmoothMeshLines( [-15*MSL_width -mesh.y mesh.y 15*MSL_width] , resolution, 1.3, 0);
mesh.z = SmoothMeshLines( [-10*substrate_thickness [-2300:50:-254] -200 -130 -70 0 50 130 200 [254:50:2300] 10*substrate_thickness], resolution/4 );
CSX = DefineRectGrid( CSX, unit, mesh );

CSX = AddMaterial( CSX, 'RO4350B' );
CSX = SetMaterialProperty( CSX, 'RO4350B', 'Epsilon', substrate_epr );
start = [mesh.x(1),   mesh.y(1),  0];
stop  = [10000, mesh.y(end), substrate_thickness];
CSX = AddBox( CSX, 'RO4350B', 0, start, stop );


CSX = AddMetal( CSX, 'PEC' );

%%% ground plane
start = [mesh.x(1),   mesh.y(1),   0];
stop  = [10000, mesh.y(end), 0];
CSX = AddBox( CSX, 'PEC', 999, start, stop );

%% MSL port
portstart = [ mesh.x(1), -MSL_width/2, substrate_thickness];
portstop  = [ 0,  MSL_width/2, 0];
[CSX,port{1}] = AddMSLPort( CSX, 999, 1, 'PEC', portstart, portstop, 0, [0 0 -1], 'ExcitePort', true, 'FeedShift', 10*resolution, 'MeasPlaneShift',  MSL_length/3);

portstart = [mesh.x(end), 0, substrate_thickness+180];
portstop  = [10000          ,  0, substrate_thickness+180];

[CSX,port{2}] = AddCoaxialPort( CSX, 999, 2, 'PEC', '', portstart, portstop, 'x', 200, 1500, 1700, 'MeasPlaneShift', MSL_length/3, 'FeedShift', 10*resolution);

start = [0,  -MSL_width/2, substrate_thickness];
stop  = [10000,  MSL_width/2, substrate_thickness];
CSX = AddBox( CSX, 'PEC', 999, start, stop );


%% Field dump
CSX = AddDump(CSX,'Et','DumpMode', 2);
start = [mesh.x(1)   mesh.x(1)   substrate_thickness];
stop  = [mesh.x(end) mesh.x(end) substrate_thickness];
CSX = AddBox(CSX,'Et',0 , start,stop);

 
%% write/show/run the openEMS compatible xml-file
Sim_Path = 'tmp';
Sim_CSX = 'msl.xml';

[status, message, messageid] = rmdir( Sim_Path, 's' ); % clear previous directory
[status, message, messageid] = mkdir( Sim_Path ); % create empty simulation folder

WriteOpenEMS( [Sim_Path '/' Sim_CSX], FDTD, CSX );
CSXGeomPlot( [Sim_Path '/' Sim_CSX] );
RunOpenEMS( Sim_Path, Sim_CSX );

Thank you very much in advance.

Best regards
Ruben

Forum is down

Is the forum still active? Is there another place that I can ask generic usage questions?

Thanks,

How to generate the exe file ? (run in windows)

Hi, I successfully run the source code in ubuntu and generate the file in floder 'opt' by using the update_openEMS.sh file, but I don't know how to generate the exe file that can run in the windows.

openEMS.pyx AssertionError due to checking non-canonical path name

Currently, running openEMS's example Python scripts on macOS always fails with the following error:

$ python3 MSL_NotchFilter.py 
Traceback (most recent call last):
  File "/Users/gentoo/code/openEMS-Project/openEMS/python/Tutorials/MSL_NotchFilter.py", line 103, in <module>
    FDTD.Run(Sim_Path, cleanup=True)
  File "openEMS/openEMS.pyx", line 489, in openEMS.openEMS.openEMS.Run
AssertionError

This is caused by an oversight of an assertion in openEMS.pyx:

os.chdir(sim_path)
# ...
assert os.getcwd() == sim_path

The problem here is that sim_path is not a canonical path name, so the assertion would fail if the path we're switching into contains a symbolic link. This problem affects all operating systems, it's not limited to macOS. But on macOS, the problem is especially serious, since macOS's /tmp is a link to /private/tmp by default. Thus, it causes an AssertionError in all the included Python examples.

$ python3
Python 3.11.3 (main, May  3 2023, 02:26:34) [GCC 12.2.0] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.path.realpath("/tmp")
'/private/tmp'
>>> os.chdir("/tmp")
>>> os.getcwd()
'/private/tmp'

Instead of doing assert os.getcwd() == sim_path, we should do assert os.getcwd() == os.path.realpath(sim_path) instead. I'll submit my patch in a Pull Request to fix this problem.

20%-30% Speedup Possible by Fixing Suboptimal Array Layout

I just investigated the performance of the current FDTD engine implementation, and I've identified two bottlenecks that are causing unnecessary slowdowns in simulations - at the same time, they're easy to fix without making any change to the algorithm.

  1. The N_3DArray_v4sf 4D array is allocated as multiple non-contiguous arrays linked by pointers, instead of a single array in linear memory. This is to allow pointers to the multi-dimension array to be accessed via the regular C syntax array[n][x][y][z]. But it comes with a high cost, each time the electric or magnetic field at a single point is accessed, the access must go through three layers of pointer dereferences before the actual data can be obtained. This problem is known as pointer chasing.

  2. X/Y/Z-axis of the E&M fields are stored as the first dimension of the 4D array. However, in a simulation, they're almost always accessed in rapid succession, as in array[0][a][b][c], array[1][a][b][c], array[2][a][b][c]. Each time a component of the field is accessed, it causes a large jump of memory location, as large as the entire size of the 3D space, producing many unnecessary cache misses.

A simple fix is available for both problems by changing the memory layout of the arrays. First, the array is flattened to a contiguous region in linear memory, all indirections are removed. Next, move the X/Y/Z components to the last dimension of the array, instead of the first dimension. So each access is consecutive as in n, n + 1, n + 2, allowing the CPU to do a better job at fetching them from memory.

This underlying memory change can also be made transparent to all the current code without rewriting them by C++ operator overloading.

Unfortunately, overloading multi-dimension array indexing, as in array[x][y][z] is not possible in C++. To solve this problem, most software libraries overloaded the operator () instead. So it means every single array access in the current code must be changed from array[n][x][y][z] to array(n, x, y, z) to allow both fixes. It's surely a tedious job, but it does not require modifying any equations, just a lot of keystrokes. And I think this change would be a worthwhile effort.

In my experiment, after these changes are made, I found there's a up-to-30% speedup in simulation speed. Please let me know if you have any comment about this proposed change, and if the project is willing to accept such a patch. Thanks.

libopenEMS.so.0.0.35 doesn't have a SONAME

====> Running Q/A tests (stage-qa)
Warning: /disk-samsung/freebsd-ports/science/openems/work/stage/usr/local/lib/libopenEMS.so.0.0.35 doesn't have a SONAME.
Warning: pkg(8) will not register it as being provided by the port.
Warning: If another port depend on it, pkg will not be able to know where it comes from.
Warning: It is directly in /usr/local/lib, it is probably used by other ports.

Trivial typo in python/README.md

The word 'python' is typed as 'pyhton' on about the 12 line of the above file. Probably more effort to create a pull request than just fix it!

Thanks,

Matt

Inconsistent Multi-thread Performance Especially on Many-Core Systems

During my performance testing, I've found the multi-threaded performance of openEMS is inconsistent. A performance degradation around 10% to 20% is common on desktops during "unlucky" runs, the probability of triggering it seems to be one per 5-10 test runs.

This inconsistency can be extreme on a many-core system, like a workstation or server with 16 cores or more. In one test run, I saw a performance variation about 1000% in the worst case scenario, jumping from 150 MC/s from a good run to 25 MC/s in a pathologically bad test run of MSL_Filter.py on a 64-core AWS virtual server with 10 threads.

I suspect the dynamic memory allocation of many small chunks, as I reported in #100, can be a possible reason, but I was still occasionally seeing the 10% to 20% performance variation even with my contiguous-memory patched applied, so there must be other factors.

My current hypotheses include:

  1. 2D arrays. I only patched the vectorized N_3DArray memory allocator, but openEMS still uses many dynamically allocated 2D arrays, which may have the same problem.
  2. Some kind of memory / cacheline alignment problem, only triggered when the offset is unlucky.
  3. Bad process scheduling by the operating system. Perhaps some process arrangement can be particularly bad, for example, if a core and a hyperthread are scheduled to processes with unrelated simulation domain, there would be a massive overhead. Similar problem can occur in a NUMA platform.

I'll continue to investigate this performance problem.

Help to run the examples for the first time

Hi, I am trying to learn this awesome tool. I am starting with the examples on matlab/examples/antennas
Then I am seeing this.

RunFDTD: Warning: Max. number of timesteps was reached before the end-criteria of -50dB was reached... 
	You may want to choose a higher number of max. timesteps... 
Time for 30000 iterations with 70004.00 cells : 131.53 sec
Speed: 15.97 MCells/s 
calculating far field at phi=[0 90] deg...
 ---------------------------------------------------------------------- 
 | nf2ff, near-field to far-field transformation for openEMS 
 | (C) 2012-2014 Thorsten Liebig <[email protected]>  GPL license
 ---------------------------------------------------------------------- 
warning: function "h5readatt_octave" not found, trying to run "setup"
warning: called from
    ReadHDF5Attribute at line 15 column 9
    ReadNF2FF at line 22 column 12
    CalcNF2FF at line 141 column 7
    Patch_Antenna at line 189 column 7
setting up openEMS matlab/octave interface
compiling oct files
HDF5 library path found at: /usr/lib/x86_64-linux-gnu/hdf5/serial
HDF5 include path found at: /usr/include/hdf5/serial
g++: error: h5readatt_octave.cc: No such file or directory
g++: fatal error: no input files
compilation terminated.
warning: mkoctfile: building exited with failure status
error: 'h5readatt_octave' undefined near line 22 column 19
error: called from
    ReadHDF5Attribute at line 22 column 10
    ReadNF2FF at line 22 column 12
    CalcNF2FF at line 141 column 7
    Patch_Antenna at line 189 column 7
warning: gh_manager::do_close_all_figures: some graphics elements failed to close.
make: *** [Makefile:31: Patch_Antenna] Error 1

Do you have any idea how to fix this?
I've installed openEMS from the OS package manager on Ubuntu 20.04.
And I am running the examples from the repo I cloned from the GitHub.

SIGSEGV for infinite dipole example

I just installed openEMS on Archlinux and tried to simulate using MATLAB. I tried to simulate the examples infDipol and Bent_Patch_Antenna and openEMS crashed with SIGSEGV.

I am using:

 ---------------------------------------------------------------------- 
 | openEMS 64bit -- version v0.0.35
 | (C) 2010-2016 Thorsten Liebig <[email protected]>  GPL license
 ---------------------------------------------------------------------- 
	Used external libraries:
		CSXCAD -- Version: v0.6.2
		hdf5   -- Version: 1.10.5
		          compiled against: HDF5 library version: 1.10.5
		tinyxml -- compiled against: 2.6.2
		fparser
		boost  -- compiled against: 1_69
		vtk -- Version: 8.2.0
		       compiled against: 8.2.0

and matlab R2019a.

I used valgrind to get a little bit more information:

==1546== Memcheck, a memory error detector
==1546== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==1546== Using Valgrind-3.14.0 and LibVEX; rerun with -h for copyright info
==1546== Command: openEMS tmp.xml
==1546== 
 ---------------------------------------------------------------------- 
 | openEMS 64bit -- version v0.0.35
 | (C) 2010-2016 Thorsten Liebig <[email protected]>  GPL license
 ---------------------------------------------------------------------- 
	Used external libraries:
		CSXCAD -- Version: v0.6.2
		hdf5   -- Version: 1.10.5
		          compiled against: HDF5 library version: 1.10.5
		tinyxml -- compiled against: 2.6.2
		fparser
		boost  -- compiled against: 1_69
		vtk -- Version: 8.2.0
		       compiled against: 8.2.0

==1546== 
==1546== Process terminating with default action of signal 11 (SIGSEGV): dumping core
==1546==  General Protection Fault
==1546==    at 0x4BB2054: uw_update_context_1 (unwind-dw2.c:1395)
==1546==    by 0x4BB2546: uw_init_context_1 (unwind-dw2.c:1607)
==1546==    by 0x4BB2EDA: _Unwind_Resume (unwind.inc:235)
==1546==    by 0x4906054: ??? (in /usr/lib/libopenEMS.so.0.0.35)
==1546==    by 0x1FFEFFFC6F: ???
==1546==    by 0x4: ???
==1546==    by 0x385F4C4D4F: ???
==1546==    by 0x4DBA16E: ParameterScalar::Evaluate() (in /usr/lib/libCSXCAD.so.0.6.2)
==1546==    by 0x3: ???
==1546==    by 0x78616D78: ???
==1546==    by 0x89490EAD3C466FF: ???
==1546==    by 0x1FFEFFFD2F: ???
==1546== 
==1546== HEAP SUMMARY:
==1546==     in use at exit: 443,038 bytes in 4,091 blocks
==1546==   total heap usage: 8,483 allocs, 4,392 frees, 1,062,770 bytes allocated
==1546== 
==1546== LEAK SUMMARY:
==1546==    definitely lost: 112 bytes in 1 blocks
==1546==    indirectly lost: 367 bytes in 4 blocks
==1546==      possibly lost: 0 bytes in 0 blocks
==1546==    still reachable: 442,559 bytes in 4,086 blocks
==1546==         suppressed: 0 bytes in 0 blocks
==1546== Rerun with --leak-check=full to see details of leaked memory
==1546== 
==1546== For counts of detected and suppressed errors, rerun with: -v
==1546== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
fish: “valgrind openEMS tmp.xml” terminated by signal SIGSEGV (Address boundary error)

If you need more information, feel free to ask.

clang-11 prints a lot of: warning: 'this' pointer cannot be null in well-defined C++ code; pointer may be assumed to always convert to true

/usr/local/include/CSXCAD/CSPrimitives.h:151:40: warning: 'this' pointer cannot be null in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
        CSPrimRotPoly* ToRotPoly() { return ( this && Type == ROTPOLY ) ? (CSPrimRotPoly*) this : 0; } /// Cast Primitive to a more defined type. Will return null if not of the requested type.
                                              ^~~~ ~~
  • there's no need to check if this!=nullptr.

error related to QVTK when building

using Linux mint 21.1 . Not sure what that translates too in ubuntu version, but relatively recent

/opt/openEMS-Project/QCSXCAD/QVTKStructure.cpp:23:12: fatal error: QVTKOpenGLStereoWidget.h: No such file or directory

In the installation instructions

Note: For later versions of Ubuntu you may have to choose a later version of vtk.

Not sure what that means so i installed vtk7 AND vtk9 just in case . Doesn't look like that worked.

edit:

aha, I forgot

libvtk9-qt-dev

success.

Field dumps with python interface

I'm trying to get an E-field dump that I can visualize with vtk. However, I'm having trouble getting this to work with python (worked fine whenever I did it with octave).

For example, if I run python Rect_Waveguide.py from the Tutorials folder, the simulation appears to run fine (I don't see any errors in the output, and both plots are generated), but I don't see any Et... files. The following should be the only lines necessary to create the dump files, right (not including the call to Run())?

Et = CSX.AddDump('Et', file_type=0, sub_sampling=[2,2,2])
start = [0, 0, 0];
stop  = [a, b, length];
Et.AddBox(start, stop);

RCS sphere tutorial issue

Hi guys,
in the RCS sphere tutorial, some math functions such as sin(x) and cos(x) are used.

k_dir = [cos(inc_angle), sin(inc_angle), 0] # plane wave direction
The parameter x should be in radiant as it is mentioned here. However, in the code implementation, these functions get an argument in degree which is false.
inc_angle = 0 #incident angle (to x-axis) in deg
Please note that exceptionally this example works, because 0 degree is equal to 0 radiant. If you choose any other angle you will get a wrong result. The correct implementation would be: k_dir = [cos(inc_angle*2*pi/360), sin(inc_angle*2*pi/360), 0] in the line 62.

Different far field results using TD and FD dump data

Hello,

I tried to use OpenEMS to simulate the far-field radiation of a metal plate. Following the RCS_Sphere tutorial, I invoked CreateNF2FFBox to define the dump planes and CalcNF2FF to calculate the far-field RCS.

However, specifying "frequency" in CreateNF2FFBox or not yields different RCS patterns, as shown in the figures below.
fd
td

By stepping in CreateNF2FFBox, I find that it dumps FD data when "frequency" is specified. Otherwise, it dumps TD data. Then, in CalcNF2FF, if only TD data is provided, it conducts an additional step to calculate the DFT of the TD data and obtain the steady-state frequency data. Then, the dumped FD data seems incorrect since its imagery components are almost zero. So I guess I made some mistakes in configuring the dump boxes. I have attached the code below (in MATLAB). Could you please help me debug the code? Thank you!

clear
clc

%% setup the simulation
physical_constants;
unit = 1e-3; % all length in mm

f0 = 60e9;
lambda = c0 ./ f0 / unit;
eps_r = 2.6;
lambda_eff = lambda ./ sqrt(eps_r);

ele.num = 21;
ele.length = lambda / 2;
gp.thick = 0.5;
gp.length = ele.length * ele.num;

theta_inc = 45;
phi_inc = 0;
k_inc = -[sind(theta_inc) * cosd(phi_inc), sind(theta_inc) * sind(phi_inc), cosd(theta_inc)];
e_inc = [-sind(phi_inc), cosd(phi_inc), 0]; % TE
% e_inc = [-cosd(phi_inc) * sind(theta_inc), -sind(phi_inc) * sind(theta_inc), cosd(theta_inc)] % TM

% size of simulation box
gap_sp_xy = lambda / 2;
gap_pb_xy = lambda / 2;
gap_sp_z = lambda / 2;
gap_pb_z = lambda / 2;
sim_xy = gp.length + gap_sp_xy * 2 + gap_pb_xy * 2;
sim_z = gp.thick + 2 * lambda_eff + gap_sp_z * 2 + gap_pb_z * 2;
offset_z = (2 * lambda_eff - gp.thick) / 2;

%% setup FDTD parameter & excitation function
fdtd = InitFDTD();
fdtd = SetSinusExcite(fdtd, f0);
bc = [3 3 3 3 3 3];
fdtd = SetBoundaryCond(fdtd, bc);

%% setup CSXCAD geometry & mesh
max_res = lambda / 10;
csx = InitCSX();

% create mesh
sm_xy = SmoothMeshLines([-sim_xy / 2, sim_xy / 2], max_res);
sm_z = SmoothMeshLines([offset_z - sim_z / 2, offset_z + sim_z / 2], max_res);
sim_mesh.x = sm_xy;
sim_mesh.y = sm_xy;
sim_mesh.z = sm_z;

%% create plate
csx = AddMetal(csx, 'groundplane');
gp_start = [-gp.length / 2, -gp.length / 2, -gp.thick];
gp_stop = [gp.length / 2, gp.length / 2, 0];
csx = AddBox(csx, 'groundplane', 10, gp_start, gp_stop);

%% plane wave excitation
csx = AddPlaneWaveExcite(csx, 'plane_wave', k_inc, e_inc, f0);
pw_start = [sim_mesh.x(1) + gap_pb_xy, sim_mesh.y(1) + gap_pb_xy, sim_mesh.z(1) + gap_pb_z];
pw_stop = [sim_mesh.x(end) - gap_pb_xy, sim_mesh.y(end) - gap_pb_xy, sim_mesh.z(end) - gap_pb_z];
csx = AddBox(csx, 'plane_wave', 0, pw_start, pw_stop);

%% dump boxes
start = [sim_mesh.x(1), sim_mesh.y(1), sim_mesh.z(1)];
stop  = [sim_mesh.x(end), sim_mesh.y(end), sim_mesh.z(end)];
[csx nf2ff] = CreateNF2FFBox(csx, 'nf2ff', start, stop);

% add 10 lines in all direction as pml spacing
sim_mesh = AddPML(sim_mesh, 10);

csx = DefineRectGrid(csx, unit, sim_mesh);

%% prepare simulation folder
sim_path = 'Plate';
sim_csx = 'Plate.xml';

[status, message, messageid] = rmdir(sim_path, 's'); % clear previous directory
[status, message, messageid] = mkdir(sim_path); % create empty simulation folder

%% write openEMS compatible xml-file
WriteOpenEMS([sim_path '/' sim_csx], fdtd, csx);

%% show the structure
CSXGeomPlot([sim_path '/' sim_csx]);

%% run openEMS
RunOpenEMS(sim_path, sim_csx);

%%
disp('Use Paraview to display the elctric fields dumped by openEMS');

%%
EF = ReadUI('et', sim_path, f0); % time domain/freq domain voltage
Pin = 0.5*norm(e_inc)^2/Z0 .* abs(EF.FD{1}.val).^2;

%%
nf2ff = CalcNF2FF(nf2ff, sim_path, f0, (0:2:90)*pi/180, (0:2:359)*pi/180, 'Mode',1);
RCS = 4*pi./Pin(1).*nf2ff.P_rad{1};
surf(0:2:359, 0:2:90, RCS);
hold on
grid on```

API version issue with HDF5

I'm seeing an API version issue with HDF5. For instance if I run the rectangular waveguide tutorial I see this output:

octave> source rect_waveguide.m 
args = "rect_wg.xml" 
 ---------------------------------------------------------------------- 
 | openEMS 64bit -- version v0.0.35-45-gde23172
 | (C) 2010-2018 Thorsten Liebig <[email protected]>  GPL license
 ---------------------------------------------------------------------- 
	Used external libraries:
		CSXCAD -- Version: v0.6.2-85-g55899d0
		hdf5   -- Version: 1.10.4
		          compiled against: HDF5 library version: 1.10.4
		tinyxml -- compiled against: 2.6.2
		fparser
		boost  -- compiled against: 1_69
		vtk -- Version: 8.1.2
		       compiled against: 8.1.2

Create FDTD operator (compressed SSE + multi-threading)
FDTD simulation size: 27x12x122 --> 39528 FDTD cells 
FDTD timestep is: 7.79642e-13 s; Nyquist rate: 24 timesteps @2.67217e+10 Hz
Excitation signal length is: 1225 timesteps (9.55062e-10s)
Max. number of timesteps: 10000 ( --> 8.16327 * Excitation signal length)
Create FDTD engine (compressed SSE + multi-threading)
Running FDTD engine... this may take a while... grab a cup of coffee?!?
[@        4s] Timestep:         3496 || Speed:   34.5 MC/s (1.144e-03 s/TS) || Energy: ~1.09e-30 (-81.26dB)
Time for 3496 iterations with 39528.00 cells : 4.00 sec
Speed: 34.54 MCells/s 
warning: legend: 'best' not yet implemented for location specifier, using 'northeast' instead
warning: legend: 'best' not yet implemented for location specifier, using 'northeast' instead
error: API version api-v52+ found in .oct file function 'h5readatt_octave'
       does not match the running Octave (API version api-v53)
       this can lead to incorrect results or other failures
       you can fix this problem by recompiling this .oct file
error: called from
    ReadHDF5Attribute at line 22 column 10
    ReadHDF5FieldData>ReadHDF5FieldData_octave at line 97 column 34
    ReadHDF5FieldData at line 29 column 19
    PlotHDF5FieldData at line 25 column 8
    rect_waveguide at line 121 column 1

I believe I have the latest master versions of both Octave and OpenEMS. Have you encountered this issue? I'm using Arch Linux.

Compile on Ubuntu 16.04 Fails

Attempting to compile OpenEMS on Ubuntu 16.04.10

cloned from github on 2019-08-08

Issue: AppCSXCAD doesn't compile
Suspect wrong or missing version of qt...

From the log file:
/usr/bin/ld: cannot find -lQt5::Core
/usr/bin/ld: cannot find -lQt5::Widgets
/usr/bin/ld: cannot find -lQt5::Xml

Needed to add these packages to get this far -- might be good to add to install instructions for 16.04
tcl-vtk
python-vtk
libvtk-java

Tried adding to the following to AppCSXCAD/CMakeLists.txt (both NEW and OLD):

if(POLICY CMP0028)
cmake_policy(SET CMP0028 NEW)
endif()

which changed error messages, but to no avail.

HERE FOLLOWS LOTS OF DATA THAT MIGHT BE RELEVANT

------------------- SYSTEM --------

Ubuntu 16.04.10

from /proc/version
Linux version 4.4.0-157-generic (buildd@lgw01-amd64-037)
(gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.10) )
#185-Ubuntu SMP Tue Jul 23 09:17:01 UTC 2019

------ LOADED PACKAGES (output below) ---------

sudo apt-get install
build-essential
cmake
git
libhdf5-dev
libvtk5-dev
libboost-all-dev
libcgal-dev
libtinyxml-dev
libqt4-dev
libvtk5-qt4-dev
octave
liboctave-dev
gengetopt
help2man
groff
pod2pdf
bison
flex
libhpdf-dev
libtool
libopenmpi-dev
paraview
octave
libcgal-qt5-dev
tcl-vtk
python-vtk
libvtk-java \

this fails

./update_openEMS.sh ~/opt/openEMS

this works

./update_openEMS.sh ~/opt/openEMS -disable-GUI

this fails

./update_openEMS.sh ~/opt/openEMS --with-hyp2mat --with-CTB --with-MPI

this works

./update_openEMS.sh ~/opt/openEMS --with-hyp2mat --with-CTB --with-MPI --disable-GUI

------------ FAILURE LOG RESULTS -- MANY VARIANTS OF THESE -----------------

CMake Warning (dev) at CMakeLists.txt:134 (ADD_EXECUTABLE):
Policy CMP0028 is not set: Double colon in target name means ALIAS or
IMPORTED target. Run "cmake --help-policy CMP0028" for policy details.
Use the cmake_policy command to set the policy and suppress this warning.

Target "AppCSXCAD" links to target "Qt5::Xml" but the target was not found.
Perhaps a find_package() call is missing for an IMPORTED target, or an
ALIAS target is missing?
This warning is for project developers. Use -Wno-dev to suppress it.

------------ FAILURE LOG RESULTS -- NEAR END OF LOG -----------------

-- Generating done
-- Build files have been written to: /tmp/tmp.mi1NWEQCsE/AppCSXCAD-prefix/src/AppCSXCAD-build
[ 75%] Performing build step for 'AppCSXCAD'
Scanning dependencies of target AppCSXCAD_automoc
[ 20%] Automatic moc for target AppCSXCAD
Generating moc_AppCSXCAD.cpp
[ 20%] Built target AppCSXCAD_automoc
Scanning dependencies of target AppCSXCAD
[ 40%] Building CXX object CMakeFiles/AppCSXCAD.dir/main.cpp.o
[ 60%] Building CXX object CMakeFiles/AppCSXCAD.dir/AppCSXCAD.cpp.o
[ 80%] Building CXX object CMakeFiles/AppCSXCAD.dir/AppCSXCAD_automoc.cpp.o
[100%] Linking CXX executable AppCSXCAD
/usr/bin/ld: cannot find -lQt5::Core
/usr/bin/ld: cannot find -lQt5::Widgets
/usr/bin/ld: cannot find -lQt5::Xml
collect2: error: ld returned 1 exit status
CMakeFiles/AppCSXCAD.dir/build.make:192: recipe for target 'AppCSXCAD' failed
... more fail, fail, fail

------------------ OUTPUT OF apt-get ABOVE (for version numbers) ---------------------

--- note:

--- cmake 3.5.1

--- qt4-dev 4.4.8.7

Reading package lists... Done
Building dependency tree
Reading state information... Done
bison is already the newest version (2:3.0.4.dfsg-1).
build-essential is already the newest version (12.1ubuntu2).
flex is already the newest version (2.6.0-11).
libqt4-dev is already the newest version (4:4.8.7+dfsg-5ubuntu2).
libtinyxml-dev is already the newest version (2.6.2-3).
libtool is already the newest version (2.4.6-0.1).
gengetopt is already the newest version (2.22.6+dfsg0-1).
groff is already the newest version (1.22.3-7).
help2man is already the newest version (1.47.3).
libboost-all-dev is already the newest version (1.58.0.1ubuntu1).
libcgal-dev is already the newest version (4.7-4).
libcgal-qt5-dev is already the newest version (4.7-4).
libhpdf-dev is already the newest version (2.2.1-1.1).
libopenmpi-dev is already the newest version (1.10.2-8ubuntu1).
libvtk-java is already the newest version (5.10.1+dfsg-2.1build1).
libvtk5-dev is already the newest version (5.10.1+dfsg-2.1build1).
libvtk5-qt4-dev is already the newest version (5.10.1+dfsg-2.1build1).
paraview is already the newest version (5.0.1+dfsg1-4).
pod2pdf is already the newest version (0.42-5).
python-vtk is already the newest version (5.10.1+dfsg-2.1build1).
tcl-vtk is already the newest version (5.10.1+dfsg-2.1build1).
cmake is already the newest version (3.5.1-1ubuntu3).
git is already the newest version (1:2.7.4-0ubuntu1.6).
libhdf5-dev is already the newest version (1.8.16+docs-4ubuntu1.1).
liboctave-dev is already the newest version (4.0.0-3ubuntu9.2).
octave is already the newest version (4.0.0-3ubuntu9.2).

MPI issue with python interface

I'm experiencing an openmpi issue when using the python interface. I'm getting the following error message:

Create FDTD operator (compressed SSE + multi-threading)
*** The MPI_Comm_size() function was called before MPI_INIT was invoked.
*** This is disallowed by the MPI standard.
*** Your MPI job will now abort.

This occurs when attempting to call FDTD.Run(). For instance, this happens if I run

$ python Simple_Patch_Antenna.py

where Simple_Patch_Antenna.py is from the openems python tutorials directory. I built openems with MPI support and mpirun is in PATH.

Have you encountered this? I haven't experienced any issues when using the matlab/octave interface.

plotRefl.m not Matlab compatible?

openEMS 64-bit v0.0.35 on Windows 10 with Matlab R2020b

Trying to run the patch antenna example (first time user). It fails with:

Error: File: plotRefl.m Line: 120 Column: 19
Indexing with parentheses '()' must appear as the last operation of a valid indexing expression.

Which corresponds to the following line:

llegend = num2str(port.f(lowerind)(1)/1e6, ffmt);

(And there are a few other lines in that file with similar syntax - the Matlab editor says Cannot call or index into a temporary array)

I think this syntax for cascaded indexing is only supported in Octave, not Matlab.

If I use temp variables to work around it, I then get:

Error using linspace (line 22)
Inputs must be scalars.

Which is from:

linspace(-ImZ, ImZ, 256)

Where ImZ = 0.0000 + 1.0000i 0.0000 + 2.0000i 0.0000 + 5.0000i 0.0000 + 2.0000i

Again, looks like this is something supported by Octave, but not Matlab.

Simulation end criteria

I have a simulation of a magnetic loop antenna where the end criteria of -50dB energy is sometimes reached prematurely (depending on parameters like excitation frequency). Looking at the dump of current density there are still plenty of current in the antenna structure at the end. I'm guessing the energy calculation is only based on total E fields, whereas this antenna can store most of its energy in the magnetic field at some time instants. Is it true that the energy calculation only looks at E fields?

Problem Registering on forum

Hello,
I have a problem registering on your forum. To finish the inscription I have to put the latest version of OpenEMS.
I put:
v6.0
................

But nothing worked for me.
Did anyone know the latest version. I want to connect and ask my questions.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.