kicad2ems.gui.volume3d¶
3D field views: a volume dump as a translucent voxel cloud over the board
(copper, vias, substrate), a plane dump as a coloured sheet in place, and the
far-field pattern as a surface over it, for the GUI's field panel (volumetab.py)
and its GIF / MP4 export. No Qt here: the arrays the OpenGL items take.
vol = Volume(src, frame) # one frame of a volume dump
# (fields.frames.DumpSource)
v, (origin, step) = vol.scalar('mag', phase)
# uniform grid (mm): |F| or |Re(F e^jphi)| or a component
rgba = colour(v, lo, hi, log=True) # (nx, ny, nz, 4) uint8: low values
# transparent
tris = copper_triangles(geometry)
# [(layer, z mm, vertices (n, 3), faces (m, 3))]
ps = solid_pieces(board) # the drawn solids as the solvers mesh
# them (core.solids.pieces)
for look, rgba, v, f in solid_meshes(ps, zs): ... # one mesh a look
The openEMS mesh is graded (fine at the copper, coarse in the air): the dump is
resampled onto a uniform grid of about `n` points along its longest side (OpenGL
volume textures are uniform), each axis linearly. A frequency-domain dump
animates over the phase, Re(F e^(j phi)): its magnitude shows the standing and
travelling waves; a time-domain one over its frames.
- class kicad2ems.gui.volume3d.Volume(src, frame, n=128, zfine=2.0)[source]¶
One frame of a volume dump on a uniform grid of about n points along its longest side (z refined by zfine: the substrate is thin). Complex for a frequency-domain dump.
- kicad2ems.gui.volume3d.board_box(geometry)[source]¶
(xmin, ymin, xmax, ymax, z0, z1) of the board outline and stack (model mm), or None.
- kicad2ems.gui.volume3d.colour(v, lo, hi, log=True, signed=False, opacity=0.6, gamma=1.5, cmap=None, floor=0.0)[source]¶
RGBA voxels (uint8): the colour map of v between lo and hi (log: magnitudes, decades below hi), alpha rising with the value (gamma > 1: the weak field fades out, the strong field stays visible through it). floor: the least of that rise (a map whose low end is not nothing: a temperature's coolest point is still the board). NaN (off the board) is clear.
- kicad2ems.gui.volume3d.component_solids(component, cu_z, zs=1.0, lift=0.0)[source]¶
Display-only package silhouette extruded by an approximate height; never a solver solid.
- kicad2ems.gui.volume3d.copper_outlines(geometry)[source]¶
Every copper ring as line segments at its layer's height: (2 k, 3) points (pairs), model mm.
- kicad2ems.gui.volume3d.copper_solids(geometry, thickness)[source]¶
The copper as slabs `thickness` mm thick (centred on each layer: shown thicker than it is, so that its edges catch the light): [(layer, z mm, vertices (n, 3), faces (m, 3))], faces wound with outward normals (top +z, bottom -z, walls away from the copper) for a shaded mesh. Whole layers at a time, as copper_triangles.
- kicad2ems.gui.volume3d.copper_triangles(geometry)[source]¶
The copper of dump_info.json's geometry as triangle meshes: [(layer, z mm, vertices (n, 3), faces (m, 3))], model mm (y up, as the dumps). Whole layers at a time (shapely's array functions): a large board's every net, one triangle at a time, took minutes and gigabytes in the window's own thread.
- kicad2ems.gui.volume3d.geometry_from_board(path)[source]¶
A <name>_board.json (or its content, Board.to_dict()) as the geometry the dumps carry (copper rings per layer, cu_z, vias, outline, thickness, model mm): the 3D view's board without a dump.
- kicad2ems.gui.volume3d.is_volume(src)[source]¶
Is a dump a volume (more than one point along every axis)?
- kicad2ems.gui.volume3d.levels(vals, signed, log, decades=2.5, clip=99.9, span=False)[source]¶
(lo, hi) of a set of frames: symmetric for a signed component, `decades` below the top for log. The top is the `clip` percentile of |values| (a port's gap, a few voxels, would otherwise take the whole colour range). span: the values' own smallest to largest (a temperature: from the coolest point, not from zero).
- kicad2ems.gui.volume3d.part_kind(p)[source]¶
A board.json part's colour key: 'C' with a capacitance, 'L' with an inductance, 'short' for a 0 ohm link, else 'R'.
- kicad2ems.gui.volume3d.part_solids(p, cu_z, zs=1.0, lift=0.0)[source]¶
A board.json part as its chip at true size (body L x W x H, along its pads' axis; the height scale zs places it on its layer but does not stretch it), standing on its copper (`lift` mm on screen above it: the copper's shown half thickness), below the board on the bottom layer: [(role 'body' | 'cap', rgb, vertices, faces)] for a shaded mesh, and the point above it for its label. None for a part without a body (older board.json).
- kicad2ems.gui.volume3d.pattern_mesh(sph, i, scale, centre, radius, range_db=30.0, cmap='jet')[source]¶
A far-field pattern as a coloured surface for the 3D view: the gain (sphere_gain at recorded frequency i, times scale) as the distance from `centre` (mm) in each direction, `radius` mm at the peak and 0 at range_db below it. Returns (vertices (n, 3), faces (m, 3), colours (n, 4) floats, peak dBi).
- kicad2ems.gui.volume3d.rings(geom)[source]¶
GeoJSON-like polygon / multipolygon -> [[outer, hole, ...], ...].
- kicad2ems.gui.volume3d.scalar_of(d, complex_, component='mag', phase=None)[source]¶
Volume.scalar of field values d (..., 3): also of a part of a volume's (its subsample).
- kicad2ems.gui.volume3d.solid_look(p)[source]¶
(look, rgba 0-1) of a core.solids Piece: its material's colour (a magnet's own, though it meshes as metal).
- kicad2ems.gui.volume3d.solid_meshes(pieces, zs=1.0, sheet=0.02)[source]¶
[(look, rgba, vertices, faces)]: the pieces extruded, one mesh a look (300 posts: one item, not 300), heights times zs (the view's height scale); a sheet of metal (no thickness) `sheet` mm thick on screen.