kicad2ems.gfdtd.csx¶
CSXCAD-compatible geometry: the part of CSXCAD's Python API that openEMS scripts
(and kicad2ems's build_fdtd) use, and CSXCAD's XML format both ways, so a model
built for openEMS can be built, written, read and run here.
CSX = ContinuousStructure()
grid = CSX.GetGrid(); grid.SetDeltaUnit(1e-3); grid.SetLines('x', [...])
CSX.AddMaterial('FR4', epsilon=4.3, kappa=0.01).AddLinPoly([xs, ys], 'z',
0.0, 1.6, priority=1)
CSX.AddMetal('cu').AddPolygon([xs, ys], 'z', 1.6, priority=10)
CSX.Write2XML('model.xml'); CSX2 = ContinuousStructure();
CSX2.ReadFromXML('model.xml')
Properties: Material, DebyeMaterial, Metal, ConductingSheet, LumpedElement,
Excitation (with weight functions or a mode file), ProbeBox (with mode functions
or a mode file), DumpBox (and LorentzMaterial, read with its static epsilon).
Primitives: Box, Polygon, LinPoly, RotPoly, Cylinder, CylindricalShell, Sphere,
SphericalShell, Curve (any of them with a transform: CSTransform). Anything
else in a file read here is kept out of the model and listed in `CSX.skipped`.
Weight and mode functions are CSXCAD's function-parser expressions in x, y, z,
rho, a, r, t (drawing units, from the weight origin): evaluate(expr, coords)
runs them on numpy arrays.
- class kicad2ems.gfdtd.csx.CSRectGrid[source]¶
Rectilinear grid: mesh lines per axis in drawing units, DeltaUnit metres per drawing unit.
- GetLine(d, idx)[source]¶
Line idx (sorted, unique; a negative idx counts from the end) as CSXCAD's: IndexError out of range.
- SmoothMeshLines(d, max_res, ratio=1.5, check_symmetry=True)[source]¶
The lines in direction d ('all': every one) smoothed to steps of max_res at most, growing by `ratio` at most: CSXCAD's own function (smooth.py), so openEMS's scripts get the lines openEMS would.
- class kicad2ems.gfdtd.csx.CSTransform[source]¶
An affine transform of a primitive, as CSXCAD's: transforms added after the earlier ones (post-multiplied: the last added applies last), angles in degrees unless deg=False; Transform(coord) maps a primitive's own coordinates to the model's, invers=True back.
- class kicad2ems.gfdtd.csx.ConductingSheet(name, conductivity=0.0, thickness=0.0, roughness=0.0, finish=(), finish_share=1.0, face=False, **kw)[source]¶
- class kicad2ems.gfdtd.csx.Curve(prop, points, priority=0)[source]¶
A polyline (points: [xs, ys, zs], as CSXCAD's): a wire along the mesh edges nearest to it in metals and excitations.
- class kicad2ems.gfdtd.csx.CylindricalShell(prop, start, stop, radius, shell_width, priority=0)[source]¶
The points whose distance from the axis start -> stop is within shell_width / 2 of radius.
- class kicad2ems.gfdtd.csx.DebyeMaterial(name, order=0, **kw)[source]¶
epsilon(w) = epsilon + sum over the poles of eps_delta / (1 + j w eps_relax), and kappa: openEMS's CSPropDebyeMaterial (epsilon is the value at infinite frequency).
- class kicad2ems.gfdtd.csx.DumpBox(name, dump_type=0, dump_mode=1, file_type=0, frequency=None, sub_sampling=None, **kw)[source]¶
A field dump over its box, as openEMS's: dump_type 0 E, 1 H, 2 conduction current density, 3 total current density (rot H); 10-13 the same in the frequency domain at `frequency` (Hz). file_type 0 VTK, 1 HDF5; dump_mode 0 at the nodes, 2 at the cell centres (interpolated). sub_sampling: every n-th time sample.
- class kicad2ems.gfdtd.csx.Excitation(name, exc_type=0, exc_val=(0, 0, 0), delay=0.0, number=0, **kw)[source]¶
exc_type 0: soft E field (added to the edges in its primitives), 1: hard E field (the edges set to it), 2: soft H field, 3: hard H field; exc_val: the E (V/m) or H (A/m) vector, times the excitation signal, delay seconds late. A weight function per component (SetWeightFunction, in x, y, z, rho, a, r, t from SetWeightOrigin) or a mode file (SetWeightFile, with SetPropagationDir) scales it across the primitives.
- class kicad2ems.gfdtd.csx.FerriteMaterial(name, ms=0.0, alpha=0.0, gamma=221280.0, bias=0.0, freq=0.0, scheme='faces', **kw)[source]¶
gfdtd's, beyond openEMS: a magnetised microwave ferrite, its permeability the Polder tensor of the linearised Landau-Lifshitz-Gilbert equation about each cell's static magnetisation (gfdtd.operator._ferrite: the magnetisation at the cell centres, the trapezoidal rule). epsilon and kappa as a Material's; ms the saturation magnetisation (A/m); alpha Gilbert's damping; gamma the gyromagnetic ratio times mu0 (rad/s per A/m: 2.21e5 at g = 2); bias the internal static field (A/m), the ferrite saturated along it: one value along z (negative: along -z), one vector (hx, hy, hz), or a table dict(x, y, z: the lines (drawing units), hz and optionally hx, hy: (len x, len y, len z) A/m, and optionally mx, my, mz: M / Ms, its direction and how far it is magnetised) read at each cell's centre (nearest point). Where m is given and |m| < 1 the cell is partly magnetised (Green and Sandy's mu at freq, Hz: the band centre, and Rado's kappa; its h unused); NaN: left unbiased (a dielectric of mu 1).
- class kicad2ems.gfdtd.csx.LinPoly(prop, points, norm_dir, elevation, length, priority=0)[source]¶
A polygon extruded from `elevation` by `length` along norm_dir.
- class kicad2ems.gfdtd.csx.LumpedElement(name, ny, caps=True, R=None, C=None, L=None, LEtype=0, **kw)[source]¶
R / L / C between the faces of its box along `ny`; LEtype 0 parallel, 1 series. caps: metal end caps.
- class kicad2ems.gfdtd.csx.Polygon(prop, points, norm_dir, elevation, priority=0)[source]¶
A flat polygon at `elevation` normal to `norm_dir`; points = [coords of the first in-plane axis, of the second] (in-plane axes in xyz order without norm_dir).
- class kicad2ems.gfdtd.csx.ProbeBox(name, p_type=0, weight=1.0, norm_dir=-1, mode_function=None, frequency=None, **kw)[source]¶
p_type 0: voltage (the E integral from start to stop), 1: current (the H loop around the box, normal norm_dir), 10 / 11: voltage / current mode matching (the transverse E / H on the box's plane against a mode function or mode file, as openEMS's waveguide ports); the probe's value is multiplied by weight. Written to a file of its name.
- class kicad2ems.gfdtd.csx.Property(name, **attrs)[source]¶
A CSXCAD property: its type (the XML tag), name, attributes and primitives.
- class kicad2ems.gfdtd.csx.RotPoly(prop, points, norm_dir, rot_axis, angle=(0, 6.283185307179586), priority=0)[source]¶
A polygon (in the plane normal to norm_dir, its points CSXCAD's X1, X2: the axes after norm_dir, cyclic) turned about rot_axis (one of those two) from angle[0] to angle[1] (rad): a body of revolution, as CSXCAD's RotPoly (its elevation 0).
- class kicad2ems.gfdtd.csx.Sphere(prop, center, radius, priority=0)[source]¶
The points within radius of center.
- class kicad2ems.gfdtd.csx.SphericalShell(prop, center, radius, shell_width, priority=0)[source]¶
The points whose distance from center is within shell_width / 2 of radius.
- kicad2ems.gfdtd.csx.evaluate(expr, coords)[source]¶
A weight / mode function on arrays: coords = (x, y, z) relative to its origin (drawing units). Returns an array broadcast to the coordinates; nan and inf become 0, as openEMS's mode matching does.
- kicad2ems.gfdtd.csx.evaluate_signal(expr, t)[source]¶
openEMS's custom excitation (SetCustomExcite): its expression of t (seconds), in CSXCAD's syntax, at the times t.
- kicad2ems.gfdtd.csx.mode_file_values(data, u, v)[source]¶
(Vx, Vy) of a mode file bilinearly interpolated at (u, v), clamped to its grid (CSModeData::LinInterp2).