Skip to content

refactor(palace): consolidate MeshConfig/MeshResult, drop pipeline.py#115

Merged
vvahidd merged 7 commits intomainfrom
refactor/consolidate-mesh-config
Apr 18, 2026
Merged

refactor(palace): consolidate MeshConfig/MeshResult, drop pipeline.py#115
vvahidd merged 7 commits intomainfrom
refactor/consolidate-mesh-config

Conversation

@vvahidd
Copy link
Copy Markdown
Contributor

@vvahidd vvahidd commented Apr 17, 2026

Summary

  • 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 generator.generate_mesh directly with pydantic MeshConfig fields.
  • Delete mesh/pipeline.py along with the orphaned MeshPreset enum, _MESH_PRESETS dict, and unused GroundPlane dataclass left over from refactor(palace): drop graded preset and PEC refinement flag #113.
  • Remove the MeshConfigModel alias on gsim.palace; single MeshConfig (pydantic) is now the public API.

Net: +31 / -308 lines.

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.
vvahidd added 2 commits April 17, 2026 22:04
_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.
@github-actions github-actions bot added the documentation Improvements or additions to documentation label Apr 17, 2026
vvahidd added 4 commits April 18, 2026 12:21
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.
@vvahidd vvahidd merged commit a2c0033 into main Apr 18, 2026
5 checks passed
@vvahidd vvahidd deleted the refactor/consolidate-mesh-config branch April 18, 2026 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant