← Commit history

Merge PR #538: Lead cooling: two equal power bars are leads, not an exposed pad; a split exposed pad is one pad (fix/lead-cooling-equal-bars -> main) merge

Colby Knox ·478e66272c · ·parents a8d780b, 1d4f34b

Showing changes introduced by the merge (against its first parent).

2 files changed +48−8
crates/aiflow-analyze/src/lead_cooling.rs+47−7
@@ -48,19 +48,33 @@ pub fn preliminary(reference: &str, h: &Value) -> Value { }  /// Refuse lead cooling for a part that has an exposed pad: its heat goes into that pad's net.-/// Two-terminal parts are their leads; with three or more pads, one pad at least three times the-/// median of the others is a tab.+/// Two-terminal parts are their leads; with three or more pads, the one largest pad is a tab when it+/// is at least three times the median of the others. The lands of one pad number (a split exposed+/// pad, an exposed pad with its via pads) count as one pad. Two or more pads of about the same size+/// at the top (the next under 80 % of the largest is not reached) are not a tab: they are power leads,+/// and the heat leaves through each of them (an eFuse with an IN bar and an OUT bar, a dual part with a+/// pad per die), which one tabNet cannot describe; the Fields solve judges such a part through its leads. pub fn check_footprint(b: &Board, reference: &str) -> Result<(), String> {     let pads: Vec<_> = b.pads.iter().filter(|p| p.reference == reference).collect();     if pads.is_empty() { return Err(format!("{reference} (cooling \"leads\") has no pads on the board")); }-    if pads.len() < 3 { return Ok(()); }     let area = |p: &aiflow_board::Pad| p.size.0 * p.size.1;-    let big = pads.iter().copied().max_by(|a, z| area(a).total_cmp(&area(z))).unwrap();-    let mut rest: Vec<f64> = pads.iter().filter(|p| !std::ptr::eq(**p, big)).map(|p| area(p)).collect();+    // (number, net, area): the lands of one numbered pad summed+    let mut groups: Vec<(String, String, f64)> = Vec::new();+    for p in &pads {+        match groups.iter_mut().find(|g| !p.name.is_empty() && g.0 == p.name) {+            Some(g) => g.2 += area(p),+            None => groups.push((p.name.clone(), p.net.clone(), area(p))),+        }+    }+    if groups.len() < 3 { return Ok(()); }+    groups.sort_by(|a, z| z.2.total_cmp(&a.2));+    let (big, second) = (&groups[0], groups[1].2);+    if second >= 0.8 * big.2 { return Ok(()); }+    let mut rest: Vec<f64> = groups[1..].iter().map(|g| g.2).collect();     rest.sort_by(f64::total_cmp);     let median = rest[rest.len() / 2];-    if area(big) >= 3.0 * median {-        return Err(format!("{reference} has an exposed pad ({} on {}, {:.2} mm2 against {:.2} mm2 for its leads): declare tabNet {} instead of cooling \"leads\"", big.name, if big.net.is_empty() { "no net" } else { big.net.as_str() }, area(big), median, if big.net.is_empty() { "<its net>" } else { big.net.as_str() }));+    if big.2 >= 3.0 * median {+        return Err(format!("{reference} has an exposed pad ({} on {}, {:.2} mm2 against {:.2} mm2 for its leads): declare tabNet {} instead of cooling \"leads\"", big.0, if big.1.is_empty() { "no net" } else { big.1.as_str() }, big.2, median, if big.1.is_empty() { "<its net>" } else { big.1.as_str() }));     }     Ok(()) }@@ -135,4 +149,30 @@ mod tests {         assert!(e.contains("exposed pad") && e.contains("GND"), "{e}");         assert!(check_footprint(&board(leads), "U9").is_err());     }++    /// Eight small signal pins along one edge (as on a 2 x 3 mm VQFN), net GND.+    fn small_pins() -> String {+        (0..8).map(|i| format!("(pad \"{}\" smd rect (at {} -1.5) (size 0.25 0.6) (layers \"F.Cu\") (net 1 \"GND\")) ", i + 10, i as f64 * 0.4 - 1.4)).collect()+    }++    #[test]+    fn two_equal_power_bars_are_leads_not_an_exposed_pad() {+        // an eFuse in a VQFN-HR: an IN bar and an OUT bar of the same size, on two nets, and eight small pins.+        // A tabNet would put all the watts into one bar; half of it leaves through the other.+        let bars = format!("{} (pad \"5\" smd rect (at -0.25 0.5) (size 0.29 2.4) (layers \"F.Cu\") (net 2 \"A\")) (pad \"6\" smd rect (at 0.25 0.5) (size 0.29 2.4) (layers \"F.Cu\") (net 1 \"GND\"))", small_pins());+        assert!(check_footprint(&board(&bars), "U1").is_ok());+        // one bar clearly the largest is still an exposed pad+        let unequal = format!("{} (pad \"5\" smd rect (at -0.25 0.5) (size 0.29 2.4) (layers \"F.Cu\") (net 2 \"A\")) (pad \"6\" smd rect (at 0.6 0.5) (size 0.6 2.4) (layers \"F.Cu\") (net 1 \"GND\"))", small_pins());+        let e = check_footprint(&board(&unequal), "U1").unwrap_err();+        assert!(e.contains("exposed pad (6 on GND"), "{e}");+    }++    #[test]+    fn a_split_exposed_pad_is_one_pad() {+        // an exposed pad drawn as four equal lands with one number (and a via pad) is one tab, not four leads+        let quads: String = [(-0.6, -0.6), (0.6, -0.6), (-0.6, 0.6), (0.6, 0.6)].iter().map(|(x, y)| format!("(pad \"17\" smd rect (at {x} {y}) (size 1.0 1.0) (layers \"F.Cu\") (net 1 \"GND\")) ")).collect();+        let split = format!("{}{quads}(pad \"17\" thru_hole circle (at 0 0) (size 0.5 0.5) (drill 0.3) (layers \"*.Cu\") (net 1 \"GND\"))", small_pins());+        let e = check_footprint(&board(&split), "U1").unwrap_err();+        assert!(e.contains("exposed pad (17 on GND") && e.contains("declare tabNet GND"), "{e}");+    } }
docs/lead-cooled-parts.md+1−1
@@ -18,5 +18,5 @@ Most parts that warm up have no exposed tab: LEDs, inductors, small leaded ICs. - **Junction limit:** a `tjMaxC` on a lead-cooled part needs `thetaJcKPerW` (the datasheet's junction-to-board figure for the package) and `thetaSource`. The screen then checks ambient (`ambientC`, default 25 C) plus the solved rise plus thetaJcKPerW times watts against it. - **Refused:**   - an explicit `cooling: "leads"` together with a `tabNet`, a `tabPad` or `packageCooling`;-  - a footprint with an exposed pad (with three or more pads, one at least three times the median of the others). Give that part its real `tabNet`.+  - a footprint with an exposed pad (with three or more pads, the one largest at least three times the median of the others; the lands of one pad number count as one pad). Give that part its real `tabNet`. Two or more pads of about the same size at the top (the next at 80 % of the largest or more), like an eFuse's IN and OUT bars, are power leads, not a tab: one tabNet cannot describe them, so the part stays lead-cooled and the Fields solve judges it. - **A part with an exposed tab** still needs its `tabNet`: the exposed-pad check above catches one that was left out.