Grand-tour knobs

The module needs no extra. The grand tour (tutorial 9) uses it.

The knobs of the grand tour, derived from the model.

A knob is a slider or a dropdown that the tour derives from the model for one subject (longeron.analysis.subject). No annotation and no Python table declares a knob. derive_knobs() reads the knobs off one definition with these rules:

  1. An input attribute is an attribute whose value is a numeric literal, not a derived expression. The function lists the input attributes of the definition, own and inherited.

  2. A bound source is an assert constraint of the definition, or a require constraint of a requirement definition whose subject type the definition conforms to. The function removes the subject name from a require body, so uav.x becomes x.

  3. An assume constraint is never a bound source. An assume constraint states where a requirement applies, not a range.

  4. The function folds x >= a and x <= b in both orientations and through and conjunctions. Only a literal a or b counts.

  5. An input attribute with a lower and an upper bound becomes a Slider over the closed interval. The slider starts at the literal value.

  6. An input attribute with one bound gets no slider. KnobSet.skipped lists it with the reason, so a notebook can print the gap.

  7. Each variation point of the trade study becomes a Dropdown over its variants, except the airframe point. A click in the tour fills the airframe point.

  8. With a trade study, a slider is kept only if its input reaches the mission: the metric, or a constraint of the study’s assembly that reads more than the input itself. A constraint that reads only the input is the input’s range, not a use of it. TradeStudy.dependents answers the question from the model’s references, so no attribute name is matched. An input that does not reach goes to KnobSet.skipped as "unreachable". For example, the ISR mission never reads the airframe’s cruiseSpeed.

The module imports no third-party package, and no function creates a widget. The knob set describes the knobs, and the tour builds them.

class longeron.analysis.knobs.Dropdown(point, variants, selected)[source]

Bases: object

A variation point and its variants, in model order.

class longeron.analysis.knobs.KnobSet(sliders, dropdowns, skipped)[source]

Bases: object

The knobs of one subject, in model order.

longeron.analysis.knobs.SkipReason

why an input attribute with a bound gets no slider: "lower_only" and "upper_only" name the one bound found, "default_outside" says the literal value is outside the interval, and "unreachable" says the input reaches neither the metric nor a constraint of the subject mission (rule 8)

alias of Literal[‘lower_only’, ‘upper_only’, ‘default_outside’, ‘unreachable’]

class longeron.analysis.knobs.Skipped(name, reason, low, high)[source]

Bases: object

An input attribute with a bound but no slider, and the reason.

name: str

in the form of Slider.name

class longeron.analysis.knobs.Slider(name, low, high, step, value)[source]

Bases: object

An input attribute with two literal bounds.

name is the override key of TradeStudy.evaluate. An attribute of the airframe variant takes the form <point>.<attribute>.

step: float

a power of ten, see _slider_step

value: float

the literal value of the attribute in the model

longeron.analysis.knobs.derive_knobs(interp, definition, *, study=None, selection=None, point='airframe', metric=None)[source]

The knobs of definition by the rules of this module.

definition is a mission definition, an airframe definition, an airframe variant usage, or a sizing context such as ScoutSizing::IsrPrime.

study is the trade study over definition. Each of its variation points except point becomes a dropdown. Without a study, the knob set has no dropdowns.

selection maps variation points to variant names, in the form of TradeStudy.evaluate. If it names a point variant, the sliders of that variant join the set as <point>.<attribute>. Each dropdown selects the variant that selection names, or the first variant if selection names none. A selection needs a study.

With a study, rule 8 removes each slider whose input reaches neither metric (a derived attribute of the study, the mission metric) nor a constraint of the study’s assembly.

Return type:

KnobSet