openEMS

class openEMS.openEMS

This class is the main control class for the FDTD options and setup and to run the final simulation.

Examples

>>> CSX = CSXCAD.ContinuousStructure()
>>>
>>> grid = CSX.GetGrid()
>>> grid.SetLines('x', np.arange(-50,50,1))
>>> grid.SetLines('y', np.arange(-50,50,1))
>>> grid.SetLines('z', np.arange(-2,2.1,1))
>>> grid.SetDeltaUnit(1e-3)
>>>
>>> FDTD = openEMS(NrTS=1e4, EndCriteria=1e-4)
>>>
>>> FDTD.SetCSX(CSX)
>>> FDTD.SetBoundaryCond(['PML_8', 'PML_8', 'PML_8', 'PML_8', 'PEC', 'PEC'])
>>> FDTD.SetGaussExcite(0, 10e9)
>>>
>>> FDTD.AddLumpedPort(port_nr=1, R=50, start=[10, 0, -2], stop=[10, 0, 2], p_dir='z', excite=1)
>>>
>>> FDTD.Run(sim_path='/tmp/test')
Parameters:
  • NrTS – max. number of timesteps to simulate (e.g. default=1e9)

  • EndCriteria – end criteria, e.g. 1e-5, simulations stops if energy has decayed by this value (<1e-4 is recommended, default=1e-5)

  • MaxTime – max. real time in seconds to simulate

  • OverSampling – nyquist oversampling of time domain dumps

  • CoordSystem – choose coordinate system (0 Cartesian, 1 Cylindrical)

  • MultiGrid – define a cylindrical sub-grid radius

  • TimeStep – force to use a given timestep (dangerous!)

  • TimeStepFactor – reduce the timestep by a given factor (>0 to <=1)

  • TimeStepMethod – 1 or 3 chose timestep method (1=CFL, 3=Rennigs (default))

  • CellConstantMaterial – set to 1 to assume a material is constant inside a cell (material probing in cell center)

AddEdges2Grid(primitives, dirs, **kw)

Add the edges of the given primitives to the FDTD grid.

Parameters:
  • dirs – primitives – one or more primitives

  • dirs – str – ‘x’,’y’,’z’ or ‘xy’, ‘yz’ or ‘xyz’ or ‘all’

AddLumpedPort(port_nr, R, start, stop, p_dir, excite=0, **kw)

Add a lumped port with the given values and location.

AddMSLPort(port_nr, metal_prop, start, stop, prop_dir, exc_dir, excite=0, **kw)

Add a microstrip transmission line port.

AddRectWaveGuidePort(port_nr, start, stop, p_dir, a, b, mode_name, excite=0, **kw)

Add a rectilinear waveguide port.

AddWaveGuidePort(self, port_nr, start, stop, p_dir, E_func, H_func, kc, excite=0, **kw)

Add a arbitrary waveguide port.

CreateNF2FFBox(name='nf2ff', start=None, stop=None, **kw)

Create a near-field to far-field box.

This method will automatically adept the recording box to the current FDTD grid and boundary conditions.

Notes

  • Make sure the mesh grid and all boundary conditions are finially defined.

GetCSX()
Run(sim_path, cleanup=False, setup_only=False, verbose=None)

Run the openEMS FDTD simulation.

Parameters:
  • sim_path – str – path to run in and create result data

  • cleanup – bool – remove existing sim_path to cleanup old results

  • setup_only – bool – only perform FDTD setup, do not run simulation

  • verbose – int – set the openEMS verbosity level 0..3

Additional keyword parameter: :param numThreads: int – set the number of threads (default 0 –> max)

SetAbort()
SetBoundaryCond(BC)

Set the boundary conditions for all six FDTD directions.

Options:

  • 0 or ‘PEC’ : perfect electric conductor (default)

  • 1 or ‘PMC’ : perfect magnetic conductor, useful for symmetries

  • 2 or ‘MUR’ : simple MUR absorbing boundary conditions

  • 3 or ‘PML-8’ : PML absorbing boundary conditions

Parameters:

BC – (8,) array or list – see options above

SetCSX(CSX)

Set the CSXCAD Continuous Structure for CAD data handling.

SetCellConstantMaterial(val)

Set cell material averaging to assume constant material inside each primary cell. (Advanced option)

Parameters:

val – bool – Enable or Disable (default disabled)

SetCoordSystem(val)

Set the coordinate system. 0 –> Cartesian (default), 1 –> cylindrical

SetCylinderCoords()

Enable use of cylindircal coordinates.

SetDiracExcite(f_max)

Set a dirac pulse as excitation signal.

Parameters:

f_max – float – maximum simulated frequency in Hz.

SetEndCriteria(val)

Set the end criteria value. E.g. 1e-6 for -60dB

SetGaussExcite(f0, fc)

Set a Gaussian pulse as excitation signal.

Parameters:
  • f0 – float – Center frequency in Hz.

  • fc – float – -20dB bandwidth in Hz.

SetMaxTime(val)

Set max simulation time for a max. number of timesteps.

SetMultiGrid(radii)

Define radii at which a cylindrical multi grid should be defined.

Parameters:

radii – array like, multigrid radii

SetNumberOfTimeSteps(val)

Set the number of timesteps. E.g. 5e4 (default is 1e9)

SetOverSampling(val)

Set the time domain signal oversampling as multiple of the Nyquist-rate.

SetSinusExcite(f0)

Set a sinusoidal signal as excitation signal.

Parameters:

f0 – float – frequency in Hz.

SetStepExcite(f_max)

Set a step function as excitation signal.

Parameters:

f_max – float – maximum simulated frequency in Hz.

SetTimeStep(val)

Set/force the timestep. (Advanced option)

It is highly recommended to not use this method! You may use the SetTimeStepFactor instead to reduce the time step if necessary!

SetTimeStepFactor(val)

Set a time step factor (>0..1) to increase FDTD stability.

Parameters:

val – float – >0..1

SetTimeStepMethod(val)

Set the time step calculation method. (Advanced option)

Options:

  • 1: CFL criteria

  • 3: Advanced Rennings criteria (default)

Parameters:

val – int – 1 or 3 (See above)

static WelcomeScreen()

Show the openEMS welcome screen.