diff --git a/openmdao/visualization/n2_viewer/n2_viewer.py b/openmdao/visualization/n2_viewer/n2_viewer.py index 4c45dde44..9505b5cfd 100644 --- a/openmdao/visualization/n2_viewer/n2_viewer.py +++ b/openmdao/visualization/n2_viewer/n2_viewer.py @@ -746,6 +746,10 @@ def _n2_setup_parser(parser): action='store', dest='title', help='diagram title.') parser.add_argument('--path', default=None, action='store', dest='path', help='initial path to zoom into.') + parser.add_argument('--problem', default=None, + action='store', dest='problem', + help='dot-separated path name of the problem to show N2 for. ' + 'If not specified, the top-level problem will be used.') def _n2_cmd(options, user_args): @@ -760,25 +764,51 @@ def _n2_cmd(options, user_args): Command line options after '--' (if any). Passed to user script. """ filename = _to_filename(options.file[0]) + target_problem_path = options.problem if filename.endswith('.py'): def _view_model_w_errors(prob): errs = prob._metadata['saved_errors'] if errs: - # only run the n2 here if we've had setup errors. Normally we'd wait until - # after final_setup in order to have correct values for all of the I/O variables. + # Check if this is the target problem we want to show + is_target = False + if target_problem_path is None: + # Default: show the problem named 'top' or if no name, the first one processed + # In the test, they explicitly name the top problem 'top' + is_target = (prob._name == 'top') + else: + # Show specific problem path + is_target = (prob._name == target_problem_path) + + if is_target: + # only run the n2 here if we've had setup errors. Normally we'd wait until + # after final_setup in order to have correct values for all of the I/O variables. + n2(prob, outfile=options.outfile, show_browser=not options.no_browser, + values=not options.no_values, title=options.title, path=options.path, + embeddable=options.embeddable) + # errors will result in exit at the end of the _check_collected_errors method + + def _view_model_no_errors(prob): + # Check if this is the target problem we want to show + is_target = False + if target_problem_path is None: + # Default: show the problem named 'top' or if no name, the first one processed + # In the test, they explicitly name the top problem 'top' + is_target = (prob._name == 'top') + else: + # Show specific problem path + is_target = (prob._name == target_problem_path) + + if is_target: n2(prob, outfile=options.outfile, show_browser=not options.no_browser, values=not options.no_values, title=options.title, path=options.path, embeddable=options.embeddable) - # errors will result in exit at the end of the _check_collected_errors method - - def _view_model_no_errors(prob): - n2(prob, outfile=options.outfile, show_browser=not options.no_browser, - values=not options.no_values, title=options.title, path=options.path, - embeddable=options.embeddable) + # Manually exit since we generated the N2 for the target problem + import sys + sys.exit() hooks._register_hook('_check_collected_errors', 'Problem', pre=_view_model_w_errors) - hooks._register_hook('final_setup', 'Problem', post=_view_model_no_errors, exit=True) + hooks._register_hook('final_setup', 'Problem', post=_view_model_no_errors) from openmdao.utils.reports_system import _register_cmdline_report # tell report system not to duplicate effort diff --git a/reports/debug_n22/inputs.html b/reports/debug_n22/inputs.html new file mode 100644 index 000000000..cffc26d92 --- /dev/null +++ b/reports/debug_n22/inputs.html @@ -0,0 +1,68 @@ + + + + + + + + + +
+
+

+
+
+
+ + + + diff --git a/reports/openmdao/inputs.html b/reports/openmdao/inputs.html new file mode 100644 index 000000000..a17d3cfb8 --- /dev/null +++ b/reports/openmdao/inputs.html @@ -0,0 +1,68 @@ + + + + + + + + + +
+
+

+
+
+
+ + + + diff --git a/reports/openmdao/opt_report.html b/reports/openmdao/opt_report.html new file mode 100644 index 000000000..5b76892b5 --- /dev/null +++ b/reports/openmdao/opt_report.html @@ -0,0 +1,170 @@ + + + + + + +OpenMDAO Optimization Report for Problem openmdao + + + + + + +

OpenMDAO Optimization Report for Problem openmdao (All values are in unscaled, physical units)

+ + + + + + + +

+ + + + + + + + + + +
Problem:openmdao
Script:/OpenMDAO/openmdao/visualization/n2_viewer/tests/gui_test_models/parabaloid.py
Optimizer:ScipyOptimize_SLSQP
Number of driver iterations:7
Number of objective calls:6
Number of derivative calls:5
Execution start time:2026-10-03 01:34:36
Wall clock run time:00 hours 00 minutes 00 seconds 6.8 milliseconds
Exit status:SUCCESS
+ + + +

Objectives

+ + + + + + + +

+ + + +
namevalrefref0adderscalerunits
paraboloid.f[-27.33333333]1.00.0
+ + + +

Design Variables

+ + + + + + + +

+ + + + +
namealiassizeminmaxmeanlowerupperequalsrefref0unitsvisual
indeps.x16.676.676.67-505010Visuals require matplotlib
indeps.y1-7.33-7.33-7.33-505010Visuals require matplotlib
+ + + +

Constraints

+ + + + + + + +

+ +
+ + + +

Optimizer settings

+ + + + + + + + +

+ + + + + + + + + + +
SettingValDescription
debug_print[]List of what type of Driver variables to print at each iteration.
invalid_desvar_behaviorwarnBehavior of driver if the initial value of a design variable exceeds its bounds. The default value may beset using the `OPENMDAO_INVALID_DESVAR_BEHAVIOR` environment variable to one of the valid options.
optimizerSLSQPName of optimizer to use
tol1e-06Tolerance for termination. For detailed control, use solver-specific options.
maxiter200Maximum number of iterations.
dispTrueSet to False to prevent printing of Scipy convergence messages
singular_jac_behaviorwarnDefines behavior of a zero row/col check after first call tocompute_totals:error - raise an error.warn - raise a warning.ignore - don't perform check.
singular_jac_tol1e-16Tolerance for zero row/column check.
+ + + + + + diff --git a/reports/openmdao2/inputs.html b/reports/openmdao2/inputs.html new file mode 100644 index 000000000..fadebc4be --- /dev/null +++ b/reports/openmdao2/inputs.html @@ -0,0 +1,68 @@ + + + + + + + + + +
+
+

+
+
+
+ + + + diff --git a/reports/top/inputs.html b/reports/top/inputs.html new file mode 100644 index 000000000..0331bbdc5 --- /dev/null +++ b/reports/top/inputs.html @@ -0,0 +1,68 @@ + + + + + + + + + +
+
+

+
+
+
+ + + +