Structure views

Requires the viz extra (pip install "longeron[viz]").

Structure views of the analysis problems themselves (anywidgets).

Two interactive diagrams over the shape of an analysis, not its numbers, both following the house widget pattern (Python bakes one JSON payload; the inline vanilla-JS front-end only paints):

  • n2_view() – the classic N2 matrix of an OpenMDAO problem built by longeron.analysis.mdao.build_problem(), in the NASA/OpenMDAO orientation: components on the diagonal in execution order, a dot wherever one component’s output feeds another’s input. Each connection sits in the SOURCE’s row and the TARGET’s column, so the flow reads clockwise – out along the source’s row, then down the column to the receiver – FEED-FORWARD couplings fill the UPPER triangle and FEEDBACK couplings (a source that runs after its receiver) land in the LOWER triangle, drawn warm and ringed. DISCIPLINE blocks – components grouped by build_problem from the model’s own package structure – are outlined and named along the diagonal. Hovering a cell highlights its row and column and lists the coupled variables; clicking pins the tooltip. (openmdao_n2() embeds OpenMDAO’s own full-strength diagram for the deep dive; this widget is the lightweight dependency-free in-notebook map.)

  • openmdao_n2() – the official interactive N2 application (openmdao.api.n2) generated headlessly and returned inline as a sandboxed srcdoc iframe, so the full tool (solver hierarchy, collapsing, search) opens right in the notebook.

  • constraint_network() – a bipartite view of a TradeStudy: variation points (the decision variables) in one column, assert constraint bodies in the other, an edge wherever a constraint’s expression – transitively, through the derived attributes – touches a point’s selection. Hovering either side highlights its neighborhood; constraints that actually kill candidate mixes (pass architectures) are tinted warm with their violation count.

Payload builders (n2_payload(), constraint_network_payload()) are widget-free and unit-tested; the pure JS interaction math is factored into node-testable snippets.

Requires the viz extra for the widgets: pip install "longeron[viz]".

longeron.analysis.structure.constraint_network(study, architectures=None, *, width_px=760)[source]

The bipartite decision/constraint participation view of a study.

Hover a constraint to light up the variation points its expression (transitively) touches, and vice versa; constraints that kill mixes in architectures are tinted warm with their violation count.

Return type:

AnyWidget

longeron.analysis.structure.constraint_network_payload(study, architectures=None)[source]

The baked bipartite constraint-participation payload.

variables are the study’s variation points; constraints its assert constraint bodies; edges are [variable_index, constraint_index] pairs wherever the body references a point – directly or transitively through the derived attributes it names. With architectures (e.g. study.all_architectures()) each constraint carries its violation count over that space and is tinted when it actually kills mixes.

Return type:

dict[str, Any]

longeron.analysis.structure.n2_payload(problem)[source]

The baked N2 payload for a built OpenMDAO problem.

problem is an om.Problem or a ProblemBuild (its .problem is used). Components arrive in execution order; every global connection becomes a cell {row, col, feedback, vars} in the NASA/OpenMDAO orientation – row = the SOURCE component, col = the TARGET – so feed-forward couplings (source runs first) fill the upper triangle and the flow reads clockwise: out along the source’s row, down the target’s column. Feedback (a source that runs after its receiver) sits below the diagonal. groups records one level of grouping – contiguous components sharing a top-level OpenMDAO group (a SysML discipline package or a nested part) as {name, start, end} index runs, so the view can outline the discipline blocks. The synthetic _auto_ivc outputs (unconnected-input defaults) are skipped – they are bookkeeping, not couplings.

Return type:

dict[str, Any]

longeron.analysis.structure.n2_view(problem, *, width_px=640)[source]

An interactive N2 matrix of a built OpenMDAO problem.

NASA/OpenMDAO orientation: diagonal = components in execution order; dots = data couplings in the source’s row and the target’s column, so the flow reads clockwise (out along the row, down the column) and feed-forward fills the upper triangle; feedback couplings sit below the diagonal, warm and dash-ringed. Discipline groups (from the model’s package structure, via build_problem()) are outlined and named along the diagonal. Hover highlights a cell’s row and column and lists the coupled variables; click pins the tooltip.

Return type:

AnyWidget

longeron.analysis.structure.openmdao_n2(problem, *, height=620)[source]

OpenMDAO’s own interactive N2 diagram, embedded inline.

Generates the official standalone HTML application (openmdao.api.n2 with show_browser=False, embeddable=True) into a temporary file and returns it as an inline <iframe srcdoc=...> display object – self-contained (no server, no files left behind) and sandbox-friendly, which renders reliably in JupyterLab. Use it as the full-strength deep dive (solver hierarchy, collapsing, search) next to the lightweight n2_view() map.

Return type:

_InlineHTML