axfluxmdo.solvers¶
Gmsh mesh export requires the [fea] extra; the GetDP runner needs the
external getdp binary (ONELAB bundle, or AXFLUXMDO_GETDP=/path/to/getdp).
axfluxmdo.solvers.gmsh_export ¶
Gmsh geometry and mesh export.
Two models:
- 2D unrolled (
build_linear_2d_model/export_mesh): the annulus unrolled at the mean radius into a linear-machine cross-section — one pole pair, x circumferential in [0, 2*tau_p], y axial with y=0 at the air-gap center. Solvable as planar magnetostatics by GetDP; the slotless variant places stator iron directly at +g/2 so the magnetic gap is exactlymotor.air_gap(the load line's circuit). The slotted variant opens winding slots so the Carter factor can be MEASURED. - 3D sector (
export_3d_sector): an OCC annular sector with rotor / magnet / gap / winding / stator volumes for visualization and downstream meshing credibility; no solver hookup.
gmsh is a process-global singleton: every session goes through
_gmsh_session (try/finally finalize), and all paths are resolved to
absolute before writing (gmsh writes CWD-relative otherwise). Mesh files are
written as MSH 2.2, the format GetDP handles best.
Linear2DLayout
dataclass
¶
Linear2DLayout(x_span_m: float, gap_midline_y_m: float, depth_m: float, pole_pitch_m: float, magnet_arc_ratio: float, slotted: bool, group_tags: dict[str, int], y_interfaces_m: dict[str, float])
Everything the GetDP template and the parser need to know about the mesh.
build_linear_2d_model ¶
build_linear_2d_model(motor: AxialFluxMotor, *, slotted: bool = False, n_pole_pairs_modeled: int = 1, airgap_layers: int = 4, mesh_size_factor: float = 1.0, slots_per_pole_pair: int | None = None) -> Linear2DLayout
Populate the CURRENT gmsh model with the unrolled cross-section.
Requires an active gmsh session (see export_mesh for the session-owning
wrapper). Returns the layout descriptor; the mesh is not yet generated.
Source code in src/axfluxmdo/solvers/gmsh_export.py
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 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 201 202 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 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | |
export_mesh ¶
export_mesh(motor: AxialFluxMotor, path: str | Path, *, geo_unrolled: bool = False, **build_kwargs) -> tuple[Path, Linear2DLayout]
Build the unrolled 2D model, mesh it, and write a .msh (MSH 2.2).
Source code in src/axfluxmdo/solvers/gmsh_export.py
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | |
export_3d_sector ¶
export_3d_sector(motor: AxialFluxMotor, path: str | Path, *, sector_poles: int = 1, mesh_size_factor: float = 1.0) -> Path
Export a 3D annular sector mesh (rotor/magnets/gap/winding/stator volumes).
Source code in src/axfluxmdo/solvers/gmsh_export.py
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 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 355 356 357 358 359 | |
axfluxmdo.solvers.getdp_runner ¶
GetDP solver orchestration.
GetDP (https://getdp.info) is an external binary, never a Python dependency.
Discovery order: the AXFLUXMDO_GETDP environment variable (must point at
an existing file — a set-but-wrong override fails loudly), then getdp on
PATH. All solver tests skip cleanly when the binary is absent.
SolverError ¶
Bases: RuntimeError
GetDP invocation failed; the message carries the output tail.
find_getdp ¶
find_getdp() -> str | None
Locate the getdp binary (env var override first, then PATH).
Source code in src/axfluxmdo/solvers/getdp_runner.py
33 34 35 36 37 38 39 40 41 | |
run_getdp ¶
run_getdp(pro_path: str | Path, msh_path: str | Path, *, resolution: str = 'Magnetostatics2D', post_operation: str = 'gap_field', table_filename: str = 'gap_field.dat', workdir: str | Path | None = None, timeout: float = 120.0) -> Path
Run getdp on a rendered .pro + .msh; return the output table path.
Source code in src/axfluxmdo/solvers/getdp_runner.py
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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | |
solve_open_circuit ¶
solve_open_circuit(motor: AxialFluxMotor, workdir: str | Path | None = None, *, slotted: bool = False, n_samples: int = 720, magnet_temp_c: float | None = None, mesh_size_factor: float = 1.0) -> GapFieldSolution
One-call pipeline: mesh export -> .pro render -> getdp -> parsed gap field.
magnet_temp_c defaults to ambient (25 C) + MAGNET_TEMP_RISE_C = 65 C — exactly the magnet temperature AnalyticalModel uses at the default operating point, so default residual comparisons are apples-to-apples.
Source code in src/axfluxmdo/solvers/getdp_runner.py
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 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | |
axfluxmdo.solvers.results_parser ¶
Parse GetDP output tables into gap-field solutions.
GapFieldSolution
dataclass
¶
GapFieldSolution(x_m: ndarray, by_t: ndarray, pole_pitch_m: float, magnet_arc_ratio: float, magnet_temp_c: float, slotted: bool)
Axial flux density sampled along the air-gap midline of the unrolled model.
mean_b_t
property
¶
mean_b_t: float
Mean |By| over the magnet-covered intervals only.
This is the load-line B_g semantics — flux density UNDER the
magnet — not the full-pitch mean (see mean_b_full_pitch_t).
fundamental_b1_t
property
¶
fundamental_b1_t: float
Amplitude of the spatial fundamental (period = one pole pair).
Trapezoid Fourier projection over the periodic span — robust to the duplicated x=0 / x=L endpoint that an OnLine sample produces (a naive FFT bin would double-count it).
from_table
classmethod
¶
from_table(path: str | Path, motor, *, magnet_temp_c: float, slotted: bool = False) -> GapFieldSolution
Build a solution from a (possibly committed golden) GetDP table.
Source code in src/axfluxmdo/solvers/results_parser.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
parse_table ¶
parse_table(path: str | Path) -> np.ndarray
Parse a GetDP Format Table line print of a 3-component vector field.
GetDP Table rows carry a variable number of leading metadata columns
(element type / index), but for a vector field printed OnLine the
TRAILING SIX columns are always x y z vx vy vz. Returns an (n, 6)
array of those columns, sorted by x. Sanity-checks that y and z are
constant (it was a line sample).
Source code in src/axfluxmdo/solvers/results_parser.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | |