""" MIL-HDBK-217F Appendix A Part Stress Supplement / Replacement Calculator Revision: 1.0 source-locked audit build Purpose ------- Console-driven calculator for selected non-microcircuit MIL-HDBK-217F Part Stress or main-body assembly contributions used with an Appendix A Parts Count prediction. Core accounting rule -------------------- A Part Stress calculation for a physical part population is a REPLACEMENT for the corresponding Appendix A Parts Count contribution, not an addition to that same population. Section 16/17 assembly and connection models are handled separately as supplemental main-body contributions and must not double-count the same joints. Source basis ------------ MIL-HDBK-217F, 2 Dec 1991, as controlled by Notices 1 and 2, using the supplied "MIL-HDBK-217F Master Governing Formula Inventory" as the revision-controlled formula inventory. This implementation intentionally hard-stops unsupported or ambiguous cases rather than inventing a factor. Intentionally excluded ---------------------- Section 5 ICs / microcircuits and Section 5.5 hybrid microcircuits. """ import csv import math from pathlib import Path K_B = 8.617e-5 # exact handbook constant used by the supplied source inventory RESULTS = [] SOURCE_LOCK = ( "MIL-HDBK-217F (2 Dec 1991) + Notices 1/2; supplied Master Governing Formula Inventory" ) # ============================================================================= # HMI / CONSOLE HELPERS # ============================================================================= WIDTH = 96 class ModelApplicabilityError(RuntimeError): """Raised when the selected handbook model is not valid for the entered condition.""" class EngineeringDispositionRequired(RuntimeError): """Raised when the source requires engineering disposition instead of silent calculation.""" def _wrap(text, width=WIDTH-6): words = str(text).split() lines, line = [], "" for word in words: if not line: line = word elif len(line) + 1 + len(word) <= width: line += " " + word else: lines.append(line) line = word if line: lines.append(line) return lines or [""] def banner(title, subtitle=None, char="="): print("\n" + char * WIDTH) print(title.center(WIDTH)) if subtitle: for line in _wrap(subtitle, WIDTH-4): print(line.center(WIDTH)) print(char * WIDTH) def panel(title, body, char="-"): print("\n" + char * WIDTH) print(f" {title}") print(char * WIDTH) if isinstance(body, (list, tuple)): items = body else: items = [body] for item in items: for line in _wrap(item): print(" " + line) def step(n, title, text=None): print("\n" + "-" * WIDTH) print(f"STEP {n} — {title}") print("-" * WIDTH) if text: for line in _wrap(text): print(" " + line) def stop_message(exc): banner("CALCULATION STOPPED — NO VALID RELEASE VALUE GENERATED", char="!") for line in _wrap(str(exc)): print(" " + line) print("!" * WIDTH) def ask_text(prompt, *, required=True, default=None, help_text=None): if help_text: for line in _wrap(help_text): print(" " + line) while True: suffix = f" [{default}]" if default is not None else "" s = input(f"{prompt}{suffix}: ").strip() if not s and default is not None: return str(default) if s: return s if not required: return "" print(" -> A value is required. This field may not be left blank.") def ask_float(prompt, *, minimum=None, maximum=None, default=None, allow_blank=False, help_text=None): if help_text: for line in _wrap(help_text): print(" " + line) while True: suffix = f" [{default}]" if default is not None else "" raw = input(f"{prompt}{suffix}: ").strip() if not raw and allow_blank: return None if not raw and default is not None: value = float(default) else: try: value = float(raw) except ValueError: print(" -> Enter a numeric value using ordinary decimal/scientific notation.") continue if not math.isfinite(value): print(" -> Enter a finite number.") continue if minimum is not None and value < minimum: print(f" -> Value must be >= {minimum}.") continue if maximum is not None and value > maximum: print(f" -> Value must be <= {maximum}.") continue return value def ask_int(prompt, *, minimum=None, maximum=None, default=None, help_text=None): if help_text: for line in _wrap(help_text): print(" " + line) while True: suffix = f" [{default}]" if default is not None else "" raw = input(f"{prompt}{suffix}: ").strip() if not raw and default is not None: value = int(default) else: try: value = int(raw) except ValueError: print(" -> Enter a whole number.") continue if minimum is not None and value < minimum: print(f" -> Value must be >= {minimum}.") continue if maximum is not None and value > maximum: print(f" -> Value must be <= {maximum}.") continue return value def ask_yes_no(prompt, *, default=None, help_text=None): if help_text: for line in _wrap(help_text): print(" " + line) if default is True: suffix = " [Y/n]" elif default is False: suffix = " [y/N]" else: suffix = " [y/n]" while True: raw = input(prompt + suffix + ": ").strip().lower() if not raw and default is not None: return bool(default) if raw in {"y", "yes"}: return True if raw in {"n", "no"}: return False print(" -> Enter y or n. No engineering selection is assumed when no default is shown.") def ask_choice(prompt, options, *, default=None, help_text=None): """options: dict[str, str]. Engineering choices should normally use default=None.""" if help_text: for line in _wrap(help_text): print(" " + line) print(f"\n{prompt}") for key, desc in options.items(): print(f" [{key}] {desc}") while True: suffix = f" [{default}]" if default is not None else "" raw = input(f"Selection{suffix}: ").strip().upper() if not raw and default is not None: raw = str(default).upper() if raw in options: return raw print(" -> Select one of: " + ", ".join(options.keys())) def ask_evidence(prompt, explanation=None): return ask_text( prompt, required=True, help_text=explanation or "Enter a datasheet, drawing, specification, PO/C of C, analysis, or calculation reference." ) def require_attestation(prompt, explanation): ok = ask_yes_no(prompt, default=None, help_text=explanation) if not ok: raise ModelApplicabilityError( "Required applicability/evidence attestation was not confirmed. The handbook model is not released for this case." ) # ============================================================================= # COMMON NUMERICAL HELPERS # ============================================================================= def arrhenius(temp_c, ea_ev, reference_k=298.0): """Handbook form exp[-Ea/k * (1/(T+273)-1/Tref)].""" return math.exp(-(ea_ev / K_B) * (1.0 / (temp_c + 273.0) - 1.0 / reference_k)) def exp_temp(temp_c, coefficient, reference_k=298.0): """Equivalent coefficient form used by Section 6 tables.""" return math.exp(-coefficient * (1.0 / (temp_c + 273.0) - 1.0 / reference_k)) def check_rating(value, rating, quantity_name, rating_name): if value > rating: raise ModelApplicabilityError( f"{quantity_name}={value:g} exceeds {rating_name}={rating:g}. " "The handbook model does not authorize operation beyond the actual component rating." ) ENV_DESC = { "GB":"Ground Benign", "GF":"Ground Fixed", "GM":"Ground Mobile", "NS":"Naval Sheltered", "NU":"Naval Unsheltered", "AIC":"Airborne Inhabited Cargo", "AIF":"Airborne Inhabited Fighter", "AUC":"Airborne Uninhabited Cargo", "AUF":"Airborne Uninhabited Fighter", "ARW":"Airborne Rotary Wing", "SF":"Space Flight", "MF":"Missile Flight", "ML":"Missile Launch", "CL":"Cannon Launch", } RES_ENV = { "GB":1.0, "GF":4.0, "GM":16.0, "NS":12.0, "NU":42.0, "AIC":18.0, "AIF":23.0, "AUC":31.0, "AUF":43.0, "ARW":63.0, "SF":0.50, "MF":37.0, "ML":87.0, "CL":1728.0, } CAP_ENV = { "GB":1.0, "GF":10.0, "GM":20.0, "NS":7.0, "NU":15.0, "AIC":12.0, "AIF":15.0, "AUC":25.0, "AUF":30.0, "ARW":40.0, "SF":0.50, "MF":20.0, "ML":50.0, "CL":570.0, } IND_ENV = { "GB":1.0, "GF":6.0, "GM":12.0, "NS":5.0, "NU":16.0, "AIC":6.0, "AIF":8.0, "AUC":7.0, "AUF":9.0, "ARW":24.0, "SF":0.50, "MF":13.0, "ML":34.0, "CL":610.0, } DISC_ENV = { "GB":1.0, "GF":6.0, "GM":9.0, "NS":9.0, "NU":19.0, "AIC":13.0, "AIF":29.0, "AUC":20.0, "AUF":43.0, "ARW":24.0, "SF":0.50, "MF":14.0, "ML":32.0, "CL":320.0, } OPTO_ENV = { "GB":1.0, "GF":2.0, "GM":8.0, "NS":5.0, "NU":12.0, "AIC":4.0, "AIF":6.0, "AUC":6.0, "AUF":8.0, "ARW":17.0, "SF":0.50, "MF":9.0, "ML":24.0, "CL":450.0, } CONN_ENV = { "GB":1.0, "GF":1.0, "GM":8.0, "NS":5.0, "NU":13.0, "AIC":3.0, "AIF":5.0, "AUC":8.0, "AUF":12.0, "ARW":19.0, "SF":0.50, "MF":10.0, "ML":27.0, "CL":490.0, } SSR_ENV = { "GB":1.0, "GF":3.0, "GM":12.0, "NS":6.0, "NU":17.0, "AIC":12.0, "AIF":19.0, "AUC":21.0, "AUF":32.0, "ARW":23.0, "SF":0.40, "MF":12.0, "ML":33.0, "CL":590.0, } PTH_ENV = { "GB":1.0, "GF":2.0, "GM":7.0, "NS":5.0, "NU":13.0, "AIC":5.0, "AIF":8.0, "AUC":16.0, "AUF":28.0, "ARW":19.0, "SF":0.50, "MF":10.0, "ML":27.0, "CL":500.0, } CONNECTION_ENV = { "GB":1.0, "GF":2.0, "GM":7.0, "NS":4.0, "NU":11.0, "AIC":4.0, "AIF":6.0, "AUC":6.0, "AUF":8.0, "ARW":16.0, "SF":0.50, "MF":9.0, "ML":24.0, "CL":420.0, } TABLE_6_1_TC = { "GB":35.0, "GF":45.0, "GM":50.0, "NS":45.0, "NU":50.0, "AIC":60.0, "AIF":60.0, "AUC":75.0, "AUF":75.0, "ARW":60.0, "SF":35.0, "MF":50.0, "ML":60.0, "CL":45.0, } TABLE_6_2_THETA = { "TO-1":70, "TO-3":10, "TO-5":70, "TO-8":70, "TO-9":70, "TO-12":70, "TO-18":70, "TO-28":5, "TO-33":70, "TO-39":70, "TO-41":10, "TO-44":70, "TO-46":70, "TO-52":70, "TO-53":5, "TO-57":5, "TO-59":5, "TO-60":5, "TO-61":5, "TO-63":5, "TO-66":10, "TO-71":70, "TO-72":70, "TO-83":5, "TO-89":22, "TO-92":70, "TO-94":5, "TO-99":70, "TO-126":5, "TO-127":5, "TO-204":10, "TO-204AA":10, "TO-205AD":70, "TO-205AF":70, "TO-220":5, "DO-4":5, "DO-5":5, "DO-7":10, "DO-8":5, "DO-9":5, "DO-13":10, "DO-14":5, "DO-29":10, "DO-35":10, "DO-41":10, "DO-45":5, "DO-204MB":70, "DO-205AB":5, "PA-42A/B":70, "PD-36C":70, "PD-50":70, "PD-77":70, "PD-180":70, "PD-319":70, "PD-262":70, "PD-975":70, "PD-280":70, "PD-216":70, "PT-2G":70, "PT-6B":70, "PH-13":70, "PH-16":70, "PH-56":70, "PY-58":70, "PY-373":70, } def select_environment(table, title="Use environment"): options = { k: f"{ENV_DESC.get(k,k)} — piE = {v:g}" for k, v in table.items() } key = ask_choice( title, options, default=None, help_text=( "Select the actual intended-use environment. The handbook does not supply a universal unknown-" "environment default, so this selection is intentionally mandatory." ), ) return key, table[key] def select_model_basis(family, direct_basis_text): mode = ask_choice( f"{family} model applicability basis", { "D": "DIRECT — actual part is supported by the handbook-listed style/specification/applicability", "A": "ALTERNATE/SURROGATE — program-approved analogous handbook model will be used", }, default=None, help_text=( direct_basis_text + " A commercial part that merely looks similar is not automatically a direct " "handbook style. If using an engineering surrogate, the approval/basis must remain visible in the NOTE." ), ) if mode == "D": evidence = ask_evidence("Direct applicability/specification evidence reference") return "DIRECT", evidence evidence = ask_evidence( "Approved alternate/surrogate basis reference", "Enter the program-approved engineering rationale, deviation, calculation, or other controlled approval." ) return "ALTERNATE_SURROGATE", evidence def select_quality(table, descriptions, *, eligibility=None): options = {k: f"{descriptions[k]} — piQ = {v:g}" for k, v in table.items()} key = ask_choice( "Quality / procurement classification", options, default=None, help_text=( "Select from procurement/specification/screening evidence. Do not select a more favorable class based on " "manufacturer reputation, automotive qualification alone, or part-name similarity." ), ) if eligibility is not None: eligibility(key) evidence = ask_evidence("Quality/procurement evidence reference") return key, table[key], evidence # ============================================================================= # APPENDIX A COMPARISON + RESULT RECORDING # ============================================================================= def appendix_a_comparison(qty): mode = ask_choice( "Optional Appendix A comparison", { "R": "RATE DATABASE INPUT — I have raw Appendix A generic lambda_g and Appendix A piQ", "L": "LINE RESULT INPUT — I already have the complete Appendix A line lambda", "S": "SKIP — do not compare this Part Stress result with Appendix A now", }, default=None, help_text=( "IMPORTANT: a Rate_Database value such as 0.0035 is normally lambda_g, not the complete line contribution. " "For non-microcircuit Appendix A lines, this notebook computes line lambda = N * lambda_g * Appendix-A piQ. " "The Appendix-A piQ is entered separately and must not be silently copied from the Part Stress model." ), ) if mode == "S": return None if mode == "L": line = ask_float( "Existing complete Appendix A line lambda [failures/1e6 h]", minimum=0, help_text="Enter the already-aggregated line contribution after quantity and Appendix-A quality have been applied." ) return {"mode":"LINE_INPUT", "appendix_line_lambda":line} lg = ask_float( "Appendix A generic rate lambda_g from Rate_Database [failures/1e6 h per part]", minimum=0, help_text="Paste the raw generic rate from the Appendix A rate table/database for the selected category and environment." ) piq = ask_float( "Appendix A quality factor piQ used by the existing Parts Count line", minimum=0, help_text="Enter the Appendix A part-class quality multiplier used by your workbook for this line." ) line = qty * lg * piq panel( "APPENDIX A RECONSTRUCTION", [ f"Quantity N = {qty}", f"Generic rate lambda_g = {lg:.12g} failures/1e6 h per part", f"Appendix A piQ = {piq:.12g}", f"Existing Appendix A line lambda = N * lambda_g * piQ = {line:.12g} failures/1e6 h", ], ) return { "mode":"RATE_DATABASE", "appendix_lambda_g":lg, "appendix_piQ":piq, "appendix_line_lambda":line, } def comparison_text(part_stress_line, comp): if not comp: return "No Appendix A numerical comparison was requested." old = comp["appendix_line_lambda"] if old == 0: if part_stress_line == 0: return "Appendix A and Part Stress line contributions are both zero." return "Appendix A line is zero; a finite ratio is not defined." ratio = part_stress_line / old pct = (part_stress_line - old) / old * 100.0 if abs(pct) < 1e-10: verdict = "numerically equal" elif pct < 0: verdict = f"Part Stress is {-pct:.3f}% LOWER than Appendix A" else: verdict = f"Part Stress is {pct:.3f}% HIGHER than Appendix A" return ( f"Appendix A line lambda={old:.12g}; Part Stress line lambda={part_stress_line:.12g}; " f"ratio PartStress/AppendixA={ratio:.8g}; {verdict}. Numerical favorability alone is NOT the method-selection rule." ) def finalize_piece_part(part, section, source, formula, lambda_p, qty, factors, basis, warnings=None): warnings = list(warnings or []) line_lambda = lambda_p * qty step(8, "APPENDIX A COMPARISON / METHOD DECISION") comp = appendix_a_comparison(qty) comp_text = comparison_text(line_lambda, comp) panel("NUMERICAL COMPARISON", comp_text) selected = ask_yes_no( "Designate this Part Stress result as the selected REPLACEMENT for the same Appendix A physical population?", default=False, help_text=( "Select YES only when the detailed Part Stress method is the approved/appropriate method for this population and the " "corresponding Appendix A contribution will be excluded. Do NOT choose based only on whichever lambda is smaller." ), ) selection_ref = "" if selected: require_attestation( "Will the corresponding Appendix A contribution for this SAME physical population be removed/excluded?", "This prevents double counting. The same physical part population may not be included by both Parts Count and Part Stress." ) selection_ref = ask_evidence( "Replacement selection / calculation approval reference", "Enter the calculation note, analyst decision, review record, or program approval that identifies this as the selected method." ) status = "SELECTED_PART_STRESS_REPLACEMENT" else: status = "EVALUATED_ONLY_NOT_SELECTED" warning_text = " | ".join(warnings) if warnings else "None" factor_text = "; ".join(f"{k}={v}" for k, v in factors.items()) note = ( f"NOTE — {part}: {status}. Source basis: {SOURCE_LOCK}; {source}. " f"Governing equation: {formula}. Individual Part Stress lambda_p={lambda_p:.12g} failures/1e6 operating hours. " f"Quantity N={qty}; Part Stress line lambda=N*lambda_p={line_lambda:.12g} failures/1e6 operating hours. " f"Inputs/factors: {factor_text}. Model/applicability basis: {basis}. {comp_text} " f"Appendix A mixed-method justification: detailed part-specific information is available and a main-body Part Stress result may " f"replace the corresponding generic Parts Count population when the accounting remains complete and non-overlapping. " f"Replacement selection reference: {selection_ref if selected else 'not selected'}. Warnings/dispositions: {warning_text}." ) rec = { "kind":"PIECE_PART_REPLACEMENT", "status":status, "part":part, "section":section, "source":source, "formula":formula, "lambda_p":lambda_p, "quantity":qty, "line_lambda":line_lambda, "appendix_comparison":comp, "factors":factors, "basis":basis, "selection_reference":selection_ref, "warnings":warnings, "note":note, } RESULTS.append(rec) banner("CALCULATION RESULT") print(f"PART / GROUP : {part}") print(f"SECTION : {section}") print(f"STATUS : {status}") print(f"INDIVIDUAL lambda_p : {lambda_p:.12g} failures / 1e6 operating h") print(f"QUANTITY N : {qty}") print(f"PART STRESS LINE lambda: {line_lambda:.12g} failures / 1e6 operating h") if line_lambda > 0: print(f"RECIPROCAL LINE MTBF* : {1e6/line_lambda:.8g} h") print("*MTBF shown only as reciprocal of this line contribution; it is not the equipment MTBF.") panel("COPY/PASTE NOTE", note) return rec def finalize_supplement(part, section, source, formula, line_lambda, factors, basis, warnings=None): warnings = list(warnings or []) warning_text = " | ".join(warnings) if warnings else "None" factor_text = "; ".join(f"{k}={v}" for k, v in factors.items()) note = ( f"NOTE — {part}: SUPPLEMENTAL_MAIN_BODY_CONTRIBUTION. Source basis: {SOURCE_LOCK}; {source}. " f"Governing equation: {formula}. Calculated contribution={line_lambda:.12g} failures/1e6 operating hours. " f"Inputs/factors: {factor_text}. Basis: {basis}. This result is not automatically a piece-part Appendix A replacement. " f"It must be incorporated at the correct assembly/accounting boundary without double counting a connection or interconnection " f"failure mechanism already represented elsewhere. Warnings/dispositions: {warning_text}." ) rec = { "kind":"SUPPLEMENTAL_MAIN_BODY", "status":"SUPPLEMENTAL_MAIN_BODY_CONTRIBUTION", "part":part, "section":section, "source":source, "formula":formula, "lambda_p":None, "quantity":1, "line_lambda":line_lambda, "appendix_comparison":None, "factors":factors, "basis":basis, "selection_reference":"", "warnings":warnings, "note":note, } RESULTS.append(rec) banner("SUPPLEMENTAL CONTRIBUTION RESULT") print(f"ASSEMBLY / GROUP : {part}") print(f"SECTION : {section}") print(f"CONTRIBUTION lambda : {line_lambda:.12g} failures / 1e6 operating h") panel("COPY/PASTE NOTE", note) return rec # ============================================================================= # SECTION 9.1 — RESISTORS # ============================================================================= RES_STYLES = { "RC": (.0017,1,2,"Fixed composition, insulated","MIL-R-11",False), "RCR": (.0017,1,2,"Fixed composition, established reliability","MIL-R-39008",True), "RL": (.0037,2,1,"Fixed film, insulated","MIL-R-22684",False), "RLR": (.0037,2,1,"Fixed film, established reliability","MIL-R-39017",True), "RN_ER":(.0037,2,1,"Fixed film, established reliability","MIL-R-55182",True), "RM": (.0037,2,1,"Fixed film chip, established reliability","MIL-R-55342",True), "RN_HS":(.0037,2,1,"Fixed film, high stability","MIL-R-10509",False), "RD": (.0037,0,1,"Fixed film, power type","MIL-R-11804",False), "RZ": (.0019,1,0,"Fixed film resistor network","MIL-R-83401",False), "RB": (.0024,2,1,"Fixed wirewound, accurate","MIL-R-93",False), "RBR": (.0024,2,1,"Fixed wirewound, accurate, ER","MIL-R-39005",True), "RW": (.0024,2,2,"Fixed wirewound, power type","MIL-R-26",False), "RWR": (.0024,2,2,"Fixed wirewound, power type, ER","MIL-R-39007",True), "RE": (.0024,2,2,"Fixed wirewound, chassis mounted","MIL-R-18546",False), "RER": (.0024,2,2,"Fixed wirewound, chassis mounted, ER","MIL-R-39009",True), "RTH": (.0019,0,0,"Thermistor, thermally sensitive","MIL-R-23648",False), "RT": (.0024,2,1,"Variable wirewound, lead-screw activated","MIL-R-27208",False), "RTR": (.0024,2,1,"Variable wirewound, lead-screw activated, ER","MIL-R-39015",True), "RR": (.0024,2,1,"Variable wirewound, precision","MIL-R-12934",False), "RA": (.0024,1,1,"Variable wirewound, low operating temperature","MIL-R-19",False), "RK": (.0024,1,1,"Variable wirewound, semiprecision","MIL-R-39002",False), "RP": (.0024,2,1,"Variable wirewound, power type","MIL-R-22",False), "RJ": (.0037,2,1,"Variable nonwirewound","MIL-R-22097",False), "RJR": (.0037,2,1,"Variable nonwirewound, ER","MIL-R-39035",True), "RV": (.0037,2,1,"Variable composition","MIL-R-94",False), "RQ": (.0037,1,1,"Variable nonwirewound, precision","MIL-R-39023",False), "RVC": (.0037,1,1,"Variable nonwirewound","MIL-R-23285",False), } RES_Q = {"S":.03,"R":.10,"P":.30,"M":1.0,"NON_ER":3.0,"COMMERCIAL":10.0} RES_Q_DESC = { "S":"Established-reliability grade S", "R":"Established-reliability grade R", "P":"Established-reliability grade P", "M":"Established-reliability grade M", "NON_ER":"Supported non-established-reliability resistor category", "COMMERCIAL":"Commercial or unknown screening level", } RES_POWER_STYLES = {"RD","RW","RWR","RE","RER","RP"} def resistor_piS(column, stress): if not 0 <= stress <= 1: raise ModelApplicabilityError("Resistor stress ratio S=PD/PR must be within 0 to 1.") if column == 0: return 1.0 if column == 1: return .71 * math.exp(1.1 * stress) if column == 2: return .54 * math.exp(2.04 * stress) raise RuntimeError("Invalid resistor stress column in immutable source table.") def calc_resistor(): banner("SECTION 9.1 — RESISTOR PART STRESS", "Notice 2 unified resistor model") step(1,"IDENTIFY THE PHYSICAL POPULATION") part = ask_text("Manufacturer part number / group identifier") qty = ask_int("Quantity N represented by this calculation line", minimum=1) step(2,"ROUTE TO THE HANDBOOK STYLE") style = ask_choice( "Select the Section 9.1 style used for base-rate/temperature/stress routing", {k:f"{v[3]} | {v[4]} | lambda_b={v[0]}" for k,v in RES_STYLES.items()}, default=None, help_text="No style is preselected. The style controls lambda_b and the temperature/stress equation branches." ) lb,tcol,scol,desc,spec,is_er_style = RES_STYLES[style] basis_mode,basis_ev = select_model_basis( "Resistor", "Direct Section 9.1 use requires the actual resistor style/applicable specification evidence to support the selected row." ) step(3,"ESTABLISH TEMPERATURE") if style in RES_POWER_STYLES: tmode = "CASE" else: tmode = ask_choice( "Temperature source", { "C":"Use known resistor case temperature", "A":"Use ambient as case-temperature approximation for a low-dissipation, non-power-type resistor", }, default=None, ) T = ask_float("Resistor case temperature T [deg C]" if tmode=="CASE" or tmode=="C" else "Ambient component temperature used as case approximation [deg C]") if tmode == "A": require_attestation( "Is this a low-dissipation, non-power-type resistor with negligible self-heating?", "Notice 2 permits the ambient approximation only for low-dissipation non-power-type resistors." ) t_rating = ask_float("Actual component maximum applicable temperature rating [deg C]") check_rating(T,t_rating,"Modeled resistor temperature","component temperature rating") piT = 1.0 if tcol==0 else arrhenius(T, .20 if tcol==1 else .08) step(4,"ESTABLISH ACTUAL POWER AND POWER STRESS") PD = ask_float("Actual worst-case resistor power dissipation PD [W]", minimum=0) PR = ask_float("Applicable rated/DERATED power PR at the modeled condition [W]", minimum=1e-30) S = PD/PR if S > 1: raise ModelApplicabilityError(f"Resistor power stress S=PD/PR={S:.6g} exceeds 1.0.") piP = PD**.39 if PD>0 else 0.0 piS = resistor_piS(scol,S) step(5,"QUALITY / PROCUREMENT") def eligibility(q): if q in {"S","R","P","M"}: if not is_er_style or basis_mode != "DIRECT": raise ModelApplicabilityError( "An ER grade S/R/P/M may only be used here when the actual procured resistor is supported as the applicable ER style/specification." ) qk,piQ,qev = select_quality(RES_Q,RES_Q_DESC,eligibility=eligibility) step(6,"ENVIRONMENT") ek,piE = select_environment(RES_ENV) step(7,"CALCULATE") lp = lb*piT*piP*piS*piQ*piE warnings=[] if PD < .001 or PD > 150: warnings.append("PD lies outside the printed 0.001–150 W piP table span; equation used and engineering disposition should be retained") if basis_mode != "DIRECT": warnings.append("Alternate/surrogate resistor-style mapping — not represented as direct military-style qualification") factors={"style":style,"lambda_b":lb,"T_C":T,"piT":piT,"PD_W":PD,"PR_W":PR,"S":S,"piP":piP,"piS":piS,"quality":qk,"piQ":piQ,"environment":ek,"piE":piE} basis=f"{basis_mode}; selected style={style} ({desc}, {spec}); applicability evidence={basis_ev}; quality evidence={qev}" return finalize_piece_part(part,"9.1","Notice 2 Section 9.1, handbook pages 9-1 through 9-3","lambda_p=lambda_b*piT*piP*piS*piQ*piE",lp,qty,factors,basis,warnings) # ============================================================================= # SECTION 10.1 — CAPACITORS # ============================================================================= # tuple: lambda_b, Tcol, Ccol, Vcol, SRroute, description, spec, ER-capable CAP_STYLES = { "CP":(.00037,1,1,1,"ONE","Fixed paper dielectric, DC, hermetic metal case","MIL-C-25",False), "CA":(.00037,1,1,1,"ONE","RFI paper dielectric, AC/DC, hermetic metallic case","MIL-C-12889",False), "CZ/CZR":(.00037,1,1,1,"ONE","Feed-through RFI, ER and non-ER","MIL-C-11693",True), "CQ/CQR":(.00051,1,1,1,"ONE","Plastic/paper-plastic dielectric, ER and non-ER","MIL-C-19978",True), "CH":(.00037,1,1,1,"ONE","Metallized paper/paper-plastic/plastic-film, DC","MIL-C-18312",False), "CHR":(.00051,1,1,1,"ONE","Metallized paper/plastic-film","MIL-C-39022",True), "CFR":(.00051,1,1,1,"ONE","Plastic or metallized-plastic dielectric, non-metal case","MIL-C-55514",False), "CRH":(.00051,1,1,1,"ONE","Supermetallized plastic-film, hermetic metal, ER","MIL-C-83421",True), "CM":(.00076,2,1,2,"ONE","Fixed mica dielectric","MIL-C-5",False), "CMR":(.00076,2,1,2,"ONE","Fixed mica dielectric, ER","MIL-C-39001",True), "CB":(.00076,2,1,2,"ONE","Fixed mica dielectric, button style","MIL-C-10950",False), "CY":(.00076,2,1,2,"ONE","Fixed glass dielectric","MIL-C-11272",False), "CYR":(.00076,2,1,2,"ONE","Fixed glass dielectric, ER","MIL-C-23269",True), "CK":(.00099,2,1,3,"ONE","Fixed ceramic dielectric, general purpose","MIL-C-11015",False), "CKR":(.00099,2,1,3,"ONE","Fixed ceramic dielectric, general purpose, ER","MIL-C-39014",True), "CC/CCR":(.00099,2,1,3,"ONE","Fixed ceramic dielectric, temperature compensating, ER/non-ER","MIL-C-20",True), "CDR":(.0020,2,1,3,"ONE","Fixed multilayer ceramic chip, ER","MIL-C-55681",True), "CSR":(.00040,1,2,4,"TABLE","Fixed solid-electrolyte tantalum, ER","MIL-C-39003",True), "CWR":(.00005,1,2,4,"TABLE","Fixed tantalum electrolytic chip, ER","MIL-C-55365",True), "CL":(.00040,1,2,4,"ONE","Fixed nonsolid-electrolyte tantalum","MIL-C-3965",False), "CLR":(.00040,1,2,4,"ONE","Fixed nonsolid-electrolyte tantalum, ER","MIL-C-39006",True), "CRL":(.00040,1,2,4,"ONE","Fixed nonsolid-electrolyte tantalum-cathode construction","MIL-C-83500",False), "CU/CUR":(.00012,2,2,1,"ONE","Fixed aluminum-oxide electrolytic, ER/non-ER","MIL-C-39018",True), "CE":(.00012,2,2,1,"ONE","Fixed dry-electrolyte aluminum, polarized","MIL-C-62",False), "CV":(.0079,1,1,5,"ONE","Variable ceramic dielectric trimmer","MIL-C-81",False), "PC":(.0060,2,1,5,"ONE","Variable piston-type tubular trimmer","MIL-C-14409",False), "CT":(.0000072,2,1,5,"ONE","Variable air-dielectric trimmer","MIL-C-92",False), "CG":(.0060,1,1,5,"ONE","Fixed or variable vacuum dielectric","MIL-C-23183",False), } CAP_Q = {"D":.001,"C":.01,"S_OR_B":.03,"R":.1,"P":.3,"M":1.0,"L":1.5,"NON_ER":3.0,"COMMERCIAL":10.0} CAP_Q_DESC = { "D":"Established reliability grade D", "C":"Established reliability grade C", "S_OR_B":"Established reliability grade S or B", "R":"Established reliability grade R", "P":"Established reliability grade P", "M":"Established reliability grade M", "L":"Established reliability grade L", "NON_ER":"Supported non-established-reliability capacitor category", "COMMERCIAL":"Commercial or unknown screening level", } def capacitor_piV(col,S): if not 0 <= S <= 1: raise ModelApplicabilityError("Capacitor voltage stress S must be within 0 to 1.") if col==1: return (S/.6)**5 + 1 if col==2: return (S/.6)**10 + 1 if col==3: return (S/.6)**3 + 1 if col==4: return (S/.6)**17 + 1 if col==5: return (S/.5)**3 + 1 raise RuntimeError("Invalid capacitor voltage-stress column.") def capacitor_piSR(cr): if cr < 0: raise ModelApplicabilityError("Circuit resistance CR cannot be negative.") if cr > .8: return .66 if cr > .6: return 1.0 if cr > .4: return 1.3 if cr > .2: return 2.0 if cr > .1: return 2.7 return 3.3 def ask_peak_ac(): mode = ask_choice( "AC voltage component", { "0":"No AC component — peak AC = 0 V", "P":"Peak AC voltage is already known", "R":"Sinusoidal AC is known in RMS — convert peak = sqrt(2)*Vrms", "W":"Nonsinusoidal waveform — enter the actual measured/calculated peak AC voltage", }, default=None, help_text="Notice 2 uses applied DC plus PEAK AC voltage. The sqrt(2) conversion is valid only for a sinusoid." ) if mode=="0": return 0.0,"no AC component" if mode=="R": rms=ask_float("Sinusoidal AC RMS voltage [V]",minimum=0) return math.sqrt(2)*rms,f"sinusoidal RMS-to-peak conversion from {rms:g} Vrms" peak=ask_float("Peak AC voltage [V]",minimum=0) return peak,"known peak AC" if mode=="P" else "actual nonsinusoidal peak AC" def calc_capacitor(): banner("SECTION 10.1 — CAPACITOR PART STRESS","Notice 2 unified capacitor model") step(1,"IDENTIFY THE PHYSICAL POPULATION") part=ask_text("Manufacturer part number / group identifier") qty=ask_int("Quantity N represented by this calculation line",minimum=1) step(2,"ROUTE TO THE HANDBOOK STYLE") style=ask_choice( "Select the Section 10.1 style used for model routing", {k:f"{v[5]} | {v[6]} | lambda_b={v[0]} | route T/C/V/SR={v[1]}/{v[2]}/{v[3]}/{v[4]}" for k,v in CAP_STYLES.items()}, default=None, help_text="No capacitor style is assumed. Dielectric family alone is not sufficient where multiple styles have different routes." ) lb,tcol,ccol,vcol,srroute,desc,spec,er_capable=CAP_STYLES[style] basis_mode,basis_ev=select_model_basis( "Capacitor", "Direct Section 10.1 use requires the actual capacitor to be supported by a listed style/applicable specification." ) step(3,"TEMPERATURE AND RATING") T=ask_float("Capacitor ambient operating temperature T [deg C]") T_rating=ask_float("Actual capacitor maximum applicable temperature rating [deg C]") check_rating(T,T_rating,"Capacitor ambient temperature","component temperature rating") piT=arrhenius(T,.15 if tcol==1 else .35) step(4,"CAPACITANCE") C_uF=ask_float("Capacitance C [microfarads, uF]",minimum=1e-30,help_text="Convert pF/nF before entry if needed: 1 pF=1e-6 uF; 1 nF=1e-3 uF.") piC=C_uF**(.09 if ccol==1 else .23) step(5,"VOLTAGE STRESS") vdc=ask_float("Applied DC voltage [V]",minimum=0) vacpk,ac_basis=ask_peak_ac() vop=vdc+vacpk vrated=ask_float("Actual rated capacitor voltage [V]",minimum=1e-30) S=vop/vrated if S>1: raise ModelApplicabilityError(f"Capacitor voltage stress S=(Vdc+Vac_peak)/Vrated={S:.6g} exceeds 1.0.") piV=capacitor_piV(vcol,S) step(6,"SERIES-RESISTANCE FACTOR / QUALITY / ENVIRONMENT") if srroute=="TABLE": cr=ask_float("Circuit resistance CR [ohms/volt]",minimum=0,help_text="CR = effective resistance between capacitor and supply / applied capacitor voltage.") piSR=capacitor_piSR(cr) else: cr=None; piSR=1.0 def eligibility(q): if q in {"D","C","S_OR_B","R","P","M","L"}: if not er_capable or basis_mode!="DIRECT": raise ModelApplicabilityError("An established-reliability capacitor grade may only be used when actual procurement/specification evidence supports the applicable ER style.") qk,piQ,qev=select_quality(CAP_Q,CAP_Q_DESC,eligibility=eligibility) ek,piE=select_environment(CAP_ENV) step(7,"CALCULATE") lp=lb*piT*piC*piV*piSR*piQ*piE warnings=[] if not (1e-6 <= C_uF <= 1.2e5): warnings.append("Capacitance lies outside the printed Section 10.1 piC table span; retain an outside-table engineering-disposition flag") if style=="CWR": warnings.append("CWR source anomaly retained: Notice 2 style table routes CWR to the piSR table although the printed piSR heading says CSR only") if basis_mode!="DIRECT": warnings.append("Alternate/surrogate capacitor-style mapping — not represented as direct military-style qualification") factors={"style":style,"lambda_b":lb,"T_ambient_C":T,"piT":piT,"C_uF":C_uF,"piC":piC,"Vdc":vdc,"Vac_peak":vacpk,"AC_basis":ac_basis,"Voperating":vop,"Vrated":vrated,"S":S,"piV":piV,"CR_ohm_per_V":cr,"piSR":piSR,"quality":qk,"piQ":piQ,"environment":ek,"piE":piE} basis=f"{basis_mode}; selected style={style} ({desc}, {spec}); applicability evidence={basis_ev}; quality evidence={qev}" return finalize_piece_part(part,"10.1","Notice 2 Section 10.1, handbook pages 10-1 through 10-6","lambda_p=lambda_b*piT*piC*piV*piSR*piQ*piE",lp,qty,factors,basis,warnings) # ============================================================================= # SECTION 11.3 THERMAL HELPER + 11.1 TRANSFORMERS + 11.2 COILS # ============================================================================= COIL_Q={"S":.03,"R":.10,"P":.30,"M":1.0,"MIL_SPEC":1.0,"LOWER":3.0} COIL_Q_DESC={ "S":"Established reliability grade S", "R":"Established reliability grade R", "P":"Established reliability grade P", "M":"Established reliability grade M", "MIL_SPEC":"MIL-SPEC category", "LOWER":"Lower/commercial/non-MIL category", } TRANS_Q={"MIL_SPEC":1.0,"LOWER":3.0} TRANS_Q_DESC={"MIL_SPEC":"MIL-SPEC transformer category","LOWER":"Lower/commercial category"} SLASH_RISE = { "15C":"MIL-C-39010 /1C–3C, /5C, /7C, /9A, /10A, /13, /14 — deltaT=15 C", "35C":"MIL-C-39010 /4C, /6C, /8A, /11, /12 — deltaT=35 C", } def inductive_hotspot(environment, *, allow_slash=True): panel( "SECTION 11.3 THERMAL HIERARCHY", [ "The source priority is: specification/test temperature rise > applicable MIL-C-39010 slash-sheet rise > power-loss/radiating-area approximation > power-loss/weight approximation > input-power/weight approximation.", "For Space Flight (SF), the source directs dedicated thermal analysis rather than the non-space approximations.", "The final hot-spot temperature is THS = TA + 1.1*deltaT.", ] ) TA=ask_float("Inductive-device ambient operating temperature TA [deg C]") if environment=="SF": method=ask_choice( "Space-flight thermal basis", {"D":"Dedicated thermal analysis — enter validated THS directly","T":"Specification/test temperature rise is available"}, default=None, ) if method=="D": ths=ask_float("Validated winding hot-spot temperature THS [deg C]") ref=ask_evidence("Dedicated thermal-analysis reference") return ths,{"thermal_method":"SF dedicated thermal analysis","TA_C":TA,"THS_C":ths,"source":ref} dT=ask_float("Specification/test average temperature rise deltaT [deg C]",minimum=0) ref=ask_evidence("Specification/test temperature-rise reference") ths=TA+1.1*dT return ths,{"thermal_method":"specification/test rise","TA_C":TA,"deltaT_C":dT,"THS_C":ths,"source":ref} # Enforce preferred order by asking availability sequentially. if ask_yes_no("Do you have a valid specification/test average temperature-rise value deltaT?",default=None): dT=ask_float("Specification/test deltaT [deg C]",minimum=0) ref=ask_evidence("Specification/test rise reference") ths=TA+1.1*dT return ths,{"thermal_method":"specification/test rise","TA_C":TA,"deltaT_C":dT,"THS_C":ths,"source":ref} if allow_slash and ask_yes_no("Is this an applicable MIL-C-39010 device with a listed slash-sheet rise?",default=None): grp=ask_choice("MIL-C-39010 slash-sheet rise group",SLASH_RISE,default=None) dT=15.0 if grp=="15C" else 35.0 ref=ask_evidence("MIL-C-39010 slash-sheet / procurement reference") ths=TA+1.1*dT return ths,{"thermal_method":"MIL-C-39010 slash-sheet rise","slash_group":grp,"TA_C":TA,"deltaT_C":dT,"THS_C":ths,"source":ref} if ask_yes_no("Are power loss WL and EXCLUDING-MOUNTING-SURFACE radiating area A available?",default=None): WL=ask_float("Power loss WL [W]",minimum=0) A=ask_float("Radiating surface area A [in^2], excluding mounting surface",minimum=1e-30) if not (3 <= A <= 150): raise ModelApplicabilityError("Section 11.3 power-loss/area approximation is published only for 3 <= A <= 150 in^2.") dT=125*WL/A ths=TA+1.1*dT return ths,{"thermal_method":"125*WL/A","TA_C":TA,"WL_W":WL,"A_in2":A,"deltaT_C":dT,"THS_C":ths} if ask_yes_no("Are power loss WL and device/transformer weight Wt available?",default=None): WL=ask_float("Power loss WL [W]",minimum=0) wt=ask_float("Weight Wt [lb]",minimum=1e-30) dT=11.5*WL/(wt**.6766) ths=TA+1.1*dT return ths,{"thermal_method":"11.5*WL/Wt^0.6766","TA_C":TA,"WL_W":WL,"Wt_lb":wt,"deltaT_C":dT,"THS_C":ths} if ask_yes_no("Are input power WI and device/transformer weight Wt available AND is the handbook 80% efficiency assumption applicable?",default=None): require_attestation("Confirm the printed 80% efficiency assumption is applicable", "Section 11.3 Method 4 is not valid without this assumption unless an approved alternate basis is documented.") WI=ask_float("Input power WI [W]",minimum=0) wt=ask_float("Weight Wt [lb]",minimum=1e-30) dT=2.1*WI/(wt**.6766) ths=TA+1.1*dT return ths,{"thermal_method":"2.1*WI/Wt^0.6766","TA_C":TA,"WI_W":WI,"Wt_lb":wt,"efficiency_assumption":"80%","deltaT_C":dT,"THS_C":ths} raise ModelApplicabilityError( "No supported Section 11.3 thermal method is available. Obtain specification/test rise or a dedicated thermal analysis; do not insert a nominal hot-spot temperature." ) def calc_coil(): banner("SECTION 11.2 — COIL / INDUCTOR PART STRESS") step(1,"IDENTIFY POPULATION") part=ask_text("Manufacturer part number / group identifier") qty=ask_int("Quantity N represented",minimum=1) step(2,"MODEL APPLICABILITY") kind=ask_choice("Inductor type",{"F":"Fixed inductor or choke — lambda_b=0.000030","V":"Variable inductor — lambda_b=0.000050"},default=None) basis_mode,basis_ev=select_model_basis( "Coil / inductor", "Direct Section 11.2 applicability is for the published MIL-C-15305 RF coils, MIL-C-83446 RF chip coils, and MIL-C-39010 molded ER coils." ) if basis_mode=="DIRECT": family=ask_choice("Direct specification family",{"15305":"MIL-C-15305 fixed/variable RF coil","83446":"MIL-C-83446 fixed/variable RF chip coil","39010":"MIL-C-39010 molded RF established-reliability coil"},default=None) else: family="ALTERNATE" lb=.000030 if kind=="F" else .000050 step(3,"ENVIRONMENT") ek,piE=select_environment(IND_ENV) step(4,"SECTION 11.3 HOT-SPOT TEMPERATURE") ths,thermal=inductive_hotspot(ek,allow_slash=True) rating=ask_float("Actual coil maximum applicable temperature rating [deg C]") check_rating(ths,rating,"Calculated hot-spot temperature THS","coil temperature rating") piT=arrhenius(ths,.11) step(5,"QUALITY") def eligibility(q): if q in {"S","R","P","M"} and not (basis_mode=="DIRECT" and family=="39010"): raise ModelApplicabilityError("Coil ER grade S/R/P/M requires applicable MIL-C-39010 ER grading evidence.") if q=="MIL_SPEC" and basis_mode!="DIRECT": raise ModelApplicabilityError("MIL-SPEC quality requires direct applicable military-specification procurement evidence.") qk,piQ,qev=select_quality(COIL_Q,COIL_Q_DESC,eligibility=eligibility) step(6,"CALCULATE") lp=lb*piT*piQ*piE warnings=[] if basis_mode!="DIRECT": warnings.append("Alternate/surrogate Section 11.2 use; unlisted coil technology is not represented as direct handbook applicability") factors={"type":"fixed/choke" if kind=="F" else "variable","lambda_b":lb,**thermal,"temperature_rating_C":rating,"piT":piT,"quality":qk,"piQ":piQ,"environment":ek,"piE":piE} basis=f"{basis_mode}; family={family}; applicability evidence={basis_ev}; quality evidence={qev}" return finalize_piece_part(part,"11.2","Notice 2 Section 11.2 page 11-3; Section 11.3 page 11-4","lambda_p=lambda_b*piT*piQ*piE",lp,qty,factors,basis,warnings) TRANS_TYPES={ "FLYBACK":(.0054,"Flyback, less than 20 V"), "AUDIO":(.014,"Audio, 15 Hz through 20 kHz"), "LOW_PULSE":(.022,"Low-power pulse: peak <300 W AND average <5 W"), "HIGH_PULSE":(.049,"High-power/pulse: peak >=300 W AND average >=5 W"), "RF":(.13,"RF, 10 kHz through 10 MHz"), } def calc_transformer(): banner("SECTION 11.1 — TRANSFORMER PART STRESS") step(1,"IDENTIFY POPULATION") part=ask_text("Manufacturer part number / group identifier") qty=ask_int("Quantity N represented",minimum=1) step(2,"FUNCTION / MODEL ROUTING") tt=ask_choice("Transformer category",{k:f"{v[1]} — lambda_b={v[0]}" for k,v in TRANS_TYPES.items()},default=None) lb,desc=TRANS_TYPES[tt] basis_mode,basis_ev=select_model_basis( "Transformer", "Direct Section 11.1 applicability uses the published transformer function/construction categories and, where applicable, MIL-T-27, MIL-T-21038, or MIL-T-55631 evidence." ) if tt=="FLYBACK": flyv=ask_float("Flyback voltage used to verify '<20 V' category [V]",minimum=0) if flyv>=20: raise ModelApplicabilityError("The published flyback category is '<20 V'.") elif tt=="AUDIO": f=ask_float("Operating frequency used for category verification [Hz]",minimum=0) if not (15<=f<=20000): raise ModelApplicabilityError("Audio category requires 15 Hz through 20 kHz.") elif tt=="RF": f=ask_float("Operating frequency used for category verification [Hz]",minimum=0) if not (1e4<=f<=1e7): raise ModelApplicabilityError("RF category requires 10 kHz through 10 MHz.") else: ppk=ask_float("Peak pulse power [W]",minimum=0) pav=ask_float("Average power [W]",minimum=0) if tt=="LOW_PULSE" and not (ppk<300 and pav<5): raise ModelApplicabilityError("Low-power pulse category requires BOTH peak <300 W and average <5 W.") if tt=="HIGH_PULSE" and not (ppk>=300 and pav>=5): raise ModelApplicabilityError("High-power pulse category requires BOTH peak >=300 W and average >=5 W; mixed thresholds are not assigned a published category.") step(3,"ENVIRONMENT") ek,piE=select_environment(IND_ENV) step(4,"SECTION 11.3 HOT-SPOT") ths,thermal=inductive_hotspot(ek,allow_slash=False) ins_rating=ask_float("Transformer insulation / maximum operating-temperature rating [deg C]") if ths>ins_rating: pct=ask_float("Percent of operating time expected above the insulation rating [%]",minimum=0,maximum=100) if pct>5: raise ModelApplicabilityError("Section 11.1 assumes insulation rated temperature is not exceeded for more than 5% of the time.") else: pct=0.0 piT=arrhenius(ths,.11) step(5,"QUALITY") def eligibility(q): if q=="MIL_SPEC" and basis_mode!="DIRECT": raise ModelApplicabilityError("MIL-SPEC transformer quality requires direct applicable specification/procurement evidence.") qk,piQ,qev=select_quality(TRANS_Q,TRANS_Q_DESC,eligibility=eligibility) step(6,"CALCULATE") lp=lb*piT*piQ*piE warnings=[] if basis_mode!="DIRECT": warnings.append("Alternate/surrogate Section 11.1 model use") if ths>ins_rating: warnings.append(f"THS exceeds insulation rating during {pct:g}% of operating time; retained only because entered value is <=5%") factors={"transformer_category":tt,"lambda_b":lb,**thermal,"insulation_rating_C":ins_rating,"pct_time_above_rating":pct,"piT":piT,"quality":qk,"piQ":piQ,"environment":ek,"piE":piE} basis=f"{basis_mode}; function={desc}; applicability evidence={basis_ev}; quality evidence={qev}" return finalize_piece_part(part,"11.1","Notice 2 Section 11.1 pages 11-1 through 11-2; Section 11.3 page 11-4","lambda_p=lambda_b*piT*piQ*piE",lp,qty,factors,basis,warnings) # ============================================================================= # SECTION 6.14 THERMAL HELPER + SECTION 6.1 / 6.4 / 6.11 # ============================================================================= DISC_Q={"JANTXV":.70,"JANTX":1.0,"JAN":2.4,"LOWER":5.5,"PLASTIC":8.0} DISC_Q_DESC={ "JANTXV":"MIL-S-19500 JANTXV", "JANTX":"MIL-S-19500 JANTX", "JAN":"MIL-S-19500 JAN", "LOWER":"Lower quality category", "PLASTIC":"Published plastic-device quality category", } def select_discrete_quality(): package_is_plastic=ask_yes_no("Is the actual semiconductor package plastic/nonhermetic plastic?",default=None) package_ev=ask_evidence("Package construction evidence reference") def eligibility(q): if q in {"JANTXV","JANTX","JAN"}: require_attestation( f"Does the ACTUAL procured part have documented {q} qualification/procurement evidence?", "Do not credit JAN/JANTX/JANTXV from automotive qualification, temperature rating, or a related military sibling part." ) if q=="PLASTIC" and not package_is_plastic: raise ModelApplicabilityError("PLASTIC quality was selected but the package was not identified as plastic.") if package_is_plastic and q=="LOWER": raise ModelApplicabilityError("This selected Section 6 model publishes an explicit PLASTIC category; use PLASTIC for a known plastic package rather than silently treating it as LOWER.") qk,piQ,qev=select_quality(DISC_Q,DISC_Q_DESC,eligibility=eligibility) return qk,piQ,f"package evidence={package_ev}; quality evidence={qev}" def semiconductor_thermal(environment): panel( "SECTION 6.14 THERMAL INPUT HIERARCHY", [ "Case temperature TC: detailed worst-case equipment thermal analysis when available; otherwise use the actual environment's Table 6-1 default.", "thetaJC: compare all applicable vendor, military-specification, Table 6-2, and valid derating-estimate candidates and use the GREATEST applicable value. If none can be determined, use the explicit 70 C/W fallback and flag it.", "Power P: actual worst-case device dissipation, not rated power by default.", "TJ,max: use the LOWER authoritative maximum when both military and vendor ratings are available.", ] ) if ask_yes_no("Is a detailed worst-case equipment thermal analysis available for device case temperature TC?",default=None): TC=ask_float("Worst-case case temperature TC [deg C]") tc_source=ask_evidence("Case-temperature thermal-analysis reference") tc_mode="DETAILED_ANALYSIS" else: TC=TABLE_6_1_TC[environment] tc_source=f"MIL-HDBK-217F Table 6-1 default for {environment}" tc_mode="TABLE_6_1_DEFAULT" print(f" -> Using Table 6-1 TC default for {environment}: {TC:g} deg C") candidates=[] vendor=ask_float("Vendor thetaJC [deg C/W] (blank if unavailable)",minimum=0,allow_blank=True) if vendor is not None: candidates.append((vendor,"vendor")) mil=ask_float("Military specification thetaJC [deg C/W] (blank if unavailable)",minimum=0,allow_blank=True) if mil is not None: candidates.append((mil,"MIL specification")) if ask_yes_no("Does the actual package exactly match a package listed in handbook Table 6-2?",default=None): pkg=ask_choice("Table 6-2 package",{k:f"{k} — thetaJC={v:g} C/W" for k,v in TABLE_6_2_THETA.items()},default=None) candidates.append((float(TABLE_6_2_THETA[pkg]),f"Table 6-2 {pkg}")) else: pkg="NOT_USED" slope=ask_float("Valid recommended power-derating slope DT [W/deg C] (blank if unavailable/not applicable)",minimum=1e-30,allow_blank=True) if slope is not None: candidates.append((1.0/slope,"1/DT derating estimate")) fallback=False if candidates: theta,theta_source=max(candidates,key=lambda x:x[0]) else: theta=70.0; theta_source="explicit Section 6.14 unresolved-theta fallback"; fallback=True print(" -> No thetaJC source was available. Using explicit handbook fallback thetaJC=70 C/W.") P=ask_float("Actual worst-case device power dissipation P [W]",minimum=0) TJ=TC+theta*P vendor_max=ask_float("Vendor maximum rated junction temperature TJ,max [deg C] (blank if unavailable)",allow_blank=True) mil_max=ask_float("Military slash-sheet maximum TJ,max [deg C] (blank if unavailable)",allow_blank=True) maxima=[x for x in (vendor_max,mil_max) if x is not None] if not maxima: raise ModelApplicabilityError("At least one authoritative maximum junction-temperature rating is required to perform the Section 6.14 overstress gate.") tjmax=min(maxima) if TJ>tjmax: raise ModelApplicabilityError(f"Calculated TJ={TJ:.6g} C exceeds controlling TJ,max={tjmax:.6g} C. Section 6 model is not applicable; TJ may not be clipped.") return TJ,{ "TC_C":TC,"TC_source":tc_source,"TC_mode":tc_mode, "theta_candidates":candidates,"thetaJC_C_per_W":theta,"theta_source":theta_source, "theta_70_fallback":fallback,"P_W":P,"TJ_C":TJ,"TJmax_C":tjmax, "vendor_TJmax_C":vendor_max,"MIL_TJmax_C":mil_max, } DIODE_TYPES={ "GENERAL":(.0038,3091,False,"General-purpose analog diode"), "SWITCHING":(.0010,3091,False,"Switching diode"), "FAST_RECT":(.025,3091,False,"Fast-recovery power rectifier"), "SCHOTTKY_POWER":(.0030,3091,False,"Power rectifier / Schottky power diode"), "HV_STACK":(.0050,3091,False,"Power rectifier high-voltage stack — 0.0050 per junction"), "TVS":(.0013,3091,True,"Transient suppressor / varistor"), "CURRENT_REG":(.0034,1925,True,"Current regulator"), "VOLT_REG_REF":(.0020,1925,True,"Voltage regulator/reference, avalanche or Zener"), } def diode_piS(S): if not 0<=S<=1: raise ModelApplicabilityError("Diode reverse-voltage stress ratio must be within 0 to 1.") return .054 if S<=.30 else S**2.43 def calc_diode(): banner("SECTION 6.1 — LOW-FREQUENCY DIODE PART STRESS") step(1,"IDENTIFY POPULATION / SINGLE-DEVICE BOUNDARY") part=ask_text("Manufacturer part number / group identifier") qty=ask_int("Physical package quantity N represented",minimum=1) dtype=ask_choice("Section 6.1 diode category",{k:f"{v[3]} — lambda_b={v[0]}" for k,v in DIODE_TYPES.items()},default=None) lb,tcoef,unity_stress,desc=DIODE_TYPES[dtype] if dtype=="HV_STACK": nj=ask_int("Physical junction count in EACH high-voltage stack",minimum=1) lb=lb*nj else: multi=ask_yes_no("Does one physical package contain multiple separately modeled semiconductor devices/dice/junction devices?",default=None) if multi: raise ModelApplicabilityError( "Section 6 models generally apply to single devices. This notebook will not multiply a single-device diode rate across a multi-device package. Review Section 5.5 hybrid applicability or use an explicitly approved alternate reliability basis." ) nj=1 step(2,"ENVIRONMENT") ek,piE=select_environment(DISC_ENV) step(3,"SECTION 6.14 JUNCTION TEMPERATURE") TJ,thermal=semiconductor_thermal(ek) if not (25<=TJ<=175): raise ModelApplicabilityError("Section 6.1 published temperature-factor table span is 25–175 C; this notebook does not extrapolate outside that published domain.") piT=exp_temp(TJ,tcoef) step(4,"ELECTRICAL STRESS") if unity_stress: S=None; piS=1.0; stress_basis="published unity-stress category" else: va=ask_float("Applied reverse voltage [V]",minimum=0) vr=ask_float("Rated reverse voltage [V]",minimum=1e-30) S=va/vr if S>1: raise ModelApplicabilityError(f"Reverse-voltage stress S={S:.6g} exceeds 1.0.") piS=diode_piS(S); stress_basis=f"S={va:g}/{vr:g}" step(5,"CONTACT CONSTRUCTION") ck=ask_choice("Contact construction",{"M":"Metallurgically bonded — piC=1.0","N":"Non-metallurgically bonded / spring-loaded — piC=2.0"},default=None,help_text="The handbook supplies no unknown-construction numerical default.") cev=ask_evidence("Contact-construction evidence reference") piC=1.0 if ck=="M" else 2.0 step(6,"QUALITY") qk,piQ,qev=select_discrete_quality() step(7,"CALCULATE") lp=lb*piT*piS*piC*piQ*piE warnings=[] if thermal["theta_70_fallback"]: warnings.append("Section 6.14 thetaJC=70 C/W handbook fallback used") factors={"diode_category":dtype,"lambda_b":lb,"junction_count_per_stack":nj,**thermal,"piT":piT,"S":S,"piS":piS,"stress_basis":stress_basis,"contact":ck,"piC":piC,"quality":qk,"piQ":piQ,"environment":ek,"piE":piE} basis=f"Physical classification={desc}; contact evidence={cev}; {qev}" return finalize_piece_part(part,"6.1","Notice 2 Section 6.1 pages 6-2 through 6-3; Section 6.14 pages 6-23 through 6-24","lambda_p=lambda_b*piT*piS*piC*piQ*piE",lp,qty,factors,basis,warnings) def calc_fet(): banner("SECTION 6.4 — LOW-FREQUENCY SILICON FET PART STRESS") step(1,"IDENTIFY POPULATION / APPLICABILITY") part=ask_text("Manufacturer part number / group identifier") qty=ask_int("Physical package quantity N represented",minimum=1) require_attestation("Is each represented package a single silicon FET device (not a multi-die hybrid/package)?","Section 6 models generally apply to single devices unless specifically noted.") ft=ask_choice("FET type",{"M":"MOSFET — lambda_b=0.012","J":"JFET — lambda_b=0.0045"},default=None) freq=ask_float("Maximum modeled operating frequency [MHz]",minimum=0) if freq>400: raise ModelApplicabilityError("Section 6.4 applies to silicon FETs at <=400 MHz. Evaluate Section 6.9 applicability above 400 MHz.") lb=.012 if ft=="M" else .0045 step(2,"ENVIRONMENT") ek,piE=select_environment(DISC_ENV) step(3,"SECTION 6.14 JUNCTION TEMPERATURE") TJ,thermal=semiconductor_thermal(ek) if not (25<=TJ<=175): raise ModelApplicabilityError("Section 6.4 published temperature-factor table span is 25–175 C; no extrapolation is performed.") piT=exp_temp(TJ,1925) step(4,"APPLICATION FACTOR") app=ask_choice("Actual FET application",{"L":"Linear amplification, rated power Pr <2 W — piA=1.5","S":"Small-signal switching — piA=0.70","P":"Nonlinear power FET — piA depends on rated power"},default=None) if app=="L": pr=ask_float("Rated output power Pr [W]",minimum=0) if pr>=2: raise ModelApplicabilityError("Linear branch requires rated power Pr <2 W.") piA=1.5 elif app=="S": pr=None; piA=.70 else: pr=ask_float("Rated output power Pr [W]",minimum=2) if pr<5: piA=2.0 elif pr<50: piA=4.0 elif pr<250: piA=8.0 else: piA=10.0 step(5,"QUALITY") qk,piQ,qev=select_discrete_quality() step(6,"CALCULATE") lp=lb*piT*piA*piQ*piE warnings=[] if thermal["theta_70_fallback"]: warnings.append("Section 6.14 thetaJC=70 C/W handbook fallback used") factors={"FET_type":"MOSFET" if ft=="M" else "JFET","lambda_b":lb,"frequency_MHz":freq,**thermal,"piT":piT,"application":app,"Pr_W":pr,"piA":piA,"quality":qk,"piQ":piQ,"environment":ek,"piE":piE} basis=f"Silicon FET <=400 MHz; {qev}" return finalize_piece_part(part,"6.4","Section 6.4 page 6-8; Section 6.14 pages 6-23 through 6-24","lambda_p=lambda_b*piT*piA*piQ*piE",lp,qty,factors,basis,warnings) OPTO_TYPES={ "PT_DET":(.0055,"Photodetector — phototransistor"), "PD_DET":(.0040,"Photodetector — photodiode"), "ISO_PD_SINGLE":(.0025,"Opto-isolator, photodiode output, single device"), "ISO_PT_SINGLE":(.013,"Opto-isolator, phototransistor output, single device"), "ISO_DARL_SINGLE":(.013,"Opto-isolator, photodarlington output, single device"), "ISO_LSR_SINGLE":(.0064,"Opto-isolator, light-sensitive-resistor output, single device"), "ISO_PD_DUAL":(.0033,"Opto-isolator, photodiode output, dual device"), "ISO_PT_DUAL":(.017,"Opto-isolator, phototransistor output, dual device"), "ISO_DARL_DUAL":(.017,"Opto-isolator, photodarlington output, dual device"), "ISO_LSR_DUAL":(.0086,"Opto-isolator, light-sensitive-resistor output, dual device"), "IR_LED":(.0013,"Infrared light-emitting diode"), "LED":(.00023,"Visible light-emitting diode"), } def calc_opto(): banner("SECTION 6.11 — OPTOELECTRONICS PART STRESS") step(1,"IDENTIFY ARCHITECTURE") part=ask_text("Manufacturer part number / group identifier") qty=ask_int("Physical package quantity N represented",minimum=1) ot=ask_choice("Section 6.11 published category",{k:f"{v[1]} — lambda_b={v[0]}" for k,v in OPTO_TYPES.items()},default=None) lb,desc=OPTO_TYPES[ot] mapmode=ask_choice("Architecture mapping basis",{"D":"DIRECT — actual architecture matches the selected published category","A":"ALTERNATE — approved analogous Section 6.11 category mapping"},default=None) mapref=ask_evidence("Architecture / alternate-mapping evidence reference") step(2,"ENVIRONMENT") ek,piE=select_environment(OPTO_ENV) step(3,"SECTION 6.14 JUNCTION TEMPERATURE") TJ,thermal=semiconductor_thermal(ek) if not (25<=TJ<=115): raise ModelApplicabilityError("Section 6.11 published temperature domain is 25–115 C; no extrapolation is performed.") piT=exp_temp(TJ,2790) step(4,"QUALITY") qk,piQ,qev=select_discrete_quality() step(5,"CALCULATE") lp=lb*piT*piQ*piE warnings=[] if mapmode=="A": warnings.append("Approved alternate Section 6.11 architecture mapping used") if thermal["theta_70_fallback"]: warnings.append("Section 6.14 thetaJC=70 C/W handbook fallback used") factors={"opto_category":ot,"lambda_b":lb,**thermal,"piT":piT,"quality":qk,"piQ":piQ,"environment":ek,"piE":piE} basis=f"{mapmode}; category={desc}; architecture evidence={mapref}; {qev}" return finalize_piece_part(part,"6.11","Section 6.11 page 6-19; Section 6.14 pages 6-23 through 6-24","lambda_p=lambda_b*piT*piQ*piE",lp,qty,factors,basis,warnings) # ============================================================================= # SECTION 15.1 — GENERAL CONNECTORS # ============================================================================= CONN_TYPES={ "CIRCULAR":(.0010,"Circular/cylindrical"), "CARD_EDGE":(.040,"Card edge / PCB"), "HEX":(.15,"Hexagonal"), "RACK_PANEL":(.021,"Rack and panel"), "RECTANGULAR":(.046,"Rectangular"), "RF_COAX":(.00041,"RF coaxial"), "TELEPHONE":(.0075,"Telephone"), "POWER":(.0070,"Power"), "TRIAX":(.0036,"Triaxial"), } GAUGE_K={32:3.256,30:2.856,28:2.286,24:1.345,22:.989,20:.640,18:.429,16:.274,12:.100} CONN_Q={"MIL_SPEC":1.0,"LOWER":2.0} CONN_Q_DESC={"MIL_SPEC":"MIL-SPEC quality","LOWER":"Lower/commercial quality"} def connector_piK(cycles_per_1000h): if cycles_per_1000h<0: raise ModelApplicabilityError("Mating cycle rate cannot be negative.") if cycles_per_1000h<=.05: return 1.0 if cycles_per_1000h<=.5: return 1.5 if cycles_per_1000h<=5: return 2.0 if cycles_per_1000h<=50: return 3.0 return 4.0 def calc_connector(): banner("SECTION 15.1 — GENERAL CONNECTOR PART STRESS","Model basis is one physical mated pair") step(1,"IDENTIFY MATED-PAIR POPULATION") part=ask_text("Connector / mated-pair identifier") qty=ask_int("Number of physical mated pairs represented",minimum=1) ct=ask_choice("Connector family",{k:f"{v[1]} — lambda_b={v[0]}" for k,v in CONN_TYPES.items()},default=None) lb,desc=CONN_TYPES[ct] basis_mode,basis_ev=select_model_basis("Connector","Direct Section 15.1 use requires the actual connector construction/family to match a published connector family/specification basis.") step(2,"OPERATING TEMPERATURE") TA=ask_float("Connector ambient temperature [deg C]") if ct=="RF_COAX": rm=ask_choice("RF coaxial temperature-rise branch",{"N":"Normal RF coaxial — fixed deltaT=5 C","H":"High-power RF coaxial — fixed deltaT=50 C"},default=None) dT=5.0 if rm=="N" else 50.0 rise_basis="published normal RF +5 C" if rm=="N" else "published high-power RF +50 C" else: tm=ask_choice("Contact temperature-rise method",{"G":"Published contact-gauge/current equation deltaT=kg*i^1.85","A":"Approved alternate validated deltaT (not a direct handbook contact-rise route)"},default=None) if tm=="G": g=ask_choice("Contact gauge",{str(k):f"Gauge {k}; kg={v:g}" for k,v in GAUGE_K.items()},default=None) current=ask_float("Current per contact i [A]",minimum=0) dT=GAUGE_K[int(g)]*(current**1.85) rise_basis=f"published gauge/current equation; gauge={g}, current={current:g} A" else: dT=ask_float("Validated alternate contact temperature rise deltaT [deg C]",minimum=0) rref=ask_evidence("Alternate contact-rise analysis / approval reference") rise_basis=f"ALTERNATE thermal basis: {rref}" TO=TA+dT if not (20<=TO<=250): raise ModelApplicabilityError("Section 15.1 printed operating-temperature domain is 20–250 C.") rating=ask_float("Actual connector maximum applicable temperature rating [deg C]") check_rating(TO,rating,"Connector operating temperature TO","connector temperature rating") piT=arrhenius(TO,.14) step(3,"MATING / UNMATING") cycles=ask_float("Mating/unmating cycles per 1000 operating hours",minimum=0,help_text="One cycle includes both connect and disconnect. Enter 0 only when that is the documented service profile.") piK=connector_piK(cycles) step(4,"QUALITY") def eligibility(q): if q=="MIL_SPEC" and basis_mode!="DIRECT": raise ModelApplicabilityError("MIL-SPEC connector quality requires direct applicable specification/procurement evidence.") qk,piQ,qev=select_quality(CONN_Q,CONN_Q_DESC,eligibility=eligibility) step(5,"ENVIRONMENT") ek,piE=select_environment(CONN_ENV) step(6,"CALCULATE") lp=lb*piT*piK*piQ*piE warnings=[] if basis_mode!="DIRECT": warnings.append("Alternate/surrogate connector-family mapping") if "ALTERNATE" in rise_basis: warnings.append("Alternate connector thermal-rise basis used") factors={"family":ct,"lambda_b":lb,"TA_C":TA,"deltaT_C":dT,"TO_C":TO,"temperature_rating_C":rating,"piT":piT,"cycles_per_1000h":cycles,"piK":piK,"quality":qk,"piQ":piQ,"environment":ek,"piE":piE} basis=f"{basis_mode}; family={desc}; applicability evidence={basis_ev}; rise basis={rise_basis}; quality evidence={qev}" return finalize_piece_part(part,"15.1","Notice 2 Section 15.1 pages 15-1 through 15-2","lambda_p=lambda_b*piT*piK*piQ*piE",lp,qty,factors,basis,warnings) # ============================================================================= # SECTION 13.2 — SOLID-STATE / TIME-DELAY RELAYS # ============================================================================= SSR_Q={"MIL_SPEC":1.0,"COMMERCIAL":1.9} SSR_Q_DESC={"MIL_SPEC":"MIL-SPEC default quality","COMMERCIAL":"Commercial default quality"} def calc_ssr(): banner("SECTION 13.2 — SOLID-STATE / TIME-DELAY RELAY") step(1,"IDENTIFY RELAY") part=ask_text("Relay part number / group identifier") qty=ask_int("Quantity N represented",minimum=1) rt=ask_choice("Relay construction",{"S":"Solid state","T":"Solid-state time delay","H":"Hybrid"},default=None) appmode,appref=select_model_basis("Section 13.2 relay","Notice 2 identifies MIL-R-28750 solid-state and MIL-R-83726 time-delay/hybrid/solid-state constructions; commercial analogous use should remain explicit.") step(2,"SELECT MUTUALLY EXCLUSIVE METHOD") internal=ask_yes_no("Is a COMPLETE, non-overlapping internal-component failure-rate sum available?",default=None,help_text="The handbook identifies the internal-component sum as the most accurate path when sufficient internal information exists. The default model is only for insufficient internal information.") if internal: lp=ask_float("Complete internal-sum relay lambda_p [failures/1e6 h]",minimum=0) iref=ask_evidence("Internal component calculation/sum reference") factors={"relay_type":rt,"path":"INTERNAL_SUM","entered_internal_lambda":lp} basis=f"{appmode}; applicability evidence={appref}; complete internal sum reference={iref}; default relay model NOT added" return finalize_piece_part(part,"13.2","Notice 2 Section 13.2 page 13-3","lambda_p,relay=sum(lambda_p,k)",lp,qty,factors,basis,[]) limitation=ask_text("Document why complete internal component information is insufficient",help_text="This explanation is required because the 0.029*piQ*piE route is expressly the default only when internal-component information is insufficient.") step(3,"DEFAULT QUALITY AND ENVIRONMENT") def eligibility(q): if q=="MIL_SPEC" and appmode!="DIRECT": raise ModelApplicabilityError("MIL-SPEC default quality requires applicable MIL specification/procurement evidence.") qk,piQ,qev=select_quality(SSR_Q,SSR_Q_DESC,eligibility=eligibility) ek,piE=select_environment(SSR_ENV) lb=.029 lp=lb*piQ*piE factors={"relay_type":rt,"path":"DEFAULT_INSUFFICIENT_INTERNAL_INFO","lambda_b":lb,"quality":qk,"piQ":piQ,"environment":ek,"piE":piE} basis=f"{appmode}; applicability evidence={appref}; internal information insufficient because: {limitation}; quality evidence={qev}" return finalize_piece_part(part,"13.2","Notice 2 Section 13.2 page 13-3","lambda_p,default=0.029*piQ*piE",lp,qty,factors,basis,[]) # ============================================================================= # SECTION 16.1 — PTH INTERCONNECTION ASSEMBLY (SUPPLEMENTAL) # ============================================================================= PTH_Q={"MIL_SPEC_OR_IPC3":1.0,"LOWER":2.0} PTH_Q_DESC={"MIL_SPEC_OR_IPC3":"MIL-SPEC or comparable IPC Level 3","LOWER":"Lower assembly quality"} def calc_pth(): banner("SECTION 16.1 — PTH INTERCONNECTION ASSEMBLY","Assembly-level contribution; NOT an intrinsic piece-part lambda") step(1,"DEFINE ASSEMBLY BOUNDARY") part=ask_text("Board / PTH assembly identifier") tech=ask_choice("PTH assembly technology",{"PCB":"Printed wiring assembly / PCB with PTHs — lambda_b=0.000017","DW":"Discrete wiring with electroless-deposited PTHs, <=2 circuit levels — lambda_b=0.00011"},default=None) n1=ask_int("N1: functional PTHs soldered by automated wave / infrared / vapor-phase methods",minimum=0) n2=ask_int("N2: functional hand-soldered PTHs",minimum=0) countref=ask_evidence("PTH count / solder-process evidence reference") if tech=="PCB": P=ask_int("Printed wiring board circuit planes P",minimum=2,maximum=18) lb=.000017; piC=.65*(P**.63) else: P=None; lb=.00011; piC=1.0 step(2,"QUALITY") def eligibility(q): if q=="MIL_SPEC_OR_IPC3": require_attestation("Is MIL-SPEC or comparable IPC Level 3 assembly quality documented?","Use piQ=1 only when this basis is actually supported.") qk,piQ,qev=select_quality(PTH_Q,PTH_Q_DESC,eligibility=eligibility) step(3,"ENVIRONMENT") ek,piE=select_environment(PTH_ENV) step(4,"DOUBLE-COUNTING GATE") require_attestation("Will these same PTH joints be EXCLUDED from Section 17 connection counting?","Section 16.1 already represents the PTH assembly/soldering defect contribution; the same joints must not be entered again under Section 17.") auto_term=n1*piC hand_term=n2*(piC+13) lp=lb*(auto_term+hand_term)*piQ*piE factors={"technology":tech,"lambda_b":lb,"N1_auto":n1,"N2_hand":n2,"planes":P,"piC":piC,"automated_term":auto_term,"hand_term":hand_term,"quality":qk,"piQ":piQ,"environment":ek,"piE":piE} basis=f"PTH count/process evidence={countref}; quality evidence={qev}; Section 17 overlap excluded" return finalize_supplement(part,"16.1","Notice 2 Section 16.1 page 16-1","lambda_PTH=lambda_b*[N1*piC+N2*(piC+13)]*piQ*piE",lp,factors,basis,[]) # ============================================================================= # SECTION 16.2 — SMT INTERCONNECTION ASSEMBLY (SUPPLEMENTAL WEAKEST LINK) # ============================================================================= SMT_PI_LC={"LEADLESS":1.0,"J_OR_S":150.0,"GULL_WING":5000.0} SMT_PACKAGE_TCE={"PLASTIC":7.0,"CERAMIC":6.0} SMT_CYCLE_DEFAULTS={ "AUTOMOTIVE":1.0,"CONSUMER":.08,"COMPUTER":.17,"TELECOM":.0042, "COMMERCIAL_AIRCRAFT":.25,"INDUSTRIAL":.021,"MILITARY_GROUND":.03, "MILITARY_AIRCRAFT_CARGO":.12,"MILITARY_AIRCRAFT_FIGHTER":.5, } SMT_DELTA_T_DEFAULTS={"GB":7.0,"GF":21.0,"GM":26.0,"NS":26.0,"NU":61.0,"AIC":31.0,"AIF":31.0,"AUC":57.0,"AUF":57.0,"ARW":31.0,"SF":7.0} SMT_SUBSTRATE_TCE={ "FR4_LAMINATE":18,"FR4_MULTILAYER":20,"FR4_MULTILAYER_CU_INVAR":11,"CERAMIC_MULTILAYER":7, "CU_INVAR":5,"CU_MOLY":5,"CARBON_FIBER_EPOXY":1,"KEVLAR_FIBER":3,"QUARTZ_FIBER":1, "GLASS_FIBER":5,"EPOXY_GLASS":15,"POLYAMIDE_GLASS":13,"POLYAMIDE_KEVLAR":6, "POLYAMIDE_QUARTZ":8,"EPOXY_KEVLAR":7,"ALUMINA":7,"EPOXY_ARAMID":7, "POLYAMIDE_ARAMID":6,"EPOXY_QUARTZ":9,"FIBERGLASS_TEFLON":20, "PORCELAINIZED_CU_INVAR":7,"FIBERGLASS_CERAMIC":7, } def smt_ecf(r): # Preserve printed gaps exactly; do not smooth/interpolate. intervals=[ (0.00,.10,.13),(.11,.20,.15),(.21,.30,.23),(.31,.40,.31),(.41,.50,.41), (.51,.60,.51),(.61,.70,.61),(.71,.80,.68),(.81,.90,.76), ] if r<0: raise ModelApplicabilityError("SMT life ratio r cannot be negative.") for lo,hi,val in intervals: if lo<=r<=hi: return val if r>.90: return 1.0 raise EngineeringDispositionRequired( f"SMT life ratio r={r:.12g} falls in an unassigned gap between the printed ECF intervals. The source says to flag the gap and not silently smooth/interpolate." ) def smt_candidate_lambda(d_mil,h_mil,alpha_s,delta_t,alpha_cc,theta,power,pi_lc,cr,life_hours): if min(d_mil,h_mil,cr,life_hours) <= 0: raise ModelApplicabilityError("SMT d, h, CR, and life-hours inputs must all be positive.") trise=theta*power delta_eps=abs(alpha_s*delta_t - alpha_cc*(delta_t+trise))*1e-6 if delta_eps<=0: raise ModelApplicabilityError("Calculated SMT strain range is zero; the published fatigue equation cannot be evaluated at zero strain.") # IMPORTANT source-validation form: exponent applies to the combined normalized geometry*strain term. # This is the form that reproduces the Notice 2 worked example (Nf≈18,893). nf=3.5 * (((d_mil/(.65*h_mil))*delta_eps) ** (-2.26)) * pi_lc alpha_smt=nf/cr r=life_hours/alpha_smt ecf=smt_ecf(r) lam_per_hour=ecf/alpha_smt lam_1e6=lam_per_hour*1e6 return { "TRISE_C":trise,"delta_epsilon":delta_eps,"Nf":nf,"alpha_SMT_h":alpha_smt, "life_ratio_r":r,"ECF":ecf,"lambda_per_hour":lam_per_hour,"lambda_1e6h":lam_1e6, } def calc_smt(): banner("SECTION 16.2 — SMT INTERCONNECTION ASSEMBLY","Board-level weakest-link thermal-fatigue contribution") step(1,"DEFINE BOARD / COMMON SERVICE INPUTS") board=ask_text("Board / SMT assembly identifier") env=ask_choice("Actual use environment",{k:ENV_DESC[k] for k in ENV_DESC},default=None) if ask_yes_no("Use the handbook default deltaT for this environment where published?",default=None): if env not in SMT_DELTA_T_DEFAULTS: raise ModelApplicabilityError(f"Section 16.2 default deltaT is N/A for environment {env}; provide a documented thermal profile instead.") delta_t=SMT_DELTA_T_DEFAULTS[env] dt_basis=f"handbook default deltaT for {env}" else: delta_t=ask_float("Documented assembly thermal-cycle deltaT [deg C]",minimum=0) dt_basis=ask_evidence("Thermal-cycle deltaT source/reference") crmode=ask_choice("Thermal cycle-rate CR basis",{"D":"Use a published equipment-type default","A":"Use documented actual cycle rate"},default=None) if crmode=="D": crk=ask_choice("Equipment-type default cycle rate",{k:f"{k}; CR={v:g} cycles/calendar h" for k,v in SMT_CYCLE_DEFAULTS.items()},default=None) cr=SMT_CYCLE_DEFAULTS[crk]; cr_basis=f"published {crk} default" else: cr=ask_float("Actual thermal cycle rate CR [cycles/calendar h]",minimum=1e-30) cr_basis=ask_evidence("Actual cycle-rate source/reference") submode=ask_choice("Substrate TCE alphaS basis",{"D":"Use a published substrate default","A":"Use documented actual substrate TCE"},default=None) if submode=="D": sk=ask_choice("Substrate material",{k:f"{k}; alphaS={v:g} ppm/C" for k,v in SMT_SUBSTRATE_TCE.items()},default=None) alpha_s=float(SMT_SUBSTRATE_TCE[sk]); sub_basis=f"published default {sk}" else: alpha_s=ask_float("Actual substrate TCE alphaS [ppm/deg C]",minimum=0) sub_basis=ask_evidence("Substrate TCE source/reference") life_hours=ask_float("Evaluation/service life LC [hours on the same time basis as alphaSMT]",minimum=1e-30) step(2,"EVALUATE EVERY DISTINCT SMT PACKAGE CANDIDATE") panel("WEAKEST-LINK RULE","Every SMT component/candidate must be represented. Candidate rates are NOT summed. The board contribution is the maximum candidate rate.") candidates=[] while True: cid=ask_text("SMT candidate/group identifier") lead=ask_choice("Lead configuration",{"LEADLESS":"Leadless — piLC=1; enter actual joint height h","J_OR_S":"J or S lead — piLC=150; h=8 mil","GULL_WING":"Gull wing — piLC=5000; h=8 mil"},default=None) piLC=SMT_PI_LC[lead] d=ask_float("Distance d from package center to furthest solder joint [mil]",minimum=1e-30) if lead=="LEADLESS": h=ask_float("Solder-joint height h [mil]",minimum=1e-30) else: h=8.0 print(" -> Using published h=8 mil for leaded configuration.") pmode=ask_choice("Package TCE alphaCC basis",{"D":"Use handbook material default: plastic=7 or ceramic=6 ppm/C","A":"Use documented actual package TCE"},default=None) if pmode=="D": pk=ask_choice("Package material",{k:f"{k}; alphaCC={v:g} ppm/C" for k,v in SMT_PACKAGE_TCE.items()},default=None) alpha_cc=SMT_PACKAGE_TCE[pk]; pkg_basis=f"published {pk} default" else: alpha_cc=ask_float("Actual package TCE alphaCC [ppm/deg C]",minimum=0) pkg_basis=ask_evidence("Package TCE source/reference") theta=ask_float("Package thetaJC [deg C/W] used for TRISE",minimum=0) power=ask_float("Package power P [W] used for TRISE",minimum=0) vals=smt_candidate_lambda(d,h,alpha_s,delta_t,alpha_cc,theta,power,piLC,cr,life_hours) vals.update({"id":cid,"lead":lead,"piLC":piLC,"d_mil":d,"h_mil":h,"alphaS_ppm_C":alpha_s,"alphaCC_ppm_C":alpha_cc,"thetaJC_C_W":theta,"P_W":power,"package_TCE_basis":pkg_basis}) candidates.append(vals) panel("CANDIDATE RESULT",[f"{cid}: Nf={vals['Nf']:.10g}",f"alphaSMT={vals['alpha_SMT_h']:.10g} h",f"r={vals['life_ratio_r']:.10g}; ECF={vals['ECF']}",f"candidate lambda={vals['lambda_1e6h']:.10g} failures/1e6 h"]) if not ask_yes_no("Add another distinct SMT candidate/group?",default=True): break step(3,"COMPLETENESS / WEAKEST-LINK GATE") require_attestation("Are ALL SMT components on the defined board represented by the entered candidates/equivalent groups?","If a potentially governing SMT package is omitted, the max() result is not a valid board-level weakest-link result.") weakest=max(candidates,key=lambda x:x["lambda_1e6h"]) line=weakest["lambda_1e6h"] factors={"environment":env,"deltaT_C":delta_t,"deltaT_basis":dt_basis,"CR_cycles_per_h":cr,"CR_basis":cr_basis,"alphaS_ppm_C":alpha_s,"substrate_basis":sub_basis,"LC_h":life_hours,"candidate_count":len(candidates),"governing_candidate":weakest["id"],"governing_candidate_lambda":line} basis=f"Complete SMT candidate set attested; candidate rates not summed; governing candidate={weakest['id']}" warnings=["Section 16.2 represents thermal-fatigue wearout and expressly excludes solder/lead manufacturing defects; preserve separate defect accounting as applicable"] return finalize_supplement(board,"16.2","Notice 2 Section 16.2 pages 16-2 through 16-4","lambda_SMT,board=max_j[ECF_j/alphaSMT_j]",line,factors,basis,warnings) # ============================================================================= # SECTION 17.1 — INDIVIDUAL CONNECTIONS (SUPPLEMENTAL) # ============================================================================= CONNECTION_TYPES={ "HAND_SOLDER":.0013,"HAND_SOLDER_WRAPPED":.000070,"CRIMP":.00026,"WELD":.000015, "SOLDERLESS_WRAP":.0000068,"CLIP":.00012,"REFLOW":.000069,"SPRING_CONTACT":.17,"TERMINAL_BLOCK":.062, } def calc_connection(): banner("SECTION 17.1 — INDIVIDUAL CONNECTIONS","Only connections outside the Section 16 PTH/SMT boundary") step(1,"EXCLUSION GATE") part=ask_text("Connection group / identifier") represented=ask_yes_no("Are these physical joints already represented by Section 16 PTH or SMT?",default=None) if represented: raise ModelApplicabilityError("Section 17 must not be used for joints already represented by Section 16.") qty=ask_int("Number of equivalent physical connections",minimum=1) require_attestation("Do all grouped connections have the same connection type and modeled environment?","Quantity multiplication is valid only for equivalent grouped connections.") step(2,"CONNECTION TYPE / ENVIRONMENT") ct=ask_choice("Connection type",{k:f"{k} — lambda_b={v:g}" for k,v in CONNECTION_TYPES.items()},default=None) ek,piE=select_environment(CONNECTION_ENV) lb=CONNECTION_TYPES[ct] per=lb*piE line=qty*per factors={"connection_type":ct,"lambda_b":lb,"quantity":qty,"environment":ek,"piE":piE,"per_connection_lambda":per} basis="Section 17.1 used only for equivalent eligible connections outside Section 16; no quality factor exists in the current equation" return finalize_supplement(part,"17.1","Notice 2 Section 17.1 page 17-1","lambda_line=N*lambda_b*piE",line,factors,basis,[]) # ============================================================================= # SESSION / EXPORT / TESTS # ============================================================================= CALCULATORS={ "1":("Resistor — Section 9.1",calc_resistor), "2":("Capacitor — Section 10.1",calc_capacitor), "3":("Coil / inductor — Section 11.2",calc_coil), "4":("Transformer — Section 11.1",calc_transformer), "5":("Low-frequency diode — Section 6.1",calc_diode), "6":("Low-frequency silicon FET — Section 6.4",calc_fet), "7":("Optoelectronic — Section 6.11",calc_opto), "8":("General connector / mated pair — Section 15.1",calc_connector), "9":("Solid-state / time-delay relay — Section 13.2",calc_ssr), "10":("PTH interconnection assembly — Section 16.1 [supplemental]",calc_pth), "11":("SMT interconnection assembly — Section 16.2 [supplemental weakest-link]",calc_smt), "12":("Individual connection outside Section 16 — Section 17.1 [supplemental]",calc_connection), "X":("Exit / show session summary",None), } def session_summary(): banner("SESSION SUMMARY") selected=[r for r in RESULTS if r["status"]=="SELECTED_PART_STRESS_REPLACEMENT"] evaluated=[r for r in RESULTS if r["status"]=="EVALUATED_ONLY_NOT_SELECTED"] supplemental=[r for r in RESULTS if r["status"]=="SUPPLEMENTAL_MAIN_BODY_CONTRIBUTION"] sel_total=sum(r["line_lambda"] for r in selected) supp_total=sum(r["line_lambda"] for r in supplemental) print(f"Selected Part Stress replacements : {len(selected)}") print(f"Evaluated but NOT selected : {len(evaluated)}") print(f"Supplemental main-body entries : {len(supplemental)}") print(f"Selected replacement subtotal : {sel_total:.12g} failures/1e6 h") print(f"Supplemental subtotal : {supp_total:.12g} failures/1e6 h") print("\nIMPORTANT: these subtotals are not automatically the complete equipment lambda. They must be integrated") print("with the remaining non-overlapping Appendix A / main-body contributions at the defined equipment boundary.") return {"selected":selected,"evaluated":evaluated,"supplemental":supplemental} def export_results_csv(path="PSSC_results.csv"): path=Path(path) fields=["kind","status","part","section","lambda_p","quantity","line_lambda","source","formula","basis","selection_reference","warnings","note"] with path.open("w",newline="",encoding="utf-8-sig") as f: w=csv.DictWriter(f,fieldnames=fields) w.writeheader() for r in RESULTS: row={k:r.get(k,"") for k in fields} row["warnings"]=" | ".join(r.get("warnings",[])) w.writerow(row) print(f"Exported {len(RESULTS)} result records to: {path.resolve()}") return path def run_console(): banner("MIL-HDBK-217F APPENDIX A — PART STRESS SUPPLEMENT / REPLACEMENT CALCULATOR","Source-locked console build | ICs / microcircuits intentionally excluded") panel("ACCOUNTING RULES",[ "Piece-part Part Stress results are replacement CANDIDATES for the same Appendix A physical population. The program will never automatically choose the smaller lambda.", "A selected Part Stress replacement requires confirmation that the corresponding Appendix A population will be excluded.", "Sections 16.1, 16.2 and 17.1 are displayed separately as supplemental assembly/connection contributions because they are not ordinary intrinsic piece-part replacement rates.", "Unsupported model domains, missing mandatory evidence, overstress, ambiguous multi-device semiconductor packages, and source-table gaps cause a hard stop instead of an invented value.", ]) while True: key=ask_choice("MAIN MENU",{k:v[0] for k,v in CALCULATORS.items()},default=None) if key=="X": break try: CALCULATORS[key][1]() except (ModelApplicabilityError,EngineeringDispositionRequired,ValueError) as exc: stop_message(exc) except KeyboardInterrupt: print("\nCalculation cancelled by user; no result record added.") if not ask_yes_no("Return to the main menu for another calculation?",default=True): break summary=session_summary() if RESULTS and ask_yes_no("Export all result records and NOTE text to CSV?",default=False): name=ask_text("CSV output filename",default="PSSC_results.csv") while Path(name).name != name or Path(name).suffix.lower() != ".csv" or any(c in name for c in "/\\:\x00"): print("Enter a CSV filename without a directory path.") name=ask_text("CSV output filename",default="PSSC_results.csv") export_results_csv(name) return summary def run_self_tests(verbose=True): """Source-value / worked-example acceptance checks. Raises AssertionError on failure.""" # Section 9.1 normalization and stress checks assert math.isclose(arrhenius(25,.20),1.0,rel_tol=0,abs_tol=1e-12) assert math.isclose(arrhenius(25,.08),1.0,rel_tol=0,abs_tol=1e-12) assert math.isclose(1.0**.39,1.0,rel_tol=0,abs_tol=1e-12) assert math.isclose(resistor_piS(1,.5),.71*math.exp(.55),rel_tol=0,abs_tol=1e-12) assert math.isclose(resistor_piS(2,.5),.54*math.exp(1.02),rel_tol=0,abs_tol=1e-12) # Section 10.1 Notice 2 continuous-equation worked example check (~0.04656) cap_piT=arrhenius(50,.15) cap_piC=.015**.09 cap_S=(200+math.sqrt(2)*50)/400 cap_piV=capacitor_piV(1,cap_S) cap_lp=.00051*cap_piT*cap_piC*cap_piV*1.0*3.0*10.0 assert math.isclose(cap_piT,1.5716449017549696,rel_tol=1e-12) assert math.isclose(cap_lp,.04656,rel_tol=.002) # source inventory gives approximately 0.04656 # Section 11.2 fixed coil at 25 C, MIL-SPEC, GB assert math.isclose(.000030*arrhenius(25,.11)*1*1,.000030,rel_tol=0,abs_tol=1e-15) # Section 6 normalizations assert math.isclose(exp_temp(25,3091),1.0,rel_tol=0,abs_tol=1e-12) assert math.isclose(exp_temp(25,1925),1.0,rel_tol=0,abs_tol=1e-12) assert math.isclose(exp_temp(25,2790),1.0,rel_tol=0,abs_tol=1e-12) assert math.isclose(diode_piS(1.0),1.0,rel_tol=0,abs_tol=1e-12) # Section 15.1 normalization assert math.isclose(arrhenius(25,.14),1.0,rel_tol=0,abs_tol=1e-12) assert connector_piK(.01)==1.0 and connector_piK(.1)==1.5 and connector_piK(1)==2.0 and connector_piK(10)==3.0 and connector_piK(51)==4.0 # Section 13.2 default MIL-SPEC GB assert math.isclose(.029*1.0*1.0,.029,rel_tol=0,abs_tol=1e-15) # Appendix A raw Rate_Database reconstruction example: 42 * .0035 * 10 = 1.47 assert math.isclose(42*.0035*10,1.47,rel_tol=0,abs_tol=1e-15) # Section 16.2 Notice 2 worked example: Nf ~18,893; alpha~629,767 h; lambda~0.4/1e6 h alpha=15; dt=21; acc=7; trise_theta=10; power=1; d=740; h=5; cr=.03 # choose life to give source example r≈.28; 176330 h is consistent with the unrounded model vals=smt_candidate_lambda(d,h,alpha,dt,acc,trise_theta,power,1.0,cr,176330.1590018427) assert math.isclose(vals["Nf"],18893,rel_tol=5e-5) assert math.isclose(vals["alpha_SMT_h"],629767,rel_tol=5e-5) assert math.isclose(vals["life_ratio_r"],.28,rel_tol=5e-5) assert vals["ECF"]==.23 assert math.isclose(vals["lambda_1e6h"],.3652,rel_tol=.001) if verbose: banner("SELF-TESTS PASSED") print("All source-normalization and worked-example acceptance checks passed.") print("The notebook is ready for interactive use; model-domain/evidence gates remain mandatory.") return True if __name__ == "__main__": run_self_tests() run_console()