Parameter studies in Python
Study from the CENOS Python package solves a case again and again while it changes named parameters. It runs three kinds of study: a sweep to learn what a dimension does, a search that tunes the design for you, and a tolerance check before production. This page shows all three on a dual-band printed inverted-F antenna for 800 and 1700 MHz.
Before you start
You need cenos-py 0.3.4 or newer. Installation and the trace file are on the Python scripting page. Build and solve the case in the GUI first. A study can only change what the case exposes:
- Geometry variables of a case built from a Python geometry script, or from a template. A case imported from STEP has no geometry variables.
- Material properties, written as
group.property, for exampleSolid_1.epsilon. The group is the material group name in the case.

How a study works
import numpy as np
import cenos_py
from cenos_py.tools.study import Study
case = cenos_py.CenosCaseRF()
case.open(r"C:\cases\dualband_ifa")
study = Study(case,
{"high_len": (26.0, 22.0, 30.0)}, # name: (nominal, low, high)
workspace=r"C:\studies\high_len")
- Parameters: each name gets (nominal, low, high). The study checks that material names exist in the case and stops with a clear error if they do not.
- Workspace: every solved design is stored there. Run the script again and solved designs are read back, not solved again, so a study that stops at solve 4 of 5 continues where it left off.
- Capture: what is kept from each solve. The standard one for RF keeps frequency, S11, VSWR, resistance and reactance. Pass your own to keep more:
def capture(case):
r = case.results
return {"frequency": r.get_frequency(),
"S11": r.get_s_parameter("S11"),
"radiated": r.get_radiated_power()}
study = Study(case, {"high_len": (26.0, 22.0, 30.0)}, capture=capture, workspace=r"C:\studies\high_len")
Other members: study.defaults (nominal values), study.bounds, study.nominal (the nominal design, solved on first read) and study.evaluate({...}) (solve one design, or read it from the workspace).
Sweep
sweep takes a grid (every combination of the lists) or an explicit list of designs, and returns the solved designs. A measure turns each design into one number:
solved = study.sweep({"high_len": [22, 24, 26, 28, 30]})
def high_dip(run):
"""Frequency of the deepest S11 point between 1.4 and 2 GHz, refined with a parabola."""
f, s11 = np.ravel(run["frequency"]), np.ravel(run["S11"])
band = np.flatnonzero((f > 1.4e9) & (f < 2.0e9))
i = band[np.argmin(s11[band])]
a, b, c = np.polyfit(f[i - 1:i + 2], s11[i - 1:i + 2], 2)
return -b / (2 * a)
dips = solved.metric(high_dip) # one number per solved design
for values, dip in zip(solved.values, dips):
print(values["high_len"], f"{dip / 1e6:.0f} MHz")
solved.values and solved.snapshots hold the inputs and the captured results; solved.plot(measure) draws a histogram. Five solves of about 14 minutes each gave: each extra millimetre of branch lowers the high band by about 46 MHz (1908 MHz at 22 mm, 1541 MHz at 30 mm), while the low band moves only 1.7 MHz/mm. So the two bands can be tuned one after the other.

Search
minimize searches for the design with the lowest cost. A cost is one number per design, zero when the design is right:
study = Study(case, {"high_len": (22.0, 18.0, 32.0)}, workspace=r"C:\studies\tune")
def cost(run):
return abs(high_dip(run) - 1700e6) / 1700e6
solved = study.minimize(cost, max_solves=10)
print(solved.best, solved.cost, solved.converged)
From a poor start at 22 mm (1908 MHz) it found 26.1 mm, with the dip at 1698.9 MHz, in ten solves (about 2.3 h).

Ready-made costs from cenos_py.tools.rf:
| Cost | Zero when |
|---|---|
resonance_error(f) |
the deepest S11 point sits at f (grid point, no refinement) |
band_miss((f1, f2), level_db=-10) |
S11 stays under the level across the whole band |
negative_bandwidth(level_db=-10) |
never; more negative means a wider matched band |
- The default method is Nelder-Mead, which needs no gradient: the mesh is rebuilt for every design, so a finite-difference gradient would measure mesh noise.
- It stops at
max_solves. Checkconvergedbefore you trust the answer. - For another optimizer, drive the study yourself with
study.evaluateandstudy.bounds.
Theory: how the search works
Nelder-Mead keeps n + 1 designs for n parameters (a simplex) and replaces the worst one by reflecting it through the others, stretching or shrinking the step as the cost improves or not. It needs no derivatives, which matters here: every design is meshed again, so a finite-difference gradient would mostly measure mesh noise. Its first steps are set by the parameter range, so parameters with very different effects per unit need scaling.
Tolerances and yield
solve_limits answers which tolerance matters, in 2n + 1 solves for n parameters: the nominal design, then each parameter at its low and its high limit.
study = Study(case, {
"w": (1.5, 1.4, 1.6), # trace width, mm
"board_t": (1.6, 1.45, 1.75), # board thickness, mm
"Solid_1.epsilon": (4.4, 4.2, 4.6), # FR4 permittivity
}, workspace=r"C:\studies\tolerance")
report = study.solve_limits(high_dip) # 7 solves
print(report.ranked) # largest effect first
report.plot_sensitivity()
sigmas = {"w": 0.033, "board_t": 0.05, "Solid_1.epsilon": 0.067} # limits taken as 3 sigma
print(report.sigma(sigmas)) # spread of the dip, Hz
f0 = high_dip(study.nominal)
print(report.yield_within(0.99 * f0, 1.01 * f0, sigmas)) # fraction within +-1 %
print(report.variance_contributions(sigmas))
report.plot(sigmas, low=0.99 * f0, high=1.01 * f0)
A second measure costs nothing: study.solve_limits(low_dip) reads the seven stored designs.
| ToleranceReport member | What it gives |
|---|---|
ranked |
parameters, largest effect first |
slopes, second_derivatives() |
the fitted model per parameter |
parameters_without_effect() |
parameters whose low and high gave the same result: usually a misspelled name |
sigma(sigmas) |
standard deviation of the measure |
yield_within(low, high, sigmas) |
fraction of parts inside the limits |
variance_contributions(sigmas) |
share of the spread from each parameter |
plot(sigmas), plot_sensitivity() |
histogram and shift per limit |
Theory: the tolerance model
From the three solves of each parameter (low, nominal, high, a step h from nominal) the report fits a slope and a curvature:
s = (f_high − f_low) / (2h) slope q = (f_high − 2·f_nom + f_low) / (2h²) curvature f ≈ f_nom + Σ ( s·Δx + q·Δx² ) σ_f² = Σ ( s²·σ² + 2·q²·σ⁴ )
Each parameter is treated on its own: interactions between parameters are left out. The yield is the share of random parameter draws (thousands, from the model, no solves) that land inside your limits.
For the dual-band antenna, the high band moved about +20/−19 MHz with permittivity 4.2/4.6 and +20/−13 MHz with thickness 1.45/1.75 mm. With the limits as ±3σ, the dip spreads by about 10 MHz and about 93 % of boards land within ±1 %.


study.sample(sigmas, count), which solves every draw.Examples
Runnable scripts are in the example library that comes with the installer (see Python scripting). To read more out of solved cases, see Antenna results in Python.
