{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "5f8d8af9",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:11.195516Z",
     "iopub.status.busy": "2026-10-02T14:46:11.195253Z",
     "iopub.status.idle": "2026-10-02T14:46:11.199936Z",
     "shell.execute_reply": "2026-10-02T14:46:11.199404Z"
    },
    "papermill": {
     "duration": 0.008362,
     "end_time": "2026-10-02T14:46:11.200910+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:11.192548+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output",
     "active-ipynb"
    ]
   },
   "outputs": [],
   "source": [
    "try:\n",
    "    from openmdao.utils.notebook_utils import notebook_mode  # noqa: F401\n",
    "except ImportError:\n",
    "    !python -m pip install openmdao[notebooks]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7bc3f2f0",
   "metadata": {
    "papermill": {
     "duration": 0.001747,
     "end_time": "2026-10-02T14:46:11.204380+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:11.202633+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "118db89f",
   "metadata": {
    "papermill": {
     "duration": 0.001681,
     "end_time": "2026-10-02T14:46:11.293264+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:11.291583+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "# Case Recording"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "155a6661",
   "metadata": {
    "papermill": {
     "duration": 0.001765,
     "end_time": "2026-10-02T14:46:11.296945+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:11.295180+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "## Case Recording Options\n",
    "\n",
    "The available recording options for different OpenMDAO classes are summarized in this table:\n",
    "\n",
    "|Recording Options        |Driver|System|Solver|Problem|\n",
    "|:------------------------|:----:|:----:|:----:|:-----:|\n",
    "|record_constraints       |  X   |      |      |  X    |\n",
    "|record_desvars           |  X   |      |      |  X    |\n",
    "|record_objectives        |  X   |      |      |  X    |\n",
    "|record_derivatives       |  X   |      |      |  X    |\n",
    "|record_responses         |  X   |      |      |  X    |\n",
    "|record_inputs            |  X   |  X   |  X   |  X    |\n",
    "|record_outputs           |  X   |  X   |  X   |  X    |\n",
    "|record_residuals         |  X   |  X   |      |  X    |\n",
    "|record_abs_error         |      |      |  X   |       |\n",
    "|record_rel_error         |      |      |  X   |       |\n",
    "|record_solver_residuals  |      |      |  X   |       |\n",
    "|includes                 |  X   |  X   |  X   |  X    |\n",
    "|excludes                 |  X   |  X   |  X   |  X    |\n",
    "|options_excludes         |      |  X   |      |       |"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "665ae681",
   "metadata": {
    "papermill": {
     "duration": 0.00148,
     "end_time": "2026-10-02T14:46:11.300239+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:11.298759+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "## Case Recorder Files\n",
    "\n",
    "When you instantiate a recorder, you must specify the filename to which the SQLite database of data is stored.\n",
    "By default, this file will be stored under the output directory of the problem."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "dd6f486e",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:11.461210Z",
     "iopub.status.busy": "2026-10-02T14:46:11.461016Z",
     "iopub.status.idle": "2026-10-02T14:46:14.499041Z",
     "shell.execute_reply": "2026-10-02T14:46:14.498226Z"
    },
    "papermill": {
     "duration": 3.114795,
     "end_time": "2026-10-02T14:46:14.499574+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:11.384779+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1790952373.951983] [runnervm8df0l:10468:0]        ib_iface.c:1269 UCX  ERROR mana_0: iface 0x5608ba5ba410 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",
      "[1790952373.952272] [runnervm8df0l:10468: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:10468] pml_ucx.c:313  Error: Failed to create UCP worker\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "['.openmdao_out', 'prob_recorder.sql']"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import os\n",
    "import openmdao.api as om\n",
    "\n",
    "p = om.Problem(reports=None, name='prob_recorder')\n",
    "p.model.add_subsystem('exec', om.ExecComp('z = x + y'),\n",
    "                       promotes_inputs=['x', 'y'], promotes_outputs=['z'])\n",
    "\n",
    "p.add_recorder(om.SqliteRecorder('prob_recorder.sql'))\n",
    "\n",
    "p.setup()\n",
    "p.set_val('x', 3)\n",
    "p.set_val('y', 5)\n",
    "p.run_model()\n",
    "p.record('first_case')\n",
    "\n",
    "p.set_val('x', 4)\n",
    "p.set_val('y', 5)\n",
    "p.run_model()\n",
    "p.record('second_case')\n",
    "\n",
    "p.cleanup()\n",
    "\n",
    "# Now prob_recorder.sql should exist in the problem's outputs directory.\n",
    "os.listdir(p.get_outputs_dir())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "70d27e86",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:14.504312Z",
     "iopub.status.busy": "2026-10-02T14:46:14.503987Z",
     "iopub.status.idle": "2026-10-02T14:46:14.507085Z",
     "shell.execute_reply": "2026-10-02T14:46:14.506469Z"
    },
    "papermill": {
     "duration": 0.006423,
     "end_time": "2026-10-02T14:46:14.507843+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:14.501420+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "assert((p.get_outputs_dir() / 'prob_recorder.sql').exists())"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "489c88c2",
   "metadata": {
    "papermill": {
     "duration": 0.001634,
     "end_time": "2026-10-02T14:46:14.511131+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:14.509497+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "If the filename contains path separators (`/`), then OpenMDAO will assume that the recorder file path is not to be prepended with the problem's output directory.\n",
    "\n",
    "For instance, to place the file in the current working directory rather than the problem outputs directory, one could prepend it with `./`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "152c7302",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:14.514995Z",
     "iopub.status.busy": "2026-10-02T14:46:14.514840Z",
     "iopub.status.idle": "2026-10-02T14:46:14.855375Z",
     "shell.execute_reply": "2026-10-02T14:46:14.854654Z"
    },
    "papermill": {
     "duration": 0.343377,
     "end_time": "2026-10-02T14:46:14.856001+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:14.512624+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['prob_recorder.sql']\n"
     ]
    }
   ],
   "source": [
    "import pathlib\n",
    "\n",
    "p = om.Problem(reports=None, name='prob_recorder2')\n",
    "p.model.add_subsystem('exec', om.ExecComp('z = x + y'),\n",
    "                       promotes_inputs=['x', 'y'], promotes_outputs=['z'])\n",
    "\n",
    "p.add_recorder(om.SqliteRecorder('./prob_recorder.sql'))\n",
    "\n",
    "p.setup()\n",
    "p.set_val('x', 3)\n",
    "p.set_val('y', 5)\n",
    "p.run_model()\n",
    "p.record('first_case')\n",
    "\n",
    "p.set_val('x', 4)\n",
    "p.set_val('y', 5)\n",
    "p.run_model()\n",
    "p.record('second_case')\n",
    "\n",
    "p.cleanup()\n",
    "\n",
    "# Now prob_recorder.sql should exist in the current working directory.\n",
    "print([file.parts[-1] for file in pathlib.Path.cwd().glob('*.sql')])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "49fb03dd",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:14.874580Z",
     "iopub.status.busy": "2026-10-02T14:46:14.874350Z",
     "iopub.status.idle": "2026-10-02T14:46:14.878241Z",
     "shell.execute_reply": "2026-10-02T14:46:14.877559Z"
    },
    "papermill": {
     "duration": 0.021422,
     "end_time": "2026-10-02T14:46:14.879301+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:14.857879+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "assert((pathlib.Path(os.getcwd()) / 'prob_recorder.sql').exists())"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "016e11d6",
   "metadata": {
    "papermill": {
     "duration": 0.002179,
     "end_time": "2026-10-02T14:46:14.883855+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:14.881676+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "## Specifying a Case Prefix\n",
    "It is possible to record data from multiple executions by specifying a prefix that will be used to differentiate the cases. This prefix can be specified when calling run_model or run_driver and will be prepended to the case ID in the recorded case data:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "979d8372",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:14.889496Z",
     "iopub.status.busy": "2026-10-02T14:46:14.889286Z",
     "iopub.status.idle": "2026-10-02T14:46:15.922224Z",
     "shell.execute_reply": "2026-10-02T14:46:15.921524Z"
    },
    "papermill": {
     "duration": 1.036988,
     "end_time": "2026-10-02T14:46:15.923234+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:14.886246+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_src87"
      }
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "from openmdao.utils.notebook_utils import get_code\n",
    "from myst_nb import glue\n",
    "glue(\"code_src87\", get_code(\"openmdao.test_suite.components.sellar_feature.SellarDerivatives\"), display=False)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3240f508",
   "metadata": {
    "papermill": {
     "duration": 0.00237,
     "end_time": "2026-10-02T14:46:15.928175+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:15.925805+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    ":::{dropdown} `SellarDerivatives` class definition \n",
    "\n",
    "{glue:}`code_src87`\n",
    ":::"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "b14a9419",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:15.933890Z",
     "iopub.status.busy": "2026-10-02T14:46:15.933635Z",
     "iopub.status.idle": "2026-10-02T14:46:16.540086Z",
     "shell.execute_reply": "2026-10-02T14:46:16.539026Z"
    },
    "papermill": {
     "duration": 0.610254,
     "end_time": "2026-10-02T14:46:16.540711+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:15.930457+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "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;\">root</th></tr>\n",
       "       <tr style=\"background-color: ghostwhite;\"><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: left;\">Model_Run1_rank0:root._solve_nonlinear|0</td></tr>\n",
       "       <tr style=\"background-color: #F3F3F3;\"><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: left;\">Driver_Run1_rank0:Driver|0|root._solve_nonlinear|0</td></tr>\n",
       "       <tr style=\"background-color: ghostwhite;\"><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: left;\">Model_Run2_rank0:root._solve_nonlinear|0</td></tr>\n",
       "       <tr style=\"background-color: #F3F3F3;\"><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: left;\">Driver_Run2_rank0:Driver|0|root._solve_nonlinear|0</td></tr>\n",
       "    </table>\n",
       "</body>\n",
       "</html>\n"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from openmdao.test_suite.components.sellar_feature import SellarDerivatives\n",
    "\n",
    "prob = om.Problem(name='case_recording_options', model=SellarDerivatives())\n",
    "prob.setup()\n",
    "\n",
    "recorder = om.SqliteRecorder(\"case_recording_options.sql\", record_viewer_data=False)\n",
    "prob.model.add_recorder(recorder)\n",
    "prob.driver.add_recorder(recorder)\n",
    "\n",
    "prob.set_solver_print(0)\n",
    "\n",
    "prob.run_model(case_prefix='Model_Run1')\n",
    "prob.run_driver(case_prefix='Driver_Run1')\n",
    "\n",
    "prob.run_model('Model_Run2')\n",
    "prob.run_driver('Driver_Run2')\n",
    "\n",
    "prob.cleanup()\n",
    "\n",
    "cr = om.CaseReader(prob.get_outputs_dir() / \"case_recording_options.sql\")\n",
    "\n",
    "# all cases recorded by the root system\n",
    "model_cases = cr.list_cases('root', recurse=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "5c5eaeda",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:16.546955Z",
     "iopub.status.busy": "2026-10-02T14:46:16.546773Z",
     "iopub.status.idle": "2026-10-02T14:46:16.550036Z",
     "shell.execute_reply": "2026-10-02T14:46:16.549373Z"
    },
    "papermill": {
     "duration": 0.007016,
     "end_time": "2026-10-02T14:46:16.550570+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:16.543554+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "assert '\\n'.join(model_cases) == '\\n'.join([\n",
    "    'Model_Run1_rank0:root._solve_nonlinear|0',\n",
    "    'Driver_Run1_rank0:Driver|0|root._solve_nonlinear|0',\n",
    "    'Model_Run2_rank0:root._solve_nonlinear|0',\n",
    "    'Driver_Run2_rank0:Driver|0|root._solve_nonlinear|0'\n",
    "])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "d31369f4",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:16.555969Z",
     "iopub.status.busy": "2026-10-02T14:46:16.555793Z",
     "iopub.status.idle": "2026-10-02T14:46:16.560018Z",
     "shell.execute_reply": "2026-10-02T14:46:16.559444Z"
    },
    "papermill": {
     "duration": 0.007984,
     "end_time": "2026-10-02T14:46:16.560709+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:16.552725+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "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;\">driver</th></tr>\n",
       "       <tr style=\"background-color: ghostwhite;\"><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: left;\">Driver_Run1_rank0:Driver|0</td></tr>\n",
       "       <tr style=\"background-color: #F3F3F3;\"><td style=\"border: 1px solid #999; border-collapse: collapse; padding: 5px; text-align: left;\">Driver_Run2_rank0:Driver|0</td></tr>\n",
       "    </table>\n",
       "</body>\n",
       "</html>\n"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# all cases recorded by the driver\n",
    "driver_cases = cr.list_cases('driver', recurse=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "864ac779",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:16.565947Z",
     "iopub.status.busy": "2026-10-02T14:46:16.565767Z",
     "iopub.status.idle": "2026-10-02T14:46:16.568656Z",
     "shell.execute_reply": "2026-10-02T14:46:16.568172Z"
    },
    "papermill": {
     "duration": 0.006648,
     "end_time": "2026-10-02T14:46:16.569399+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:16.562751+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "assert '\\n'.join(driver_cases) == '\\n'.join([\n",
    "    'Driver_Run1_rank0:Driver|0',\n",
    "    'Driver_Run2_rank0:Driver|0'\n",
    "])\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b75dec6e",
   "metadata": {
    "papermill": {
     "duration": 0.002162,
     "end_time": "2026-10-02T14:46:16.574032+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:16.571870+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "```{note}\n",
    "A recorder can be attached to more than one object. Also, more than one recorder can be attached to an object.\n",
    "```\n",
    "```{note}\n",
    "In this example, we have disabled the saving of data needed by the standalone N2 visualizer and debugging tool by setting `record_viewer_data` to `False`.\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fddc228b",
   "metadata": {
    "papermill": {
     "duration": 0.002184,
     "end_time": "2026-10-02T14:46:16.578308+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:16.576124+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "# Recording Options Include and Exclude Matching\n",
    "\n",
    "The `includes` and `excludes` recording options provide support for Unix shell-style wildcards, which are not \n",
    "the same as regular expressions. The documentation for the `fnmatchcase` function from the Python standard library\n",
    "documents the wildcards."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2a50f0b8",
   "metadata": {
    "papermill": {
     "duration": 0.002137,
     "end_time": "2026-10-02T14:46:16.582586+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:16.580449+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "# Recording Options Precedence\n",
    "\n",
    "The precedence of recording options that determines what gets recorded can sometime be a little confusing. \n",
    "Here is an example that might help. The code shows how the record_desvars and includes options interact."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "915fe237",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:16.587783Z",
     "iopub.status.busy": "2026-10-02T14:46:16.587605Z",
     "iopub.status.idle": "2026-10-02T14:46:16.597126Z",
     "shell.execute_reply": "2026-10-02T14:46:16.596598Z"
    },
    "papermill": {
     "duration": 0.013075,
     "end_time": "2026-10-02T14:46:16.597871+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:16.584796+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\">Paraboloid</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;</span>\n<span class=\"sd\">    Evaluates the equation f(x,y) = (x-3)^2 + xy + (y+4)^2 - 3.</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_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.0</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;y&#39;</span><span class=\"p\">,</span> <span class=\"n\">val</span><span class=\"o\">=</span><span class=\"mf\">0.0</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;f_xy&#39;</span><span class=\"p\">,</span> <span class=\"n\">val</span><span class=\"o\">=</span><span class=\"mf\">0.0</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=\"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\">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=\"w\">        </span><span class=\"sd\">&quot;&quot;&quot;</span>\n<span class=\"sd\">        f(x,y) = (x-3)^2 + xy + (y+4)^2 - 3</span>\n\n<span class=\"sd\">        Optimal solution (minimum): x = 6.6667; y = -7.3333</span>\n<span class=\"sd\">        &quot;&quot;&quot;</span>\n        <span class=\"n\">x</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\">y</span> <span class=\"o\">=</span> <span class=\"n\">inputs</span><span class=\"p\">[</span><span class=\"s1\">&#39;y&#39;</span><span class=\"p\">]</span>\n\n        <span class=\"n\">outputs</span><span class=\"p\">[</span><span class=\"s1\">&#39;f_xy&#39;</span><span class=\"p\">]</span> <span class=\"o\">=</span> <span class=\"p\">(</span><span class=\"n\">x</span><span class=\"o\">-</span><span class=\"mf\">3.0</span><span class=\"p\">)</span><span class=\"o\">**</span><span class=\"mi\">2</span> <span class=\"o\">+</span> <span class=\"n\">x</span><span class=\"o\">*</span><span class=\"n\">y</span> <span class=\"o\">+</span> <span class=\"p\">(</span><span class=\"n\">y</span><span class=\"o\">+</span><span class=\"mf\">4.0</span><span class=\"p\">)</span><span class=\"o\">**</span><span class=\"mi\">2</span> <span class=\"o\">-</span> <span class=\"mf\">3.0</span>\n\n    <span class=\"k\">def</span><span class=\"w\"> </span><span class=\"nf\">compute_partials</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\">partials</span><span class=\"p\">):</span>\n<span class=\"w\">        </span><span class=\"sd\">&quot;&quot;&quot;</span>\n<span class=\"sd\">        Jacobian for our paraboloid.</span>\n<span class=\"sd\">        &quot;&quot;&quot;</span>\n        <span class=\"n\">x</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\">y</span> <span class=\"o\">=</span> <span class=\"n\">inputs</span><span class=\"p\">[</span><span class=\"s1\">&#39;y&#39;</span><span class=\"p\">]</span>\n\n        <span class=\"n\">partials</span><span class=\"p\">[</span><span class=\"s1\">&#39;f_xy&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;x&#39;</span><span class=\"p\">]</span> <span class=\"o\">=</span> <span class=\"mf\">2.0</span><span class=\"o\">*</span><span class=\"n\">x</span> <span class=\"o\">-</span> <span class=\"mf\">6.0</span> <span class=\"o\">+</span> <span class=\"n\">y</span>\n        <span class=\"n\">partials</span><span class=\"p\">[</span><span class=\"s1\">&#39;f_xy&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;y&#39;</span><span class=\"p\">]</span> <span class=\"o\">=</span> <span class=\"mf\">2.0</span><span class=\"o\">*</span><span class=\"n\">y</span> <span class=\"o\">+</span> <span class=\"mf\">8.0</span> <span class=\"o\">+</span> <span class=\"n\">x</span>\n</pre></div>\n",
      "application/papermill.record/text/latex": "\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n\\PY{k}{class}\\PY{+w}{ }\\PY{n+nc}{Paraboloid}\\PY{p}{(}\\PY{n}{om}\\PY{o}{.}\\PY{n}{ExplicitComponent}\\PY{p}{)}\\PY{p}{:}\n\\PY{+w}{    }\\PY{l+s+sd}{\\PYZdq{}\\PYZdq{}\\PYZdq{}}\n\\PY{l+s+sd}{    Evaluates the equation f(x,y) = (x\\PYZhy{}3)\\PYZca{}2 + xy + (y+4)\\PYZca{}2 \\PYZhy{} 3.}\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{}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.0}\\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}{y}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{n}{val}\\PY{o}{=}\\PY{l+m+mf}{0.0}\\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}{f\\PYZus{}xy}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{n}{val}\\PY{o}{=}\\PY{l+m+mf}{0.0}\\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{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}{compute}\\PY{p}{(}\\PY{n+nb+bp}{self}\\PY{p}{,} \\PY{n}{inputs}\\PY{p}{,} \\PY{n}{outputs}\\PY{p}{)}\\PY{p}{:}\n\\PY{+w}{        }\\PY{l+s+sd}{\\PYZdq{}\\PYZdq{}\\PYZdq{}}\n\\PY{l+s+sd}{        f(x,y) = (x\\PYZhy{}3)\\PYZca{}2 + xy + (y+4)\\PYZca{}2 \\PYZhy{} 3}\n\n\\PY{l+s+sd}{        Optimal solution (minimum): x = 6.6667; y = \\PYZhy{}7.3333}\n\\PY{l+s+sd}{        \\PYZdq{}\\PYZdq{}\\PYZdq{}}\n        \\PY{n}{x} \\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}{y} \\PY{o}{=} \\PY{n}{inputs}\\PY{p}{[}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{y}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{]}\n\n        \\PY{n}{outputs}\\PY{p}{[}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{f\\PYZus{}xy}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{]} \\PY{o}{=} \\PY{p}{(}\\PY{n}{x}\\PY{o}{\\PYZhy{}}\\PY{l+m+mf}{3.0}\\PY{p}{)}\\PY{o}{*}\\PY{o}{*}\\PY{l+m+mi}{2} \\PY{o}{+} \\PY{n}{x}\\PY{o}{*}\\PY{n}{y} \\PY{o}{+} \\PY{p}{(}\\PY{n}{y}\\PY{o}{+}\\PY{l+m+mf}{4.0}\\PY{p}{)}\\PY{o}{*}\\PY{o}{*}\\PY{l+m+mi}{2} \\PY{o}{\\PYZhy{}} \\PY{l+m+mf}{3.0}\n\n    \\PY{k}{def}\\PY{+w}{ }\\PY{n+nf}{compute\\PYZus{}partials}\\PY{p}{(}\\PY{n+nb+bp}{self}\\PY{p}{,} \\PY{n}{inputs}\\PY{p}{,} \\PY{n}{partials}\\PY{p}{)}\\PY{p}{:}\n\\PY{+w}{        }\\PY{l+s+sd}{\\PYZdq{}\\PYZdq{}\\PYZdq{}}\n\\PY{l+s+sd}{        Jacobian for our paraboloid.}\n\\PY{l+s+sd}{        \\PYZdq{}\\PYZdq{}\\PYZdq{}}\n        \\PY{n}{x} \\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}{y} \\PY{o}{=} \\PY{n}{inputs}\\PY{p}{[}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{y}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{]}\n\n        \\PY{n}{partials}\\PY{p}{[}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{f\\PYZus{}xy}\\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{l+m+mf}{2.0}\\PY{o}{*}\\PY{n}{x} \\PY{o}{\\PYZhy{}} \\PY{l+m+mf}{6.0} \\PY{o}{+} \\PY{n}{y}\n        \\PY{n}{partials}\\PY{p}{[}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{f\\PYZus{}xy}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{y}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{]} \\PY{o}{=} \\PY{l+m+mf}{2.0}\\PY{o}{*}\\PY{n}{y} \\PY{o}{+} \\PY{l+m+mf}{8.0} \\PY{o}{+} \\PY{n}{x}\n\\end{Verbatim}\n",
      "application/papermill.record/text/plain": "class Paraboloid(om.ExplicitComponent):\n    \"\"\"\n    Evaluates the equation f(x,y) = (x-3)^2 + xy + (y+4)^2 - 3.\n    \"\"\"\n\n    def setup(self):\n        self.add_input('x', val=0.0)\n        self.add_input('y', val=0.0)\n\n        self.add_output('f_xy', val=0.0)\n\n    def setup_partials(self):\n        self.declare_partials('*', '*')\n\n    def compute(self, inputs, outputs):\n        \"\"\"\n        f(x,y) = (x-3)^2 + xy + (y+4)^2 - 3\n\n        Optimal solution (minimum): x = 6.6667; y = -7.3333\n        \"\"\"\n        x = inputs['x']\n        y = inputs['y']\n\n        outputs['f_xy'] = (x-3.0)**2 + x*y + (y+4.0)**2 - 3.0\n\n    def compute_partials(self, inputs, partials):\n        \"\"\"\n        Jacobian for our paraboloid.\n        \"\"\"\n        x = inputs['x']\n        y = inputs['y']\n\n        partials['f_xy', 'x'] = 2.0*x - 6.0 + y\n        partials['f_xy', 'y'] = 2.0*y + 8.0 + x"
     },
     "metadata": {
      "scrapbook": {
       "mime_prefix": "application/papermill.record/",
       "name": "code_src88"
      }
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "from openmdao.utils.notebook_utils import get_code\n",
    "from myst_nb import glue\n",
    "glue(\"code_src88\", get_code(\"openmdao.test_suite.components.paraboloid.Paraboloid\"), display=False)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2358e829",
   "metadata": {
    "papermill": {
     "duration": 0.025143,
     "end_time": "2026-10-02T14:46:16.625350+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:16.600207+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    ":::{dropdown} `Paraboloid` class definition \n",
    "\n",
    "{glue:}`code_src88`\n",
    ":::"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "7b98a4d7",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:16.631262Z",
     "iopub.status.busy": "2026-10-02T14:46:16.631059Z",
     "iopub.status.idle": "2026-10-02T14:46:16.635928Z",
     "shell.execute_reply": "2026-10-02T14:46:16.635339Z"
    },
    "papermill": {
     "duration": 0.008565,
     "end_time": "2026-10-02T14:46:16.636379+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:16.627814+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "import openmdao.api as om\n",
    "from openmdao.test_suite.components.paraboloid import Paraboloid\n",
    "\n",
    "prob = om.Problem(name='case_recording_options2')\n",
    "prob.driver = om.ScipyOptimizeDriver(optimizer='SLSQP', tol=1e-9, disp=False)\n",
    "\n",
    "model = prob.model\n",
    "\n",
    "model.add_subsystem('comp', Paraboloid(), promotes=['*'])\n",
    "model.add_subsystem('con', om.ExecComp('c = x - y'), promotes=['*'])\n",
    "\n",
    "model.set_input_defaults('x', val=50.0)\n",
    "model.set_input_defaults('y', val=50.0)\n",
    "\n",
    "model.add_design_var('x', lower=-50.0, upper=50.0)\n",
    "model.add_design_var('y', lower=-50.0, upper=50.0)\n",
    "model.add_objective('f_xy')\n",
    "model.add_constraint('c', lower=15.0)\n",
    "\n",
    "case_file = 'case_recording_options.sql'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "d771b84e",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:16.644163Z",
     "iopub.status.busy": "2026-10-02T14:46:16.643829Z",
     "iopub.status.idle": "2026-10-02T14:46:17.195223Z",
     "shell.execute_reply": "2026-10-02T14:46:17.194549Z"
    },
    "papermill": {
     "duration": 0.555241,
     "end_time": "2026-10-02T14:46:17.195850+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:16.640609+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'x': array([50.]),\n",
       " 'y': array([50.]),\n",
       " 'f_xy': array([7622.]),\n",
       " 'c': array([0.])}"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# First case with record_desvars = True and includes = []\n",
    "recorder = om.SqliteRecorder(case_file)\n",
    "prob.driver.add_recorder(recorder)\n",
    "prob.driver.recording_options['record_desvars'] = True\n",
    "prob.driver.recording_options['record_outputs'] = True\n",
    "prob.driver.recording_options['includes'] = []\n",
    "prob.driver.recording_options['excludes'] = []\n",
    "\n",
    "prob.setup()\n",
    "prob.run_driver()\n",
    "prob.cleanup()\n",
    "\n",
    "cr = om.CaseReader(prob.get_outputs_dir() / case_file)\n",
    "case = cr.get_case(0)\n",
    "\n",
    "case.outputs"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "6e282013",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:17.202774Z",
     "iopub.status.busy": "2026-10-02T14:46:17.202413Z",
     "iopub.status.idle": "2026-10-02T14:46:17.204752Z",
     "shell.execute_reply": "2026-10-02T14:46:17.204355Z"
    },
    "papermill": {
     "duration": 0.006681,
     "end_time": "2026-10-02T14:46:17.205602+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:17.198921+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "assert sorted(case.outputs.keys()) == ['c', 'f_xy', 'x', 'y']\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "feb60d54",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:17.211763Z",
     "iopub.status.busy": "2026-10-02T14:46:17.211604Z",
     "iopub.status.idle": "2026-10-02T14:46:17.795836Z",
     "shell.execute_reply": "2026-10-02T14:46:17.795153Z"
    },
    "papermill": {
     "duration": 0.588337,
     "end_time": "2026-10-02T14:46:17.796661+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:17.208324+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'f_xy': array([7622.]), 'c': array([0.])}"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Second case with record_desvars = False and includes = []\n",
    "recorder = om.SqliteRecorder(case_file)\n",
    "prob.driver.add_recorder(recorder)\n",
    "prob.driver.recording_options['record_desvars'] = False\n",
    "prob.driver.recording_options['record_outputs'] = True\n",
    "prob.driver.recording_options['includes'] = []\n",
    "\n",
    "prob.setup()\n",
    "prob.run_driver()\n",
    "prob.cleanup()\n",
    "\n",
    "cr = om.CaseReader(prob.get_outputs_dir() / case_file)\n",
    "case = cr.get_case(0)\n",
    "\n",
    "case.outputs"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "607dbbf4",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:17.803933Z",
     "iopub.status.busy": "2026-10-02T14:46:17.803722Z",
     "iopub.status.idle": "2026-10-02T14:46:17.806373Z",
     "shell.execute_reply": "2026-10-02T14:46:17.805776Z"
    },
    "papermill": {
     "duration": 0.007066,
     "end_time": "2026-10-02T14:46:17.806972+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:17.799906+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "assert sorted(case.outputs.keys()) == ['c', 'f_xy']\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "c1641d99",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:17.812680Z",
     "iopub.status.busy": "2026-10-02T14:46:17.812512Z",
     "iopub.status.idle": "2026-10-02T14:46:18.122851Z",
     "shell.execute_reply": "2026-10-02T14:46:18.122140Z"
    },
    "papermill": {
     "duration": 0.314112,
     "end_time": "2026-10-02T14:46:18.123643+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:17.809531+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'x': array([50.]),\n",
       " 'y': array([50.]),\n",
       " 'f_xy': array([7622.]),\n",
       " 'c': array([0.])}"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Third case with record_desvars = True and includes = ['*']\n",
    "recorder = om.SqliteRecorder(case_file)\n",
    "prob.driver.add_recorder(recorder)\n",
    "prob.driver.recording_options['record_desvars'] = True\n",
    "prob.driver.recording_options['record_outputs'] = True\n",
    "prob.driver.recording_options['includes'] = ['*']\n",
    "\n",
    "prob.setup()\n",
    "prob.run_driver()\n",
    "prob.cleanup()\n",
    "\n",
    "cr = om.CaseReader(prob.get_outputs_dir() / case_file)\n",
    "case = cr.get_case(0)\n",
    "\n",
    "case.outputs"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "fbfc3805",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:18.130601Z",
     "iopub.status.busy": "2026-10-02T14:46:18.130398Z",
     "iopub.status.idle": "2026-10-02T14:46:18.133762Z",
     "shell.execute_reply": "2026-10-02T14:46:18.132899Z"
    },
    "papermill": {
     "duration": 0.007456,
     "end_time": "2026-10-02T14:46:18.134326+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:18.126870+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "assert sorted(case.outputs.keys()) == ['c', 'f_xy', 'x', 'y']\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "39490cfc",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:18.140264Z",
     "iopub.status.busy": "2026-10-02T14:46:18.140084Z",
     "iopub.status.idle": "2026-10-02T14:46:18.824486Z",
     "shell.execute_reply": "2026-10-02T14:46:18.823533Z"
    },
    "papermill": {
     "duration": 0.688785,
     "end_time": "2026-10-02T14:46:18.825600+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:18.136815+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'x': array([50.]),\n",
       " 'y': array([50.]),\n",
       " 'f_xy': array([7622.]),\n",
       " 'c': array([0.])}"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Fourth case with record_desvars = False, record_outputs = True, and includes = ['*']\n",
    "recorder = om.SqliteRecorder(case_file)\n",
    "prob.driver.add_recorder(recorder)\n",
    "prob.driver.recording_options['record_desvars'] = False\n",
    "prob.driver.recording_options['record_outputs'] = True\n",
    "prob.driver.recording_options['includes'] = ['*']\n",
    "\n",
    "prob.setup()\n",
    "prob.run_driver()\n",
    "prob.cleanup()\n",
    "\n",
    "cr = om.CaseReader(prob.get_outputs_dir() / case_file)\n",
    "case = cr.get_case(0)\n",
    "\n",
    "case.outputs"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "242da023",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:18.832731Z",
     "iopub.status.busy": "2026-10-02T14:46:18.832506Z",
     "iopub.status.idle": "2026-10-02T14:46:18.836232Z",
     "shell.execute_reply": "2026-10-02T14:46:18.835262Z"
    },
    "papermill": {
     "duration": 0.007945,
     "end_time": "2026-10-02T14:46:18.836798+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:18.828853+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "assert sorted(case.outputs.keys()) == ['c', 'f_xy', 'x', 'y']"
   ]
  }
 ],
 "metadata": {
  "celltoolbar": "Tags",
  "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"
  },
  "orphan": true,
  "papermill": {
   "default_parameters": {},
   "duration": 9.30853,
   "end_time": "2026-10-02T14:46:19.857277+00:00",
   "environment_variables": {},
   "exception": null,
   "input_path": "/home/runner/work/OpenMDAO/OpenMDAO/openmdao/docs/openmdao_book/features/recording/case_recording_options.ipynb",
   "output_path": "/home/runner/work/OpenMDAO/OpenMDAO/openmdao/docs/_executed_book/features/recording/case_recording_options.ipynb",
   "parameters": {},
   "start_time": "2026-10-02T14:46:10.548747+00:00",
   "version": "2.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}