Optimisation

OptSq — square-spiral inductor optimisation.

Mirrors the binary’s cmd_opt_l_sq (case 700 in commands.json): given a target inductance and operating frequency, search over (length, turns, width, spacing) for the geometry that maximises Q while meeting the L target. We use scipy.optimize.minimize with the SLSQP algorithm for constrained optimisation.

The original ASITIC’s optimiser is a hand-rolled gradient descent with finite differences (set_cell_size_normal / compute_inductance re-evaluated each step). scipy.optimize’s SLSQP is more robust, supports multiple constraints, and gives us quasi-Newton convergence for free.

class reasitic.optimise.opt_sq.OptResult[source]

Bases: object

One optimisation result.

success: bool
length_um: float
width_um: float
spacing_um: float
turns: float
L_nH: float
Q: float
n_iter: int
message: str
__init__(success, length_um, width_um, spacing_um, turns, L_nH, Q, n_iter, message)
Parameters:
Return type:

None

reasitic.optimise.opt_sq.optimise_square_spiral(tech, *, target_L_nH, freq_ghz, metal=0, length_bounds=(50.0, 500.0), width_bounds=(2.0, 30.0), spacing_bounds=(1.0, 10.0), turns_bounds=(1.0, 10.0), init=None, L_tolerance=0.05)[source]

Maximise Q for a square spiral subject to L = target_L_nH.

init is an optional (length, width, spacing, turns) starting point; if omitted, the centre of each parameter’s bounds is used. Returns an OptResult with the best geometry plus its computed L and Q.

The constraint |L - target| / target L_tolerance is enforced via SLSQP inequality constraints.

Parameters:
Return type:

OptResult

OptPoly and related optimisation drivers.

Extensions of reasitic.optimise.opt_sq.optimise_square_spiral() to other inductor topologies. All use the same scipy SLSQP solver and report the same OptResult for uniformity.

Mirrors the binary’s OptPoly (case 708), OptArea (case 706), OptSymSq (case 713), OptSymPoly (case 714).

reasitic.optimise.opt_poly.optimise_polygon_spiral(tech, *, target_L_nH, freq_ghz, sides=8, metal=0, radius_bounds=(50.0, 500.0), width_bounds=(2.0, 30.0), spacing_bounds=(1.0, 10.0), turns_bounds=(1.0, 10.0), L_tolerance=0.05)[source]

Maximise Q for an N-sided polygon spiral subject to an L target.

Mirrors cmd_opt_l_poly (case 708).

Parameters:
Return type:

OptResult

reasitic.optimise.opt_poly.optimise_area_square_spiral(tech, *, target_L_nH, freq_ghz, metal=0, length_bounds=(50.0, 500.0), width_bounds=(2.0, 30.0), spacing_bounds=(1.0, 10.0), turns_bounds=(1.0, 10.0), L_tolerance=0.05)[source]

Minimise the chip-area footprint of a square spiral while meeting an L target.

Mirrors cmd_opt_area (case 706). Optimises length² (the bounding-box area of the spiral) directly; the bias-balance with Q is not enforced.

Parameters:
Return type:

OptResult

reasitic.optimise.opt_poly.optimise_symmetric_square(tech, *, target_L_nH, freq_ghz, metal=0, length_bounds=(50.0, 500.0), width_bounds=(2.0, 30.0), spacing_bounds=(1.0, 10.0), turns_bounds=(1.0, 10.0), L_tolerance=0.05)[source]

OptSymSq — symmetric centre-tapped square spiral.

Parameters:
Return type:

OptResult

BatchOpt — batch optimisation across multiple design points.

Run the per-point optimiser at every entry of a (target_L_nH, freq_ghz) table, returning a NumPy structured array of best geometries. Mirrors cmd_batchopt (case 707).

reasitic.optimise.batch.batch_opt_square(tech, *, targets, metal=0)[source]

Run optimise_square_spiral() for each (L_nH, f_GHz) pair.

Returns one row per target with the best geometry parameters, achieved L and Q, plus a success flag.

Parameters:
Return type:

ndarray

Parametric geometry sweep.

Mirrors the binary’s Sweep / SweepMM commands (cases 711 / 715). Iterates a square-spiral builder over a Cartesian grid of (length, width, spacing, turns) values, computing the inductance and metal-loss Q at each grid point. The result is a NumPy structured array suitable for numpy.savetxt / pandas / matplotlib.

Useful for quick design-space exploration: pick the corner of parameter space that maximises Q while meeting an L target.

reasitic.optimise.sweep.sweep_square_spiral(tech, *, length_um, width_um, spacing_um, turns, freq_ghz, metal=0)[source]

Cartesian sweep of square-spiral geometry → structured array.

Returns an np.ndarray with dtype (length_um, width_um, spacing_um, turns, L_nH, Q). Bad geometries (where the inner radius collapses) appear with L_nH = NaN and Q = NaN.

Parameters:
Return type:

ndarray

reasitic.optimise.sweep.sweep_to_tsv(arr)[source]

Format a sweep result as TSV (tab-separated values).

Parameters:

arr (ndarray)

Return type:

str

reasitic.optimise.sweep.sweep_to_csv(arr)[source]

Format a sweep result as CSV (comma-separated values).

Loads directly into pandas via pd.read_csv(StringIO(s)).

Parameters:

arr (ndarray)

Return type:

str