axfluxmdo.viz¶
2D plotting is core (matplotlib); the 3D functions require the [viz3d]
extra (PyVista).
axfluxmdo.viz.geometry_plot ¶
2D geometry visualization: front view and axial cross-section.
plot_geometry ¶
plot_geometry(motor: AxialFluxMotor, view: str = 'both', show: bool = False) -> Figure
Plot the motor geometry.
view: "front" (magnet disk seen along the axis), "section" (r-z axial cross-section), or "both".
Source code in src/axfluxmdo/viz/geometry_plot.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | |
axfluxmdo.viz.fields ¶
Field/profile visualization: radial profiles and efficiency maps.
plot_radial_profiles ¶
plot_radial_profiles(result: AnnularResult, show: bool = False) -> Figure
2x2 grid of per-slice quantities vs radius from an AnnularResult.
Source code in src/axfluxmdo/viz/fields.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
plot_efficiency_map ¶
plot_efficiency_map(emap: EfficiencyMap, show: bool = False) -> Figure
Efficiency contours over the speed-torque plane; infeasible region greyed.
Source code in src/axfluxmdo/viz/fields.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |
plot_gap_field ¶
plot_gap_field(solution: GapFieldSolution, comparison: OpenCircuitComparison | None = None, show: bool = False) -> Figure
FEA air-gap field By(x) along the midline, with analytical overlays.
Source code in src/axfluxmdo/viz/fields.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | |
axfluxmdo.viz.pareto ¶
Pareto-front visualization.
plot_pareto ¶
plot_pareto(study: ParetoStudy, *, x: str = 'torque_density', y: str = 'efficiency', color: str | None = None, annotate_best: bool = False, show: bool = False) -> Figure
Scatter the Pareto front; axes accept aliases, to_dict keys, or design variables.
A three-objective study renders as x/y position plus the color channel.
Source code in src/axfluxmdo/viz/pareto.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |
axfluxmdo.viz.sensitivity ¶
Tornado chart for one-at-a-time design sensitivities.
plot_tornado ¶
plot_tornado(sens: SensitivityResult, *, show: bool = False) -> Figure
Horizontal diverging bars around the baseline output, largest swing on top.
Source code in src/axfluxmdo/viz/sensitivity.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
axfluxmdo.viz.bayesopt ¶
Bayesian-optimization visualization (matplotlib-only; sklearn objects arrive inside the study argument, so this module never imports sklearn).
plot_convergence ¶
plot_convergence(study: BOStudy, *, show: bool = False) -> Figure
Best-feasible-so-far trace vs evaluation index.
Source code in src/axfluxmdo/viz/bayesopt.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | |
plot_surrogate_slice ¶
plot_surrogate_slice(study: BOStudy, x_var: str, *, n: int = 100, show: bool = False) -> Figure
GP mean ± 2σ along one variable through the best design (the uncertainty view).
Other variables are frozen at best_x; evaluated points are projected
onto the slice axis at their true objective values, so points far from
the slice can sit away from the band — the band is the surrogate's
uncertainty ALONG THIS SLICE only.
Source code in src/axfluxmdo/viz/bayesopt.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
axfluxmdo.viz.pyvista_3d ¶
PyVista 3D assembly, static views, and animations (SPEC viz/pyvista_3d.py).
Every component is built from one primitive: a closed hexahedral annular
sector as a pv.StructuredGrid over a numpy (r, theta, z) vertex grid.
Full rings are 360-degree sectors; magnets, teeth, slots, and the cutaway
are partial sectors. Vertices lie exactly on the bounding circles (bounds
are exact) and the solids have meaningful .volume (tested against the
motor's analytic volume properties).
Conventions:
- Axial stack matches solvers/gmsh_export.py / Linear2DLayout with
the air-gap midline at z = 0.
- The optional cutaway wedge applies to STATOR-side parts only — cutting the
rotor would slice a moving part mid-animation.
- Animations are GIF-only (GitHub renders GIFs in READMEs; MP4 would pull in
the imageio-ffmpeg binary wheel for no documentation benefit).
This module imports pyvista at module level but is only reachable lazily
from axfluxmdo.viz (PEP 562) — the base package never imports VTK.
build_motor_assembly ¶
build_motor_assembly(motor: AxialFluxMotor, *, theta_cutaway_deg: float | None = 90.0, rotor_angle_rad: float = 0.0, theta_resolution_deg: float = 3.0) -> dict
Full-360° motor assembly as PyVista solids.
Returns a dict with stable keys: rotor_iron (StructuredGrid),
magnets (MultiBlock of 2p sectors), stator_teeth,
stator_coils, stator_yoke. The cutaway wedge (over
[0, theta_cutaway_deg]) removes STATOR-side material only.
Source code in src/axfluxmdo/viz/pyvista_3d.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | |
can_render
cached
¶
can_render() -> bool
Probe whether an off-screen VTK render is possible.
Run in a SUBPROCESS: without a usable GL context VTK can segfault rather than raise, and an in-process probe would take the caller down with it. On Linux without a display, try pyvista's xvfb helper first.
Source code in src/axfluxmdo/viz/pyvista_3d.py
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | |
plot_motor_3d ¶
plot_motor_3d(motor: AxialFluxMotor, *, theta_cutaway_deg: float | None = 90.0, show: bool = False, screenshot: str | Path | None = None, window_size: tuple[int, int] = (960, 720)) -> pv.Plotter
Static 3D view; returns the Plotter (the Figure analogue of this layer).
Source code in src/axfluxmdo/viz/pyvista_3d.py
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | |
animate_rotation ¶
animate_rotation(motor: AxialFluxMotor, path: str | Path, *, n_frames: int = 72, fps: int = 15, theta_cutaway_deg: float | None = 90.0, window_size: tuple[int, int] = (640, 480)) -> Path
One full mechanical revolution of the rotor over the (cutaway) stator.
Source code in src/axfluxmdo/viz/pyvista_3d.py
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 | |
animate_exploded ¶
animate_exploded(motor: AxialFluxMotor, path: str | Path, *, n_frames: int = 60, fps: int = 15, travel: float | None = None, window_size: tuple[int, int] = (640, 480)) -> Path
Components separate axially, hold, and reassemble (ease-in-out).
Source code in src/axfluxmdo/viz/pyvista_3d.py
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 | |