1- load("../units.zen", "Capacitance", "Resistance", "Temperature", "Voltage")
1+ load("../units.zen", "Capacitance", "Inductance", " Resistance", "Temperature", "Voltage")
22load("../utils.zen", "format_value")
33
44# -----------------------------------------------------------------------------
@@ -18,18 +18,19 @@ package = config("package", Package, default=Package("0603"))
1818value = config("value", Capacitance)
1919
2020# Optional
21- mpn = config("mpn", str, optional=True)
22- manufacturer = config("manufacturer", str, optional=True)
23- mount = config("mount", Mount, default=Mount("SMD"), optional=True)
24- voltage = config("voltage", Voltage, optional=True)
25- dielectric = config("dielectric", Dielectric, optional=True)
26- esr = config("esr", Resistance, optional=True)
27- t_max = config("t_max", Temperature, optional=True)
28- t_min = config("t_min", Temperature, optional=True)
29-
30- do_not_populate = config("do_not_populate", bool, default=False)
31- exclude_from_bom = config("exclude_from_bom", bool, default=False)
32- skip_bom = config("skip_bom", bool, default=False)
21+ mpn = config("mpn", str, optional=True, help="Manufacturer Part Number")
22+ manufacturer = config("manufacturer", str, optional=True, help="Manufacturer")
23+ mount = config("mount", Mount, default=Mount("SMD"), optional=True, help="Mounting type")
24+ voltage = config("voltage", Voltage, optional=True, help="Maximum operating voltage")
25+ dielectric = config("dielectric", Dielectric, optional=True, help="Dielectric material type")
26+ esr = config("esr", Resistance, optional=True, help="Equivalent series resistance")
27+ esl = config("esl", Inductance, optional=True, help="Equivalent series inductance")
28+ t_max = config("t_max", Temperature, optional=True, help="Maximum operating temperature")
29+ t_min = config("t_min", Temperature, optional=True, help="Minimum operating temperature")
30+
31+ do_not_populate = config("do_not_populate", bool, default=False, help="Do not populate the component in the BOM")
32+ exclude_from_bom = config("exclude_from_bom", bool, default=False, help="Exclude the component from the BOM")
33+ skip_bom = config("skip_bom", bool, default=False, help="Skip the BOM generation")
3334
3435if do_not_populate:
3536 warn("do_not_populate is deprecated. Use dnp instead.", kind="deprecated.do_not_populate")
@@ -94,6 +95,53 @@ def _footprint(mount: Mount, package: Package):
9495 return kicad_footprints[(mount, package)]
9596
9697
98+ def _spice_args(value, package, esr=None, esl=None):
99+ """Derive series RLC model parameters for a realistic capacitor.
100+
101+ ESL is estimated from package size (pad geometry determines loop inductance).
102+ ESR uses the user-supplied value if available, otherwise a reasonable
103+ default that scales with package size.
104+ """
105+
106+ # Typical ESL by package -- based on published MLCC measurements (nH)
107+ esl_table = {
108+ Package("01005"): Inductance("0.08nH"),
109+ Package("0201"): Inductance("0.15nH"),
110+ Package("0402"): Inductance("0.35nH"),
111+ Package("0603"): Inductance("0.5nH"),
112+ Package("0805"): Inductance("0.7nH"),
113+ Package("1206"): Inductance("1.0nH"),
114+ Package("1210"): Inductance("1.0nH"),
115+ Package("1812"): Inductance("1.5nH"),
116+ Package("1825"): Inductance("1.5nH"),
117+ Package("2220"): Inductance("2.0nH"),
118+ Package("2225"): Inductance("2.0nH"),
119+ Package("3640"): Inductance("2.5nH"),
120+ }
121+
122+ # Typical ESR by package -- larger bodies dissipate better
123+ esr_table = {
124+ Package("01005"): Resistance("50mOhm"),
125+ Package("0201"): Resistance("30mOhm"),
126+ Package("0402"): Resistance("10mOhm"),
127+ Package("0603"): Resistance("5mOhm"),
128+ Package("0805"): Resistance("3mOhm"),
129+ Package("1206"): Resistance("2mOhm"),
130+ Package("1210"): Resistance("2mOhm"),
131+ Package("1812"): Resistance("1.5mOhm"),
132+ Package("1825"): Resistance("1.5mOhm"),
133+ Package("2220"): Resistance("1mOhm"),
134+ Package("2225"): Resistance("1mOhm"),
135+ Package("3640"): Resistance("1mOhm"),
136+ }
137+
138+ return {
139+ "CVAL": str(value),
140+ "ESR": str(esr or esr_table.get(package, Resistance("50mOhm"))),
141+ "ESL": str(esl or esl_table.get(package, Inductance("0.5nH"))),
142+ }
143+
144+
97145# -----------------------------------------------------------------------------
98146# Component definition
99147# -----------------------------------------------------------------------------
@@ -116,10 +164,10 @@ Component(
116164 "P2": P2,
117165 },
118166 spice_model=SpiceModel(
119- "../simulation /Capacitor.lib",
167+ "spice /Capacitor.lib",
120168 "C",
121169 nets=[P1, P2],
122- args={"CVAL": str (value.value)} ,
170+ args=_spice_args (value, package, esr, esl) ,
123171 ),
124172 dnp=do_not_populate,
125173 skip_bom=skip_bom or exclude_from_bom,
0 commit comments