I am running openEMS on Python 3.11.9. My OS is Windows 11 Enterprise. When I run the following code, adapted from this tutorial, I get the results shown below the code. The file containing the invalid float is port_it_0, and it is copied below the output. The program also does not write the xml file rect_wg.xml
Code
import os, tempfile
from pylab import *
# Add dll folder to trusted locations
dll_directory = 'C:\\Users\\KyleBeatty\\Downloads\\openEMS_v0.0.36\\openEMS\\python'
os.add_dll_directory(dll_directory)
from CSXCAD import ContinuousStructure
from openEMS import openEMS
from openEMS.physical_constants import *
now = datetime.datetime.now()
now_string = now.strftime('%m-%d_%H-%M')
Sim_Path = os.path.join(os.getcwd(), 'Rect_WGi_{}'.format(now_string))
post_proc_only = False
unit = 1e-6
a = 10700
b = 4300
length = 50000
f_start = 20e9
f_0 = 24e9
f_stop = 26e9
lambda0 = C0/f_0/unit;
TE_mode = 'TE10'
mesh_res = lambda0 / 30
FDTD = openEMS(NrTS=1e4)
FDTD.SetGaussExcite(0.5 * (f_start+f_stop), 0.5 * (f_stop-f_start))
FDTD.SetBoundaryCond([0, 0, 0, 0, 3, 3])
# set up geometry and mesh
CSX = ContinuousStructure()
FDTD.SetCSX(CSX)
mesh = CSX.GetGrid()
mesh.SetDeltaUnit(unit)
mesh.AddLine('x', [0, a])
mesh.AddLine('y', [0, b])
mesh.AddLine('z', [0, length])
# apply the waveguide port
ports = []
start = [0, 0, 10*mesh_res]
stop = [a, b, 15 * mesh_res]
mesh.AddLine('z', [start[2], stop[2]])
ports.append(FDTD.AddRectWaveGuidePort(0, start, stop, 'z', a*unit, b*unit, TE_mode, 1))
start = [0, 0, length- 10*mesh_res]
stop = [a, b, length - 15 * mesh_res]
mesh.AddLine('z', [start[2], stop[2]])
ports.append(FDTD.AddRectWaveGuidePort(0, start, stop, 'z', a*unit, b*unit, TE_mode))
mesh.SmoothMeshLines('all', mesh_res, ratio=1.4)
# Define dump box
Et = CSX.AddDump('Et', file_type=0, sub_sampling=[2, 2, 2])
start = [0, 0, 0]
stop = [a, b, length]
Et.AddBox(start, stop)
# Run simulation
if True: # debugging only
CSX_file = os.path.join(Sim_Path, 'rect_wg.xml')
if not os.path.exists(Sim_Path):
os.mkdir(Sim_Path)
print('writing to xml')
CSX.Write2XML(CSX_file)
print('written to xml')
#from CSXCAD import AppCSXCAD_BIN
#os.system(AppCSXCAD_BIN + ' "{}"'.format(CSX_file))
if not post_proc_only:
FDTD.Run(Sim_Path, cleanup=True)
# post-processing and plotting
freq = linspace(f_start, f_stop, 201)
for port in ports:
#print('{} {}'.format(Sim_Path, freq))
port.CalcPort(Sim_Path, freq)
Output
writing to xml
written to xml
----------------------------------------------------------------------
| openEMS 64bit -- version v0.0.36
| (C) 2010-2023 Thorsten Liebig <thorsten.liebig@gmx.de> GPL license
----------------------------------------------------------------------
Used external libraries:
CSXCAD -- Version: v0.6.3
hdf5 -- Version: 1.12.0
compiled against: HDF5 library version: 1.12.0
tinyxml -- compiled against: 2.6.2
fparser
boost -- compiled against: 1_72
vtk -- Version: 8.2.0
compiled against: 8.2.0
Create FDTD operator (compressed SSE + multi-threading)
FDTD simulation size: 27x12x132 --> 42768 FDTD cells
FDTD timestep is: 5.18459e-13 s; Nyquist rate: 37 timesteps @2.60648e+10 Hz
Excitation signal length is: 1842 timesteps (9.55001e-10s)
Max. number of timesteps: 10000 ( --> 5.42888 * 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: 3546 || Speed: 37.9 MC/s (1.129e-03 s/TS) || Energy: ~2.14e-30 (-81.53dB)
Time for 3546 iterations with 42768.00 cells : 4.01 sec
Speed: 37.86 MCells/s
file: C:\Users\KyleBeatty\python\mwe\Rect_WGi_06-17_13-09\port_ut_0
file: C:\Users\KyleBeatty\python\mwe\Rect_WGi_06-17_13-09\port_it_0
Traceback (most recent call last):
File "C:\Users\KyleBeatty\python\mwe\script.py", line 91, in <module>
port.CalcPort(Sim_Path, freq)
File "C:\Users\KyleBeatty\AppData\Local\Programs\Python\Python311\Lib\site-packages\openEMS\ports.py", line 379, in CalcPort
super(WaveguidePort, self).CalcPort(sim_path, freq, ref_impedance, ref_plane_shift, signal_type)
File "C:\Users\KyleBeatty\AppData\Local\Programs\Python\Python311\Lib\site-packages\openEMS\ports.py", line 105, in CalcPort
self.ReadUIData(sim_path, freq, signal_type)
File "C:\Users\KyleBeatty\AppData\Local\Programs\Python\Python311\Lib\site-packages\openEMS\ports.py", line 96, in ReadUIData
self.i_data = UI_data(self.I_filenames, sim_path, freq, signal_type )
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\KyleBeatty\AppData\Local\Programs\Python\Python311\Lib\site-packages\openEMS\ports.py", line 44, in __init__
tmp = np.loadtxt(os.path.join(path, fn),comments='%')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\KyleBeatty\AppData\Local\Programs\Python\Python311\Lib\site-packages\numpy\lib\npyio.py", line 1373, in loadtxt
arr = _read(fname, dtype=dtype, comment=comment, delimiter=delimiter,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\KyleBeatty\AppData\Local\Programs\Python\Python311\Lib\site-packages\numpy\lib\npyio.py", line 1016, in _read
arr = _load_from_filelike(
^^^^^^^^^^^^^^^^^^^^
ValueError: could not convert string '-04.4.92535963379e-12' to float64 at row 0, column 3.
I think the problem is that you re-used the same port number. Ideally this should be allowed, but currently this seems to be broken. Just avoid this, this is usually not what you want...
I am running openEMS on Python 3.11.9. My OS is Windows 11 Enterprise. When I run the following code, adapted from this tutorial, I get the results shown below the code. The file containing the invalid float is
port_it_0
, and it is copied below the output. The program also does not write the xml filerect_wg.xml
Code
Output
port_it_0