solver module#

class ResistorSelection(resistance, mpn, query)[source]#

Bases: object

A resistor chosen by the solver.

Carries a resolved ResistorQuery pinned to the exact part (by MPN, with resistance and precision) so the circuit can instantiate it through the public jitxlib.parts.Resistor factory.

Parameters:
resistance: float#
mpn: str#
query: ResistorQuery#
class VoltageDividerSolution(R_h, R_l, vo)[source]#

Bases: object

Voltage Divider Solution Type

Parameters:
R_h: ResistorSelection#
R_l: ResistorSelection#
vo: Toleranced#
class Ratio(high, low, loss)[source]#

Bases: object

Parameters:
high: float#
low: float#
loss: float#
solve(constraints)[source]#

Solve the Voltage Divider Constraint Problem.

Return type:

VoltageDividerSolution

Parameters:

constraints (VoltageDividerConstraints)

solve_over_series(constraints, precision, search_prec)[source]#
Return type:

Optional[VoltageDividerSolution]

Parameters:
filter_query_results(constraints, ratio, precision)[source]#
Return type:

Optional[VoltageDividerSolution]

Parameters:
sort_pairs_by_best_fit(constraints, precision, hi_res, lo_res)[source]#
Return type:

List[Ratio]

Parameters:
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).

Return type:

List[float]

Parameters:
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:
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:

List[Toleranced]

Parameters:
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:

Toleranced

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:

Toleranced

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:

Optional[Toleranced]

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:

Toleranced

Parameters: