{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "a0700e3a",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:50:12.583927Z",
     "iopub.status.busy": "2026-10-02T14:50:12.583680Z",
     "iopub.status.idle": "2026-10-02T14:50:12.587774Z",
     "shell.execute_reply": "2026-10-02T14:50:12.587251Z"
    },
    "hide_input": true,
    "papermill": {
     "duration": 0.010034,
     "end_time": "2026-10-02T14:50:12.588603+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:12.578569+00:00",
     "status": "completed"
    },
    "tags": [
     "active-ipynb",
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "try:\n",
    "    from openmdao.utils.notebook_utils import notebook_mode  # noqa: F401\n",
    "except ImportError:\n",
    "    !python -m pip install openmdao[notebooks]"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "72dae1b6",
   "metadata": {
    "papermill": {
     "duration": 0.002924,
     "end_time": "2026-10-02T14:50:12.594914+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:12.591990+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "# Listing Variables\n",
    "\n",
    "When working with a model, it may sometimes be helpful to examine the input and output variables. Several methods are provided for this purpose.\n",
    "\n",
    "```{eval-rst}\n",
    "    .. automethod:: openmdao.core.system.System.list_inputs\n",
    "        :noindex:\n",
    "\n",
    "    .. automethod:: openmdao.core.system.System.list_outputs\n",
    "        :noindex:\n",
    "\n",
    "    .. automethod:: openmdao.core.system.System.list_vars\n",
    "        :noindex:\n",
    "```\n",
    "\n",
    "## Example\n",
    "\n",
    "In the following example, we create a model consisting of two instances of `ImplicitComponent`.\n",
    "\n",
    "The implicit components are both instances of `QuadraticComp`, defined as shown here."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "7d3e8f30",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:50:12.648220Z",
     "iopub.status.busy": "2026-10-02T14:50:12.648052Z",
     "iopub.status.idle": "2026-10-02T14:50:13.772435Z",
     "shell.execute_reply": "2026-10-02T14:50:13.771721Z"
    },
    "papermill": {
     "duration": 1.128573,
     "end_time": "2026-10-02T14:50:13.773022+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:12.644449+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "import openmdao.api as om\n",
    "\n",
    "\n",
    "class QuadraticComp(om.ImplicitComponent):\n",
    "    \"\"\"\n",
    "    A Simple Implicit Component representing a Quadratic Equation.\n",
    "\n",
    "    R(a, b, c, x) = ax^2 + bx + c\n",
    "\n",
    "    Solution via Quadratic Formula:\n",
    "    x = (-b + sqrt(b^2 - 4ac)) / 2a\n",
    "    \"\"\"\n",
    "\n",
    "    def setup(self):\n",
    "        self.add_input('a', val=1., tags=['tag_a'])\n",
    "        self.add_input('b', val=1.)\n",
    "        self.add_input('c', val=1.)\n",
    "        self.add_output('x', val=0., tags=['tag_x'])\n",
    "\n",
    "    def setup_partials(self):\n",
    "        self.declare_partials(of='*', wrt='*')\n",
    "\n",
    "    def apply_nonlinear(self, inputs, outputs, residuals):\n",
    "        a = inputs['a']\n",
    "        b = inputs['b']\n",
    "        c = inputs['c']\n",
    "        x = outputs['x']\n",
    "        residuals['x'] = a * x ** 2 + b * x + c\n",
    "\n",
    "    def solve_nonlinear(self, inputs, outputs):\n",
    "        a = inputs['a']\n",
    "        b = inputs['b']\n",
    "        c = inputs['c']\n",
    "        outputs['x'] = (-b + (b ** 2 - 4 * a * c) ** 0.5) / (2 * a)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "23777c56",
   "metadata": {
    "papermill": {
     "duration": 0.029737,
     "end_time": "2026-10-02T14:50:13.805594+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:13.775857+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "These two components are placed in a `Group` with their common inputs promoted together."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "d50baf22",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:50:13.812433Z",
     "iopub.status.busy": "2026-10-02T14:50:13.812042Z",
     "iopub.status.idle": "2026-10-02T14:50:14.992082Z",
     "shell.execute_reply": "2026-10-02T14:50:14.991450Z"
    },
    "papermill": {
     "duration": 1.184196,
     "end_time": "2026-10-02T14:50:14.992561+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:13.808365+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1790952614.981064] [runnervm8df0l:11939:0]        ib_iface.c:1269 UCX  ERROR mana_0: iface 0x55ca6ef152b0 failed to create UD QP TX wr:256 sge:6 inl:64 resp:0 RX wr:4096 sge:1 resp:0 failed: Operation not supported\n",
      "[1790952614.981306] [runnervm8df0l:11939:0]      ucp_worker.c:1412 UCX  ERROR uct_iface_open(ud_verbs/mana_0:1) failed: Input/output error\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "[runnervm8df0l:11939] pml_ucx.c:313  Error: Failed to create UCP worker\n"
     ]
    }
   ],
   "source": [
    "import openmdao.api as om\n",
    "\n",
    "group = om.Group()\n",
    "\n",
    "sub = group.add_subsystem('sub', om.Group(), promotes_inputs=['a', 'b', 'c'])\n",
    "\n",
    "sub.add_subsystem('comp1', QuadraticComp(), promotes_inputs=['a', 'b', 'c'])\n",
    "sub.add_subsystem('comp2', QuadraticComp(), promotes_inputs=['a', 'b', 'c'])\n",
    "\n",
    "global prob\n",
    "prob = om.Problem(model=group)\n",
    "prob.setup()\n",
    "\n",
    "prob.set_val('a', 1.)\n",
    "prob.set_val('b', -4.)\n",
    "prob.set_val('c', 3.)\n",
    "prob.run_model()"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "9acdadbc",
   "metadata": {
    "papermill": {
     "duration": 0.002472,
     "end_time": "2026-10-02T14:50:14.997818+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:14.995346+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "## Usage\n",
    "\n",
    "(list-inputs)=\n",
    "### *List Inputs*\n",
    "\n",
    "The `list_inputs()` method on a System will display all the inputs in execution order with their values. By default, the variable name and variable value are displayed. Also by default, the variables are displayed as part of the System hierarchy."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "cd7b8440",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:50:15.083814Z",
     "iopub.status.busy": "2026-10-02T14:50:15.083563Z",
     "iopub.status.idle": "2026-10-02T14:50:15.087525Z",
     "shell.execute_reply": "2026-10-02T14:50:15.086725Z"
    },
    "papermill": {
     "duration": 0.008422,
     "end_time": "2026-10-02T14:50:15.088049+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:15.079627+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "6 Input(s) in 'model'\n",
      "\n",
      "varname  val    prom_name\n",
      "-------  -----  ---------\n",
      "sub\n",
      "  comp1\n",
      "    a    [1.]   a        \n",
      "    b    [-4.]  b        \n",
      "    c    [3.]   c        \n",
      "  comp2\n",
      "    a    [1.]   a        \n",
      "    b    [-4.]  b        \n",
      "    c    [3.]   c        \n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "prob.model.list_inputs();"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "95a43e9a",
   "metadata": {
    "papermill": {
     "duration": 0.002638,
     "end_time": "2026-10-02T14:50:15.093401+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:15.090763+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "### *List Outputs*\n",
    "\n",
    "The `list_outputs()` method will display all the outputs in execution order. There are many options to this method, which we will explore below. For this example, we will only display the value in addition to the name of the output variable."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "def2658d",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:50:15.099400Z",
     "iopub.status.busy": "2026-10-02T14:50:15.099224Z",
     "iopub.status.idle": "2026-10-02T14:50:15.102274Z",
     "shell.execute_reply": "2026-10-02T14:50:15.101745Z"
    },
    "papermill": {
     "duration": 0.006723,
     "end_time": "2026-10-02T14:50:15.102722+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:15.095999+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0 Explicit Output(s) in 'model'\n",
      "\n",
      "\n",
      "2 Implicit Output(s) in 'model'\n",
      "\n",
      "varname  val   prom_name  \n",
      "-------  ----  -----------\n",
      "sub\n",
      "  comp1\n",
      "    x    [3.]  sub.comp1.x\n",
      "  comp2\n",
      "    x    [3.]  sub.comp2.x\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "prob.model.list_outputs();"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "5dbcf006",
   "metadata": {
    "papermill": {
     "duration": 0.002496,
     "end_time": "2026-10-02T14:50:15.107676+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:15.105180+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "### *List Implicit or Explicit Outputs*\n",
    "\n",
    "Note that explicit and implicit outputs are listed separately. If you are only interested in seeing one or the other, you can exclude the ones you do not wish to see via the implicit and explicit arguments."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "65732b47",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:50:15.113377Z",
     "iopub.status.busy": "2026-10-02T14:50:15.113229Z",
     "iopub.status.idle": "2026-10-02T14:50:15.115959Z",
     "shell.execute_reply": "2026-10-02T14:50:15.115412Z"
    },
    "papermill": {
     "duration": 0.006146,
     "end_time": "2026-10-02T14:50:15.116303+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:15.110157+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0 Explicit Output(s) in 'model'\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "prob.model.list_outputs(implicit=False);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "ee63c8ff",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:50:15.122109Z",
     "iopub.status.busy": "2026-10-02T14:50:15.121985Z",
     "iopub.status.idle": "2026-10-02T14:50:15.124893Z",
     "shell.execute_reply": "2026-10-02T14:50:15.124329Z"
    },
    "papermill": {
     "duration": 0.006532,
     "end_time": "2026-10-02T14:50:15.125350+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:15.118818+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2 Implicit Output(s) in 'model'\n",
      "\n",
      "varname  val   prom_name  \n",
      "-------  ----  -----------\n",
      "sub\n",
      "  comp1\n",
      "    x    [3.]  sub.comp1.x\n",
      "  comp2\n",
      "    x    [3.]  sub.comp2.x\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "prob.model.list_outputs(explicit=False);"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "d68263b0",
   "metadata": {
    "papermill": {
     "duration": 0.002441,
     "end_time": "2026-10-02T14:50:15.130493+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:15.128052+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "### *Get List via Return Value*\n",
    "\n",
    "Both of these methods also return the information in the form of a list. You can disable the display of the information by setting the argument `out_stream` to `None` and then access the data instead via the return value."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "33e679ae",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:50:15.171262Z",
     "iopub.status.busy": "2026-10-02T14:50:15.171082Z",
     "iopub.status.idle": "2026-10-02T14:50:15.174555Z",
     "shell.execute_reply": "2026-10-02T14:50:15.174013Z"
    },
    "papermill": {
     "duration": 0.042022,
     "end_time": "2026-10-02T14:50:15.175021+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:15.132999+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[('sub.comp1.a', {'prom_name': 'a', 'val': array([1.])}),\n",
      " ('sub.comp1.b', {'prom_name': 'b', 'val': array([-4.])}),\n",
      " ('sub.comp1.c', {'prom_name': 'c', 'val': array([3.])}),\n",
      " ('sub.comp2.a', {'prom_name': 'a', 'val': array([1.])}),\n",
      " ('sub.comp2.b', {'prom_name': 'b', 'val': array([-4.])}),\n",
      " ('sub.comp2.c', {'prom_name': 'c', 'val': array([3.])})]\n"
     ]
    }
   ],
   "source": [
    "# list inputs\n",
    "inputs = prob.model.list_inputs(out_stream=None)\n",
    "\n",
    "from pprint import pprint\n",
    "pprint(sorted(inputs))"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "c0e80984",
   "metadata": {
    "papermill": {
     "duration": 0.002518,
     "end_time": "2026-10-02T14:50:15.180261+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:15.177743+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "### *List Names Only*\n",
    "\n",
    "If you just want to see the names of the variables, you can disable the display of the values by setting the optional argument `val` to *False*."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "f88f793e",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:50:15.187154Z",
     "iopub.status.busy": "2026-10-02T14:50:15.187000Z",
     "iopub.status.idle": "2026-10-02T14:50:15.189661Z",
     "shell.execute_reply": "2026-10-02T14:50:15.189094Z"
    },
    "papermill": {
     "duration": 0.006164,
     "end_time": "2026-10-02T14:50:15.190060+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:15.183896+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "6 Input(s) in 'model'\n",
      "\n",
      "varname  prom_name\n",
      "-------  ---------\n",
      "sub\n",
      "  comp1\n",
      "    a    a        \n",
      "    b    b        \n",
      "    c    c        \n",
      "  comp2\n",
      "    a    a        \n",
      "    b    b        \n",
      "    c    c        \n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "prob.model.list_inputs(val=False);"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "6677e343",
   "metadata": {
    "papermill": {
     "duration": 0.002686,
     "end_time": "2026-10-02T14:50:15.195312+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:15.192626+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "### *List Names and Promoted Name*\n",
    "\n",
    "If you want the names of the variables and their promoted name within the model, you can enable the display of promoted names by setting the optional argument `prom_name` to *True*."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "7811bbb8",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:50:15.201323Z",
     "iopub.status.busy": "2026-10-02T14:50:15.201183Z",
     "iopub.status.idle": "2026-10-02T14:50:15.203943Z",
     "shell.execute_reply": "2026-10-02T14:50:15.203507Z"
    },
    "papermill": {
     "duration": 0.006623,
     "end_time": "2026-10-02T14:50:15.204610+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:15.197987+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0 Explicit Output(s) in 'model'\n",
      "\n",
      "\n",
      "2 Implicit Output(s) in 'model'\n",
      "\n",
      "varname  val   prom_name  \n",
      "-------  ----  -----------\n",
      "sub\n",
      "  comp1\n",
      "    x    [3.]  sub.comp1.x\n",
      "  comp2\n",
      "    x    [3.]  sub.comp2.x\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "prob.model.list_outputs(prom_name=True);"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "5ec0245f",
   "metadata": {
    "papermill": {
     "duration": 0.002466,
     "end_time": "2026-10-02T14:50:15.209687+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:15.207221+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "### *List Variables Filtered by Name*\n",
    "\n",
    "You can use the `includes` and `excludes` optional arguments to filter what variables are returned from `System.list_inputs` and `System.list_outputs`. Here are some short examples showing this feature."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "beffa031",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:50:15.215563Z",
     "iopub.status.busy": "2026-10-02T14:50:15.215412Z",
     "iopub.status.idle": "2026-10-02T14:50:15.218102Z",
     "shell.execute_reply": "2026-10-02T14:50:15.217565Z"
    },
    "papermill": {
     "duration": 0.006182,
     "end_time": "2026-10-02T14:50:15.218492+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:15.212310+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3 Input(s) in 'model'\n",
      "\n",
      "varname  prom_name\n",
      "-------  ---------\n",
      "sub\n",
      "  comp2\n",
      "    a    a        \n",
      "    b    b        \n",
      "    c    c        \n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "prob.model.list_inputs(val=False, includes=['*comp2*',]);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "e3e053a1",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:50:15.224302Z",
     "iopub.status.busy": "2026-10-02T14:50:15.224170Z",
     "iopub.status.idle": "2026-10-02T14:50:15.226819Z",
     "shell.execute_reply": "2026-10-02T14:50:15.226281Z"
    },
    "papermill": {
     "duration": 0.006154,
     "end_time": "2026-10-02T14:50:15.227214+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:15.221060+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0 Explicit Output(s) in 'model'\n",
      "\n",
      "\n",
      "1 Implicit Output(s) in 'model'\n",
      "\n",
      "varname  prom_name  \n",
      "-------  -----------\n",
      "sub\n",
      "  comp1\n",
      "    x    sub.comp1.x\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "prob.model.list_outputs(val=False, excludes=['*comp2*',]);"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "bbb05cf6",
   "metadata": {
    "papermill": {
     "duration": 0.002568,
     "end_time": "2026-10-02T14:50:15.232571+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:15.230003+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "### *List Independent Variables and Design Variables*\n",
    "\n",
    "The `System.list_inputs` method also provides a way to determine which inputs you are ultimately responsible for setting. The [inputs report](../reports/reports_system.ipynb) achieves this in a graphical format, but this method allows it to be done programmatically.\n",
    "\n",
    "Consider the following simple example using the Sellar model, where we intentionally have not added the variable `x` as a design variable:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "aa97a04a",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:50:15.262229Z",
     "iopub.status.busy": "2026-10-02T14:50:15.262075Z",
     "iopub.status.idle": "2026-10-02T14:50:15.271438Z",
     "shell.execute_reply": "2026-10-02T14:50:15.270892Z"
    },
    "papermill": {
     "duration": 0.036759,
     "end_time": "2026-10-02T14:50:15.271889+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:15.235130+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import openmdao.api as om\n",
    "\n",
    "from openmdao.test_suite.components.sellar_feature import SellarMDA\n",
    "\n",
    "\n",
    "model = SellarMDA()\n",
    "\n",
    "model.add_design_var('z', lower=np.array([-10.0, 0.0]), upper=np.array([10.0, 10.0]))\n",
    "# model.add_design_var('x', lower=0.0, upper=10.0)\n",
    "model.add_objective('obj')\n",
    "model.add_constraint('con1', upper=0.0)\n",
    "model.add_constraint('con2', upper=0.0)\n",
    "\n",
    "prob = om.Problem(model)\n",
    "\n",
    "prob.setup()\n",
    "prob.final_setup();"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "d6bbd897",
   "metadata": {
    "papermill": {
     "duration": 0.002552,
     "end_time": "2026-10-02T14:50:15.277078+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:15.274526+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "The `is_indep_var` argument provides inputs that the user can ultimately change, though some of them maybe be overridden by the Driver as design variables:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "c685d26c",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:50:15.283030Z",
     "iopub.status.busy": "2026-10-02T14:50:15.282890Z",
     "iopub.status.idle": "2026-10-02T14:50:15.285897Z",
     "shell.execute_reply": "2026-10-02T14:50:15.285299Z"
    },
    "papermill": {
     "duration": 0.006613,
     "end_time": "2026-10-02T14:50:15.286295+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:15.279682+00:00",
     "status": "completed"
    },
    "scrolled": true,
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "5 Input(s) in 'model'\n",
      "\n",
      "varname  val    prom_name\n",
      "-------  -----  ---------\n",
      "cycle\n",
      "  d1\n",
      "    z    |0.0|  z        \n",
      "    x    [0.]   x        \n",
      "  d2\n",
      "    z    |0.0|  z        \n",
      "obj_cmp\n",
      "  x      [0.]   x        \n",
      "  z      |0.0|  z        \n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "indeps = model.list_inputs(is_indep_var=True, prom_name=True)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "8b935dd8",
   "metadata": {
    "papermill": {
     "duration": 0.002774,
     "end_time": "2026-10-02T14:50:15.291728+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:15.288954+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "We can also get a list of design variables using the `is_design_var` argument:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "056b20b5",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:50:15.297574Z",
     "iopub.status.busy": "2026-10-02T14:50:15.297431Z",
     "iopub.status.idle": "2026-10-02T14:50:15.300031Z",
     "shell.execute_reply": "2026-10-02T14:50:15.299513Z"
    },
    "papermill": {
     "duration": 0.006341,
     "end_time": "2026-10-02T14:50:15.300686+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:15.294345+00:00",
     "status": "completed"
    },
    "scrolled": true,
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3 Input(s) in 'model'\n",
      "\n",
      "varname  val    prom_name\n",
      "-------  -----  ---------\n",
      "cycle\n",
      "  d1\n",
      "    z    |0.0|  z        \n",
      "  d2\n",
      "    z    |0.0|  z        \n",
      "obj_cmp\n",
      "  z      |0.0|  z        \n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "desvars = model.list_inputs(is_design_var=True, prom_name=True)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "788d9848",
   "metadata": {
    "papermill": {
     "duration": 0.002594,
     "end_time": "2026-10-02T14:50:15.306028+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:15.303434+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "Combining these two arguments will show those variables that should be set by the user and whose values will not be overridden by the Driver:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "627ec269",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:50:15.322431Z",
     "iopub.status.busy": "2026-10-02T14:50:15.322301Z",
     "iopub.status.idle": "2026-10-02T14:50:15.325091Z",
     "shell.execute_reply": "2026-10-02T14:50:15.324541Z"
    },
    "papermill": {
     "duration": 0.0065,
     "end_time": "2026-10-02T14:50:15.325523+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:15.319023+00:00",
     "status": "completed"
    },
    "scrolled": true,
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2 Input(s) in 'model'\n",
      "\n",
      "varname  val   prom_name\n",
      "-------  ----  ---------\n",
      "cycle\n",
      "  d1\n",
      "    x    [0.]  x        \n",
      "obj_cmp\n",
      "  x      [0.]  x        \n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "nonDV_indeps = model.list_inputs(is_indep_var=True, is_design_var=False, prom_name=True)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "30ef9b62",
   "metadata": {
    "papermill": {
     "duration": 0.002619,
     "end_time": "2026-10-02T14:50:15.330952+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:15.328333+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "### *List Variables Filtered by Tags*\n",
    "\n",
    "When you add inputs and outputs to components, you can optionally set tags on the variables. These tags can then be used to filter what variables are printed and returned by the `System.list_inputs` and `System.list_outputs` methods. Each of those methods has an optional argument `tags` for that purpose.\n",
    "\n",
    "Here is a simple example to show you how this works. Imagine that a model-builder builds a model with some set of variables they expect other non-model-builder users to vary. They want to classify the inputs into two sets: “beginner” and “advanced”. The model-builder would like to write some functions that query the model for the set of *basic* and *advanced* inputs and do some stuff with those lists (like make fancy formatted outputs or something)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "b7eb445a",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:50:15.431832Z",
     "iopub.status.busy": "2026-10-02T14:50:15.431603Z",
     "iopub.status.idle": "2026-10-02T14:50:15.559868Z",
     "shell.execute_reply": "2026-10-02T14:50:15.559246Z"
    },
    "papermill": {
     "duration": 0.13287,
     "end_time": "2026-10-02T14:50:15.560387+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:15.427517+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Optimization terminated successfully    (Exit mode 0)\n",
      "            Current function value: -0.5925925906659251\n",
      "            Iterations: 5\n",
      "            Function evaluations: 6\n",
      "            Gradient evaluations: 5\n",
      "Optimization Complete\n",
      "-----------------------------------\n"
     ]
    }
   ],
   "source": [
    "import openmdao.api as om\n",
    "\n",
    "class ActuatorDiscWithTags(om.ExplicitComponent):\n",
    "    \"\"\"Simple wind turbine model based on actuator disc theory\"\"\"\n",
    "\n",
    "    def setup(self):\n",
    "\n",
    "        # Inputs\n",
    "        self.add_input('a', 0.5, desc=\"Induced Velocity Factor\", tags=\"advanced\")\n",
    "        self.add_input('Area', 10.0, units=\"m**2\", desc=\"Rotor disc area\", tags=\"basic\")\n",
    "        self.add_input('rho', 1.225, units=\"kg/m**3\", desc=\"air density\", tags=\"advanced\")\n",
    "        self.add_input('Vu', 10.0, units=\"m/s\",\n",
    "                       desc=\"Freestream air velocity, upstream of rotor\", tags=\"basic\")\n",
    "\n",
    "        # Outputs\n",
    "        self.add_output('Vr', 0.0, units=\"m/s\",\n",
    "                        desc=\"Air velocity at rotor exit plane\")\n",
    "        self.add_output('Vd', 0.0, units=\"m/s\",\n",
    "                        desc=\"Slipstream air velocity, downstream of rotor\")\n",
    "        self.add_output('Ct', 0.0, desc=\"Thrust Coefficient\")\n",
    "        self.add_output('thrust', 0.0, units=\"N\",\n",
    "                        desc=\"Thrust produced by the rotor\")\n",
    "        self.add_output('Cp', 0.0, desc=\"Power Coefficient\")\n",
    "        self.add_output('power', 0.0, units=\"W\", desc=\"Power produced by the rotor\")\n",
    "\n",
    "    def setup_partials(self):\n",
    "        self.declare_partials('Vr', ['a', 'Vu'])\n",
    "        self.declare_partials('Vd', 'a')\n",
    "        self.declare_partials('Ct', 'a')\n",
    "        self.declare_partials('thrust', ['a', 'Area', 'rho', 'Vu'])\n",
    "        self.declare_partials('Cp', 'a')\n",
    "        self.declare_partials('power', ['a', 'Area', 'rho', 'Vu'])\n",
    "\n",
    "    def compute(self, inputs, outputs):\n",
    "        \"\"\" Considering the entire rotor as a single disc that extracts\n",
    "        velocity uniformly from the incoming flow and converts it to\n",
    "        power.\"\"\"\n",
    "\n",
    "        a = inputs['a']\n",
    "        Vu = inputs['Vu']\n",
    "\n",
    "        qA = .5 * inputs['rho'] * inputs['Area'] * Vu ** 2\n",
    "\n",
    "        outputs['Vd'] = Vd = Vu * (1 - 2 * a)\n",
    "        outputs['Vr'] = .5 * (Vu + Vd)\n",
    "\n",
    "        outputs['Ct'] = Ct = 4 * a * (1 - a)\n",
    "        outputs['thrust'] = Ct * qA\n",
    "\n",
    "        outputs['Cp'] = Cp = Ct * (1 - a)\n",
    "        outputs['power'] = Cp * qA * Vu\n",
    "\n",
    "    def compute_partials(self, inputs, J):\n",
    "        \"\"\" Jacobian of partial derivatives.\"\"\"\n",
    "\n",
    "        a = inputs['a']\n",
    "        Vu = inputs['Vu']\n",
    "        Area = inputs['Area']\n",
    "        rho = inputs['rho']\n",
    "\n",
    "        # pre-compute commonly needed quantities\n",
    "        a_times_area = a * Area\n",
    "        one_minus_a = 1.0 - a\n",
    "        a_area_rho_vu = a_times_area * rho * Vu\n",
    "\n",
    "        J['Vr', 'a'] = -Vu\n",
    "        J['Vr', 'Vu'] = one_minus_a\n",
    "\n",
    "        J['Vd', 'a'] = -2.0 * Vu\n",
    "\n",
    "        J['Ct', 'a'] = 4.0 - 8.0 * a\n",
    "\n",
    "        J['thrust', 'a'] = .5 * rho * Vu**2 * Area * J['Ct', 'a']\n",
    "        J['thrust', 'Area'] = 2.0 * Vu**2 * a * rho * one_minus_a\n",
    "        J['thrust', 'rho'] = 2.0 * a_times_area * Vu ** 2 * (one_minus_a)\n",
    "        J['thrust', 'Vu'] = 4.0 * a_area_rho_vu * (one_minus_a)\n",
    "\n",
    "        J['Cp', 'a'] = 4.0 * a * (2.0 * a - 2.0) + 4.0 * (one_minus_a)**2\n",
    "\n",
    "        J['power', 'a'] = 2.0 * Area * Vu**3 * a * rho * (\n",
    "        2.0 * a - 2.0) + 2.0 * Area * Vu**3 * rho * one_minus_a ** 2\n",
    "        J['power', 'Area'] = 2.0 * Vu**3 * a * rho * one_minus_a ** 2\n",
    "        J['power', 'rho'] = 2.0 * a_times_area * Vu ** 3 * (one_minus_a)**2\n",
    "        J['power', 'Vu'] = 6.0 * Area * Vu**2 * a * rho * one_minus_a**2\n",
    "\n",
    "\n",
    "# build the model\n",
    "prob = om.Problem()\n",
    "indeps = prob.model.add_subsystem('indeps', om.IndepVarComp(), promotes=['*'])\n",
    "indeps.add_output('a', .5, tags=\"advanced\")\n",
    "indeps.add_output('Area', 10.0, units='m**2', tags=\"basic\")\n",
    "indeps.add_output('rho', 1.225, units='kg/m**3', tags=\"advanced\")\n",
    "indeps.add_output('Vu', 10.0, units='m/s', tags=\"basic\")\n",
    "\n",
    "prob.model.add_subsystem('a_disk', ActuatorDiscWithTags(),\n",
    "                        promotes_inputs=['a', 'Area', 'rho', 'Vu'])\n",
    "\n",
    "# setup the optimization\n",
    "prob.driver = om.ScipyOptimizeDriver()\n",
    "prob.driver.options['optimizer'] = 'SLSQP'\n",
    "\n",
    "prob.model.add_design_var('a', lower=0., upper=1.)\n",
    "prob.model.add_objective('a_disk.Cp', scaler=-1)  # negated to maximize the objective\n",
    "\n",
    "prob.setup()\n",
    "prob.run_driver();"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "335ef0f5",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:50:15.567466Z",
     "iopub.status.busy": "2026-10-02T14:50:15.567219Z",
     "iopub.status.idle": "2026-10-02T14:50:15.570139Z",
     "shell.execute_reply": "2026-10-02T14:50:15.569627Z"
    },
    "papermill": {
     "duration": 0.007095,
     "end_time": "2026-10-02T14:50:15.570749+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:15.563654+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2 Input(s) in 'model'\n",
      "\n",
      "varname  val    units  shape  prom_name\n",
      "-------  -----  -----  -----  ---------\n",
      "a_disk\n",
      "  Area   [10.]  m**2   (1,)   Area     \n",
      "  Vu     [10.]  m/s    (1,)   Vu       \n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "prob.model.list_inputs(tags='basic', units=True, shape=True);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "e53b606c",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:50:15.576928Z",
     "iopub.status.busy": "2026-10-02T14:50:15.576785Z",
     "iopub.status.idle": "2026-10-02T14:50:15.579435Z",
     "shell.execute_reply": "2026-10-02T14:50:15.578994Z"
    },
    "papermill": {
     "duration": 0.00646,
     "end_time": "2026-10-02T14:50:15.580007+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:15.573547+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4 Input(s) in 'model'\n",
      "\n",
      "varname  val           units    shape  prom_name\n",
      "-------  ------------  -------  -----  ---------\n",
      "a_disk\n",
      "  a      [0.33335528]  None     (1,)   a        \n",
      "  Area   [10.]         m**2     (1,)   Area     \n",
      "  rho    [1.225]       kg/m**3  (1,)   rho      \n",
      "  Vu     [10.]         m/s      (1,)   Vu       \n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "prob.model.list_inputs(tags=['basic','advanced'], units=True, shape=True);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "d943af57",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:50:15.586222Z",
     "iopub.status.busy": "2026-10-02T14:50:15.586092Z",
     "iopub.status.idle": "2026-10-02T14:50:15.588813Z",
     "shell.execute_reply": "2026-10-02T14:50:15.588265Z"
    },
    "papermill": {
     "duration": 0.006429,
     "end_time": "2026-10-02T14:50:15.589181+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:15.582752+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2 Explicit Output(s) in 'model'\n",
      "\n",
      "varname  val    prom_name\n",
      "-------  -----  ---------\n",
      "indeps\n",
      "  Area   [10.]  Area     \n",
      "  Vu     [10.]  Vu       \n",
      "\n",
      "\n",
      "0 Implicit Output(s) in 'model'\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "prob.model.list_outputs(tags='basic', units=False, shape=False);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "4a9aa7c1",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:50:15.595564Z",
     "iopub.status.busy": "2026-10-02T14:50:15.595414Z",
     "iopub.status.idle": "2026-10-02T14:50:15.598207Z",
     "shell.execute_reply": "2026-10-02T14:50:15.597680Z"
    },
    "papermill": {
     "duration": 0.006655,
     "end_time": "2026-10-02T14:50:15.598821+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:15.592166+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4 Explicit Output(s) in 'model'\n",
      "\n",
      "varname  val           prom_name\n",
      "-------  ------------  ---------\n",
      "indeps\n",
      "  a      [0.33335528]  a        \n",
      "  Area   [10.]         Area     \n",
      "  rho    [1.225]       rho      \n",
      "  Vu     [10.]         Vu       \n",
      "\n",
      "\n",
      "0 Implicit Output(s) in 'model'\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "prob.model.list_outputs(tags=['basic','advanced'], units=False, shape=False);"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "500617db",
   "metadata": {
    "papermill": {
     "duration": 0.002779,
     "end_time": "2026-10-02T14:50:15.604429+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:15.601650+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "Notice that if you only have one tag, you can set the argument tags to a string. If you have more than one tag, you use a list of strings.\n",
    "\n",
    "This example showed how to add tags when using the `add_input` and `add_output` methods. You can also add tags to `IndepVarComp` and `ExecComp` variables using code like this:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "33175c1f",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:50:15.617607Z",
     "iopub.status.busy": "2026-10-02T14:50:15.617485Z",
     "iopub.status.idle": "2026-10-02T14:50:15.619886Z",
     "shell.execute_reply": "2026-10-02T14:50:15.619328Z"
    },
    "papermill": {
     "duration": 0.00621,
     "end_time": "2026-10-02T14:50:15.620293+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:15.614083+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "comp = om.IndepVarComp('indep_var', tags='tag1')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "855a199d",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:50:15.626725Z",
     "iopub.status.busy": "2026-10-02T14:50:15.626573Z",
     "iopub.status.idle": "2026-10-02T14:50:15.628983Z",
     "shell.execute_reply": "2026-10-02T14:50:15.628411Z"
    },
    "papermill": {
     "duration": 0.006182,
     "end_time": "2026-10-02T14:50:15.629354+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:15.623172+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "ec = om.ExecComp('y=x+z+1.',\n",
    "                 x={'val': 1.0, 'units': 'm', 'tags': 'tagx'},\n",
    "                 y={'units': 'm', 'tags': ['tagy','tagm']},\n",
    "                 z={'val': 2.0, 'tags': 'tagz'})"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "86c67394",
   "metadata": {
    "papermill": {
     "duration": 0.002816,
     "end_time": "2026-10-02T14:50:15.635313+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:15.632497+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "```{note}\n",
    "Note that outputs of `IndepVarComp` are always tagged with `openmdao:indep_var`.\n",
    "```"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "d4ccf490",
   "metadata": {
    "papermill": {
     "duration": 0.003319,
     "end_time": "2026-10-02T14:50:15.710157+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:15.706838+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "### *List Residuals Above a Tolerance*\n",
    "\n",
    "In some cases, it might be convenient to only list variables whose residuals are above a given tolerance. The `list_outputs` method provides the optional argument `residuals_tol` for this purpose."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "87fa70e6",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:50:15.717125Z",
     "iopub.status.busy": "2026-10-02T14:50:15.716925Z",
     "iopub.status.idle": "2026-10-02T14:50:16.339569Z",
     "shell.execute_reply": "2026-10-02T14:50:16.338773Z"
    },
    "papermill": {
     "duration": 0.626931,
     "end_time": "2026-10-02T14:50:16.340094+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:15.713163+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [
    {
     "data": {
      "application/papermill.record/text/html": "<style>pre { line-height: 125%; }\ntd.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }\nspan.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }\ntd.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }\nspan.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }\n.output_html .hll { background-color: #ffffcc }\n.output_html { background: #f8f8f8; }\n.output_html .c { color: #3D7B7B; font-style: italic } /* Comment */\n.output_html .err { border: 1px solid #F00 } /* Error */\n.output_html .k { color: #008000; font-weight: bold } /* Keyword */\n.output_html .o { color: #666 } /* Operator */\n.output_html .ch { color: #3D7B7B; font-style: italic } /* Comment.Hashbang */\n.output_html .cm { color: #3D7B7B; font-style: italic } /* Comment.Multiline */\n.output_html .cp { color: #9C6500 } /* Comment.Preproc */\n.output_html .cpf { color: #3D7B7B; font-style: italic } /* Comment.PreprocFile */\n.output_html .c1 { color: #3D7B7B; font-style: italic } /* Comment.Single */\n.output_html .cs { color: #3D7B7B; font-style: italic } /* Comment.Special */\n.output_html .gd { color: #A00000 } /* Generic.Deleted */\n.output_html .ge { font-style: italic } /* Generic.Emph */\n.output_html .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */\n.output_html .gr { color: #E40000 } /* Generic.Error */\n.output_html .gh { color: #000080; font-weight: bold } /* Generic.Heading */\n.output_html .gi { color: #008400 } /* Generic.Inserted */\n.output_html .go { color: #717171 } /* Generic.Output */\n.output_html .gp { color: #000080; font-weight: bold } /* Generic.Prompt */\n.output_html .gs { font-weight: bold } /* Generic.Strong */\n.output_html .gu { color: #800080; font-weight: bold } /* Generic.Subheading */\n.output_html .gt { color: #04D } /* Generic.Traceback */\n.output_html .kc { color: #008000; font-weight: bold } /* Keyword.Constant */\n.output_html .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */\n.output_html .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */\n.output_html .kp { color: #008000 } /* Keyword.Pseudo */\n.output_html .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */\n.output_html .kt { color: #B00040 } /* Keyword.Type */\n.output_html .m { color: #666 } /* Literal.Number */\n.output_html .s { color: #BA2121 } /* Literal.String */\n.output_html .na { color: #687822 } /* Name.Attribute */\n.output_html .nb { color: #008000 } /* Name.Builtin */\n.output_html .nc { color: #00F; font-weight: bold } /* Name.Class */\n.output_html .no { color: #800 } /* Name.Constant */\n.output_html .nd { color: #A2F } /* Name.Decorator */\n.output_html .ni { color: #717171; font-weight: bold } /* Name.Entity */\n.output_html .ne { color: #CB3F38; font-weight: bold } /* Name.Exception */\n.output_html .nf { color: #00F } /* Name.Function */\n.output_html .nl { color: #767600 } /* Name.Label */\n.output_html .nn { color: #00F; font-weight: bold } /* Name.Namespace */\n.output_html .nt { color: #008000; font-weight: bold } /* Name.Tag */\n.output_html .nv { color: #19177C } /* Name.Variable */\n.output_html .ow { color: #A2F; font-weight: bold } /* Operator.Word */\n.output_html .w { color: #BBB } /* Text.Whitespace */\n.output_html .mb { color: #666 } /* Literal.Number.Bin */\n.output_html .mf { color: #666 } /* Literal.Number.Float */\n.output_html .mh { color: #666 } /* Literal.Number.Hex */\n.output_html .mi { color: #666 } /* Literal.Number.Integer */\n.output_html .mo { color: #666 } /* Literal.Number.Oct */\n.output_html .sa { color: #BA2121 } /* Literal.String.Affix */\n.output_html .sb { color: #BA2121 } /* Literal.String.Backtick */\n.output_html .sc { color: #BA2121 } /* Literal.String.Char */\n.output_html .dl { color: #BA2121 } /* Literal.String.Delimiter */\n.output_html .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */\n.output_html .s2 { color: #BA2121 } /* Literal.String.Double */\n.output_html .se { color: #AA5D1F; font-weight: bold } /* Literal.String.Escape */\n.output_html .sh { color: #BA2121 } /* Literal.String.Heredoc */\n.output_html .si { color: #A45A77; font-weight: bold } /* Literal.String.Interpol */\n.output_html .sx { color: #008000 } /* Literal.String.Other */\n.output_html .sr { color: #A45A77 } /* Literal.String.Regex */\n.output_html .s1 { color: #BA2121 } /* Literal.String.Single */\n.output_html .ss { color: #19177C } /* Literal.String.Symbol */\n.output_html .bp { color: #008000 } /* Name.Builtin.Pseudo */\n.output_html .fm { color: #00F } /* Name.Function.Magic */\n.output_html .vc { color: #19177C } /* Name.Variable.Class */\n.output_html .vg { color: #19177C } /* Name.Variable.Global */\n.output_html .vi { color: #19177C } /* Name.Variable.Instance */\n.output_html .vm { color: #19177C } /* Name.Variable.Magic */\n.output_html .il { color: #666 } /* Literal.Number.Integer.Long */</style><div class=\"highlight\"><pre><span></span><span class=\"k\">class</span><span class=\"w\"> </span><span class=\"nc\">SellarImplicitDis1</span><span class=\"p\">(</span><span class=\"n\">om</span><span class=\"o\">.</span><span class=\"n\">ImplicitComponent</span><span class=\"p\">):</span>\n<span class=\"w\">    </span><span class=\"sd\">&quot;&quot;&quot;</span>\n<span class=\"sd\">    Component containing Discipline 1 -- no derivatives version.</span>\n<span class=\"sd\">    &quot;&quot;&quot;</span>\n\n    <span class=\"k\">def</span><span class=\"w\"> </span><span class=\"fm\">__init__</span><span class=\"p\">(</span><span class=\"bp\">self</span><span class=\"p\">,</span> <span class=\"n\">units</span><span class=\"o\">=</span><span class=\"kc\">None</span><span class=\"p\">,</span> <span class=\"n\">scaling</span><span class=\"o\">=</span><span class=\"kc\">None</span><span class=\"p\">):</span>\n        <span class=\"nb\">super</span><span class=\"p\">()</span><span class=\"o\">.</span><span class=\"fm\">__init__</span><span class=\"p\">()</span>\n        <span class=\"bp\">self</span><span class=\"o\">.</span><span class=\"n\">execution_count</span> <span class=\"o\">=</span> <span class=\"mi\">0</span>\n        <span class=\"bp\">self</span><span class=\"o\">.</span><span class=\"n\">_units</span> <span class=\"o\">=</span> <span class=\"n\">units</span>\n        <span class=\"bp\">self</span><span class=\"o\">.</span><span class=\"n\">_do_scaling</span> <span class=\"o\">=</span> <span class=\"n\">scaling</span>\n\n    <span class=\"k\">def</span><span class=\"w\"> </span><span class=\"nf\">setup</span><span class=\"p\">(</span><span class=\"bp\">self</span><span class=\"p\">):</span>\n        <span class=\"k\">if</span> <span class=\"bp\">self</span><span class=\"o\">.</span><span class=\"n\">_units</span><span class=\"p\">:</span>\n            <span class=\"n\">units</span> <span class=\"o\">=</span> <span class=\"s1\">&#39;ft&#39;</span>\n        <span class=\"k\">else</span><span class=\"p\">:</span>\n            <span class=\"n\">units</span> <span class=\"o\">=</span> <span class=\"kc\">None</span>\n\n        <span class=\"k\">if</span> <span class=\"bp\">self</span><span class=\"o\">.</span><span class=\"n\">_do_scaling</span> <span class=\"ow\">is</span> <span class=\"kc\">None</span><span class=\"p\">:</span>\n            <span class=\"n\">ref</span> <span class=\"o\">=</span> <span class=\"mf\">1.</span>\n        <span class=\"k\">else</span><span class=\"p\">:</span>\n            <span class=\"n\">ref</span> <span class=\"o\">=</span> <span class=\"mf\">.1</span>\n\n        <span class=\"c1\"># Global Design Variable</span>\n        <span class=\"bp\">self</span><span class=\"o\">.</span><span class=\"n\">add_input</span><span class=\"p\">(</span><span class=\"s1\">&#39;z&#39;</span><span class=\"p\">,</span> <span class=\"n\">val</span><span class=\"o\">=</span><span class=\"n\">np</span><span class=\"o\">.</span><span class=\"n\">zeros</span><span class=\"p\">(</span><span class=\"mi\">2</span><span class=\"p\">),</span> <span class=\"n\">units</span><span class=\"o\">=</span><span class=\"n\">units</span><span class=\"p\">)</span>\n\n        <span class=\"c1\"># Local Design Variable</span>\n        <span class=\"bp\">self</span><span class=\"o\">.</span><span class=\"n\">add_input</span><span class=\"p\">(</span><span class=\"s1\">&#39;x&#39;</span><span class=\"p\">,</span> <span class=\"n\">val</span><span class=\"o\">=</span><span class=\"mf\">0.</span><span class=\"p\">,</span> <span class=\"n\">units</span><span class=\"o\">=</span><span class=\"n\">units</span><span class=\"p\">)</span>\n\n        <span class=\"c1\"># Coupling parameter</span>\n        <span class=\"bp\">self</span><span class=\"o\">.</span><span class=\"n\">add_input</span><span class=\"p\">(</span><span class=\"s1\">&#39;y2&#39;</span><span class=\"p\">,</span> <span class=\"n\">val</span><span class=\"o\">=</span><span class=\"mf\">1.0</span><span class=\"p\">,</span> <span class=\"n\">units</span><span class=\"o\">=</span><span class=\"n\">units</span><span class=\"p\">)</span>\n\n        <span class=\"c1\"># Coupling output</span>\n        <span class=\"bp\">self</span><span class=\"o\">.</span><span class=\"n\">add_output</span><span class=\"p\">(</span><span class=\"s1\">&#39;y1&#39;</span><span class=\"p\">,</span> <span class=\"n\">val</span><span class=\"o\">=</span><span class=\"mf\">1.0</span><span class=\"p\">,</span> <span class=\"n\">lower</span><span class=\"o\">=-</span><span class=\"mf\">0.1</span><span class=\"p\">,</span> <span class=\"n\">upper</span><span class=\"o\">=</span><span class=\"mi\">1000</span><span class=\"p\">,</span> <span class=\"n\">units</span><span class=\"o\">=</span><span class=\"n\">units</span><span class=\"p\">,</span> <span class=\"n\">ref</span><span class=\"o\">=</span><span class=\"n\">ref</span><span class=\"p\">)</span>\n\n    <span class=\"k\">def</span><span class=\"w\"> </span><span class=\"nf\">setup_partials</span><span class=\"p\">(</span><span class=\"bp\">self</span><span class=\"p\">):</span>\n        <span class=\"c1\"># Derivatives</span>\n        <span class=\"bp\">self</span><span class=\"o\">.</span><span class=\"n\">declare_partials</span><span class=\"p\">(</span><span class=\"s1\">&#39;*&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;*&#39;</span><span class=\"p\">)</span>\n\n    <span class=\"k\">def</span><span class=\"w\"> </span><span class=\"nf\">apply_nonlinear</span><span class=\"p\">(</span><span class=\"bp\">self</span><span class=\"p\">,</span> <span class=\"n\">inputs</span><span class=\"p\">,</span> <span class=\"n\">outputs</span><span class=\"p\">,</span> <span class=\"n\">resids</span><span class=\"p\">):</span>\n<span class=\"w\">        </span><span class=\"sd\">&quot;&quot;&quot;</span>\n<span class=\"sd\">        Evaluates the equation</span>\n<span class=\"sd\">        y1 = z1**2 + z2 + x1 - 0.2*y2</span>\n<span class=\"sd\">        &quot;&quot;&quot;</span>\n\n        <span class=\"n\">z1</span> <span class=\"o\">=</span> <span class=\"n\">inputs</span><span class=\"p\">[</span><span class=\"s1\">&#39;z&#39;</span><span class=\"p\">][</span><span class=\"mi\">0</span><span class=\"p\">]</span>\n        <span class=\"n\">z2</span> <span class=\"o\">=</span> <span class=\"n\">inputs</span><span class=\"p\">[</span><span class=\"s1\">&#39;z&#39;</span><span class=\"p\">][</span><span class=\"mi\">1</span><span class=\"p\">]</span>\n        <span class=\"n\">x1</span> <span class=\"o\">=</span> <span class=\"n\">inputs</span><span class=\"p\">[</span><span class=\"s1\">&#39;x&#39;</span><span class=\"p\">]</span>\n        <span class=\"n\">y2</span> <span class=\"o\">=</span> <span class=\"n\">inputs</span><span class=\"p\">[</span><span class=\"s1\">&#39;y2&#39;</span><span class=\"p\">]</span>\n\n        <span class=\"n\">y1</span> <span class=\"o\">=</span> <span class=\"n\">outputs</span><span class=\"p\">[</span><span class=\"s1\">&#39;y1&#39;</span><span class=\"p\">]</span>\n\n        <span class=\"n\">resids</span><span class=\"p\">[</span><span class=\"s1\">&#39;y1&#39;</span><span class=\"p\">]</span> <span class=\"o\">=</span> <span class=\"o\">-</span><span class=\"p\">(</span><span class=\"n\">z1</span><span class=\"o\">**</span><span class=\"mi\">2</span> <span class=\"o\">+</span> <span class=\"n\">z2</span> <span class=\"o\">+</span> <span class=\"n\">x1</span> <span class=\"o\">-</span> <span class=\"mf\">0.2</span><span class=\"o\">*</span><span class=\"n\">y2</span> <span class=\"o\">-</span> <span class=\"n\">y1</span><span class=\"p\">)</span>\n\n    <span class=\"k\">def</span><span class=\"w\"> </span><span class=\"nf\">linearize</span><span class=\"p\">(</span><span class=\"bp\">self</span><span class=\"p\">,</span> <span class=\"n\">inputs</span><span class=\"p\">,</span> <span class=\"n\">outputs</span><span class=\"p\">,</span> <span class=\"n\">J</span><span class=\"p\">):</span>\n<span class=\"w\">        </span><span class=\"sd\">&quot;&quot;&quot;</span>\n<span class=\"sd\">        Jacobian for Sellar discipline 1.</span>\n<span class=\"sd\">        &quot;&quot;&quot;</span>\n        <span class=\"n\">J</span><span class=\"p\">[</span><span class=\"s1\">&#39;y1&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;y2&#39;</span><span class=\"p\">]</span> <span class=\"o\">=</span> <span class=\"mf\">0.2</span>\n        <span class=\"n\">J</span><span class=\"p\">[</span><span class=\"s1\">&#39;y1&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;z&#39;</span><span class=\"p\">]</span> <span class=\"o\">=</span> <span class=\"o\">-</span><span class=\"n\">np</span><span class=\"o\">.</span><span class=\"n\">array</span><span class=\"p\">([[</span><span class=\"mf\">2.0</span> <span class=\"o\">*</span> <span class=\"n\">inputs</span><span class=\"p\">[</span><span class=\"s1\">&#39;z&#39;</span><span class=\"p\">][</span><span class=\"mi\">0</span><span class=\"p\">],</span> <span class=\"mf\">1.0</span><span class=\"p\">]])</span>\n        <span class=\"n\">J</span><span class=\"p\">[</span><span class=\"s1\">&#39;y1&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;x&#39;</span><span class=\"p\">]</span> <span class=\"o\">=</span> <span class=\"o\">-</span><span class=\"mf\">1.0</span>\n        <span class=\"n\">J</span><span class=\"p\">[</span><span class=\"s1\">&#39;y1&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;y1&#39;</span><span class=\"p\">]</span> <span class=\"o\">=</span> <span class=\"mf\">1.0</span>\n</pre></div>\n",
      "application/papermill.record/text/latex": "\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n\\PY{k}{class}\\PY{+w}{ }\\PY{n+nc}{SellarImplicitDis1}\\PY{p}{(}\\PY{n}{om}\\PY{o}{.}\\PY{n}{ImplicitComponent}\\PY{p}{)}\\PY{p}{:}\n\\PY{+w}{    }\\PY{l+s+sd}{\\PYZdq{}\\PYZdq{}\\PYZdq{}}\n\\PY{l+s+sd}{    Component containing Discipline 1 \\PYZhy{}\\PYZhy{} no derivatives version.}\n\\PY{l+s+sd}{    \\PYZdq{}\\PYZdq{}\\PYZdq{}}\n\n    \\PY{k}{def}\\PY{+w}{ }\\PY{n+nf+fm}{\\PYZus{}\\PYZus{}init\\PYZus{}\\PYZus{}}\\PY{p}{(}\\PY{n+nb+bp}{self}\\PY{p}{,} \\PY{n}{units}\\PY{o}{=}\\PY{k+kc}{None}\\PY{p}{,} \\PY{n}{scaling}\\PY{o}{=}\\PY{k+kc}{None}\\PY{p}{)}\\PY{p}{:}\n        \\PY{n+nb}{super}\\PY{p}{(}\\PY{p}{)}\\PY{o}{.}\\PY{n+nf+fm}{\\PYZus{}\\PYZus{}init\\PYZus{}\\PYZus{}}\\PY{p}{(}\\PY{p}{)}\n        \\PY{n+nb+bp}{self}\\PY{o}{.}\\PY{n}{execution\\PYZus{}count} \\PY{o}{=} \\PY{l+m+mi}{0}\n        \\PY{n+nb+bp}{self}\\PY{o}{.}\\PY{n}{\\PYZus{}units} \\PY{o}{=} \\PY{n}{units}\n        \\PY{n+nb+bp}{self}\\PY{o}{.}\\PY{n}{\\PYZus{}do\\PYZus{}scaling} \\PY{o}{=} \\PY{n}{scaling}\n\n    \\PY{k}{def}\\PY{+w}{ }\\PY{n+nf}{setup}\\PY{p}{(}\\PY{n+nb+bp}{self}\\PY{p}{)}\\PY{p}{:}\n        \\PY{k}{if} \\PY{n+nb+bp}{self}\\PY{o}{.}\\PY{n}{\\PYZus{}units}\\PY{p}{:}\n            \\PY{n}{units} \\PY{o}{=} \\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{ft}\\PY{l+s+s1}{\\PYZsq{}}\n        \\PY{k}{else}\\PY{p}{:}\n            \\PY{n}{units} \\PY{o}{=} \\PY{k+kc}{None}\n\n        \\PY{k}{if} \\PY{n+nb+bp}{self}\\PY{o}{.}\\PY{n}{\\PYZus{}do\\PYZus{}scaling} \\PY{o+ow}{is} \\PY{k+kc}{None}\\PY{p}{:}\n            \\PY{n}{ref} \\PY{o}{=} \\PY{l+m+mf}{1.}\n        \\PY{k}{else}\\PY{p}{:}\n            \\PY{n}{ref} \\PY{o}{=} \\PY{l+m+mf}{.1}\n\n        \\PY{c+c1}{\\PYZsh{} Global Design Variable}\n        \\PY{n+nb+bp}{self}\\PY{o}{.}\\PY{n}{add\\PYZus{}input}\\PY{p}{(}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{z}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{n}{val}\\PY{o}{=}\\PY{n}{np}\\PY{o}{.}\\PY{n}{zeros}\\PY{p}{(}\\PY{l+m+mi}{2}\\PY{p}{)}\\PY{p}{,} \\PY{n}{units}\\PY{o}{=}\\PY{n}{units}\\PY{p}{)}\n\n        \\PY{c+c1}{\\PYZsh{} Local Design Variable}\n        \\PY{n+nb+bp}{self}\\PY{o}{.}\\PY{n}{add\\PYZus{}input}\\PY{p}{(}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{x}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{n}{val}\\PY{o}{=}\\PY{l+m+mf}{0.}\\PY{p}{,} \\PY{n}{units}\\PY{o}{=}\\PY{n}{units}\\PY{p}{)}\n\n        \\PY{c+c1}{\\PYZsh{} Coupling parameter}\n        \\PY{n+nb+bp}{self}\\PY{o}{.}\\PY{n}{add\\PYZus{}input}\\PY{p}{(}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{y2}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{n}{val}\\PY{o}{=}\\PY{l+m+mf}{1.0}\\PY{p}{,} \\PY{n}{units}\\PY{o}{=}\\PY{n}{units}\\PY{p}{)}\n\n        \\PY{c+c1}{\\PYZsh{} Coupling output}\n        \\PY{n+nb+bp}{self}\\PY{o}{.}\\PY{n}{add\\PYZus{}output}\\PY{p}{(}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{y1}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{n}{val}\\PY{o}{=}\\PY{l+m+mf}{1.0}\\PY{p}{,} \\PY{n}{lower}\\PY{o}{=}\\PY{o}{\\PYZhy{}}\\PY{l+m+mf}{0.1}\\PY{p}{,} \\PY{n}{upper}\\PY{o}{=}\\PY{l+m+mi}{1000}\\PY{p}{,} \\PY{n}{units}\\PY{o}{=}\\PY{n}{units}\\PY{p}{,} \\PY{n}{ref}\\PY{o}{=}\\PY{n}{ref}\\PY{p}{)}\n\n    \\PY{k}{def}\\PY{+w}{ }\\PY{n+nf}{setup\\PYZus{}partials}\\PY{p}{(}\\PY{n+nb+bp}{self}\\PY{p}{)}\\PY{p}{:}\n        \\PY{c+c1}{\\PYZsh{} Derivatives}\n        \\PY{n+nb+bp}{self}\\PY{o}{.}\\PY{n}{declare\\PYZus{}partials}\\PY{p}{(}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{*}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{*}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{)}\n\n    \\PY{k}{def}\\PY{+w}{ }\\PY{n+nf}{apply\\PYZus{}nonlinear}\\PY{p}{(}\\PY{n+nb+bp}{self}\\PY{p}{,} \\PY{n}{inputs}\\PY{p}{,} \\PY{n}{outputs}\\PY{p}{,} \\PY{n}{resids}\\PY{p}{)}\\PY{p}{:}\n\\PY{+w}{        }\\PY{l+s+sd}{\\PYZdq{}\\PYZdq{}\\PYZdq{}}\n\\PY{l+s+sd}{        Evaluates the equation}\n\\PY{l+s+sd}{        y1 = z1**2 + z2 + x1 \\PYZhy{} 0.2*y2}\n\\PY{l+s+sd}{        \\PYZdq{}\\PYZdq{}\\PYZdq{}}\n\n        \\PY{n}{z1} \\PY{o}{=} \\PY{n}{inputs}\\PY{p}{[}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{z}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{]}\\PY{p}{[}\\PY{l+m+mi}{0}\\PY{p}{]}\n        \\PY{n}{z2} \\PY{o}{=} \\PY{n}{inputs}\\PY{p}{[}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{z}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{]}\\PY{p}{[}\\PY{l+m+mi}{1}\\PY{p}{]}\n        \\PY{n}{x1} \\PY{o}{=} \\PY{n}{inputs}\\PY{p}{[}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{x}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{]}\n        \\PY{n}{y2} \\PY{o}{=} \\PY{n}{inputs}\\PY{p}{[}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{y2}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{]}\n\n        \\PY{n}{y1} \\PY{o}{=} \\PY{n}{outputs}\\PY{p}{[}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{y1}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{]}\n\n        \\PY{n}{resids}\\PY{p}{[}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{y1}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{]} \\PY{o}{=} \\PY{o}{\\PYZhy{}}\\PY{p}{(}\\PY{n}{z1}\\PY{o}{*}\\PY{o}{*}\\PY{l+m+mi}{2} \\PY{o}{+} \\PY{n}{z2} \\PY{o}{+} \\PY{n}{x1} \\PY{o}{\\PYZhy{}} \\PY{l+m+mf}{0.2}\\PY{o}{*}\\PY{n}{y2} \\PY{o}{\\PYZhy{}} \\PY{n}{y1}\\PY{p}{)}\n\n    \\PY{k}{def}\\PY{+w}{ }\\PY{n+nf}{linearize}\\PY{p}{(}\\PY{n+nb+bp}{self}\\PY{p}{,} \\PY{n}{inputs}\\PY{p}{,} \\PY{n}{outputs}\\PY{p}{,} \\PY{n}{J}\\PY{p}{)}\\PY{p}{:}\n\\PY{+w}{        }\\PY{l+s+sd}{\\PYZdq{}\\PYZdq{}\\PYZdq{}}\n\\PY{l+s+sd}{        Jacobian for Sellar discipline 1.}\n\\PY{l+s+sd}{        \\PYZdq{}\\PYZdq{}\\PYZdq{}}\n        \\PY{n}{J}\\PY{p}{[}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{y1}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{y2}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{]} \\PY{o}{=} \\PY{l+m+mf}{0.2}\n        \\PY{n}{J}\\PY{p}{[}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{y1}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{z}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{]} \\PY{o}{=} \\PY{o}{\\PYZhy{}}\\PY{n}{np}\\PY{o}{.}\\PY{n}{array}\\PY{p}{(}\\PY{p}{[}\\PY{p}{[}\\PY{l+m+mf}{2.0} \\PY{o}{*} \\PY{n}{inputs}\\PY{p}{[}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{z}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{]}\\PY{p}{[}\\PY{l+m+mi}{0}\\PY{p}{]}\\PY{p}{,} \\PY{l+m+mf}{1.0}\\PY{p}{]}\\PY{p}{]}\\PY{p}{)}\n        \\PY{n}{J}\\PY{p}{[}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{y1}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{x}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{]} \\PY{o}{=} \\PY{o}{\\PYZhy{}}\\PY{l+m+mf}{1.0}\n        \\PY{n}{J}\\PY{p}{[}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{y1}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{y1}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{]} \\PY{o}{=} \\PY{l+m+mf}{1.0}\n\\end{Verbatim}\n",
      "application/papermill.record/text/plain": "class SellarImplicitDis1(om.ImplicitComponent):\n    \"\"\"\n    Component containing Discipline 1 -- no derivatives version.\n    \"\"\"\n\n    def __init__(self, units=None, scaling=None):\n        super().__init__()\n        self.execution_count = 0\n        self._units = units\n        self._do_scaling = scaling\n\n    def setup(self):\n        if self._units:\n            units = 'ft'\n        else:\n            units = None\n\n        if self._do_scaling is None:\n            ref = 1.\n        else:\n            ref = .1\n\n        # Global Design Variable\n        self.add_input('z', val=np.zeros(2), units=units)\n\n        # Local Design Variable\n        self.add_input('x', val=0., units=units)\n\n        # Coupling parameter\n        self.add_input('y2', val=1.0, units=units)\n\n        # Coupling output\n        self.add_output('y1', val=1.0, lower=-0.1, upper=1000, units=units, ref=ref)\n\n    def setup_partials(self):\n        # Derivatives\n        self.declare_partials('*', '*')\n\n    def apply_nonlinear(self, inputs, outputs, resids):\n        \"\"\"\n        Evaluates the equation\n        y1 = z1**2 + z2 + x1 - 0.2*y2\n        \"\"\"\n\n        z1 = inputs['z'][0]\n        z2 = inputs['z'][1]\n        x1 = inputs['x']\n        y2 = inputs['y2']\n\n        y1 = outputs['y1']\n\n        resids['y1'] = -(z1**2 + z2 + x1 - 0.2*y2 - y1)\n\n    def linearize(self, inputs, outputs, J):\n        \"\"\"\n        Jacobian for Sellar discipline 1.\n        \"\"\"\n        J['y1', 'y2'] = 0.2\n        J['y1', 'z'] = -np.array([[2.0 * inputs['z'][0], 1.0]])\n        J['y1', 'x'] = -1.0\n        J['y1', 'y1'] = 1.0"
     },
     "metadata": {
      "scrapbook": {
       "mime_prefix": "application/papermill.record/",
       "name": "code_src68"
      }
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "from openmdao.utils.notebook_utils import get_code\n",
    "from myst_nb import glue\n",
    "glue(\"code_src68\", get_code(\"openmdao.test_suite.components.sellar.SellarImplicitDis1\"), display=False)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "42685ce3",
   "metadata": {
    "papermill": {
     "duration": 0.003105,
     "end_time": "2026-10-02T14:50:16.346513+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:16.343408+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    ":::{dropdown} `SellarImplicitDis1` class definition \n",
    "\n",
    "{glue:}`code_src68`\n",
    ":::"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "5ab3f84d",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:50:16.417451Z",
     "iopub.status.busy": "2026-10-02T14:50:16.417212Z",
     "iopub.status.idle": "2026-10-02T14:50:16.427343Z",
     "shell.execute_reply": "2026-10-02T14:50:16.426519Z"
    },
    "papermill": {
     "duration": 0.078166,
     "end_time": "2026-10-02T14:50:16.427791+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:16.349625+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [
    {
     "data": {
      "application/papermill.record/text/html": "<style>pre { line-height: 125%; }\ntd.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }\nspan.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }\ntd.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }\nspan.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }\n.output_html .hll { background-color: #ffffcc }\n.output_html { background: #f8f8f8; }\n.output_html .c { color: #3D7B7B; font-style: italic } /* Comment */\n.output_html .err { border: 1px solid #F00 } /* Error */\n.output_html .k { color: #008000; font-weight: bold } /* Keyword */\n.output_html .o { color: #666 } /* Operator */\n.output_html .ch { color: #3D7B7B; font-style: italic } /* Comment.Hashbang */\n.output_html .cm { color: #3D7B7B; font-style: italic } /* Comment.Multiline */\n.output_html .cp { color: #9C6500 } /* Comment.Preproc */\n.output_html .cpf { color: #3D7B7B; font-style: italic } /* Comment.PreprocFile */\n.output_html .c1 { color: #3D7B7B; font-style: italic } /* Comment.Single */\n.output_html .cs { color: #3D7B7B; font-style: italic } /* Comment.Special */\n.output_html .gd { color: #A00000 } /* Generic.Deleted */\n.output_html .ge { font-style: italic } /* Generic.Emph */\n.output_html .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */\n.output_html .gr { color: #E40000 } /* Generic.Error */\n.output_html .gh { color: #000080; font-weight: bold } /* Generic.Heading */\n.output_html .gi { color: #008400 } /* Generic.Inserted */\n.output_html .go { color: #717171 } /* Generic.Output */\n.output_html .gp { color: #000080; font-weight: bold } /* Generic.Prompt */\n.output_html .gs { font-weight: bold } /* Generic.Strong */\n.output_html .gu { color: #800080; font-weight: bold } /* Generic.Subheading */\n.output_html .gt { color: #04D } /* Generic.Traceback */\n.output_html .kc { color: #008000; font-weight: bold } /* Keyword.Constant */\n.output_html .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */\n.output_html .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */\n.output_html .kp { color: #008000 } /* Keyword.Pseudo */\n.output_html .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */\n.output_html .kt { color: #B00040 } /* Keyword.Type */\n.output_html .m { color: #666 } /* Literal.Number */\n.output_html .s { color: #BA2121 } /* Literal.String */\n.output_html .na { color: #687822 } /* Name.Attribute */\n.output_html .nb { color: #008000 } /* Name.Builtin */\n.output_html .nc { color: #00F; font-weight: bold } /* Name.Class */\n.output_html .no { color: #800 } /* Name.Constant */\n.output_html .nd { color: #A2F } /* Name.Decorator */\n.output_html .ni { color: #717171; font-weight: bold } /* Name.Entity */\n.output_html .ne { color: #CB3F38; font-weight: bold } /* Name.Exception */\n.output_html .nf { color: #00F } /* Name.Function */\n.output_html .nl { color: #767600 } /* Name.Label */\n.output_html .nn { color: #00F; font-weight: bold } /* Name.Namespace */\n.output_html .nt { color: #008000; font-weight: bold } /* Name.Tag */\n.output_html .nv { color: #19177C } /* Name.Variable */\n.output_html .ow { color: #A2F; font-weight: bold } /* Operator.Word */\n.output_html .w { color: #BBB } /* Text.Whitespace */\n.output_html .mb { color: #666 } /* Literal.Number.Bin */\n.output_html .mf { color: #666 } /* Literal.Number.Float */\n.output_html .mh { color: #666 } /* Literal.Number.Hex */\n.output_html .mi { color: #666 } /* Literal.Number.Integer */\n.output_html .mo { color: #666 } /* Literal.Number.Oct */\n.output_html .sa { color: #BA2121 } /* Literal.String.Affix */\n.output_html .sb { color: #BA2121 } /* Literal.String.Backtick */\n.output_html .sc { color: #BA2121 } /* Literal.String.Char */\n.output_html .dl { color: #BA2121 } /* Literal.String.Delimiter */\n.output_html .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */\n.output_html .s2 { color: #BA2121 } /* Literal.String.Double */\n.output_html .se { color: #AA5D1F; font-weight: bold } /* Literal.String.Escape */\n.output_html .sh { color: #BA2121 } /* Literal.String.Heredoc */\n.output_html .si { color: #A45A77; font-weight: bold } /* Literal.String.Interpol */\n.output_html .sx { color: #008000 } /* Literal.String.Other */\n.output_html .sr { color: #A45A77 } /* Literal.String.Regex */\n.output_html .s1 { color: #BA2121 } /* Literal.String.Single */\n.output_html .ss { color: #19177C } /* Literal.String.Symbol */\n.output_html .bp { color: #008000 } /* Name.Builtin.Pseudo */\n.output_html .fm { color: #00F } /* Name.Function.Magic */\n.output_html .vc { color: #19177C } /* Name.Variable.Class */\n.output_html .vg { color: #19177C } /* Name.Variable.Global */\n.output_html .vi { color: #19177C } /* Name.Variable.Instance */\n.output_html .vm { color: #19177C } /* Name.Variable.Magic */\n.output_html .il { color: #666 } /* Literal.Number.Integer.Long */</style><div class=\"highlight\"><pre><span></span><span class=\"k\">class</span><span class=\"w\"> </span><span class=\"nc\">SellarImplicitDis2</span><span class=\"p\">(</span><span class=\"n\">om</span><span class=\"o\">.</span><span class=\"n\">ImplicitComponent</span><span class=\"p\">):</span>\n<span class=\"w\">    </span><span class=\"sd\">&quot;&quot;&quot;</span>\n<span class=\"sd\">    Component containing Discipline 2 -- implicit version.</span>\n<span class=\"sd\">    &quot;&quot;&quot;</span>\n\n    <span class=\"k\">def</span><span class=\"w\"> </span><span class=\"fm\">__init__</span><span class=\"p\">(</span><span class=\"bp\">self</span><span class=\"p\">,</span> <span class=\"n\">units</span><span class=\"o\">=</span><span class=\"kc\">None</span><span class=\"p\">,</span> <span class=\"n\">scaling</span><span class=\"o\">=</span><span class=\"kc\">None</span><span class=\"p\">):</span>\n        <span class=\"nb\">super</span><span class=\"p\">()</span><span class=\"o\">.</span><span class=\"fm\">__init__</span><span class=\"p\">()</span>\n        <span class=\"bp\">self</span><span class=\"o\">.</span><span class=\"n\">execution_count</span> <span class=\"o\">=</span> <span class=\"mi\">0</span>\n        <span class=\"bp\">self</span><span class=\"o\">.</span><span class=\"n\">_units</span> <span class=\"o\">=</span> <span class=\"n\">units</span>\n        <span class=\"bp\">self</span><span class=\"o\">.</span><span class=\"n\">_do_scaling</span> <span class=\"o\">=</span> <span class=\"n\">scaling</span>\n\n    <span class=\"k\">def</span><span class=\"w\"> </span><span class=\"nf\">setup</span><span class=\"p\">(</span><span class=\"bp\">self</span><span class=\"p\">):</span>\n        <span class=\"k\">if</span> <span class=\"bp\">self</span><span class=\"o\">.</span><span class=\"n\">_units</span><span class=\"p\">:</span>\n            <span class=\"n\">units</span> <span class=\"o\">=</span> <span class=\"s1\">&#39;inch&#39;</span>\n        <span class=\"k\">else</span><span class=\"p\">:</span>\n            <span class=\"n\">units</span> <span class=\"o\">=</span> <span class=\"kc\">None</span>\n\n        <span class=\"k\">if</span> <span class=\"bp\">self</span><span class=\"o\">.</span><span class=\"n\">_do_scaling</span> <span class=\"ow\">is</span> <span class=\"kc\">None</span><span class=\"p\">:</span>\n            <span class=\"n\">ref</span> <span class=\"o\">=</span> <span class=\"mf\">1.0</span>\n        <span class=\"k\">else</span><span class=\"p\">:</span>\n            <span class=\"n\">ref</span> <span class=\"o\">=</span> <span class=\"mf\">.18</span>\n\n        <span class=\"c1\"># Global Design Variable</span>\n        <span class=\"bp\">self</span><span class=\"o\">.</span><span class=\"n\">add_input</span><span class=\"p\">(</span><span class=\"s1\">&#39;z&#39;</span><span class=\"p\">,</span> <span class=\"n\">val</span><span class=\"o\">=</span><span class=\"n\">np</span><span class=\"o\">.</span><span class=\"n\">zeros</span><span class=\"p\">(</span><span class=\"mi\">2</span><span class=\"p\">),</span> <span class=\"n\">units</span><span class=\"o\">=</span><span class=\"n\">units</span><span class=\"p\">)</span>\n\n        <span class=\"c1\"># Coupling parameter</span>\n        <span class=\"bp\">self</span><span class=\"o\">.</span><span class=\"n\">add_input</span><span class=\"p\">(</span><span class=\"s1\">&#39;y1&#39;</span><span class=\"p\">,</span> <span class=\"n\">val</span><span class=\"o\">=</span><span class=\"mf\">1.0</span><span class=\"p\">,</span> <span class=\"n\">units</span><span class=\"o\">=</span><span class=\"n\">units</span><span class=\"p\">)</span>\n\n        <span class=\"c1\"># Coupling output</span>\n        <span class=\"bp\">self</span><span class=\"o\">.</span><span class=\"n\">add_output</span><span class=\"p\">(</span><span class=\"s1\">&#39;y2&#39;</span><span class=\"p\">,</span> <span class=\"n\">val</span><span class=\"o\">=</span><span class=\"mf\">1.0</span><span class=\"p\">,</span> <span class=\"n\">lower</span><span class=\"o\">=</span><span class=\"mf\">0.1</span><span class=\"p\">,</span> <span class=\"n\">upper</span><span class=\"o\">=</span><span class=\"mf\">1000.</span><span class=\"p\">,</span> <span class=\"n\">units</span><span class=\"o\">=</span><span class=\"n\">units</span><span class=\"p\">,</span> <span class=\"n\">ref</span><span class=\"o\">=</span><span class=\"n\">ref</span><span class=\"p\">)</span>\n\n    <span class=\"k\">def</span><span class=\"w\"> </span><span class=\"nf\">setup_partials</span><span class=\"p\">(</span><span class=\"bp\">self</span><span class=\"p\">):</span>\n        <span class=\"c1\"># Derivatives</span>\n        <span class=\"bp\">self</span><span class=\"o\">.</span><span class=\"n\">declare_partials</span><span class=\"p\">(</span><span class=\"s1\">&#39;*&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;*&#39;</span><span class=\"p\">)</span>\n\n    <span class=\"k\">def</span><span class=\"w\"> </span><span class=\"nf\">apply_nonlinear</span><span class=\"p\">(</span><span class=\"bp\">self</span><span class=\"p\">,</span> <span class=\"n\">inputs</span><span class=\"p\">,</span> <span class=\"n\">outputs</span><span class=\"p\">,</span> <span class=\"n\">resids</span><span class=\"p\">):</span>\n<span class=\"w\">        </span><span class=\"sd\">&quot;&quot;&quot;</span>\n<span class=\"sd\">        Evaluates the equation</span>\n<span class=\"sd\">        y2 = y1**(.5) + z1 + z2</span>\n<span class=\"sd\">        &quot;&quot;&quot;</span>\n\n        <span class=\"n\">z1</span> <span class=\"o\">=</span> <span class=\"n\">inputs</span><span class=\"p\">[</span><span class=\"s1\">&#39;z&#39;</span><span class=\"p\">][</span><span class=\"mi\">0</span><span class=\"p\">]</span>\n        <span class=\"n\">z2</span> <span class=\"o\">=</span> <span class=\"n\">inputs</span><span class=\"p\">[</span><span class=\"s1\">&#39;z&#39;</span><span class=\"p\">][</span><span class=\"mi\">1</span><span class=\"p\">]</span>\n        <span class=\"n\">y1</span> <span class=\"o\">=</span> <span class=\"n\">inputs</span><span class=\"p\">[</span><span class=\"s1\">&#39;y1&#39;</span><span class=\"p\">]</span><span class=\"o\">.</span><span class=\"n\">copy</span><span class=\"p\">()</span>\n\n        <span class=\"n\">y2</span> <span class=\"o\">=</span> <span class=\"n\">outputs</span><span class=\"p\">[</span><span class=\"s1\">&#39;y2&#39;</span><span class=\"p\">]</span>\n\n        <span class=\"c1\"># Note: this may cause some issues. However, y1 is constrained to be</span>\n        <span class=\"c1\"># above 3.16, so lets just let it converge, and the optimizer will</span>\n        <span class=\"c1\"># throw it out</span>\n        <span class=\"k\">if</span> <span class=\"n\">y1</span><span class=\"o\">.</span><span class=\"n\">real</span> <span class=\"o\">&lt;</span> <span class=\"mf\">0.0</span><span class=\"p\">:</span>\n            <span class=\"n\">y1</span> <span class=\"o\">*=</span> <span class=\"o\">-</span><span class=\"mi\">1</span>\n\n        <span class=\"n\">resids</span><span class=\"p\">[</span><span class=\"s1\">&#39;y2&#39;</span><span class=\"p\">]</span> <span class=\"o\">=</span> <span class=\"o\">-</span><span class=\"p\">(</span><span class=\"n\">y1</span><span class=\"o\">**</span><span class=\"mf\">.5</span> <span class=\"o\">+</span> <span class=\"n\">z1</span> <span class=\"o\">+</span> <span class=\"n\">z2</span> <span class=\"o\">-</span> <span class=\"n\">y2</span><span class=\"p\">)</span>\n\n    <span class=\"k\">def</span><span class=\"w\"> </span><span class=\"nf\">linearize</span><span class=\"p\">(</span><span class=\"bp\">self</span><span class=\"p\">,</span> <span class=\"n\">inputs</span><span class=\"p\">,</span> <span class=\"n\">outputs</span><span class=\"p\">,</span> <span class=\"n\">J</span><span class=\"p\">):</span>\n<span class=\"w\">        </span><span class=\"sd\">&quot;&quot;&quot;</span>\n<span class=\"sd\">        Jacobian for Sellar discipline 2.</span>\n<span class=\"sd\">        &quot;&quot;&quot;</span>\n        <span class=\"n\">y1</span> <span class=\"o\">=</span> <span class=\"n\">inputs</span><span class=\"p\">[</span><span class=\"s1\">&#39;y1&#39;</span><span class=\"p\">]</span>\n        <span class=\"k\">if</span> <span class=\"n\">y1</span><span class=\"o\">.</span><span class=\"n\">real</span> <span class=\"o\">&lt;</span> <span class=\"mf\">0.0</span><span class=\"p\">:</span>\n            <span class=\"n\">y1</span> <span class=\"o\">*=</span> <span class=\"o\">-</span><span class=\"mi\">1</span>\n        <span class=\"k\">if</span> <span class=\"n\">y1</span><span class=\"o\">.</span><span class=\"n\">real</span> <span class=\"o\">&lt;</span> <span class=\"mf\">1e-8</span><span class=\"p\">:</span>\n            <span class=\"n\">y1</span> <span class=\"o\">=</span> <span class=\"mf\">1e-8</span>\n\n        <span class=\"n\">J</span><span class=\"p\">[</span><span class=\"s1\">&#39;y2&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;y1&#39;</span><span class=\"p\">]</span> <span class=\"o\">=</span> <span class=\"o\">-</span><span class=\"mf\">.5</span><span class=\"o\">*</span><span class=\"n\">y1</span><span class=\"o\">**-</span><span class=\"mf\">.5</span>\n        <span class=\"n\">J</span><span class=\"p\">[</span><span class=\"s1\">&#39;y2&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;z&#39;</span><span class=\"p\">]</span> <span class=\"o\">=</span> <span class=\"o\">-</span><span class=\"n\">np</span><span class=\"o\">.</span><span class=\"n\">array</span><span class=\"p\">([[</span><span class=\"mf\">1.0</span><span class=\"p\">,</span> <span class=\"mf\">1.0</span><span class=\"p\">]])</span>\n        <span class=\"n\">J</span><span class=\"p\">[</span><span class=\"s1\">&#39;y2&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;y2&#39;</span><span class=\"p\">]</span> <span class=\"o\">=</span> <span class=\"mf\">1.0</span>\n</pre></div>\n",
      "application/papermill.record/text/latex": "\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n\\PY{k}{class}\\PY{+w}{ }\\PY{n+nc}{SellarImplicitDis2}\\PY{p}{(}\\PY{n}{om}\\PY{o}{.}\\PY{n}{ImplicitComponent}\\PY{p}{)}\\PY{p}{:}\n\\PY{+w}{    }\\PY{l+s+sd}{\\PYZdq{}\\PYZdq{}\\PYZdq{}}\n\\PY{l+s+sd}{    Component containing Discipline 2 \\PYZhy{}\\PYZhy{} implicit version.}\n\\PY{l+s+sd}{    \\PYZdq{}\\PYZdq{}\\PYZdq{}}\n\n    \\PY{k}{def}\\PY{+w}{ }\\PY{n+nf+fm}{\\PYZus{}\\PYZus{}init\\PYZus{}\\PYZus{}}\\PY{p}{(}\\PY{n+nb+bp}{self}\\PY{p}{,} \\PY{n}{units}\\PY{o}{=}\\PY{k+kc}{None}\\PY{p}{,} \\PY{n}{scaling}\\PY{o}{=}\\PY{k+kc}{None}\\PY{p}{)}\\PY{p}{:}\n        \\PY{n+nb}{super}\\PY{p}{(}\\PY{p}{)}\\PY{o}{.}\\PY{n+nf+fm}{\\PYZus{}\\PYZus{}init\\PYZus{}\\PYZus{}}\\PY{p}{(}\\PY{p}{)}\n        \\PY{n+nb+bp}{self}\\PY{o}{.}\\PY{n}{execution\\PYZus{}count} \\PY{o}{=} \\PY{l+m+mi}{0}\n        \\PY{n+nb+bp}{self}\\PY{o}{.}\\PY{n}{\\PYZus{}units} \\PY{o}{=} \\PY{n}{units}\n        \\PY{n+nb+bp}{self}\\PY{o}{.}\\PY{n}{\\PYZus{}do\\PYZus{}scaling} \\PY{o}{=} \\PY{n}{scaling}\n\n    \\PY{k}{def}\\PY{+w}{ }\\PY{n+nf}{setup}\\PY{p}{(}\\PY{n+nb+bp}{self}\\PY{p}{)}\\PY{p}{:}\n        \\PY{k}{if} \\PY{n+nb+bp}{self}\\PY{o}{.}\\PY{n}{\\PYZus{}units}\\PY{p}{:}\n            \\PY{n}{units} \\PY{o}{=} \\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{inch}\\PY{l+s+s1}{\\PYZsq{}}\n        \\PY{k}{else}\\PY{p}{:}\n            \\PY{n}{units} \\PY{o}{=} \\PY{k+kc}{None}\n\n        \\PY{k}{if} \\PY{n+nb+bp}{self}\\PY{o}{.}\\PY{n}{\\PYZus{}do\\PYZus{}scaling} \\PY{o+ow}{is} \\PY{k+kc}{None}\\PY{p}{:}\n            \\PY{n}{ref} \\PY{o}{=} \\PY{l+m+mf}{1.0}\n        \\PY{k}{else}\\PY{p}{:}\n            \\PY{n}{ref} \\PY{o}{=} \\PY{l+m+mf}{.18}\n\n        \\PY{c+c1}{\\PYZsh{} Global Design Variable}\n        \\PY{n+nb+bp}{self}\\PY{o}{.}\\PY{n}{add\\PYZus{}input}\\PY{p}{(}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{z}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{n}{val}\\PY{o}{=}\\PY{n}{np}\\PY{o}{.}\\PY{n}{zeros}\\PY{p}{(}\\PY{l+m+mi}{2}\\PY{p}{)}\\PY{p}{,} \\PY{n}{units}\\PY{o}{=}\\PY{n}{units}\\PY{p}{)}\n\n        \\PY{c+c1}{\\PYZsh{} Coupling parameter}\n        \\PY{n+nb+bp}{self}\\PY{o}{.}\\PY{n}{add\\PYZus{}input}\\PY{p}{(}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{y1}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{n}{val}\\PY{o}{=}\\PY{l+m+mf}{1.0}\\PY{p}{,} \\PY{n}{units}\\PY{o}{=}\\PY{n}{units}\\PY{p}{)}\n\n        \\PY{c+c1}{\\PYZsh{} Coupling output}\n        \\PY{n+nb+bp}{self}\\PY{o}{.}\\PY{n}{add\\PYZus{}output}\\PY{p}{(}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{y2}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{n}{val}\\PY{o}{=}\\PY{l+m+mf}{1.0}\\PY{p}{,} \\PY{n}{lower}\\PY{o}{=}\\PY{l+m+mf}{0.1}\\PY{p}{,} \\PY{n}{upper}\\PY{o}{=}\\PY{l+m+mf}{1000.}\\PY{p}{,} \\PY{n}{units}\\PY{o}{=}\\PY{n}{units}\\PY{p}{,} \\PY{n}{ref}\\PY{o}{=}\\PY{n}{ref}\\PY{p}{)}\n\n    \\PY{k}{def}\\PY{+w}{ }\\PY{n+nf}{setup\\PYZus{}partials}\\PY{p}{(}\\PY{n+nb+bp}{self}\\PY{p}{)}\\PY{p}{:}\n        \\PY{c+c1}{\\PYZsh{} Derivatives}\n        \\PY{n+nb+bp}{self}\\PY{o}{.}\\PY{n}{declare\\PYZus{}partials}\\PY{p}{(}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{*}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{*}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{)}\n\n    \\PY{k}{def}\\PY{+w}{ }\\PY{n+nf}{apply\\PYZus{}nonlinear}\\PY{p}{(}\\PY{n+nb+bp}{self}\\PY{p}{,} \\PY{n}{inputs}\\PY{p}{,} \\PY{n}{outputs}\\PY{p}{,} \\PY{n}{resids}\\PY{p}{)}\\PY{p}{:}\n\\PY{+w}{        }\\PY{l+s+sd}{\\PYZdq{}\\PYZdq{}\\PYZdq{}}\n\\PY{l+s+sd}{        Evaluates the equation}\n\\PY{l+s+sd}{        y2 = y1**(.5) + z1 + z2}\n\\PY{l+s+sd}{        \\PYZdq{}\\PYZdq{}\\PYZdq{}}\n\n        \\PY{n}{z1} \\PY{o}{=} \\PY{n}{inputs}\\PY{p}{[}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{z}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{]}\\PY{p}{[}\\PY{l+m+mi}{0}\\PY{p}{]}\n        \\PY{n}{z2} \\PY{o}{=} \\PY{n}{inputs}\\PY{p}{[}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{z}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{]}\\PY{p}{[}\\PY{l+m+mi}{1}\\PY{p}{]}\n        \\PY{n}{y1} \\PY{o}{=} \\PY{n}{inputs}\\PY{p}{[}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{y1}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{]}\\PY{o}{.}\\PY{n}{copy}\\PY{p}{(}\\PY{p}{)}\n\n        \\PY{n}{y2} \\PY{o}{=} \\PY{n}{outputs}\\PY{p}{[}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{y2}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{]}\n\n        \\PY{c+c1}{\\PYZsh{} Note: this may cause some issues. However, y1 is constrained to be}\n        \\PY{c+c1}{\\PYZsh{} above 3.16, so lets just let it converge, and the optimizer will}\n        \\PY{c+c1}{\\PYZsh{} throw it out}\n        \\PY{k}{if} \\PY{n}{y1}\\PY{o}{.}\\PY{n}{real} \\PY{o}{\\PYZlt{}} \\PY{l+m+mf}{0.0}\\PY{p}{:}\n            \\PY{n}{y1} \\PY{o}{*}\\PY{o}{=} \\PY{o}{\\PYZhy{}}\\PY{l+m+mi}{1}\n\n        \\PY{n}{resids}\\PY{p}{[}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{y2}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{]} \\PY{o}{=} \\PY{o}{\\PYZhy{}}\\PY{p}{(}\\PY{n}{y1}\\PY{o}{*}\\PY{o}{*}\\PY{l+m+mf}{.5} \\PY{o}{+} \\PY{n}{z1} \\PY{o}{+} \\PY{n}{z2} \\PY{o}{\\PYZhy{}} \\PY{n}{y2}\\PY{p}{)}\n\n    \\PY{k}{def}\\PY{+w}{ }\\PY{n+nf}{linearize}\\PY{p}{(}\\PY{n+nb+bp}{self}\\PY{p}{,} \\PY{n}{inputs}\\PY{p}{,} \\PY{n}{outputs}\\PY{p}{,} \\PY{n}{J}\\PY{p}{)}\\PY{p}{:}\n\\PY{+w}{        }\\PY{l+s+sd}{\\PYZdq{}\\PYZdq{}\\PYZdq{}}\n\\PY{l+s+sd}{        Jacobian for Sellar discipline 2.}\n\\PY{l+s+sd}{        \\PYZdq{}\\PYZdq{}\\PYZdq{}}\n        \\PY{n}{y1} \\PY{o}{=} \\PY{n}{inputs}\\PY{p}{[}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{y1}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{]}\n        \\PY{k}{if} \\PY{n}{y1}\\PY{o}{.}\\PY{n}{real} \\PY{o}{\\PYZlt{}} \\PY{l+m+mf}{0.0}\\PY{p}{:}\n            \\PY{n}{y1} \\PY{o}{*}\\PY{o}{=} \\PY{o}{\\PYZhy{}}\\PY{l+m+mi}{1}\n        \\PY{k}{if} \\PY{n}{y1}\\PY{o}{.}\\PY{n}{real} \\PY{o}{\\PYZlt{}} \\PY{l+m+mf}{1e\\PYZhy{}8}\\PY{p}{:}\n            \\PY{n}{y1} \\PY{o}{=} \\PY{l+m+mf}{1e\\PYZhy{}8}\n\n        \\PY{n}{J}\\PY{p}{[}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{y2}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{y1}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{]} \\PY{o}{=} \\PY{o}{\\PYZhy{}}\\PY{l+m+mf}{.5}\\PY{o}{*}\\PY{n}{y1}\\PY{o}{*}\\PY{o}{*}\\PY{o}{\\PYZhy{}}\\PY{l+m+mf}{.5}\n        \\PY{n}{J}\\PY{p}{[}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{y2}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{z}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{]} \\PY{o}{=} \\PY{o}{\\PYZhy{}}\\PY{n}{np}\\PY{o}{.}\\PY{n}{array}\\PY{p}{(}\\PY{p}{[}\\PY{p}{[}\\PY{l+m+mf}{1.0}\\PY{p}{,} \\PY{l+m+mf}{1.0}\\PY{p}{]}\\PY{p}{]}\\PY{p}{)}\n        \\PY{n}{J}\\PY{p}{[}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{y2}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{y2}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{]} \\PY{o}{=} \\PY{l+m+mf}{1.0}\n\\end{Verbatim}\n",
      "application/papermill.record/text/plain": "class SellarImplicitDis2(om.ImplicitComponent):\n    \"\"\"\n    Component containing Discipline 2 -- implicit version.\n    \"\"\"\n\n    def __init__(self, units=None, scaling=None):\n        super().__init__()\n        self.execution_count = 0\n        self._units = units\n        self._do_scaling = scaling\n\n    def setup(self):\n        if self._units:\n            units = 'inch'\n        else:\n            units = None\n\n        if self._do_scaling is None:\n            ref = 1.0\n        else:\n            ref = .18\n\n        # Global Design Variable\n        self.add_input('z', val=np.zeros(2), units=units)\n\n        # Coupling parameter\n        self.add_input('y1', val=1.0, units=units)\n\n        # Coupling output\n        self.add_output('y2', val=1.0, lower=0.1, upper=1000., units=units, ref=ref)\n\n    def setup_partials(self):\n        # Derivatives\n        self.declare_partials('*', '*')\n\n    def apply_nonlinear(self, inputs, outputs, resids):\n        \"\"\"\n        Evaluates the equation\n        y2 = y1**(.5) + z1 + z2\n        \"\"\"\n\n        z1 = inputs['z'][0]\n        z2 = inputs['z'][1]\n        y1 = inputs['y1'].copy()\n\n        y2 = outputs['y2']\n\n        # Note: this may cause some issues. However, y1 is constrained to be\n        # above 3.16, so lets just let it converge, and the optimizer will\n        # throw it out\n        if y1.real < 0.0:\n            y1 *= -1\n\n        resids['y2'] = -(y1**.5 + z1 + z2 - y2)\n\n    def linearize(self, inputs, outputs, J):\n        \"\"\"\n        Jacobian for Sellar discipline 2.\n        \"\"\"\n        y1 = inputs['y1']\n        if y1.real < 0.0:\n            y1 *= -1\n        if y1.real < 1e-8:\n            y1 = 1e-8\n\n        J['y2', 'y1'] = -.5*y1**-.5\n        J['y2', 'z'] = -np.array([[1.0, 1.0]])\n        J['y2', 'y2'] = 1.0"
     },
     "metadata": {
      "scrapbook": {
       "mime_prefix": "application/papermill.record/",
       "name": "code_src69"
      }
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "from openmdao.utils.notebook_utils import get_code\n",
    "from myst_nb import glue\n",
    "glue(\"code_src69\", get_code(\"openmdao.test_suite.components.sellar.SellarImplicitDis2\"), display=False)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "a7c1e1b0",
   "metadata": {
    "papermill": {
     "duration": 0.003143,
     "end_time": "2026-10-02T14:50:16.434294+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:16.431151+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    ":::{dropdown} `SellarImplicitDis2` class definition \n",
    "\n",
    "{glue:}`code_src69`\n",
    ":::"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "8ae741fe",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:50:16.441593Z",
     "iopub.status.busy": "2026-10-02T14:50:16.441413Z",
     "iopub.status.idle": "2026-10-02T14:50:16.468862Z",
     "shell.execute_reply": "2026-10-02T14:50:16.468222Z"
    },
    "papermill": {
     "duration": 0.031907,
     "end_time": "2026-10-02T14:50:16.469304+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:16.437397+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0 Explicit Output(s) in 'model'\n",
      "\n",
      "\n",
      "1 Implicit Output(s) in 'model'\n",
      "\n",
      "varname  val          resids       prom_name\n",
      "-------  -----------  -----------  ---------\n",
      "d2\n",
      "  y2     [0.2323774]  [0.0167747]  d2.y2    \n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "import openmdao.api as om\n",
    "from openmdao.test_suite.components.sellar import SellarImplicitDis1, SellarImplicitDis2\n",
    "prob = om.Problem()\n",
    "model = prob.model\n",
    "\n",
    "model.add_subsystem('p1', om.IndepVarComp('x', 1.0))\n",
    "model.add_subsystem('d1', SellarImplicitDis1())\n",
    "model.add_subsystem('d2', SellarImplicitDis2())\n",
    "model.connect('d1.y1', 'd2.y1')\n",
    "model.connect('d2.y2', 'd1.y2')\n",
    "\n",
    "model.nonlinear_solver = om.NewtonSolver(solve_subsystems=False)\n",
    "model.nonlinear_solver.options['maxiter'] = 5\n",
    "model.linear_solver = om.ScipyKrylov()\n",
    "model.linear_solver.precon = om.LinearBlockGS()\n",
    "\n",
    "prob.setup()\n",
    "prob.set_solver_print(level=-1)\n",
    "\n",
    "prob.run_model()\n",
    "\n",
    "outputs = model.list_outputs(residuals_tol=0.01, residuals=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "82f1199f",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:50:16.476560Z",
     "iopub.status.busy": "2026-10-02T14:50:16.476426Z",
     "iopub.status.idle": "2026-10-02T14:50:16.479009Z",
     "shell.execute_reply": "2026-10-02T14:50:16.478476Z"
    },
    "papermill": {
     "duration": 0.006834,
     "end_time": "2026-10-02T14:50:16.479416+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:16.472582+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[('d2.y2', {'val': array([0.2323774]), 'prom_name': 'd2.y2', 'resids': array([0.0167747])})]\n"
     ]
    }
   ],
   "source": [
    "print(outputs)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "de05b3df",
   "metadata": {
    "papermill": {
     "duration": 0.003261,
     "end_time": "2026-10-02T14:50:16.486019+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:16.482758+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "### *List Additional Variable Metadata*\n",
    "\n",
    "The `list_inputs()` and `list_outputs()` methods have many options to also display units, shape, bounds (lower and upper), and scaling (res, res0, and res_ref) for the variables."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "841903c4",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:50:16.492961Z",
     "iopub.status.busy": "2026-10-02T14:50:16.492827Z",
     "iopub.status.idle": "2026-10-02T14:50:16.498925Z",
     "shell.execute_reply": "2026-10-02T14:50:16.498333Z"
    },
    "papermill": {
     "duration": 0.010215,
     "end_time": "2026-10-02T14:50:16.499354+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:16.489139+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2 Input(s) in 'model'\n",
      "\n",
      "varname  val    units  prom_name\n",
      "-------  -----  -----  ---------\n",
      "comp\n",
      "  x      [12.]  inch   comp.x   \n",
      "  y      [12.]  inch   comp.y   \n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "import openmdao.api as om\n",
    "\n",
    "prob = om.Problem()\n",
    "model = prob.model\n",
    "\n",
    "model.add_subsystem('p1', om.IndepVarComp('x', 12.0,\n",
    "                                          lower=1.0, upper=100.0,\n",
    "                                          ref=1.1, ref0=2.1,\n",
    "                                          units='inch',\n",
    "                                          ))\n",
    "model.add_subsystem('p2', om.IndepVarComp('y', 1.0,\n",
    "                                          lower=2.0, upper=200.0,\n",
    "                                          ref=1.2, res_ref=2.2,\n",
    "                                          units='ft',\n",
    "                                          ))\n",
    "model.add_subsystem('comp', om.ExecComp('z=x+y',\n",
    "                                        x={'val': 0.0, 'units': 'inch'},\n",
    "                                        y={'val': 0.0, 'units': 'inch'},\n",
    "                                        z={'val': 0.0, 'units': 'inch'}))\n",
    "model.connect('p1.x', 'comp.x')\n",
    "model.connect('p2.y', 'comp.y')\n",
    "\n",
    "prob.setup()\n",
    "prob.set_solver_print(level=0)\n",
    "prob.run_model()\n",
    "\n",
    "inputs = prob.model.list_inputs(units=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "d262514b",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:50:16.506478Z",
     "iopub.status.busy": "2026-10-02T14:50:16.506189Z",
     "iopub.status.idle": "2026-10-02T14:50:16.508880Z",
     "shell.execute_reply": "2026-10-02T14:50:16.508319Z"
    },
    "papermill": {
     "duration": 0.007052,
     "end_time": "2026-10-02T14:50:16.509514+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:16.502462+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[('comp.x', {'units': 'inch', 'prom_name': 'comp.x', 'val': array([12.])}), ('comp.y', {'units': 'inch', 'prom_name': 'comp.y', 'val': array([12.])})]\n"
     ]
    }
   ],
   "source": [
    "print(inputs)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "e77194c6",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:50:16.523034Z",
     "iopub.status.busy": "2026-10-02T14:50:16.522890Z",
     "iopub.status.idle": "2026-10-02T14:50:16.527016Z",
     "shell.execute_reply": "2026-10-02T14:50:16.526366Z"
    },
    "papermill": {
     "duration": 0.008289,
     "end_time": "2026-10-02T14:50:16.527428+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:16.519139+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3 Explicit Output(s) in 'model'\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "\n",
       "<!DOCTYPE html>\n",
       "<html lang=\"en\">\n",
       "<head>\n",
       "    <style>\n",
       "        h2 {\n",
       "            text-align: center;\n",
       "        }\n",
       "    </style>\n",
       "</head>\n",
       "<body>\n",
       "    <h2></h2>\n",
       "        <table style=\"border: 1px solid #999; border-collapse: collapse;\">\n",
       "        <tr><th style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; background-color: #E9E9E9; text-align: left;\">varname</th><th style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; background-color: #E9E9E9; text-align: left;\">val</th><th style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; background-color: #E9E9E9; text-align: left;\">resids</th><th style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; background-color: #E9E9E9; text-align: left;\">units</th><th style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; background-color: #E9E9E9; text-align: left;\">shape</th><th style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; background-color: #E9E9E9; text-align: left;\">lower</th><th style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; background-color: #E9E9E9; text-align: left;\">upper</th><th style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; background-color: #E9E9E9; text-align: right;\">ref</th><th style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; background-color: #E9E9E9; text-align: right;\">ref0</th><th style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; background-color: #E9E9E9; text-align: right;\">res_ref</th><th style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; background-color: #E9E9E9; text-align: left;\">prom_name</th></tr>\n",
       "       <tr style=\"background-color: ghostwhite;\"><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: left;\">p1.x</td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: left;\">[12.]</td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: left;\">[0.]</td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: left;\">inch</td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: left;\">(1,)</td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: left;\">[1.]</td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: left;\">[100.]</td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: right;\">1.1</td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: right;\">2.1</td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: right;\">1.1</td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: left;\">p1.x</td></tr>\n",
       "       <tr style=\"background-color: #F3F3F3;\"><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: left;\">p2.y</td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: left;\">[1.]</td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: left;\">[0.]</td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: left;\">ft</td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: left;\">(1,)</td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: left;\">[2.]</td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: left;\">[200.]</td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: right;\">1.2</td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: right;\">0.0</td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: right;\">2.2</td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: left;\">p2.y</td></tr>\n",
       "       <tr style=\"background-color: ghostwhite;\"><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: left;\">comp.z</td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: left;\">[24.]</td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: left;\">[0.]</td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: left;\">inch</td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: left;\">(1,)</td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: left;\"></td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: left;\"></td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: right;\">1.0</td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: right;\">0.0</td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: right;\">1.0</td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: left;\">comp.z</td></tr>\n",
       "    </table>\n",
       "</body>\n",
       "</html>\n"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "outputs = prob.model.list_outputs(implicit=False,\n",
    "                                  val=True,\n",
    "                                  units=True,\n",
    "                                  shape=True,\n",
    "                                  bounds=True,\n",
    "                                  residuals=True,\n",
    "                                  scaling=True,\n",
    "                                  hierarchical=False,\n",
    "                                  print_arrays=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "86c8bc70",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:50:16.534884Z",
     "iopub.status.busy": "2026-10-02T14:50:16.534751Z",
     "iopub.status.idle": "2026-10-02T14:50:16.538638Z",
     "shell.execute_reply": "2026-10-02T14:50:16.538268Z"
    },
    "papermill": {
     "duration": 0.008413,
     "end_time": "2026-10-02T14:50:16.539265+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:16.530852+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[('comp.z',\n",
      "  {'lower': None,\n",
      "   'prom_name': 'comp.z',\n",
      "   'ref': 1.0,\n",
      "   'ref0': 0.0,\n",
      "   'res_ref': 1.0,\n",
      "   'resids': array([0.]),\n",
      "   'shape': (1,),\n",
      "   'units': 'inch',\n",
      "   'upper': None,\n",
      "   'val': array([24.])}),\n",
      " ('p1.x',\n",
      "  {'lower': array([1.]),\n",
      "   'prom_name': 'p1.x',\n",
      "   'ref': 1.1,\n",
      "   'ref0': 2.1,\n",
      "   'res_ref': 1.1,\n",
      "   'resids': array([0.]),\n",
      "   'shape': (1,),\n",
      "   'units': 'inch',\n",
      "   'upper': array([100.]),\n",
      "   'val': array([12.])}),\n",
      " ('p2.y',\n",
      "  {'lower': array([2.]),\n",
      "   'prom_name': 'p2.y',\n",
      "   'ref': 1.2,\n",
      "   'ref0': 0.0,\n",
      "   'res_ref': 2.2,\n",
      "   'resids': array([0.]),\n",
      "   'shape': (1,),\n",
      "   'units': 'ft',\n",
      "   'upper': array([200.]),\n",
      "   'val': array([1.])})]\n"
     ]
    }
   ],
   "source": [
    "from pprint import pprint\n",
    "pprint(sorted(outputs))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "4d8c3b62",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:50:16.548362Z",
     "iopub.status.busy": "2026-10-02T14:50:16.548248Z",
     "iopub.status.idle": "2026-10-02T14:50:16.551535Z",
     "shell.execute_reply": "2026-10-02T14:50:16.550944Z"
    },
    "papermill": {
     "duration": 0.009456,
     "end_time": "2026-10-02T14:50:16.551919+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:16.542463+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3 Explicit Output(s) in 'model'\n",
      "\n",
      "varname  val    resids  units  shape  lower  upper   ref  ref0  res_ref  prom_name\n",
      "-------  -----  ------  -----  -----  -----  ------  ---  ----  -------  ---------\n",
      "p1\n",
      "  x      [12.]  [0.]    inch   (1,)   [1.]   [100.]  1.1  2.1   1.1      p1.x     \n",
      "p2\n",
      "  y      [1.]   [0.]    ft     (1,)   [2.]   [200.]  1.2  0.0   2.2      p2.y     \n",
      "comp\n",
      "  z      [24.]  [0.]    inch   (1,)   None   None    1.0  0.0   1.0      comp.z   \n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "prob.model.list_outputs(implicit=False,\n",
    "                        val=True,\n",
    "                        units=True,\n",
    "                        shape=True,\n",
    "                        bounds=True,\n",
    "                        residuals=True,\n",
    "                        scaling=True,\n",
    "                        hierarchical=True,\n",
    "                        print_arrays=False);"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "1a53cfac",
   "metadata": {
    "papermill": {
     "duration": 0.099821,
     "end_time": "2026-10-02T14:50:16.655041+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:16.555220+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "### *Print Array Values*\n",
    "\n",
    "The `list_inputs()` and `list_outputs()` methods both have a `print_arrays` option. By default, this option is set to False and only the norm of the array will appear in the tabular display. The norm value is surrounded by vertical bars to indicate that it is a norm. When the option is set to True, the complete value of the array will also be a displayed below the row."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "0b152abe",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:50:16.663180Z",
     "iopub.status.busy": "2026-10-02T14:50:16.663021Z",
     "iopub.status.idle": "2026-10-02T14:50:16.804185Z",
     "shell.execute_reply": "2026-10-02T14:50:16.803514Z"
    },
    "papermill": {
     "duration": 0.146266,
     "end_time": "2026-10-02T14:50:16.804819+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:16.658553+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1 Input(s) in 'model'\n",
      "\n",
      "varname  val                  units  prom_name\n",
      "-------  -------------------  -----  ---------\n",
      "mult\n",
      "  x      |92.493243|          inch   x        \n",
      "         val:\n",
      "         array([ 0.,  1.,  2.,  3.,  4.,  5.,  6.,  7.,  8.,  9., 10., 11., 12.,\n",
      "                13., 14., 15., 16., 17., 18., 19., 20., 21., 22., 23., 24., 25.,\n",
      "                26., 27., 28., 29.])\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "\n",
    "import openmdao.api as om\n",
    "\n",
    "class ArrayAdder(om.ExplicitComponent):\n",
    "    \"\"\"\n",
    "    Just a simple component that has array inputs and outputs\n",
    "    \"\"\"\n",
    "\n",
    "    def __init__(self, size):\n",
    "        super().__init__()\n",
    "        self.size = size\n",
    "\n",
    "    def setup(self):\n",
    "        self.add_input('x', val=np.zeros(self.size), units='inch')\n",
    "        self.add_output('y', val=np.zeros(self.size), units='ft')\n",
    "\n",
    "    def compute(self, inputs, outputs):\n",
    "        outputs['y'] = inputs['x'] + 10.0\n",
    "\n",
    "size = 30\n",
    "\n",
    "prob = om.Problem()\n",
    "prob.model.add_subsystem('des_vars', om.IndepVarComp('x', np.ones(size), units='inch'),\n",
    "                         promotes=['x'])\n",
    "prob.model.add_subsystem('mult', ArrayAdder(size), promotes=['x', 'y'])\n",
    "\n",
    "prob.setup()\n",
    "prob['x'] = np.arange(size)\n",
    "prob.run_driver()\n",
    "\n",
    "prob.model.list_inputs(val=True,\n",
    "                       units=True,\n",
    "                       hierarchical=True,\n",
    "                       print_arrays=True);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "d8af8126",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:50:16.813415Z",
     "iopub.status.busy": "2026-10-02T14:50:16.813266Z",
     "iopub.status.idle": "2026-10-02T14:50:16.816488Z",
     "shell.execute_reply": "2026-10-02T14:50:16.815985Z"
    },
    "papermill": {
     "duration": 0.008025,
     "end_time": "2026-10-02T14:50:16.817043+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:16.809018+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2 Explicit Output(s) in 'model'\n",
      "\n",
      "varname   val                   resids  units  shape  lower  upper  ref  ref0  res_ref  prom_name\n",
      "--------  --------------------  ------  -----  -----  -----  -----  ---  ----  -------  ---------\n",
      "des_vars\n",
      "  x       |92.493243|           |0.0|   inch   (30,)  None   None   1.0  0.0   1.0      x        \n",
      "          val:\n",
      "          array([ 0.,  1.,  2.,  3.,  4.,  5.,  6.,  7.,  8.,  9., 10., 11., 12.,\n",
      "                 13., 14., 15., 16., 17., 18., 19., 20., 21., 22., 23., 24., 25.,\n",
      "                 26., 27., 28., 29.])\n",
      "          resids:\n",
      "          array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,\n",
      "                 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.])\n",
      "mult\n",
      "  y       |142.32006183|        |0.0|   ft     (30,)  None   None   1.0  0.0   1.0      y        \n",
      "          val:\n",
      "          array([10., 11., 12., 13., 14., 15., 16., 17., 18., 19., 20., 21., 22.,\n",
      "                 23., 24., 25., 26., 27., 28., 29., 30., 31., 32., 33., 34., 35.,\n",
      "                 36., 37., 38., 39.])\n",
      "          resids:\n",
      "          array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,\n",
      "                 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.])\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "prob.model.list_outputs(val=True,\n",
    "                        implicit=False,\n",
    "                        units=True,\n",
    "                        shape=True,\n",
    "                        bounds=True,\n",
    "                        residuals=True,\n",
    "                        scaling=True,\n",
    "                        hierarchical=True,\n",
    "                        print_arrays=True);"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "a7a1b437",
   "metadata": {
    "papermill": {
     "duration": 0.003414,
     "end_time": "2026-10-02T14:50:16.823912+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:16.820498+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "You can control the format of the array values via `numpy.set_printoptions`. OpenMDAO provides the `printoptions` context manager to assist with this."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "01917d3b",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:50:16.831988Z",
     "iopub.status.busy": "2026-10-02T14:50:16.831849Z",
     "iopub.status.idle": "2026-10-02T14:50:16.836050Z",
     "shell.execute_reply": "2026-10-02T14:50:16.835397Z"
    },
    "papermill": {
     "duration": 0.009241,
     "end_time": "2026-10-02T14:50:16.836481+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:16.827240+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2 Explicit Output(s) in 'model'\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "\n",
       "<!DOCTYPE html>\n",
       "<html lang=\"en\">\n",
       "<head>\n",
       "    <style>\n",
       "        h2 {\n",
       "            text-align: center;\n",
       "        }\n",
       "    </style>\n",
       "</head>\n",
       "<body>\n",
       "    <h2></h2>\n",
       "        <table style=\"border: 1px solid #999; border-collapse: collapse;\">\n",
       "        <tr><th style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; background-color: #E9E9E9; text-align: left;\">varname</th><th style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; background-color: #E9E9E9; text-align: left;\">val</th><th style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; background-color: #E9E9E9; text-align: left;\">resids</th><th style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; background-color: #E9E9E9; text-align: left;\">units</th><th style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; background-color: #E9E9E9; text-align: left;\">shape</th><th style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; background-color: #E9E9E9; text-align: left;\">lower</th><th style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; background-color: #E9E9E9; text-align: left;\">upper</th><th style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; background-color: #E9E9E9; text-align: right;\">ref</th><th style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; background-color: #E9E9E9; text-align: right;\">ref0</th><th style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; background-color: #E9E9E9; text-align: right;\">res_ref</th><th style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; background-color: #E9E9E9; text-align: left;\">prom_name</th></tr>\n",
       "       <tr style=\"background-color: ghostwhite;\"><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: left;\">des_vars.x</td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: left;\">[ 0.  1.  2.  3.  4.  5.  6.  7.  8.  9. 10. 11. 12. 13. 14. 15. 16. 17.\n",
       "     18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29.]</td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: left;\">[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.\n",
       "     0. 0. 0. 0. 0. 0.]</td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: left;\">inch</td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: left;\">(30,)</td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: left;\"></td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: left;\"></td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: right;\">1.0</td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: right;\">0.0</td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: right;\">1.0</td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: left;\">x</td></tr>\n",
       "       <tr style=\"background-color: #F3F3F3;\"><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: left;\">mult.y</td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: left;\">[10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27.\n",
       "     28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39.]</td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: left;\">[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.\n",
       "     0. 0. 0. 0. 0. 0.]</td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: left;\">ft</td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: left;\">(30,)</td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: left;\"></td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: left;\"></td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: right;\">1.0</td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: right;\">0.0</td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: right;\">1.0</td><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: left;\">y</td></tr>\n",
       "    </table>\n",
       "</body>\n",
       "</html>\n"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from openmdao.utils.general_utils import printoptions\n",
    "\n",
    "with printoptions(edgeitems=3, infstr='inf',\n",
    "                  linewidth=75, nanstr='nan', precision=8,\n",
    "                  suppress=False, threshold=1000, formatter=None):\n",
    "\n",
    "    prob.model.list_outputs(val=True,\n",
    "                            implicit=False,\n",
    "                            units=True,\n",
    "                            shape=True,\n",
    "                            bounds=True,\n",
    "                            residuals=True,\n",
    "                            scaling=True,\n",
    "                            hierarchical=False,\n",
    "                            print_arrays=True)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "6e1a86b5",
   "metadata": {
    "papermill": {
     "duration": 0.003395,
     "end_time": "2026-10-02T14:50:16.843859+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:16.840464+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "### *Print Minimum, Maximum or Mean Array Values*\n",
    "\n",
    "When working with large arrays, it can be difficult to determine how the array is interacting with the upper and lower bounds by looking through the output of the entire contents.\n",
    "Additionally, seeing the mean value of the array can be useful.\n",
    "To provide a quick visual reference, the `list_inputs()` and `list_outputs()` methods have `print_min`, `print_max`, `print_mean` options that output columns with the minimum and maximum values of the array."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "746b80dd",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:50:16.851973Z",
     "iopub.status.busy": "2026-10-02T14:50:16.851841Z",
     "iopub.status.idle": "2026-10-02T14:50:16.854483Z",
     "shell.execute_reply": "2026-10-02T14:50:16.854021Z"
    },
    "papermill": {
     "duration": 0.007254,
     "end_time": "2026-10-02T14:50:16.855115+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:16.847861+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1 Input(s) in 'model'\n",
      "\n",
      "varname  val                  units  prom_name  min  max   mean\n",
      "-------  -------------------  -----  ---------  ---  ----  ----\n",
      "mult\n",
      "  x      |92.493243|          inch   x          0.0  29.0  14.5\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "prob.model.list_inputs(val=True,\n",
    "                       units=True,\n",
    "                       hierarchical=True,\n",
    "                       print_min=True,\n",
    "                       print_max=True,\n",
    "                       print_mean=True);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "1b619c1c",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:50:16.863541Z",
     "iopub.status.busy": "2026-10-02T14:50:16.863424Z",
     "iopub.status.idle": "2026-10-02T14:50:16.866611Z",
     "shell.execute_reply": "2026-10-02T14:50:16.865970Z"
    },
    "papermill": {
     "duration": 0.007479,
     "end_time": "2026-10-02T14:50:16.867043+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:16.859564+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2 Explicit Output(s) in 'model'\n",
      "\n",
      "varname   val                   resids  units  shape  lower  upper  ref  ref0  res_ref  prom_name  min   max   mean\n",
      "--------  --------------------  ------  -----  -----  -----  -----  ---  ----  -------  ---------  ----  ----  ----\n",
      "des_vars\n",
      "  x       |92.493243|           |0.0|   inch   (30,)  None   None   1.0  0.0   1.0      x          0.0   29.0  14.5\n",
      "mult\n",
      "  y       |142.32006183|        |0.0|   ft     (30,)  None   None   1.0  0.0   1.0      y          10.0  39.0  24.5\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "prob.model.list_outputs(val=True,\n",
    "                        implicit=False,\n",
    "                        units=True,\n",
    "                        shape=True,\n",
    "                        bounds=True,\n",
    "                        residuals=True,\n",
    "                        scaling=True,\n",
    "                        hierarchical=True,\n",
    "                        print_min=True,\n",
    "                        print_max=True,\n",
    "                        print_mean=True);"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "b8c193e5",
   "metadata": {
    "papermill": {
     "duration": 0.003444,
     "end_time": "2026-10-02T14:50:16.887648+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:16.884204+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "Note that it is normally required to run the model before `list_inputs()` and `list_outputs()` can be used. This is because the final setup that occurs just before execution determines the hierarchy and builds the data structures and connections. In some cases however, it can be useful to call these functions on a system prior to execution to assist in configuring your model. At `configure` time, basic metadata about a system’s inputs and outputs is available. \n",
    "See the documentation for the [configure](../core_features/working_with_groups/configure_method.ipynb) method for one such use case.\n",
    "\n",
    "### *List Global Shape*\n",
    "\n",
    "When working with [Distributed Variables](../core_features/working_with_components/distributed_components.ipynb), it may also be useful to display the global shape of a variable as well as the shape on the current processor. Note that this information is not available until after the model has been completely set up."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "69c6e9e8",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:50:16.895168Z",
     "iopub.status.busy": "2026-10-02T14:50:16.895040Z",
     "iopub.status.idle": "2026-10-02T14:50:16.902204Z",
     "shell.execute_reply": "2026-10-02T14:50:16.901552Z"
    },
    "papermill": {
     "duration": 0.011514,
     "end_time": "2026-10-02T14:50:16.902601+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:16.891087+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [
    {
     "data": {
      "application/papermill.record/text/html": "<style>pre { line-height: 125%; }\ntd.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }\nspan.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }\ntd.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }\nspan.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }\n.output_html .hll { background-color: #ffffcc }\n.output_html { background: #f8f8f8; }\n.output_html .c { color: #3D7B7B; font-style: italic } /* Comment */\n.output_html .err { border: 1px solid #F00 } /* Error */\n.output_html .k { color: #008000; font-weight: bold } /* Keyword */\n.output_html .o { color: #666 } /* Operator */\n.output_html .ch { color: #3D7B7B; font-style: italic } /* Comment.Hashbang */\n.output_html .cm { color: #3D7B7B; font-style: italic } /* Comment.Multiline */\n.output_html .cp { color: #9C6500 } /* Comment.Preproc */\n.output_html .cpf { color: #3D7B7B; font-style: italic } /* Comment.PreprocFile */\n.output_html .c1 { color: #3D7B7B; font-style: italic } /* Comment.Single */\n.output_html .cs { color: #3D7B7B; font-style: italic } /* Comment.Special */\n.output_html .gd { color: #A00000 } /* Generic.Deleted */\n.output_html .ge { font-style: italic } /* Generic.Emph */\n.output_html .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */\n.output_html .gr { color: #E40000 } /* Generic.Error */\n.output_html .gh { color: #000080; font-weight: bold } /* Generic.Heading */\n.output_html .gi { color: #008400 } /* Generic.Inserted */\n.output_html .go { color: #717171 } /* Generic.Output */\n.output_html .gp { color: #000080; font-weight: bold } /* Generic.Prompt */\n.output_html .gs { font-weight: bold } /* Generic.Strong */\n.output_html .gu { color: #800080; font-weight: bold } /* Generic.Subheading */\n.output_html .gt { color: #04D } /* Generic.Traceback */\n.output_html .kc { color: #008000; font-weight: bold } /* Keyword.Constant */\n.output_html .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */\n.output_html .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */\n.output_html .kp { color: #008000 } /* Keyword.Pseudo */\n.output_html .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */\n.output_html .kt { color: #B00040 } /* Keyword.Type */\n.output_html .m { color: #666 } /* Literal.Number */\n.output_html .s { color: #BA2121 } /* Literal.String */\n.output_html .na { color: #687822 } /* Name.Attribute */\n.output_html .nb { color: #008000 } /* Name.Builtin */\n.output_html .nc { color: #00F; font-weight: bold } /* Name.Class */\n.output_html .no { color: #800 } /* Name.Constant */\n.output_html .nd { color: #A2F } /* Name.Decorator */\n.output_html .ni { color: #717171; font-weight: bold } /* Name.Entity */\n.output_html .ne { color: #CB3F38; font-weight: bold } /* Name.Exception */\n.output_html .nf { color: #00F } /* Name.Function */\n.output_html .nl { color: #767600 } /* Name.Label */\n.output_html .nn { color: #00F; font-weight: bold } /* Name.Namespace */\n.output_html .nt { color: #008000; font-weight: bold } /* Name.Tag */\n.output_html .nv { color: #19177C } /* Name.Variable */\n.output_html .ow { color: #A2F; font-weight: bold } /* Operator.Word */\n.output_html .w { color: #BBB } /* Text.Whitespace */\n.output_html .mb { color: #666 } /* Literal.Number.Bin */\n.output_html .mf { color: #666 } /* Literal.Number.Float */\n.output_html .mh { color: #666 } /* Literal.Number.Hex */\n.output_html .mi { color: #666 } /* Literal.Number.Integer */\n.output_html .mo { color: #666 } /* Literal.Number.Oct */\n.output_html .sa { color: #BA2121 } /* Literal.String.Affix */\n.output_html .sb { color: #BA2121 } /* Literal.String.Backtick */\n.output_html .sc { color: #BA2121 } /* Literal.String.Char */\n.output_html .dl { color: #BA2121 } /* Literal.String.Delimiter */\n.output_html .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */\n.output_html .s2 { color: #BA2121 } /* Literal.String.Double */\n.output_html .se { color: #AA5D1F; font-weight: bold } /* Literal.String.Escape */\n.output_html .sh { color: #BA2121 } /* Literal.String.Heredoc */\n.output_html .si { color: #A45A77; font-weight: bold } /* Literal.String.Interpol */\n.output_html .sx { color: #008000 } /* Literal.String.Other */\n.output_html .sr { color: #A45A77 } /* Literal.String.Regex */\n.output_html .s1 { color: #BA2121 } /* Literal.String.Single */\n.output_html .ss { color: #19177C } /* Literal.String.Symbol */\n.output_html .bp { color: #008000 } /* Name.Builtin.Pseudo */\n.output_html .fm { color: #00F } /* Name.Function.Magic */\n.output_html .vc { color: #19177C } /* Name.Variable.Class */\n.output_html .vg { color: #19177C } /* Name.Variable.Global */\n.output_html .vi { color: #19177C } /* Name.Variable.Instance */\n.output_html .vm { color: #19177C } /* Name.Variable.Magic */\n.output_html .il { color: #666 } /* Literal.Number.Integer.Long */</style><div class=\"highlight\"><pre><span></span><span class=\"k\">class</span><span class=\"w\"> </span><span class=\"nc\">DistribComp</span><span class=\"p\">(</span><span class=\"n\">om</span><span class=\"o\">.</span><span class=\"n\">ExplicitComponent</span><span class=\"p\">):</span>\n<span class=\"w\">    </span><span class=\"sd\">&quot;&quot;&quot;Simple Distributed Component.&quot;&quot;&quot;</span>\n\n    <span class=\"k\">def</span><span class=\"w\"> </span><span class=\"nf\">initialize</span><span class=\"p\">(</span><span class=\"bp\">self</span><span class=\"p\">):</span>\n        <span class=\"bp\">self</span><span class=\"o\">.</span><span class=\"n\">options</span><span class=\"o\">.</span><span class=\"n\">declare</span><span class=\"p\">(</span><span class=\"s1\">&#39;size&#39;</span><span class=\"p\">,</span> <span class=\"n\">types</span><span class=\"o\">=</span><span class=\"nb\">int</span><span class=\"p\">,</span> <span class=\"n\">default</span><span class=\"o\">=</span><span class=\"mi\">1</span><span class=\"p\">,</span>\n                             <span class=\"n\">desc</span><span class=\"o\">=</span><span class=\"s2\">&quot;Size of input and output vectors.&quot;</span><span class=\"p\">)</span>\n\n    <span class=\"k\">def</span><span class=\"w\"> </span><span class=\"nf\">setup</span><span class=\"p\">(</span><span class=\"bp\">self</span><span class=\"p\">):</span>\n        <span class=\"n\">comm</span> <span class=\"o\">=</span> <span class=\"bp\">self</span><span class=\"o\">.</span><span class=\"n\">comm</span>\n        <span class=\"n\">rank</span> <span class=\"o\">=</span> <span class=\"n\">comm</span><span class=\"o\">.</span><span class=\"n\">rank</span>\n\n        <span class=\"n\">size</span> <span class=\"o\">=</span> <span class=\"bp\">self</span><span class=\"o\">.</span><span class=\"n\">options</span><span class=\"p\">[</span><span class=\"s1\">&#39;size&#39;</span><span class=\"p\">]</span>\n\n        <span class=\"c1\"># if comm.size is 2 and size is 15, this results in</span>\n        <span class=\"c1\"># 8 entries for proc 0 and 7 entries for proc 1</span>\n        <span class=\"n\">sizes</span><span class=\"p\">,</span> <span class=\"n\">_</span> <span class=\"o\">=</span> <span class=\"n\">evenly_distrib_idxs</span><span class=\"p\">(</span><span class=\"n\">comm</span><span class=\"o\">.</span><span class=\"n\">size</span><span class=\"p\">,</span> <span class=\"n\">size</span><span class=\"p\">)</span>\n        <span class=\"n\">mysize</span> <span class=\"o\">=</span> <span class=\"n\">sizes</span><span class=\"p\">[</span><span class=\"n\">rank</span><span class=\"p\">]</span>\n\n        <span class=\"bp\">self</span><span class=\"o\">.</span><span class=\"n\">add_input</span><span class=\"p\">(</span><span class=\"s1\">&#39;invec&#39;</span><span class=\"p\">,</span> <span class=\"n\">np</span><span class=\"o\">.</span><span class=\"n\">ones</span><span class=\"p\">(</span><span class=\"n\">mysize</span><span class=\"p\">,</span> <span class=\"nb\">float</span><span class=\"p\">),</span> <span class=\"n\">distributed</span><span class=\"o\">=</span><span class=\"kc\">True</span><span class=\"p\">)</span>\n        <span class=\"bp\">self</span><span class=\"o\">.</span><span class=\"n\">add_output</span><span class=\"p\">(</span><span class=\"s1\">&#39;outvec&#39;</span><span class=\"p\">,</span> <span class=\"n\">np</span><span class=\"o\">.</span><span class=\"n\">ones</span><span class=\"p\">(</span><span class=\"n\">mysize</span><span class=\"p\">,</span> <span class=\"nb\">float</span><span class=\"p\">),</span> <span class=\"n\">distributed</span><span class=\"o\">=</span><span class=\"kc\">True</span><span class=\"p\">,)</span>\n\n    <span class=\"k\">def</span><span class=\"w\"> </span><span class=\"nf\">compute</span><span class=\"p\">(</span><span class=\"bp\">self</span><span class=\"p\">,</span> <span class=\"n\">inputs</span><span class=\"p\">,</span> <span class=\"n\">outputs</span><span class=\"p\">):</span>\n        <span class=\"k\">if</span> <span class=\"bp\">self</span><span class=\"o\">.</span><span class=\"n\">comm</span><span class=\"o\">.</span><span class=\"n\">rank</span> <span class=\"o\">==</span> <span class=\"mi\">0</span><span class=\"p\">:</span>\n            <span class=\"n\">outputs</span><span class=\"p\">[</span><span class=\"s1\">&#39;outvec&#39;</span><span class=\"p\">]</span> <span class=\"o\">=</span> <span class=\"n\">inputs</span><span class=\"p\">[</span><span class=\"s1\">&#39;invec&#39;</span><span class=\"p\">]</span> <span class=\"o\">*</span> <span class=\"mf\">2.0</span>\n        <span class=\"k\">else</span><span class=\"p\">:</span>\n            <span class=\"n\">outputs</span><span class=\"p\">[</span><span class=\"s1\">&#39;outvec&#39;</span><span class=\"p\">]</span> <span class=\"o\">=</span> <span class=\"n\">inputs</span><span class=\"p\">[</span><span class=\"s1\">&#39;invec&#39;</span><span class=\"p\">]</span> <span class=\"o\">*</span> <span class=\"o\">-</span><span class=\"mf\">3.0</span>\n</pre></div>\n",
      "application/papermill.record/text/latex": "\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n\\PY{k}{class}\\PY{+w}{ }\\PY{n+nc}{DistribComp}\\PY{p}{(}\\PY{n}{om}\\PY{o}{.}\\PY{n}{ExplicitComponent}\\PY{p}{)}\\PY{p}{:}\n\\PY{+w}{    }\\PY{l+s+sd}{\\PYZdq{}\\PYZdq{}\\PYZdq{}Simple Distributed Component.\\PYZdq{}\\PYZdq{}\\PYZdq{}}\n\n    \\PY{k}{def}\\PY{+w}{ }\\PY{n+nf}{initialize}\\PY{p}{(}\\PY{n+nb+bp}{self}\\PY{p}{)}\\PY{p}{:}\n        \\PY{n+nb+bp}{self}\\PY{o}{.}\\PY{n}{options}\\PY{o}{.}\\PY{n}{declare}\\PY{p}{(}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{size}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{n}{types}\\PY{o}{=}\\PY{n+nb}{int}\\PY{p}{,} \\PY{n}{default}\\PY{o}{=}\\PY{l+m+mi}{1}\\PY{p}{,}\n                             \\PY{n}{desc}\\PY{o}{=}\\PY{l+s+s2}{\\PYZdq{}}\\PY{l+s+s2}{Size of input and output vectors.}\\PY{l+s+s2}{\\PYZdq{}}\\PY{p}{)}\n\n    \\PY{k}{def}\\PY{+w}{ }\\PY{n+nf}{setup}\\PY{p}{(}\\PY{n+nb+bp}{self}\\PY{p}{)}\\PY{p}{:}\n        \\PY{n}{comm} \\PY{o}{=} \\PY{n+nb+bp}{self}\\PY{o}{.}\\PY{n}{comm}\n        \\PY{n}{rank} \\PY{o}{=} \\PY{n}{comm}\\PY{o}{.}\\PY{n}{rank}\n\n        \\PY{n}{size} \\PY{o}{=} \\PY{n+nb+bp}{self}\\PY{o}{.}\\PY{n}{options}\\PY{p}{[}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{size}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{]}\n\n        \\PY{c+c1}{\\PYZsh{} if comm.size is 2 and size is 15, this results in}\n        \\PY{c+c1}{\\PYZsh{} 8 entries for proc 0 and 7 entries for proc 1}\n        \\PY{n}{sizes}\\PY{p}{,} \\PY{n}{\\PYZus{}} \\PY{o}{=} \\PY{n}{evenly\\PYZus{}distrib\\PYZus{}idxs}\\PY{p}{(}\\PY{n}{comm}\\PY{o}{.}\\PY{n}{size}\\PY{p}{,} \\PY{n}{size}\\PY{p}{)}\n        \\PY{n}{mysize} \\PY{o}{=} \\PY{n}{sizes}\\PY{p}{[}\\PY{n}{rank}\\PY{p}{]}\n\n        \\PY{n+nb+bp}{self}\\PY{o}{.}\\PY{n}{add\\PYZus{}input}\\PY{p}{(}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{invec}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{n}{np}\\PY{o}{.}\\PY{n}{ones}\\PY{p}{(}\\PY{n}{mysize}\\PY{p}{,} \\PY{n+nb}{float}\\PY{p}{)}\\PY{p}{,} \\PY{n}{distributed}\\PY{o}{=}\\PY{k+kc}{True}\\PY{p}{)}\n        \\PY{n+nb+bp}{self}\\PY{o}{.}\\PY{n}{add\\PYZus{}output}\\PY{p}{(}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{outvec}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{n}{np}\\PY{o}{.}\\PY{n}{ones}\\PY{p}{(}\\PY{n}{mysize}\\PY{p}{,} \\PY{n+nb}{float}\\PY{p}{)}\\PY{p}{,} \\PY{n}{distributed}\\PY{o}{=}\\PY{k+kc}{True}\\PY{p}{,}\\PY{p}{)}\n\n    \\PY{k}{def}\\PY{+w}{ }\\PY{n+nf}{compute}\\PY{p}{(}\\PY{n+nb+bp}{self}\\PY{p}{,} \\PY{n}{inputs}\\PY{p}{,} \\PY{n}{outputs}\\PY{p}{)}\\PY{p}{:}\n        \\PY{k}{if} \\PY{n+nb+bp}{self}\\PY{o}{.}\\PY{n}{comm}\\PY{o}{.}\\PY{n}{rank} \\PY{o}{==} \\PY{l+m+mi}{0}\\PY{p}{:}\n            \\PY{n}{outputs}\\PY{p}{[}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{outvec}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{]} \\PY{o}{=} \\PY{n}{inputs}\\PY{p}{[}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{invec}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{]} \\PY{o}{*} \\PY{l+m+mf}{2.0}\n        \\PY{k}{else}\\PY{p}{:}\n            \\PY{n}{outputs}\\PY{p}{[}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{outvec}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{]} \\PY{o}{=} \\PY{n}{inputs}\\PY{p}{[}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{invec}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{]} \\PY{o}{*} \\PY{o}{\\PYZhy{}}\\PY{l+m+mf}{3.0}\n\\end{Verbatim}\n",
      "application/papermill.record/text/plain": "class DistribComp(om.ExplicitComponent):\n    \"\"\"Simple Distributed Component.\"\"\"\n\n    def initialize(self):\n        self.options.declare('size', types=int, default=1,\n                             desc=\"Size of input and output vectors.\")\n\n    def setup(self):\n        comm = self.comm\n        rank = comm.rank\n\n        size = self.options['size']\n\n        # if comm.size is 2 and size is 15, this results in\n        # 8 entries for proc 0 and 7 entries for proc 1\n        sizes, _ = evenly_distrib_idxs(comm.size, size)\n        mysize = sizes[rank]\n\n        self.add_input('invec', np.ones(mysize, float), distributed=True)\n        self.add_output('outvec', np.ones(mysize, float), distributed=True,)\n\n    def compute(self, inputs, outputs):\n        if self.comm.rank == 0:\n            outputs['outvec'] = inputs['invec'] * 2.0\n        else:\n            outputs['outvec'] = inputs['invec'] * -3.0"
     },
     "metadata": {
      "scrapbook": {
       "mime_prefix": "application/papermill.record/",
       "name": "code_src70"
      }
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "from openmdao.utils.notebook_utils import get_code\n",
    "from myst_nb import glue\n",
    "glue(\"code_src70\", get_code(\"openmdao.test_suite.components.distributed_components.DistribComp\"), display=False)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "3b285e55",
   "metadata": {
    "papermill": {
     "duration": 0.003462,
     "end_time": "2026-10-02T14:50:16.909896+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:16.906434+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    ":::{dropdown} `DistribComp` class definition \n",
    "\n",
    "{glue:}`code_src70`\n",
    ":::"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "3cd0f33a",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:50:16.917660Z",
     "iopub.status.busy": "2026-10-02T14:50:16.917526Z",
     "iopub.status.idle": "2026-10-02T14:50:16.922718Z",
     "shell.execute_reply": "2026-10-02T14:50:16.922183Z"
    },
    "papermill": {
     "duration": 0.009699,
     "end_time": "2026-10-02T14:50:16.923119+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:16.913420+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [
    {
     "data": {
      "application/papermill.record/text/html": "<style>pre { line-height: 125%; }\ntd.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }\nspan.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }\ntd.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }\nspan.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }\n.output_html .hll { background-color: #ffffcc }\n.output_html { background: #f8f8f8; }\n.output_html .c { color: #3D7B7B; font-style: italic } /* Comment */\n.output_html .err { border: 1px solid #F00 } /* Error */\n.output_html .k { color: #008000; font-weight: bold } /* Keyword */\n.output_html .o { color: #666 } /* Operator */\n.output_html .ch { color: #3D7B7B; font-style: italic } /* Comment.Hashbang */\n.output_html .cm { color: #3D7B7B; font-style: italic } /* Comment.Multiline */\n.output_html .cp { color: #9C6500 } /* Comment.Preproc */\n.output_html .cpf { color: #3D7B7B; font-style: italic } /* Comment.PreprocFile */\n.output_html .c1 { color: #3D7B7B; font-style: italic } /* Comment.Single */\n.output_html .cs { color: #3D7B7B; font-style: italic } /* Comment.Special */\n.output_html .gd { color: #A00000 } /* Generic.Deleted */\n.output_html .ge { font-style: italic } /* Generic.Emph */\n.output_html .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */\n.output_html .gr { color: #E40000 } /* Generic.Error */\n.output_html .gh { color: #000080; font-weight: bold } /* Generic.Heading */\n.output_html .gi { color: #008400 } /* Generic.Inserted */\n.output_html .go { color: #717171 } /* Generic.Output */\n.output_html .gp { color: #000080; font-weight: bold } /* Generic.Prompt */\n.output_html .gs { font-weight: bold } /* Generic.Strong */\n.output_html .gu { color: #800080; font-weight: bold } /* Generic.Subheading */\n.output_html .gt { color: #04D } /* Generic.Traceback */\n.output_html .kc { color: #008000; font-weight: bold } /* Keyword.Constant */\n.output_html .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */\n.output_html .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */\n.output_html .kp { color: #008000 } /* Keyword.Pseudo */\n.output_html .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */\n.output_html .kt { color: #B00040 } /* Keyword.Type */\n.output_html .m { color: #666 } /* Literal.Number */\n.output_html .s { color: #BA2121 } /* Literal.String */\n.output_html .na { color: #687822 } /* Name.Attribute */\n.output_html .nb { color: #008000 } /* Name.Builtin */\n.output_html .nc { color: #00F; font-weight: bold } /* Name.Class */\n.output_html .no { color: #800 } /* Name.Constant */\n.output_html .nd { color: #A2F } /* Name.Decorator */\n.output_html .ni { color: #717171; font-weight: bold } /* Name.Entity */\n.output_html .ne { color: #CB3F38; font-weight: bold } /* Name.Exception */\n.output_html .nf { color: #00F } /* Name.Function */\n.output_html .nl { color: #767600 } /* Name.Label */\n.output_html .nn { color: #00F; font-weight: bold } /* Name.Namespace */\n.output_html .nt { color: #008000; font-weight: bold } /* Name.Tag */\n.output_html .nv { color: #19177C } /* Name.Variable */\n.output_html .ow { color: #A2F; font-weight: bold } /* Operator.Word */\n.output_html .w { color: #BBB } /* Text.Whitespace */\n.output_html .mb { color: #666 } /* Literal.Number.Bin */\n.output_html .mf { color: #666 } /* Literal.Number.Float */\n.output_html .mh { color: #666 } /* Literal.Number.Hex */\n.output_html .mi { color: #666 } /* Literal.Number.Integer */\n.output_html .mo { color: #666 } /* Literal.Number.Oct */\n.output_html .sa { color: #BA2121 } /* Literal.String.Affix */\n.output_html .sb { color: #BA2121 } /* Literal.String.Backtick */\n.output_html .sc { color: #BA2121 } /* Literal.String.Char */\n.output_html .dl { color: #BA2121 } /* Literal.String.Delimiter */\n.output_html .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */\n.output_html .s2 { color: #BA2121 } /* Literal.String.Double */\n.output_html .se { color: #AA5D1F; font-weight: bold } /* Literal.String.Escape */\n.output_html .sh { color: #BA2121 } /* Literal.String.Heredoc */\n.output_html .si { color: #A45A77; font-weight: bold } /* Literal.String.Interpol */\n.output_html .sx { color: #008000 } /* Literal.String.Other */\n.output_html .sr { color: #A45A77 } /* Literal.String.Regex */\n.output_html .s1 { color: #BA2121 } /* Literal.String.Single */\n.output_html .ss { color: #19177C } /* Literal.String.Symbol */\n.output_html .bp { color: #008000 } /* Name.Builtin.Pseudo */\n.output_html .fm { color: #00F } /* Name.Function.Magic */\n.output_html .vc { color: #19177C } /* Name.Variable.Class */\n.output_html .vg { color: #19177C } /* Name.Variable.Global */\n.output_html .vi { color: #19177C } /* Name.Variable.Instance */\n.output_html .vm { color: #19177C } /* Name.Variable.Magic */\n.output_html .il { color: #666 } /* Literal.Number.Integer.Long */</style><div class=\"highlight\"><pre><span></span><span class=\"k\">class</span><span class=\"w\"> </span><span class=\"nc\">Summer</span><span class=\"p\">(</span><span class=\"n\">om</span><span class=\"o\">.</span><span class=\"n\">ExplicitComponent</span><span class=\"p\">):</span>\n<span class=\"w\">    </span><span class=\"sd\">&quot;&quot;&quot;Sums an input array.&quot;&quot;&quot;</span>\n\n    <span class=\"k\">def</span><span class=\"w\"> </span><span class=\"nf\">initialize</span><span class=\"p\">(</span><span class=\"bp\">self</span><span class=\"p\">):</span>\n        <span class=\"bp\">self</span><span class=\"o\">.</span><span class=\"n\">options</span><span class=\"o\">.</span><span class=\"n\">declare</span><span class=\"p\">(</span><span class=\"s1\">&#39;size&#39;</span><span class=\"p\">,</span> <span class=\"n\">types</span><span class=\"o\">=</span><span class=\"nb\">int</span><span class=\"p\">,</span> <span class=\"n\">default</span><span class=\"o\">=</span><span class=\"mi\">1</span><span class=\"p\">,</span>\n                             <span class=\"n\">desc</span><span class=\"o\">=</span><span class=\"s2\">&quot;Size of input and output vectors.&quot;</span><span class=\"p\">)</span>\n\n    <span class=\"k\">def</span><span class=\"w\"> </span><span class=\"nf\">setup</span><span class=\"p\">(</span><span class=\"bp\">self</span><span class=\"p\">):</span>\n        <span class=\"bp\">self</span><span class=\"o\">.</span><span class=\"n\">add_input</span><span class=\"p\">(</span><span class=\"s1\">&#39;invec&#39;</span><span class=\"p\">,</span> <span class=\"n\">np</span><span class=\"o\">.</span><span class=\"n\">ones</span><span class=\"p\">(</span><span class=\"bp\">self</span><span class=\"o\">.</span><span class=\"n\">options</span><span class=\"p\">[</span><span class=\"s1\">&#39;size&#39;</span><span class=\"p\">],</span> <span class=\"nb\">float</span><span class=\"p\">))</span>\n\n        <span class=\"bp\">self</span><span class=\"o\">.</span><span class=\"n\">add_output</span><span class=\"p\">(</span><span class=\"s1\">&#39;sum&#39;</span><span class=\"p\">,</span> <span class=\"mf\">0.0</span><span class=\"p\">,</span> <span class=\"n\">shape</span><span class=\"o\">=</span><span class=\"mi\">1</span><span class=\"p\">)</span>\n\n    <span class=\"k\">def</span><span class=\"w\"> </span><span class=\"nf\">compute</span><span class=\"p\">(</span><span class=\"bp\">self</span><span class=\"p\">,</span> <span class=\"n\">inputs</span><span class=\"p\">,</span> <span class=\"n\">outputs</span><span class=\"p\">):</span>\n        <span class=\"n\">outputs</span><span class=\"p\">[</span><span class=\"s1\">&#39;sum&#39;</span><span class=\"p\">]</span> <span class=\"o\">=</span> <span class=\"n\">np</span><span class=\"o\">.</span><span class=\"n\">sum</span><span class=\"p\">(</span><span class=\"n\">inputs</span><span class=\"p\">[</span><span class=\"s1\">&#39;invec&#39;</span><span class=\"p\">])</span>\n</pre></div>\n",
      "application/papermill.record/text/latex": "\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n\\PY{k}{class}\\PY{+w}{ }\\PY{n+nc}{Summer}\\PY{p}{(}\\PY{n}{om}\\PY{o}{.}\\PY{n}{ExplicitComponent}\\PY{p}{)}\\PY{p}{:}\n\\PY{+w}{    }\\PY{l+s+sd}{\\PYZdq{}\\PYZdq{}\\PYZdq{}Sums an input array.\\PYZdq{}\\PYZdq{}\\PYZdq{}}\n\n    \\PY{k}{def}\\PY{+w}{ }\\PY{n+nf}{initialize}\\PY{p}{(}\\PY{n+nb+bp}{self}\\PY{p}{)}\\PY{p}{:}\n        \\PY{n+nb+bp}{self}\\PY{o}{.}\\PY{n}{options}\\PY{o}{.}\\PY{n}{declare}\\PY{p}{(}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{size}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{n}{types}\\PY{o}{=}\\PY{n+nb}{int}\\PY{p}{,} \\PY{n}{default}\\PY{o}{=}\\PY{l+m+mi}{1}\\PY{p}{,}\n                             \\PY{n}{desc}\\PY{o}{=}\\PY{l+s+s2}{\\PYZdq{}}\\PY{l+s+s2}{Size of input and output vectors.}\\PY{l+s+s2}{\\PYZdq{}}\\PY{p}{)}\n\n    \\PY{k}{def}\\PY{+w}{ }\\PY{n+nf}{setup}\\PY{p}{(}\\PY{n+nb+bp}{self}\\PY{p}{)}\\PY{p}{:}\n        \\PY{n+nb+bp}{self}\\PY{o}{.}\\PY{n}{add\\PYZus{}input}\\PY{p}{(}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{invec}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{n}{np}\\PY{o}{.}\\PY{n}{ones}\\PY{p}{(}\\PY{n+nb+bp}{self}\\PY{o}{.}\\PY{n}{options}\\PY{p}{[}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{size}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{]}\\PY{p}{,} \\PY{n+nb}{float}\\PY{p}{)}\\PY{p}{)}\n\n        \\PY{n+nb+bp}{self}\\PY{o}{.}\\PY{n}{add\\PYZus{}output}\\PY{p}{(}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{sum}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{l+m+mf}{0.0}\\PY{p}{,} \\PY{n}{shape}\\PY{o}{=}\\PY{l+m+mi}{1}\\PY{p}{)}\n\n    \\PY{k}{def}\\PY{+w}{ }\\PY{n+nf}{compute}\\PY{p}{(}\\PY{n+nb+bp}{self}\\PY{p}{,} \\PY{n}{inputs}\\PY{p}{,} \\PY{n}{outputs}\\PY{p}{)}\\PY{p}{:}\n        \\PY{n}{outputs}\\PY{p}{[}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{sum}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{]} \\PY{o}{=} \\PY{n}{np}\\PY{o}{.}\\PY{n}{sum}\\PY{p}{(}\\PY{n}{inputs}\\PY{p}{[}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{invec}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{]}\\PY{p}{)}\n\\end{Verbatim}\n",
      "application/papermill.record/text/plain": "class Summer(om.ExplicitComponent):\n    \"\"\"Sums an input array.\"\"\"\n\n    def initialize(self):\n        self.options.declare('size', types=int, default=1,\n                             desc=\"Size of input and output vectors.\")\n\n    def setup(self):\n        self.add_input('invec', np.ones(self.options['size'], float))\n\n        self.add_output('sum', 0.0, shape=1)\n\n    def compute(self, inputs, outputs):\n        outputs['sum'] = np.sum(inputs['invec'])"
     },
     "metadata": {
      "scrapbook": {
       "mime_prefix": "application/papermill.record/",
       "name": "code_src71"
      }
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "from openmdao.utils.notebook_utils import get_code\n",
    "from myst_nb import glue\n",
    "glue(\"code_src71\", get_code(\"openmdao.test_suite.components.distributed_components.Summer\"), display=False)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "6f4e2667",
   "metadata": {
    "papermill": {
     "duration": 0.003547,
     "end_time": "2026-10-02T14:50:16.930274+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:16.926727+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    ":::{dropdown} `Summer` class definition \n",
    "\n",
    "{glue:}`code_src71`\n",
    ":::"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "9519575c",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:50:16.938240Z",
     "iopub.status.busy": "2026-10-02T14:50:16.938113Z",
     "iopub.status.idle": "2026-10-02T14:50:16.941150Z",
     "shell.execute_reply": "2026-10-02T14:50:16.940647Z"
    },
    "papermill": {
     "duration": 0.00766,
     "end_time": "2026-10-02T14:50:16.941526+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:16.933866+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-cell"
    ]
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Writing mpi_script_0.py\n"
     ]
    }
   ],
   "source": [
    "%%writefile mpi_script_0.py\n",
    "import numpy as np\n",
    "import openmdao.api as om\n",
    "from openmdao.test_suite.components.distributed_components import DistribComp, Summer\n",
    "from openmdao.utils.array_utils import get_evenly_distributed_size\n",
    "\n",
    "size = 15\n",
    "\n",
    "prob = om.Problem()\n",
    "model = prob.model\n",
    "\n",
    "indep = model.add_subsystem(\"indep\", om.IndepVarComp())\n",
    "indep.add_output('x', np.ones(get_evenly_distributed_size(prob.comm, size)), distributed=True)\n",
    "model.add_subsystem(\"C2\", DistribComp(size=size))\n",
    "model.add_subsystem(\"C3\", Summer(size=size))\n",
    "\n",
    "model.connect('indep.x', 'C2.invec')\n",
    "model.connect('C2.outvec', 'C3.invec', src_indices=om.slicer[:])\n",
    "\n",
    "prob.setup()\n",
    "prob.final_setup()\n",
    "\n",
    "model.C2.list_inputs(hierarchical=False, shape=True, global_shape=True, print_arrays=True);\n",
    "model.C2.list_outputs(hierarchical=False, shape=True, global_shape=True, print_arrays=True);\n",
    "\n",
    "prob.run_model()\n",
    "\n",
    "model.C2.list_outputs(hierarchical=False, shape=True, global_shape=True, print_arrays=True, all_procs=True);\n",
    "\n",
    "from openmdao.utils.assert_utils import assert_near_equal\n",
    "assert_near_equal(prob['C3.sum'], -25.)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "21bf9db4",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:50:16.949551Z",
     "iopub.status.busy": "2026-10-02T14:50:16.949430Z",
     "iopub.status.idle": "2026-10-02T14:50:20.845252Z",
     "shell.execute_reply": "2026-10-02T14:50:20.844546Z"
    },
    "papermill": {
     "duration": 3.900756,
     "end_time": "2026-10-02T14:50:20.845883+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:16.945127+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input"
    ]
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div class=\"admonition note\"><p class=\"admonition-title\">Note</p><p>This feature requires MPI, and may not be able to be run on Colab or Binder.</p></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<p>The following script is executed using <code>mpiexec -n 4 mpi_script_0.py</code>:</p><style>pre { line-height: 125%; }\n",
       "td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }\n",
       "span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }\n",
       "td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }\n",
       "span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }\n",
       ".highlight .hll { background-color: #ffffcc }\n",
       ".highlight { background: #f8f8f8; }\n",
       ".highlight .c { color: #3D7B7B; font-style: italic } /* Comment */\n",
       ".highlight .err { border: 1px solid #F00 } /* Error */\n",
       ".highlight .k { color: #008000; font-weight: bold } /* Keyword */\n",
       ".highlight .o { color: #666 } /* Operator */\n",
       ".highlight .ch { color: #3D7B7B; font-style: italic } /* Comment.Hashbang */\n",
       ".highlight .cm { color: #3D7B7B; font-style: italic } /* Comment.Multiline */\n",
       ".highlight .cp { color: #9C6500 } /* Comment.Preproc */\n",
       ".highlight .cpf { color: #3D7B7B; font-style: italic } /* Comment.PreprocFile */\n",
       ".highlight .c1 { color: #3D7B7B; font-style: italic } /* Comment.Single */\n",
       ".highlight .cs { color: #3D7B7B; font-style: italic } /* Comment.Special */\n",
       ".highlight .gd { color: #A00000 } /* Generic.Deleted */\n",
       ".highlight .ge { font-style: italic } /* Generic.Emph */\n",
       ".highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */\n",
       ".highlight .gr { color: #E40000 } /* Generic.Error */\n",
       ".highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */\n",
       ".highlight .gi { color: #008400 } /* Generic.Inserted */\n",
       ".highlight .go { color: #717171 } /* Generic.Output */\n",
       ".highlight .gp { color: #000080; font-weight: bold } /* Generic.Prompt */\n",
       ".highlight .gs { font-weight: bold } /* Generic.Strong */\n",
       ".highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */\n",
       ".highlight .gt { color: #04D } /* Generic.Traceback */\n",
       ".highlight .kc { color: #008000; font-weight: bold } /* Keyword.Constant */\n",
       ".highlight .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */\n",
       ".highlight .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */\n",
       ".highlight .kp { color: #008000 } /* Keyword.Pseudo */\n",
       ".highlight .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */\n",
       ".highlight .kt { color: #B00040 } /* Keyword.Type */\n",
       ".highlight .m { color: #666 } /* Literal.Number */\n",
       ".highlight .s { color: #BA2121 } /* Literal.String */\n",
       ".highlight .na { color: #687822 } /* Name.Attribute */\n",
       ".highlight .nb { color: #008000 } /* Name.Builtin */\n",
       ".highlight .nc { color: #00F; font-weight: bold } /* Name.Class */\n",
       ".highlight .no { color: #800 } /* Name.Constant */\n",
       ".highlight .nd { color: #A2F } /* Name.Decorator */\n",
       ".highlight .ni { color: #717171; font-weight: bold } /* Name.Entity */\n",
       ".highlight .ne { color: #CB3F38; font-weight: bold } /* Name.Exception */\n",
       ".highlight .nf { color: #00F } /* Name.Function */\n",
       ".highlight .nl { color: #767600 } /* Name.Label */\n",
       ".highlight .nn { color: #00F; font-weight: bold } /* Name.Namespace */\n",
       ".highlight .nt { color: #008000; font-weight: bold } /* Name.Tag */\n",
       ".highlight .nv { color: #19177C } /* Name.Variable */\n",
       ".highlight .ow { color: #A2F; font-weight: bold } /* Operator.Word */\n",
       ".highlight .w { color: #BBB } /* Text.Whitespace */\n",
       ".highlight .mb { color: #666 } /* Literal.Number.Bin */\n",
       ".highlight .mf { color: #666 } /* Literal.Number.Float */\n",
       ".highlight .mh { color: #666 } /* Literal.Number.Hex */\n",
       ".highlight .mi { color: #666 } /* Literal.Number.Integer */\n",
       ".highlight .mo { color: #666 } /* Literal.Number.Oct */\n",
       ".highlight .sa { color: #BA2121 } /* Literal.String.Affix */\n",
       ".highlight .sb { color: #BA2121 } /* Literal.String.Backtick */\n",
       ".highlight .sc { color: #BA2121 } /* Literal.String.Char */\n",
       ".highlight .dl { color: #BA2121 } /* Literal.String.Delimiter */\n",
       ".highlight .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */\n",
       ".highlight .s2 { color: #BA2121 } /* Literal.String.Double */\n",
       ".highlight .se { color: #AA5D1F; font-weight: bold } /* Literal.String.Escape */\n",
       ".highlight .sh { color: #BA2121 } /* Literal.String.Heredoc */\n",
       ".highlight .si { color: #A45A77; font-weight: bold } /* Literal.String.Interpol */\n",
       ".highlight .sx { color: #008000 } /* Literal.String.Other */\n",
       ".highlight .sr { color: #A45A77 } /* Literal.String.Regex */\n",
       ".highlight .s1 { color: #BA2121 } /* Literal.String.Single */\n",
       ".highlight .ss { color: #19177C } /* Literal.String.Symbol */\n",
       ".highlight .bp { color: #008000 } /* Name.Builtin.Pseudo */\n",
       ".highlight .fm { color: #00F } /* Name.Function.Magic */\n",
       ".highlight .vc { color: #19177C } /* Name.Variable.Class */\n",
       ".highlight .vg { color: #19177C } /* Name.Variable.Global */\n",
       ".highlight .vi { color: #19177C } /* Name.Variable.Instance */\n",
       ".highlight .vm { color: #19177C } /* Name.Variable.Magic */\n",
       ".highlight .il { color: #666 } /* Literal.Number.Integer.Long */</style><div class=\"highlight\"><pre><span></span><span class=\"kn\">import</span><span class=\"w\"> </span><span class=\"nn\">numpy</span><span class=\"w\"> </span><span class=\"k\">as</span><span class=\"w\"> </span><span class=\"nn\">np</span>\n",
       "<span class=\"kn\">import</span><span class=\"w\"> </span><span class=\"nn\">openmdao.api</span><span class=\"w\"> </span><span class=\"k\">as</span><span class=\"w\"> </span><span class=\"nn\">om</span>\n",
       "<span class=\"kn\">from</span><span class=\"w\"> </span><span class=\"nn\">openmdao.test_suite.components.distributed_components</span><span class=\"w\"> </span><span class=\"kn\">import</span> <span class=\"n\">DistribComp</span><span class=\"p\">,</span> <span class=\"n\">Summer</span>\n",
       "<span class=\"kn\">from</span><span class=\"w\"> </span><span class=\"nn\">openmdao.utils.array_utils</span><span class=\"w\"> </span><span class=\"kn\">import</span> <span class=\"n\">get_evenly_distributed_size</span>\n",
       "\n",
       "<span class=\"n\">size</span> <span class=\"o\">=</span> <span class=\"mi\">15</span>\n",
       "\n",
       "<span class=\"n\">prob</span> <span class=\"o\">=</span> <span class=\"n\">om</span><span class=\"o\">.</span><span class=\"n\">Problem</span><span class=\"p\">()</span>\n",
       "<span class=\"n\">model</span> <span class=\"o\">=</span> <span class=\"n\">prob</span><span class=\"o\">.</span><span class=\"n\">model</span>\n",
       "\n",
       "<span class=\"n\">indep</span> <span class=\"o\">=</span> <span class=\"n\">model</span><span class=\"o\">.</span><span class=\"n\">add_subsystem</span><span class=\"p\">(</span><span class=\"s2\">&quot;indep&quot;</span><span class=\"p\">,</span> <span class=\"n\">om</span><span class=\"o\">.</span><span class=\"n\">IndepVarComp</span><span class=\"p\">())</span>\n",
       "<span class=\"n\">indep</span><span class=\"o\">.</span><span class=\"n\">add_output</span><span class=\"p\">(</span><span class=\"s1\">&#39;x&#39;</span><span class=\"p\">,</span> <span class=\"n\">np</span><span class=\"o\">.</span><span class=\"n\">ones</span><span class=\"p\">(</span><span class=\"n\">get_evenly_distributed_size</span><span class=\"p\">(</span><span class=\"n\">prob</span><span class=\"o\">.</span><span class=\"n\">comm</span><span class=\"p\">,</span> <span class=\"n\">size</span><span class=\"p\">)),</span> <span class=\"n\">distributed</span><span class=\"o\">=</span><span class=\"kc\">True</span><span class=\"p\">)</span>\n",
       "<span class=\"n\">model</span><span class=\"o\">.</span><span class=\"n\">add_subsystem</span><span class=\"p\">(</span><span class=\"s2\">&quot;C2&quot;</span><span class=\"p\">,</span> <span class=\"n\">DistribComp</span><span class=\"p\">(</span><span class=\"n\">size</span><span class=\"o\">=</span><span class=\"n\">size</span><span class=\"p\">))</span>\n",
       "<span class=\"n\">model</span><span class=\"o\">.</span><span class=\"n\">add_subsystem</span><span class=\"p\">(</span><span class=\"s2\">&quot;C3&quot;</span><span class=\"p\">,</span> <span class=\"n\">Summer</span><span class=\"p\">(</span><span class=\"n\">size</span><span class=\"o\">=</span><span class=\"n\">size</span><span class=\"p\">))</span>\n",
       "\n",
       "<span class=\"n\">model</span><span class=\"o\">.</span><span class=\"n\">connect</span><span class=\"p\">(</span><span class=\"s1\">&#39;indep.x&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;C2.invec&#39;</span><span class=\"p\">)</span>\n",
       "<span class=\"n\">model</span><span class=\"o\">.</span><span class=\"n\">connect</span><span class=\"p\">(</span><span class=\"s1\">&#39;C2.outvec&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;C3.invec&#39;</span><span class=\"p\">,</span> <span class=\"n\">src_indices</span><span class=\"o\">=</span><span class=\"n\">om</span><span class=\"o\">.</span><span class=\"n\">slicer</span><span class=\"p\">[:])</span>\n",
       "\n",
       "<span class=\"n\">prob</span><span class=\"o\">.</span><span class=\"n\">setup</span><span class=\"p\">()</span>\n",
       "<span class=\"n\">prob</span><span class=\"o\">.</span><span class=\"n\">final_setup</span><span class=\"p\">()</span>\n",
       "\n",
       "<span class=\"n\">model</span><span class=\"o\">.</span><span class=\"n\">C2</span><span class=\"o\">.</span><span class=\"n\">list_inputs</span><span class=\"p\">(</span><span class=\"n\">hierarchical</span><span class=\"o\">=</span><span class=\"kc\">False</span><span class=\"p\">,</span> <span class=\"n\">shape</span><span class=\"o\">=</span><span class=\"kc\">True</span><span class=\"p\">,</span> <span class=\"n\">global_shape</span><span class=\"o\">=</span><span class=\"kc\">True</span><span class=\"p\">,</span> <span class=\"n\">print_arrays</span><span class=\"o\">=</span><span class=\"kc\">True</span><span class=\"p\">);</span>\n",
       "<span class=\"n\">model</span><span class=\"o\">.</span><span class=\"n\">C2</span><span class=\"o\">.</span><span class=\"n\">list_outputs</span><span class=\"p\">(</span><span class=\"n\">hierarchical</span><span class=\"o\">=</span><span class=\"kc\">False</span><span class=\"p\">,</span> <span class=\"n\">shape</span><span class=\"o\">=</span><span class=\"kc\">True</span><span class=\"p\">,</span> <span class=\"n\">global_shape</span><span class=\"o\">=</span><span class=\"kc\">True</span><span class=\"p\">,</span> <span class=\"n\">print_arrays</span><span class=\"o\">=</span><span class=\"kc\">True</span><span class=\"p\">);</span>\n",
       "\n",
       "<span class=\"n\">prob</span><span class=\"o\">.</span><span class=\"n\">run_model</span><span class=\"p\">()</span>\n",
       "\n",
       "<span class=\"n\">model</span><span class=\"o\">.</span><span class=\"n\">C2</span><span class=\"o\">.</span><span class=\"n\">list_outputs</span><span class=\"p\">(</span><span class=\"n\">hierarchical</span><span class=\"o\">=</span><span class=\"kc\">False</span><span class=\"p\">,</span> <span class=\"n\">shape</span><span class=\"o\">=</span><span class=\"kc\">True</span><span class=\"p\">,</span> <span class=\"n\">global_shape</span><span class=\"o\">=</span><span class=\"kc\">True</span><span class=\"p\">,</span> <span class=\"n\">print_arrays</span><span class=\"o\">=</span><span class=\"kc\">True</span><span class=\"p\">,</span> <span class=\"n\">all_procs</span><span class=\"o\">=</span><span class=\"kc\">True</span><span class=\"p\">);</span>\n",
       "\n",
       "<span class=\"kn\">from</span><span class=\"w\"> </span><span class=\"nn\">openmdao.utils.assert_utils</span><span class=\"w\"> </span><span class=\"kn\">import</span> <span class=\"n\">assert_near_equal</span>\n",
       "<span class=\"n\">assert_near_equal</span><span class=\"p\">(</span><span class=\"n\">prob</span><span class=\"p\">[</span><span class=\"s1\">&#39;C3.sum&#39;</span><span class=\"p\">],</span> <span class=\"o\">-</span><span class=\"mf\">25.</span><span class=\"p\">)</span>\n",
       "</pre></div>\n"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1790952618.628158] [runnervm8df0l:11965:0]        ib_iface.c:1269 UCX  ERROR mana_0: iface 0x55f23812df00 failed to create UD QP TX wr:256 sge:6 inl:64 resp:0 RX wr:4096 sge:1 resp:0 failed: Operation not supported\n",
      "[1790952618.628418] [runnervm8df0l:11965:0]      ucp_worker.c:1412 UCX  ERROR uct_iface_open(ud_verbs/mana_0:1) failed: Input/output error\n",
      "[1790952618.632684] [runnervm8df0l:11966:0]        ib_iface.c:1269 UCX  ERROR mana_0: iface 0x5574cc8b6480 failed to create UD QP TX wr:256 sge:6 inl:64 resp:0 RX wr:4096 sge:1 resp:0 failed: Operation not supported\n",
      "[1790952618.632837] [runnervm8df0l:11964:0]        ib_iface.c:1269 UCX  ERROR mana_0: iface 0x5561e4554df0 failed to create UD QP TX wr:256 sge:6 inl:64 resp:0 RX wr:4096 sge:1 resp:0 failed: Operation not supported\n",
      "[1790952618.633620] [runnervm8df0l:11966:0]      ucp_worker.c:1412 UCX  ERROR uct_iface_open(ud_verbs/mana_0:1) failed: Input/output error\n",
      "[1790952618.633669] [runnervm8df0l:11964:0]      ucp_worker.c:1412 UCX  ERROR uct_iface_open(ud_verbs/mana_0:1) failed: Input/output error\n",
      "[1790952618.633808] [runnervm8df0l:11963:0]        ib_iface.c:1269 UCX  ERROR mana_0: iface 0x55d4420e85f0 failed to create UD QP TX wr:256 sge:6 inl:64 resp:0 RX wr:4096 sge:1 resp:0 failed: Operation not supported\n",
      "[1790952618.634047] [runnervm8df0l:11963:0]      ucp_worker.c:1412 UCX  ERROR uct_iface_open(ud_verbs/mana_0:1) failed: Input/output error\n",
      "1 Input(s) in 'C2'\n",
      "\n",
      "varname  val                  shape  global_shape  prom_name\n",
      "-------  -------------------  -----  ------------  ---------\n",
      "invec    |3.87298335|         (4,)   (15,)         invec    \n",
      "         val:\n",
      "         array([1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.])\n",
      "\n",
      "\n",
      "1 Explicit Output(s) in 'C2'\n",
      "\n",
      "varname  val                  shape  global_shape  prom_name\n",
      "-------  -------------------  -----  ------------  ---------\n",
      "outvec   |3.87298335|         (4,)   (15,)         outvec   \n",
      "         val:\n",
      "         array([1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.])\n",
      "\n",
      "\n",
      "0 Implicit Output(s) in 'C2'\n",
      "\n",
      "\n",
      "1 Explicit Output(s) in 'C2'\n",
      "1 Explicit Output(s) in 'C2'\n",
      "1 Explicit Output(s) in 'C2'\n",
      "1 Explicit Output(s) in 'C2'\n",
      "\n",
      "varname  val                   shape  global_shape  prom_name\n",
      "-------  --------------------  -----  ------------  ---------\n",
      "outvec   |10.72380529|         (4,)   (15,)         outvec   \n",
      "         val:\n",
      "\n",
      "varname  val                   shape  global_shape  prom_name\n",
      "-------  --------------------  -----  ------------  ---------\n",
      "\n",
      "varname  val                   shape  global_shape  prom_name\n",
      "-------  --------------------  -----  ------------  ---------\n",
      "outvec   |10.72380529|         (4,)   (15,)         outvec   \n",
      "         val:\n",
      "         array([ 2.,  2.,  2.,  2., -3., -3., -3., -3., -3., -3., -3., -3., -3.,\n",
      "                -3., -3.])\n",
      "\n",
      "\n",
      "0 Implicit Output(s) in 'C2'\n",
      "\n",
      "\n",
      "outvec   |10.72380529|         (3,)   (15,)         outvec   \n",
      "         val:\n",
      "         array([ 2.,  2.,  2.,  2., -3., -3., -3., -3., -3., -3., -3., -3., -3.,\n",
      "                -3., -3.])\n",
      "\n",
      "\n",
      "0 Implicit Output(s) in 'C2'\n",
      "\n",
      "\n",
      "\n",
      "varname  val                   shape  global_shape  prom_name\n",
      "-------  --------------------  -----  ------------  ---------\n",
      "outvec   |10.72380529|         (4,)   (15,)         outvec   \n",
      "         val:\n",
      "         array([ 2.,  2.,  2.,  2., -3., -3., -3., -3., -3., -3., -3., -3., -3.,\n",
      "                -3., -3.])\n",
      "\n",
      "\n",
      "0 Implicit Output(s) in 'C2'\n",
      "\n",
      "\n",
      "         array([ 2.,  2.,  2.,  2., -3., -3., -3., -3., -3., -3., -3., -3., -3.,\n",
      "                -3., -3.])\n",
      "\n",
      "\n",
      "0 Implicit Output(s) in 'C2'\n",
      "\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "from openmdao.utils.notebook_utils import mpi_exec\n",
    "mpi_exec(4, 'mpi_script_0.py')"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "bd11a92c",
   "metadata": {
    "papermill": {
     "duration": 0.004029,
     "end_time": "2026-10-02T14:50:20.854384+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:20.850355+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "### *Listing Problem Variables*\n",
    "\n",
    "The `Problem` class has a method `list_driver_vars` which prints out the values and metadata for design, constraint, and objective variables.\n",
    "\n",
    "```{eval-rst}\n",
    "    .. automethod:: openmdao.core.problem.Problem.list_driver_vars\n",
    "        :noindex:\n",
    "```\n",
    "\n",
    "You can optionally print out a variety of metadata. In this example, all the metadata is printed. The `print_arrays` option is also set to true so that full array values are printed and `min` and `max` are used so that the array's lowest and highest values are shown."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "4f4fdfd4",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:50:20.862781Z",
     "iopub.status.busy": "2026-10-02T14:50:20.862599Z",
     "iopub.status.idle": "2026-10-02T14:50:20.870171Z",
     "shell.execute_reply": "2026-10-02T14:50:20.869643Z"
    },
    "papermill": {
     "duration": 0.012391,
     "end_time": "2026-10-02T14:50:20.870593+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:20.858202+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [
    {
     "data": {
      "application/papermill.record/text/html": "<style>pre { line-height: 125%; }\ntd.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }\nspan.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }\ntd.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }\nspan.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }\n.output_html .hll { background-color: #ffffcc }\n.output_html { background: #f8f8f8; }\n.output_html .c { color: #3D7B7B; font-style: italic } /* Comment */\n.output_html .err { border: 1px solid #F00 } /* Error */\n.output_html .k { color: #008000; font-weight: bold } /* Keyword */\n.output_html .o { color: #666 } /* Operator */\n.output_html .ch { color: #3D7B7B; font-style: italic } /* Comment.Hashbang */\n.output_html .cm { color: #3D7B7B; font-style: italic } /* Comment.Multiline */\n.output_html .cp { color: #9C6500 } /* Comment.Preproc */\n.output_html .cpf { color: #3D7B7B; font-style: italic } /* Comment.PreprocFile */\n.output_html .c1 { color: #3D7B7B; font-style: italic } /* Comment.Single */\n.output_html .cs { color: #3D7B7B; font-style: italic } /* Comment.Special */\n.output_html .gd { color: #A00000 } /* Generic.Deleted */\n.output_html .ge { font-style: italic } /* Generic.Emph */\n.output_html .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */\n.output_html .gr { color: #E40000 } /* Generic.Error */\n.output_html .gh { color: #000080; font-weight: bold } /* Generic.Heading */\n.output_html .gi { color: #008400 } /* Generic.Inserted */\n.output_html .go { color: #717171 } /* Generic.Output */\n.output_html .gp { color: #000080; font-weight: bold } /* Generic.Prompt */\n.output_html .gs { font-weight: bold } /* Generic.Strong */\n.output_html .gu { color: #800080; font-weight: bold } /* Generic.Subheading */\n.output_html .gt { color: #04D } /* Generic.Traceback */\n.output_html .kc { color: #008000; font-weight: bold } /* Keyword.Constant */\n.output_html .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */\n.output_html .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */\n.output_html .kp { color: #008000 } /* Keyword.Pseudo */\n.output_html .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */\n.output_html .kt { color: #B00040 } /* Keyword.Type */\n.output_html .m { color: #666 } /* Literal.Number */\n.output_html .s { color: #BA2121 } /* Literal.String */\n.output_html .na { color: #687822 } /* Name.Attribute */\n.output_html .nb { color: #008000 } /* Name.Builtin */\n.output_html .nc { color: #00F; font-weight: bold } /* Name.Class */\n.output_html .no { color: #800 } /* Name.Constant */\n.output_html .nd { color: #A2F } /* Name.Decorator */\n.output_html .ni { color: #717171; font-weight: bold } /* Name.Entity */\n.output_html .ne { color: #CB3F38; font-weight: bold } /* Name.Exception */\n.output_html .nf { color: #00F } /* Name.Function */\n.output_html .nl { color: #767600 } /* Name.Label */\n.output_html .nn { color: #00F; font-weight: bold } /* Name.Namespace */\n.output_html .nt { color: #008000; font-weight: bold } /* Name.Tag */\n.output_html .nv { color: #19177C } /* Name.Variable */\n.output_html .ow { color: #A2F; font-weight: bold } /* Operator.Word */\n.output_html .w { color: #BBB } /* Text.Whitespace */\n.output_html .mb { color: #666 } /* Literal.Number.Bin */\n.output_html .mf { color: #666 } /* Literal.Number.Float */\n.output_html .mh { color: #666 } /* Literal.Number.Hex */\n.output_html .mi { color: #666 } /* Literal.Number.Integer */\n.output_html .mo { color: #666 } /* Literal.Number.Oct */\n.output_html .sa { color: #BA2121 } /* Literal.String.Affix */\n.output_html .sb { color: #BA2121 } /* Literal.String.Backtick */\n.output_html .sc { color: #BA2121 } /* Literal.String.Char */\n.output_html .dl { color: #BA2121 } /* Literal.String.Delimiter */\n.output_html .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */\n.output_html .s2 { color: #BA2121 } /* Literal.String.Double */\n.output_html .se { color: #AA5D1F; font-weight: bold } /* Literal.String.Escape */\n.output_html .sh { color: #BA2121 } /* Literal.String.Heredoc */\n.output_html .si { color: #A45A77; font-weight: bold } /* Literal.String.Interpol */\n.output_html .sx { color: #008000 } /* Literal.String.Other */\n.output_html .sr { color: #A45A77 } /* Literal.String.Regex */\n.output_html .s1 { color: #BA2121 } /* Literal.String.Single */\n.output_html .ss { color: #19177C } /* Literal.String.Symbol */\n.output_html .bp { color: #008000 } /* Name.Builtin.Pseudo */\n.output_html .fm { color: #00F } /* Name.Function.Magic */\n.output_html .vc { color: #19177C } /* Name.Variable.Class */\n.output_html .vg { color: #19177C } /* Name.Variable.Global */\n.output_html .vi { color: #19177C } /* Name.Variable.Instance */\n.output_html .vm { color: #19177C } /* Name.Variable.Magic */\n.output_html .il { color: #666 } /* Literal.Number.Integer.Long */</style><div class=\"highlight\"><pre><span></span><span class=\"k\">class</span><span class=\"w\"> </span><span class=\"nc\">SellarDerivatives</span><span class=\"p\">(</span><span class=\"n\">om</span><span class=\"o\">.</span><span class=\"n\">Group</span><span class=\"p\">):</span>\n<span class=\"w\">    </span><span class=\"sd\">&quot;&quot;&quot;</span>\n<span class=\"sd\">    Group containing the Sellar MDA. This version uses the disciplines with derivatives.</span>\n<span class=\"sd\">    &quot;&quot;&quot;</span>\n\n    <span class=\"k\">def</span><span class=\"w\"> </span><span class=\"nf\">setup</span><span class=\"p\">(</span><span class=\"bp\">self</span><span class=\"p\">):</span>\n        <span class=\"bp\">self</span><span class=\"o\">.</span><span class=\"n\">add_subsystem</span><span class=\"p\">(</span><span class=\"s1\">&#39;d1&#39;</span><span class=\"p\">,</span> <span class=\"n\">SellarDis1withDerivatives</span><span class=\"p\">(),</span> <span class=\"n\">promotes</span><span class=\"o\">=</span><span class=\"p\">[</span><span class=\"s1\">&#39;x&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;z&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;y1&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;y2&#39;</span><span class=\"p\">])</span>\n        <span class=\"bp\">self</span><span class=\"o\">.</span><span class=\"n\">add_subsystem</span><span class=\"p\">(</span><span class=\"s1\">&#39;d2&#39;</span><span class=\"p\">,</span> <span class=\"n\">SellarDis2withDerivatives</span><span class=\"p\">(),</span> <span class=\"n\">promotes</span><span class=\"o\">=</span><span class=\"p\">[</span><span class=\"s1\">&#39;z&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;y1&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;y2&#39;</span><span class=\"p\">])</span>\n\n        <span class=\"bp\">self</span><span class=\"o\">.</span><span class=\"n\">add_subsystem</span><span class=\"p\">(</span><span class=\"s1\">&#39;obj_cmp&#39;</span><span class=\"p\">,</span> <span class=\"n\">om</span><span class=\"o\">.</span><span class=\"n\">ExecComp</span><span class=\"p\">(</span><span class=\"s1\">&#39;obj = x**2 + z[1] + y1 + exp(-y2)&#39;</span><span class=\"p\">,</span> <span class=\"n\">obj</span><span class=\"o\">=</span><span class=\"mf\">0.0</span><span class=\"p\">,</span>\n                                                  <span class=\"n\">x</span><span class=\"o\">=</span><span class=\"mf\">0.0</span><span class=\"p\">,</span> <span class=\"n\">z</span><span class=\"o\">=</span><span class=\"n\">np</span><span class=\"o\">.</span><span class=\"n\">array</span><span class=\"p\">([</span><span class=\"mf\">0.0</span><span class=\"p\">,</span> <span class=\"mf\">0.0</span><span class=\"p\">]),</span> <span class=\"n\">y1</span><span class=\"o\">=</span><span class=\"mf\">0.0</span><span class=\"p\">,</span> <span class=\"n\">y2</span><span class=\"o\">=</span><span class=\"mf\">0.0</span><span class=\"p\">),</span>\n                           <span class=\"n\">promotes</span><span class=\"o\">=</span><span class=\"p\">[</span><span class=\"s1\">&#39;obj&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;x&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;z&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;y1&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;y2&#39;</span><span class=\"p\">])</span>\n\n        <span class=\"bp\">self</span><span class=\"o\">.</span><span class=\"n\">add_subsystem</span><span class=\"p\">(</span><span class=\"s1\">&#39;con_cmp1&#39;</span><span class=\"p\">,</span> <span class=\"n\">om</span><span class=\"o\">.</span><span class=\"n\">ExecComp</span><span class=\"p\">(</span><span class=\"s1\">&#39;con1 = 3.16 - y1&#39;</span><span class=\"p\">,</span> <span class=\"n\">con1</span><span class=\"o\">=</span><span class=\"mf\">0.0</span><span class=\"p\">,</span> <span class=\"n\">y1</span><span class=\"o\">=</span><span class=\"mf\">0.0</span><span class=\"p\">),</span>\n                           <span class=\"n\">promotes</span><span class=\"o\">=</span><span class=\"p\">[</span><span class=\"s1\">&#39;con1&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;y1&#39;</span><span class=\"p\">])</span>\n        <span class=\"bp\">self</span><span class=\"o\">.</span><span class=\"n\">add_subsystem</span><span class=\"p\">(</span><span class=\"s1\">&#39;con_cmp2&#39;</span><span class=\"p\">,</span> <span class=\"n\">om</span><span class=\"o\">.</span><span class=\"n\">ExecComp</span><span class=\"p\">(</span><span class=\"s1\">&#39;con2 = y2 - 24.0&#39;</span><span class=\"p\">,</span> <span class=\"n\">con2</span><span class=\"o\">=</span><span class=\"mf\">0.0</span><span class=\"p\">,</span> <span class=\"n\">y2</span><span class=\"o\">=</span><span class=\"mf\">0.0</span><span class=\"p\">),</span>\n                           <span class=\"n\">promotes</span><span class=\"o\">=</span><span class=\"p\">[</span><span class=\"s1\">&#39;con2&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;y2&#39;</span><span class=\"p\">])</span>\n\n        <span class=\"bp\">self</span><span class=\"o\">.</span><span class=\"n\">set_input_defaults</span><span class=\"p\">(</span><span class=\"s1\">&#39;x&#39;</span><span class=\"p\">,</span> <span class=\"mf\">1.0</span><span class=\"p\">)</span>\n        <span class=\"bp\">self</span><span class=\"o\">.</span><span class=\"n\">set_input_defaults</span><span class=\"p\">(</span><span class=\"s1\">&#39;z&#39;</span><span class=\"p\">,</span> <span class=\"n\">np</span><span class=\"o\">.</span><span class=\"n\">array</span><span class=\"p\">([</span><span class=\"mf\">5.0</span><span class=\"p\">,</span> <span class=\"mf\">2.0</span><span class=\"p\">]))</span>\n</pre></div>\n",
      "application/papermill.record/text/latex": "\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n\\PY{k}{class}\\PY{+w}{ }\\PY{n+nc}{SellarDerivatives}\\PY{p}{(}\\PY{n}{om}\\PY{o}{.}\\PY{n}{Group}\\PY{p}{)}\\PY{p}{:}\n\\PY{+w}{    }\\PY{l+s+sd}{\\PYZdq{}\\PYZdq{}\\PYZdq{}}\n\\PY{l+s+sd}{    Group containing the Sellar MDA. This version uses the disciplines with derivatives.}\n\\PY{l+s+sd}{    \\PYZdq{}\\PYZdq{}\\PYZdq{}}\n\n    \\PY{k}{def}\\PY{+w}{ }\\PY{n+nf}{setup}\\PY{p}{(}\\PY{n+nb+bp}{self}\\PY{p}{)}\\PY{p}{:}\n        \\PY{n+nb+bp}{self}\\PY{o}{.}\\PY{n}{add\\PYZus{}subsystem}\\PY{p}{(}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{d1}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{n}{SellarDis1withDerivatives}\\PY{p}{(}\\PY{p}{)}\\PY{p}{,} \\PY{n}{promotes}\\PY{o}{=}\\PY{p}{[}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{x}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{z}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{y1}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{y2}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{]}\\PY{p}{)}\n        \\PY{n+nb+bp}{self}\\PY{o}{.}\\PY{n}{add\\PYZus{}subsystem}\\PY{p}{(}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{d2}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{n}{SellarDis2withDerivatives}\\PY{p}{(}\\PY{p}{)}\\PY{p}{,} \\PY{n}{promotes}\\PY{o}{=}\\PY{p}{[}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{z}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{y1}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{y2}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{]}\\PY{p}{)}\n\n        \\PY{n+nb+bp}{self}\\PY{o}{.}\\PY{n}{add\\PYZus{}subsystem}\\PY{p}{(}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{obj\\PYZus{}cmp}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{n}{om}\\PY{o}{.}\\PY{n}{ExecComp}\\PY{p}{(}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{obj = x**2 + z[1] + y1 + exp(\\PYZhy{}y2)}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{n}{obj}\\PY{o}{=}\\PY{l+m+mf}{0.0}\\PY{p}{,}\n                                                  \\PY{n}{x}\\PY{o}{=}\\PY{l+m+mf}{0.0}\\PY{p}{,} \\PY{n}{z}\\PY{o}{=}\\PY{n}{np}\\PY{o}{.}\\PY{n}{array}\\PY{p}{(}\\PY{p}{[}\\PY{l+m+mf}{0.0}\\PY{p}{,} \\PY{l+m+mf}{0.0}\\PY{p}{]}\\PY{p}{)}\\PY{p}{,} \\PY{n}{y1}\\PY{o}{=}\\PY{l+m+mf}{0.0}\\PY{p}{,} \\PY{n}{y2}\\PY{o}{=}\\PY{l+m+mf}{0.0}\\PY{p}{)}\\PY{p}{,}\n                           \\PY{n}{promotes}\\PY{o}{=}\\PY{p}{[}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{obj}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{x}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{z}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{y1}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{y2}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{]}\\PY{p}{)}\n\n        \\PY{n+nb+bp}{self}\\PY{o}{.}\\PY{n}{add\\PYZus{}subsystem}\\PY{p}{(}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{con\\PYZus{}cmp1}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{n}{om}\\PY{o}{.}\\PY{n}{ExecComp}\\PY{p}{(}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{con1 = 3.16 \\PYZhy{} y1}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{n}{con1}\\PY{o}{=}\\PY{l+m+mf}{0.0}\\PY{p}{,} \\PY{n}{y1}\\PY{o}{=}\\PY{l+m+mf}{0.0}\\PY{p}{)}\\PY{p}{,}\n                           \\PY{n}{promotes}\\PY{o}{=}\\PY{p}{[}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{con1}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{y1}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{]}\\PY{p}{)}\n        \\PY{n+nb+bp}{self}\\PY{o}{.}\\PY{n}{add\\PYZus{}subsystem}\\PY{p}{(}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{con\\PYZus{}cmp2}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{n}{om}\\PY{o}{.}\\PY{n}{ExecComp}\\PY{p}{(}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{con2 = y2 \\PYZhy{} 24.0}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{n}{con2}\\PY{o}{=}\\PY{l+m+mf}{0.0}\\PY{p}{,} \\PY{n}{y2}\\PY{o}{=}\\PY{l+m+mf}{0.0}\\PY{p}{)}\\PY{p}{,}\n                           \\PY{n}{promotes}\\PY{o}{=}\\PY{p}{[}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{con2}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{y2}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{]}\\PY{p}{)}\n\n        \\PY{n+nb+bp}{self}\\PY{o}{.}\\PY{n}{set\\PYZus{}input\\PYZus{}defaults}\\PY{p}{(}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{x}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{l+m+mf}{1.0}\\PY{p}{)}\n        \\PY{n+nb+bp}{self}\\PY{o}{.}\\PY{n}{set\\PYZus{}input\\PYZus{}defaults}\\PY{p}{(}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{z}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{n}{np}\\PY{o}{.}\\PY{n}{array}\\PY{p}{(}\\PY{p}{[}\\PY{l+m+mf}{5.0}\\PY{p}{,} \\PY{l+m+mf}{2.0}\\PY{p}{]}\\PY{p}{)}\\PY{p}{)}\n\\end{Verbatim}\n",
      "application/papermill.record/text/plain": "class SellarDerivatives(om.Group):\n    \"\"\"\n    Group containing the Sellar MDA. This version uses the disciplines with derivatives.\n    \"\"\"\n\n    def setup(self):\n        self.add_subsystem('d1', SellarDis1withDerivatives(), promotes=['x', 'z', 'y1', 'y2'])\n        self.add_subsystem('d2', SellarDis2withDerivatives(), promotes=['z', 'y1', 'y2'])\n\n        self.add_subsystem('obj_cmp', om.ExecComp('obj = x**2 + z[1] + y1 + exp(-y2)', obj=0.0,\n                                                  x=0.0, z=np.array([0.0, 0.0]), y1=0.0, y2=0.0),\n                           promotes=['obj', 'x', 'z', 'y1', 'y2'])\n\n        self.add_subsystem('con_cmp1', om.ExecComp('con1 = 3.16 - y1', con1=0.0, y1=0.0),\n                           promotes=['con1', 'y1'])\n        self.add_subsystem('con_cmp2', om.ExecComp('con2 = y2 - 24.0', con2=0.0, y2=0.0),\n                           promotes=['con2', 'y2'])\n\n        self.set_input_defaults('x', 1.0)\n        self.set_input_defaults('z', np.array([5.0, 2.0]))"
     },
     "metadata": {
      "scrapbook": {
       "mime_prefix": "application/papermill.record/",
       "name": "code_src72"
      }
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "from openmdao.utils.notebook_utils import get_code\n",
    "from myst_nb import glue\n",
    "glue(\"code_src72\", get_code(\"openmdao.test_suite.components.sellar_feature.SellarDerivatives\"), display=False)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "4fc459dd",
   "metadata": {
    "papermill": {
     "duration": 0.003929,
     "end_time": "2026-10-02T14:50:20.878586+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:20.874657+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    ":::{dropdown} `SellarDerivatives` class definition \n",
    "\n",
    "{glue:}`code_src72`\n",
    ":::"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "2fcbfba3",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:50:20.887103Z",
     "iopub.status.busy": "2026-10-02T14:50:20.886955Z",
     "iopub.status.idle": "2026-10-02T14:50:20.916435Z",
     "shell.execute_reply": "2026-10-02T14:50:20.915915Z"
    },
    "papermill": {
     "duration": 0.034555,
     "end_time": "2026-10-02T14:50:20.916959+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:20.882404+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "NL: NLBGS Converged in 8 iterations\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "NL: NLBGS Converged in 1 iterations\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "NL: NLBGS Converged in 9 iterations\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "NL: NLBGS Converged in 10 iterations\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "NL: NLBGS Converged in 10 iterations\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "NL: NLBGS Converged in 9 iterations\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "NL: NLBGS Converged in 6 iterations\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Optimization terminated successfully    (Exit mode 0)\n",
      "            Current function value: 3.183393951730529\n",
      "            Iterations: 6\n",
      "            Function evaluations: 6\n",
      "            Gradient evaluations: 6\n",
      "Optimization Complete\n",
      "-----------------------------------\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "import openmdao.api as om\n",
    "from openmdao.test_suite.components.sellar_feature import SellarDerivatives\n",
    "\n",
    "prob = om.Problem(model=SellarDerivatives())\n",
    "model = prob.model\n",
    "model.nonlinear_solver = om.NonlinearBlockGS()\n",
    "model.linear_solver = om.ScipyKrylov()\n",
    "\n",
    "prob.driver = om.ScipyOptimizeDriver()\n",
    "prob.driver.options['optimizer'] = 'SLSQP'\n",
    "prob.driver.options['tol'] = 1e-9\n",
    "\n",
    "model.add_design_var('z', lower=np.array([-10.0, 0.0]), upper=np.array([10.0, 10.0]))\n",
    "model.add_design_var('x', lower=0.0, upper=10.0)\n",
    "model.add_objective('obj')\n",
    "model.add_constraint('con1', upper=0.0)\n",
    "model.add_constraint('con2', upper=0.0)\n",
    "\n",
    "prob.setup()\n",
    "prob.run_driver();"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "6aba90ca",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:50:20.925775Z",
     "iopub.status.busy": "2026-10-02T14:50:20.925629Z",
     "iopub.status.idle": "2026-10-02T14:50:20.931364Z",
     "shell.execute_reply": "2026-10-02T14:50:20.930716Z"
    },
    "papermill": {
     "duration": 0.010795,
     "end_time": "2026-10-02T14:50:20.931768+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:50:20.920973+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "-------------------------\n",
      "Design Variables (scaled)\n",
      "-------------------------\n",
      "name  val               size  lower   upper          ref   ref0  indices  adder  scaler  parallel_deriv_color  \n",
      "----  ----------------  ----  ------  -------------  ----  ----  -------  -----  ------  -------------------- \n",
      "z     |1.97763888|      2     |10.0|  |14.14213562|  None  None  None     None   None    None                  \n",
      "      val:\n",
      "      array([1.97763888, 0.        ])\n",
      "\n",
      "      lower:\n",
      "      array([-10.,   0.])\n",
      "\n",
      "      upper:\n",
      "      array([10., 10.])\n",
      "\n",
      "x     [5.63626006e-15]  1     [0.]    [10.]          None  None  None     None   None    None                  \n",
      "\n",
      "--------------------\n",
      "Constraints (scaled)\n",
      "--------------------\n",
      "name  val                size  alias  lower  upper  equals  ref   ref0  indices  adder  scaler  linear  \n",
      "----  -----------------  ----  -----  -----  -----  ------  ----  ----  -------  -----  ------  ------ \n",
      "con1  [-9.11004605e-11]  1     None   None   [0.]   None    None  None  None     None   None    False   \n",
      "con2  [-20.24472223]     1     None   None   [0.]   None    None  None  None     None   None    False   \n",
      "\n",
      "-------------------\n",
      "Objectives (scaled)\n",
      "-------------------\n",
      "name  val           size  ref   ref0  indices  adder  scaler  parallel_deriv_color  cache_linear_solution  \n",
      "----  ------------  ----  ----  ----  -------  -----  ------  --------------------  --------------------- \n",
      "obj   [3.18339395]  1     None  None  None     None   None    None                  False                  \n",
      "\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'design_vars': [('z',\n",
       "   {'adder': None,\n",
       "    'scaler': None,\n",
       "    'name': 'z',\n",
       "    'upper': array([10., 10.]),\n",
       "    'lower': array([-10.,   0.]),\n",
       "    'ref': None,\n",
       "    'ref0': None,\n",
       "    'indices': None,\n",
       "    'parallel_deriv_color': None,\n",
       "    'size': 2,\n",
       "    'val': array([1.97763888, 0.        ])}),\n",
       "  ('x',\n",
       "   {'adder': None,\n",
       "    'scaler': None,\n",
       "    'name': 'x',\n",
       "    'upper': array([10.]),\n",
       "    'lower': array([0.]),\n",
       "    'ref': None,\n",
       "    'ref0': None,\n",
       "    'indices': None,\n",
       "    'parallel_deriv_color': None,\n",
       "    'size': 1,\n",
       "    'val': array([5.63626006e-15])})],\n",
       " 'constraints': [('con1',\n",
       "   {'name': 'con1',\n",
       "    'alias': None,\n",
       "    'lower': None,\n",
       "    'upper': array([0.]),\n",
       "    'equals': None,\n",
       "    'linear': False,\n",
       "    'indices': None,\n",
       "    'scaler': None,\n",
       "    'adder': None,\n",
       "    'ref': None,\n",
       "    'ref0': None,\n",
       "    'size': np.int32(1),\n",
       "    'val': array([-9.11004605e-11])}),\n",
       "  ('con2',\n",
       "   {'name': 'con2',\n",
       "    'alias': None,\n",
       "    'lower': None,\n",
       "    'upper': array([0.]),\n",
       "    'equals': None,\n",
       "    'linear': False,\n",
       "    'indices': None,\n",
       "    'scaler': None,\n",
       "    'adder': None,\n",
       "    'ref': None,\n",
       "    'ref0': None,\n",
       "    'size': np.int32(1),\n",
       "    'val': array([-20.24472223])})],\n",
       " 'objectives': [('obj',\n",
       "   {'name': 'obj',\n",
       "    'indices': None,\n",
       "    'scaler': None,\n",
       "    'adder': None,\n",
       "    'ref': None,\n",
       "    'ref0': None,\n",
       "    'cache_linear_solution': False,\n",
       "    'parallel_deriv_color': None,\n",
       "    'size': np.int32(1),\n",
       "    'val': array([3.18339395])})]}"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "prob.list_driver_vars(print_arrays=True,\n",
    "                      desvar_opts=['lower', 'upper', 'ref', 'ref0',\n",
    "                                   'indices', 'adder', 'scaler',\n",
    "                                   'parallel_deriv_color', 'min', 'max'],\n",
    "                      cons_opts=['lower', 'upper', 'equals', 'ref', 'ref0',\n",
    "                                 'indices', 'adder', 'scaler', 'linear', 'min', 'max'],\n",
    "                      objs_opts=['ref', 'ref0',\n",
    "                                 'indices', 'adder', 'scaler',\n",
    "                                 'parallel_deriv_color',\n",
    "                                 'cache_linear_solution'])"
   ]
  }
 ],
 "metadata": {
  "celltoolbar": "Tags",
  "interpreter": {
   "hash": "e6c7471802ed76737b16357fb02af5587f3a4cbee5ea7658f3f9a6981469039b"
  },
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.13.14"
  },
  "mpi": true,
  "orphan": true,
  "papermill": {
   "default_parameters": {},
   "duration": 9.700908,
   "end_time": "2026-10-02T14:50:21.622351+00:00",
   "environment_variables": {},
   "exception": null,
   "input_path": "/home/runner/work/OpenMDAO/OpenMDAO/openmdao/docs/openmdao_book/features/debugging/listing_variables.ipynb",
   "output_path": "/home/runner/work/OpenMDAO/OpenMDAO/openmdao/docs/_executed_book/features/debugging/listing_variables.ipynb",
   "parameters": {},
   "start_time": "2026-10-02T14:50:11.921443+00:00",
   "version": "2.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}