Fix solver correctness and input-validation issues from code review
- Refuse the uniform contact model when the fills form multiple disconnected copper groups that each touch both terminals: the prescribed injection split is ill-posed and the grounded system was singular, silently returning garbage (e.g. negative gigaohms). connected_restrict now reports the component count; a power-balance backstop (SolverError) catches any other inconsistent solve. - Connect via/pad barrels to the nearest fill copper within the pad footprint (+1 cell) instead of only the exact center cell, so thermal-relief spokes still stitch layers; barrels that reach fill on fewer than two layers are warned about. ViaLink gains pad_nm (extracted from the padstack, JSON-roundtripped). - Validate dialog input on OK (layers, current > 0, cell > 0, parseable frequency, extra Cu >= 0) with an inline error instead of silently substituting defaults; parse_frequency raises on garbage; pipeline rejects i_test <= 0; choose_cell_size rejects non-positive overrides. - Warn when a contact part is dropped by the connectivity restriction; floor instead of truncate in cell_of; correct the uniform-model summary line; drop an unused variable; refresh plugin.json wording. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
+19
-2
@@ -3,9 +3,10 @@ import numpy as np
|
||||
import pytest
|
||||
|
||||
from fill_resistance import raster, solver
|
||||
from fill_resistance.errors import ElectrodeError
|
||||
from fill_resistance.errors import ConnectivityError, ElectrodeError
|
||||
from fill_resistance.geometry import Electrode
|
||||
from tests.util import NM, make_problem, rect_mm, sigma_s, strip_problem
|
||||
from tests.util import (NM, make_multilayer, make_problem, rect_mm, sigma_s,
|
||||
strip_problem)
|
||||
|
||||
|
||||
def _solve(problem, h_mm, model, i_test=1.0):
|
||||
@@ -161,6 +162,22 @@ def test_injection_area_partition_first_wins():
|
||||
assert total == pytest.approx(1.0, rel=1e-12)
|
||||
|
||||
|
||||
def test_uniform_multicomponent_raises():
|
||||
"""Two disconnected sheets that each touch both terminals: the
|
||||
uniform model would build a singular system (one ground cell, pure-
|
||||
Neumann second component) and previously returned garbage silently
|
||||
(e.g. negative gigaohms). It must refuse; equipotential handles it."""
|
||||
strip1 = [(0, 0), (10, 0), (10, 1), (0, 1)]
|
||||
strip2 = [(0, 0), (10, 0), (10, 2), (0, 2)] # asymmetric shares
|
||||
p = make_multilayer([[(strip1, [])], [(strip2, [])]],
|
||||
(0, 0, 1, 2), (9, 0, 10, 1)) # contact 'all', no vias
|
||||
with pytest.raises(ConnectivityError, match="disconnected"):
|
||||
_solve(p, 1.0, "uniform")
|
||||
res, _ = _solve(p, 1.0, "equipotential")
|
||||
assert np.isfinite(res.R_ohm) and res.R_ohm > 0
|
||||
assert res.power_balance_rel < 1e-9
|
||||
|
||||
|
||||
def test_touching_ok_uniform_error_equipotential():
|
||||
p = make_problem([([(0, 0), (10, 0), (10, 10), (0, 10)], [])],
|
||||
rect1_mm=(0, 0, 5, 10), rect2_mm=(5, 0, 10, 10))
|
||||
|
||||
Reference in New Issue
Block a user