Commit Graph

203 Commits

Author SHA1 Message Date
Yifeng Li
840c9755d5 Handle SIGINT for openEMS and Python, with graceful exit support.
Currently, openEMS doesn't have any special code to handle SIGINT (which
is raised by pressing Control-C). By default, the program is terminated
without saving data. This worked okay in the past, but now its
limitations are becoming obvious.

1. When openEMS is used as a Python module, Control-C stops working
because SIGINT is now managed by Python in order to generate
KeyboardInterrupt exceptions, normally this isn't a problem, but if
we are running an external C++ (Cython) function such as openEMS, the
Python interpreter mainloop has no control until we return. As a
result, SIGINT is received but never handled. In Cython, programs are
expected to call PyErr_CheckSignals() in its blocking loop periodically
to temporally transfer control back to Python to handle signals. But
this introduces a dependency of Cython in the FDTD mainloop.

2. During a simulation, it's not possible to abort it gracefully by
pressing Control-C, this is a limitation of openEMS itself, it's
always a force exit. Currently the only supported method for graceful
exit is creating a file called "ABORT" in the simulation directory.
If we already need to implement a signal handler, adding a graceful
exit at the same time would be a good idea.

This commit installs SIGINT handlers during SetupFDTD() and RunFDTD().

1. In RunFDTD(), if SIGINT is received once, a status flag is set, which
is then checked in CheckAbortCond(), allowing a graceful exit with the
same effect of an "ABORT" file. If SIGINT is received twice, openEMS
force exit without saving data (just like the old default behavior).

2. In SetupFDTD(), if SIGINT is received, openEMS immediately force
exit without saving data, identical to the old behavior. In a huge
simulation, initializing and compressing operators may have a long
time. so we want an early exit before RunFDTD().

3. Before RunFDTD() and SetupFDTD() return, the original signal handler
for SIGINT is restored. This is important since when we're acting as
a shared library. When a program (such as the Python interpreter) calls
us, changing the SIGINT handler unilaterally may overwrite the original
handler and affect the functionality of the original program. For
example, Python would never be able to raise KeyboardInterrupt again.
Thus, we save the original handler and restore it later.

Signed-off-by: Yifeng Li <tomli@tomli.me>
2023-11-18 12:32:44 +01:00
G. L
ee3f2b7d80
Lumped RLC parallel & series implementation (openEMS) (#121) 2023-11-18 12:23:15 +01:00
Thorsten Liebig
6673aefd70 engine: try to find optimal number of engine threads
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2023-01-06 20:01:07 +01:00
Thorsten Liebig
df7c58d961 info: update welcome screen
Signed-off-by: Thorsten Liebig <liebig@imst.de>
2022-12-30 17:18:53 +01:00
Thorsten Liebig
e52babccbf MSVC: fix for windows compiler
Signed-off-by: Thorsten Liebig <liebig@imst.de>
2022-12-29 13:08:44 +01:00
Georg Zachl
8c08cf5312 Expose sinusoidal, dirac pulse and step pulse excitation to the Python API. 2022-12-11 11:33:21 +01:00
luz paz
026f12355f Fix various typos
Found via `codespell -q 3 -L adress,imag`
2022-12-11 11:32:04 +01:00
Thorsten Liebig
d260025a6d numeric: make sure that LC_NUMERIC is set to en_US for function parser
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2022-05-31 20:09:43 +02:00
Thorsten Liebig
0e54fbf7ac core: fix probe handling
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2021-08-25 19:05:38 +02:00
Thorsten Liebig
de2317278b setup: parse MaxTime from xml, #44
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2019-02-13 19:26:27 +01:00
Thorsten Liebig
a5838df1e1 update welcome screen
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2018-03-27 20:44:44 +02:00
Thorsten Liebig
65ca6bfc44 python: add set number of threads interface
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2018-01-04 15:51:18 +01:00
Thorsten Liebig
6133dea5b0 add field processing for electric and magnetic flux densities
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2017-05-28 12:01:04 +02:00
Thorsten Liebig
21fab76679 add debug PEC and debug CSX to API
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2017-05-01 12:34:16 +02:00
Thorsten Liebig
ab682cc0bd A few fixes for MPI
main.cpp:
	1. 	Check return value of ParseFDTDSetup and exit if false
	2. 	Use exit instead of return. These are almost identical. But
		in my OpenMPI installation the process with teh highes rank
		segfaults at the end when using return. This is not the case
		with exit. Probably some C++ cleanup problem (destructors).
openems.cpp:
	Give Parse_XML_FDTDSetup a deterministic return value.
openems_fdtd_mpi.cpp:
	1.	Remove the word "only" in an error message because there can
		also be too many processes.
	2.	Fix the indexing variables for SetSplitPos in SetupMPI. Otherwise
		more than one split results in an out-of-range exception and
		unexpected behavior.
RunOpenEMS_MPI.m:
	Apply Settings.MPI.GlobalArgs also to multi-host scenarios.
2016-12-02 19:03:35 +01:00
Thorsten Liebig
765490d7a3 cricital bug fix for mode matching probes
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2016-11-15 20:13:18 +01:00
Thorsten Liebig
bb3e73f6bf fix default over sampling
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2016-07-30 22:04:15 +02:00
Thorsten Liebig
d75069cfef MPI: update for MPI usage
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2016-01-27 18:37:07 +01:00
Thorsten Liebig
18e21d5fa0 check and update CSXCAD during setup
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2015-12-30 14:17:56 +01:00
Thorsten Liebig
22093a6347 get BC type and PML size
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2015-12-30 14:17:40 +01:00
Thorsten Liebig
2572398482 move welcome screen and show usage to openEMS lib
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2015-12-19 15:38:21 +01:00
Thorsten Liebig
d439926992 openEMS: check if an excitation was defined
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2015-12-19 15:03:30 +01:00
Thorsten Liebig
e4ad3dba0f openEMS: set verbose level method
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2015-12-19 15:03:17 +01:00
Thorsten Liebig
ad02096df5 openEMS: simple interface to create a Gaussian pulse excitation
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2015-12-19 15:03:02 +01:00
Thorsten Liebig
205c1546f6 fix boundary conditions
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2015-12-15 22:13:54 +01:00
Thorsten Liebig
6140b07c47 main: more flexible FDTD setup
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2015-12-13 22:33:26 +01:00
Thorsten Liebig
38ff1ce28c improve default steady state probe positions
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2015-09-29 19:57:21 +02:00
Thorsten Liebig
9c80672855 excitation: store only 2 periods of periodic excitations
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2015-09-03 22:53:31 +02:00
Thorsten Liebig
f06cc293dc remove using namespace std from header files
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2015-06-18 21:45:22 +02:00
Thorsten Liebig
cd1db5d21b operator: new steady state detection operator extension
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2015-05-04 20:47:19 +02:00
Thorsten Liebig
988198f968 add start/stop time for probe and dump boxes
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2015-03-06 21:38:27 +01:00
Thorsten Liebig
865e817de7 bug fix: get max freq from xml to setup conducting sheet model
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2014-04-08 21:32:18 +02:00
Thorsten Liebig
6f6ed4feac critical fix: use new Operator->GetEngine for engine interface setup
Bug fix: engine interfaces for multigrids were using subgrid operator,
but main grid engine...

Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2014-01-06 16:08:13 +01:00
Thorsten Liebig
3fc2a41af9 operator: change how to average material to allow for overloaded cylindrical handling
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2013-12-28 21:02:49 +01:00
Thorsten Liebig
6892a0c589 support for multigrid level request of dump boxes
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2013-12-19 15:15:36 +01:00
Thorsten Liebig
ad7d3a5ca3 change in how the flag "CellConstantMaterial" is handled
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2013-08-23 17:29:10 +02:00
Thorsten Liebig
6c248efa3a SAR: use cell based conductivity in all cases (new default)
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2013-08-23 17:28:18 +02:00
Thorsten Liebig
a607bc6969 more options to setup SAR averaging method
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2013-05-15 16:02:30 +02:00
Thorsten Liebig
c65b5df785 typo: replace Operator_Ext_TFST with Operator_Ext_TFSF
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2013-04-12 16:07:39 +02:00
Thorsten Liebig
b8f1184071 remove old and unused split-field pml
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2013-04-12 14:26:26 +02:00
Thorsten Liebig
816553fc34 Operator: allow to choose time stepping method
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2013-03-27 11:58:24 +01:00
Thorsten Liebig
e113afb656 new: support debye dispersive material
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2013-03-19 14:02:06 +01:00
Thorsten Liebig
8d5043bd44 operator: alternative material averaging method
If constant cell material is activated, material probing is performed
only in the center of a primary cell.

This should improve and simplify SAR calculation if all materials
are assumed as constant within a primary YEE cell.

Usage from Matlab/Octave:
FDTD = InitFDTD('CellConstantMaterial',1);

Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2013-02-18 10:38:55 +01:00
Thorsten Liebig
01ada0cdb6 do not store averaged kappa for RAW-SAR dump
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2013-02-06 16:47:18 +01:00
Thorsten Liebig
944fd3c528 SAR fix missing conductivity storage
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2013-01-30 14:15:35 +01:00
Thorsten Liebig
3b44620278 current probes can be a point or line which allows for 1D/2D lumped ports
- this needs the new probe box interface in CSXCAD
- most tutorials have been updated

Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2013-01-22 09:22:01 +01:00
Thorsten Liebig
e6c0444985 CSXCAD: match recent version with split files for primitives and properties
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2012-12-03 13:59:39 +01:00
Thorsten Liebig
c536e1f344 process fields: new SAR calculation
todo: needs much testing and evaluation

Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2012-11-29 16:45:48 +01:00
Sebastian Held
f11b98ecf4 remove dependency on H5Cpp.h 2012-11-11 17:57:36 +01:00
Thorsten Liebig
d64e43a73c run post processing after final time evaluation
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2012-11-06 12:46:54 +01:00