solver module#
- class ResistorSelection(resistance, mpn, query)[source]#
Bases:
objectA resistor chosen by the solver.
Carries a resolved
ResistorQuerypinned to the exact part (by MPN, with resistance and precision) so the circuit can instantiate it through the publicjitxlib.parts.Resistorfactory.- Parameters:
resistance (float)
mpn (str)
query (ResistorQuery)
- query: ResistorQuery#
- class VoltageDividerSolution(R_h, R_l, vo)[source]#
Bases:
objectVoltage Divider Solution Type
- Parameters:
R_h (ResistorSelection)
R_l (ResistorSelection)
vo (Toleranced)
- R_h: ResistorSelection#
- R_l: ResistorSelection#
- vo: Toleranced#
- solve(constraints)[source]#
Solve the Voltage Divider Constraint Problem.
- Return type:
- Parameters:
constraints (VoltageDividerConstraints)
- solve_over_series(constraints, precision, search_prec)[source]#
- Return type:
- Parameters:
constraints (VoltageDividerConstraints)
precision (float)
search_prec (float)
- filter_query_results(constraints, ratio, precision)[source]#
- Return type:
- Parameters:
constraints (VoltageDividerConstraints)
ratio (Ratio)
precision (float)
- query_resistance_by_values(constraints, goal_r, r_prec, min_prec)[source]#
Query for resistance values within the specified precision range using search_resistors. Returns a list of resistance values (float).
- query_resistors(constraints, target, prec)[source]#
Query for resistors matching a particular target resistance and precision. Returns the parameters the solver needs (resistance, mpn, tolerance, tcr).
- Return type:
List[_ResistorData]- Parameters:
constraints (VoltageDividerConstraints)
target (float)
prec (float)
- study_solution(constraints, r_hi, r_lo, temp_range)[source]#
Compute the voltage divider expected output over a temperature range. Returns a list of Toleranced values for [min_temp, max_temp].
- Return type:
- Parameters:
constraints (VoltageDividerConstraints)
r_hi (_ResistorData)
r_lo (_ResistorData)
temp_range (Toleranced)
- get_resistance(r)[source]#
Get the resistance value as a Toleranced. Combines the nominal resistance with the (min, max) tolerance band. Raises an error if tolerance is None.
- Return type:
- Parameters:
r (_ResistorData)
- tol_minmax(typ, tolerance)[source]#
Create a Toleranced value from a (min, max) tolerance band. Mirrors the Stanza implementation: tol(v, tolerance:MinMaxRange):
coeff = min-max(1.0 + min(tolerance), 1.0 + max(tolerance)) v * coeff
- Return type:
- Parameters:
- compute_tcr_deviation(resistor, temperature)[source]#
Compute the expected deviation window of a given resistor at a given temperature.
This function mirrors the Stanza implementation in component-types.stanza: - Extracts tcr and reference temperature from the resistor. - Converts pos/neg to a Toleranced interval using Toleranced.min_max. - Calls compute_tcr_deviation_interval. - Returns None if tcr is not present.
NOTE: This includes a workaround for known database issues with TCR values, as described in the Stanza code and PROD-328.
- Return type:
- Parameters:
resistor (_ResistorData)
temperature (float)
- compute_tcr_deviation_interval(tcr, temperature, ref_temp=25.0)[source]#
Compute the expected deviation window of a given temperature coefficient.
This function mirrors the Stanza implementation: - Returns 1.0 + (diff * tcr), where diff = temperature - ref_temp. - The result is a Toleranced window for the deviation (typically ~0.9 to 1.1).
- Return type:
- Parameters:
tcr (Toleranced)
temperature (float)
ref_temp (float)