refactor(palace): consolidate MeshConfig/MeshResult, drop pipeline.py#115
Merged
refactor(palace): consolidate MeshConfig/MeshResult, drop pipeline.py#115
Conversation
Collapse two MeshConfig classes (pydantic in models/mesh.py + dataclass in mesh/pipeline.py) and two MeshResult classes into one each. base.py now calls the low-level generator.generate_mesh directly with pydantic MeshConfig fields; pipeline.py is deleted along with its dead MeshPreset enum, _MESH_PRESETS dict, and unused GroundPlane dataclass. Public surface: single MeshConfig (pydantic), MeshResult (dataclass), generate_mesh. The MeshConfigModel alias on gsim.palace is removed.
_build_mesh_config previously fell through to MeshConfig.default() for any preset string it didn't recognize, so preset="graded" silently gave you the default preset after #113 removed the graded option. Now raises ValueError on unknown names and handles "default" and None explicitly.
Symbol was removed in the MeshConfig consolidation; mkdocstrings fails on the dangling reference during docs build.
PalaceSimMixin.run() declared `-> dict[str, Path] | str`, but the registered palace result parser converts driven-sim output to SParams behind the scenes. Readers trusting the signature wrote `results['port-S.csv']` or `load_sparams(results)` and hit a TypeError. - Widen the mixin return to `SParams | dict[str, Path] | str` (honest union across the three solver subclasses). - Override `run()` on DrivenSim to narrow to `SParams | str`, with a runtime isinstance guard so the narrower type is enforced rather than type-ignored. - Fix stale `results['port-S.csv']` examples in base.py docstrings and the class-level examples in driven/eigenmode/electrostatic.
Pin the interactive legend to the right of the figure (x=1.02, top-left anchor) with a wider right margin and a vertical modebar, so long trace names no longer overlap the curves on narrow figures.
Post PRs #111/#114, sim.mesh(preset="default") silently rescaled refined_mesh_size to min(preset, min_feature/4) whenever the user did not pass it explicitly. On a realistic CPW-via geometry this drove cloud solve time from ~3.6 min to ~25 min while barely moving S-params. Cloud benchmarks showed the default path was ~7x slower than necessary and preset tiers were no longer honest speed/accuracy steps (auto-sizing collapsed all three onto the same mesh). - sim.mesh(auto_size: bool = False, cells_per_feature: int = 2): auto-sizing is now explicit opt-in; presets use their literal refined_mesh_size; cpf default drops 4 -> 2 (cpf=4 was over-refining typical CPWs to ~51k nodes; cpf=2 matches the fine preset at ~23k while still scaling small features). - When auto_size=False and a conductor feature may be under-resolved, emit a warning suggesting auto_size=True. - Log a post-mesh summary line: "Mesh: N nodes \u00b7 M tets \u00b7 refined=X um \u00b7 max=Y um". - Warn when node count > 75,000 so slow configs are visible before cloud submission. Tests updated: pass cells_per_feature=4 explicitly where intent needs it; the generic auto-size-fires test asserts the new cpf=2 value.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MeshConfigclasses (pydantic inmodels/mesh.py+ dataclass inmesh/pipeline.py) and twoMeshResultclasses into one each.base.pynow callsgenerator.generate_meshdirectly with pydanticMeshConfigfields.mesh/pipeline.pyalong with the orphanedMeshPresetenum,_MESH_PRESETSdict, and unusedGroundPlanedataclass left over from refactor(palace): drop graded preset and PEC refinement flag #113.MeshConfigModelalias ongsim.palace; singleMeshConfig(pydantic) is now the public API.Net: +31 / -308 lines.