{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "5fefbfdb",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:47.489885Z",
     "iopub.status.busy": "2026-10-02T14:46:47.489626Z",
     "iopub.status.idle": "2026-10-02T14:46:47.494358Z",
     "shell.execute_reply": "2026-10-02T14:46:47.493678Z"
    },
    "papermill": {
     "duration": 0.010083,
     "end_time": "2026-10-02T14:46:47.494864+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:47.484781+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "active-ipynb",
     "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]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "061d7234",
   "metadata": {
    "papermill": {
     "duration": 0.021213,
     "end_time": "2026-10-02T14:46:47.519439+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:47.498226+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "# Upgrading from OpenMDAO 2.10 to OpenMDAO 3\n",
    "\n",
    "In the OpenMDAO 3.0 release, a few changes were made to the API.  In addition, we removed all\n",
    "deprecation warnings and fully deprecated the old behavior for all API changes that were made\n",
    "over the lifespan of OpenMDAO 2.x.  The changes are all summarized here.\n",
    "\n",
    "```{Note}\n",
    "A significant number of the single line examples are a change in class camelcase or removing an underscore\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "76db0a84",
   "metadata": {
    "papermill": {
     "duration": 0.003098,
     "end_time": "2026-10-02T14:46:47.525827+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:47.522729+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "## Building Component Models\n",
    "### Declare a Component with distributed variables\n",
    "\n",
    "`````{tab-set}\n",
    "````{tab-item} OpenMDAO 2.x\n",
    "```\n",
    "class DistribComp(ExplicitComponent):\n",
    "\n",
    "    def __init__(self, size):\n",
    "        super().__init__()\n",
    "        self.distributed = True\n",
    "\n",
    "```\n",
    "````\n",
    "\n",
    "````{tab-item} OpenMDAO 3.0\n",
    "```\n",
    "import openmdao.api as om\n",
    "\n",
    "\n",
    "class DistribComp(om.ExplicitComponent):\n",
    "    \"\"\"Simple Distributed Component.\"\"\"\n",
    "\n",
    "    def initialize(self):\n",
    "        self.options['distributed'] = True\n",
    "```\n",
    "````\n",
    "`````\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0bfe2b78",
   "metadata": {
    "papermill": {
     "duration": 0.003027,
     "end_time": "2026-10-02T14:46:47.532096+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:47.529069+00:00",
     "status": "completed"
    },
    "tags": [
     "remove_input"
    ]
   },
   "source": [
    "Below each tabbed example in this notebook is the runnable code from above. However, since some things have been fully deprecated, the code from OpenMDAO 2.x is no longer operational. If that is the case, we have commented out those code cell examples."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "8fa9f320",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:47.540762Z",
     "iopub.status.busy": "2026-10-02T14:46:47.540537Z",
     "iopub.status.idle": "2026-10-02T14:46:49.073093Z",
     "shell.execute_reply": "2026-10-02T14:46:49.072480Z"
    },
    "papermill": {
     "duration": 1.538522,
     "end_time": "2026-10-02T14:46:49.073866+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:47.535344+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "import openmdao.api as om\n",
    "\n",
    "\n",
    "class DistribComp(om.ExplicitComponent):\n",
    "\n",
    "    def __init__(self, size):\n",
    "        super().__init__()\n",
    "        self.distributed = True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "b1b320dd",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:49.081675Z",
     "iopub.status.busy": "2026-10-02T14:46:49.081356Z",
     "iopub.status.idle": "2026-10-02T14:46:49.083926Z",
     "shell.execute_reply": "2026-10-02T14:46:49.083518Z"
    },
    "papermill": {
     "duration": 0.007429,
     "end_time": "2026-10-02T14:46:49.084782+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:49.077353+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "import openmdao.api as om\n",
    "\n",
    "\n",
    "class DistribComp(om.ExplicitComponent):\n",
    "    \"\"\"Simple Distributed Component.\"\"\"\n",
    "\n",
    "    def initialize(self):\n",
    "        self.options['distributed'] = True"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6419cd9a",
   "metadata": {
    "papermill": {
     "duration": 0.003215,
     "end_time": "2026-10-02T14:46:49.091135+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:49.087920+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "### Declare a variable that is explicitly unitless\n",
    "\n",
    "`````{tab-set}\n",
    "````{tab-item} OpenMDAO 2.x\n",
    "```\n",
    "prob.model.add_subsystem('tgt', om.ExecComp('y = 3 * x', x={'units': 'unitless'}))\n",
    "```\n",
    "````\n",
    "\n",
    "````{tab-item} OpenMDAO 3.0\n",
    "```\n",
    "prob.model.add_subsystem('tgt', om.ExecComp('y = 3 * x', x={'units': None}))\n",
    "```\n",
    "````\n",
    "`````\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "73d731db",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:49.097991Z",
     "iopub.status.busy": "2026-10-02T14:46:49.097849Z",
     "iopub.status.idle": "2026-10-02T14:46:50.313392Z",
     "shell.execute_reply": "2026-10-02T14:46:50.312885Z"
    },
    "papermill": {
     "duration": 1.219789,
     "end_time": "2026-10-02T14:46:50.314014+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:49.094225+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1790952410.303241] [runnervm8df0l:10776:0]        ib_iface.c:1269 UCX  ERROR mana_0: iface 0x55a7e3f493b0 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"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "[runnervm8df0l:10776] pml_ucx.c:313  Error: Failed to create UCP worker\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'tgt' <class ExecComp>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1790952410.303493] [runnervm8df0l:10776:0]      ucp_worker.c:1412 UCX  ERROR uct_iface_open(ud_verbs/mana_0:1) failed: Input/output error\n"
     ]
    }
   ],
   "source": [
    "prob = om.Problem()\n",
    "prob.model.add_subsystem('tgt', om.ExecComp('y = 3 * x', x={'units': 'unitless'}))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "454347a5",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:50.328592Z",
     "iopub.status.busy": "2026-10-02T14:46:50.328407Z",
     "iopub.status.idle": "2026-10-02T14:46:50.332109Z",
     "shell.execute_reply": "2026-10-02T14:46:50.331629Z"
    },
    "papermill": {
     "duration": 0.011354,
     "end_time": "2026-10-02T14:46:50.332533+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:50.321179+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'tgt' <class ExecComp>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "prob = om.Problem()\n",
    "prob.model.add_subsystem('tgt', om.ExecComp('y = 3 * x', x={'units': None}))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "34ab9c3b",
   "metadata": {
    "papermill": {
     "duration": 0.004278,
     "end_time": "2026-10-02T14:46:50.341320+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:50.337042+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "### Add a subsystem to a Group\n",
    "\n",
    "`````{tab-set}\n",
    "````{tab-item} OpenMDAO 2.x\n",
    "```\n",
    "indeps = prob.model.add('indeps', om.IndepVarComp())\n",
    "```\n",
    "````\n",
    "\n",
    "````{tab-item} OpenMDAO 3.0\n",
    "```\n",
    "prob.model.add_subsystem('parab', Paraboloid(), promotes_inputs=['x', 'y'])\n",
    "```\n",
    "````\n",
    "`````\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "4d30cb44",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:50.354518Z",
     "iopub.status.busy": "2026-10-02T14:46:50.354311Z",
     "iopub.status.idle": "2026-10-02T14:46:50.357491Z",
     "shell.execute_reply": "2026-10-02T14:46:50.356909Z"
    },
    "papermill": {
     "duration": 0.010826,
     "end_time": "2026-10-02T14:46:50.358061+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:50.347235+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "# This will result in an AttributeError\n",
    "# prob = om.Problem()\n",
    "# indeps = prob.model.add('indeps', om.IndepVarComp())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "472e6aa9",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:50.369471Z",
     "iopub.status.busy": "2026-10-02T14:46:50.369301Z",
     "iopub.status.idle": "2026-10-02T14:46:50.374646Z",
     "shell.execute_reply": "2026-10-02T14:46:50.373973Z"
    },
    "papermill": {
     "duration": 0.011628,
     "end_time": "2026-10-02T14:46:50.375155+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:50.363527+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'parab' <class Paraboloid>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from openmdao.test_suite.components.paraboloid import Paraboloid\n",
    "\n",
    "prob = om.Problem()\n",
    "prob.model.add_subsystem('parab', Paraboloid(), promotes_inputs=['x', 'y'])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "59cdce62",
   "metadata": {
    "papermill": {
     "duration": 0.011303,
     "end_time": "2026-10-02T14:46:50.391186+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:50.379883+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "### Add a linear or nonlinear solver to a Group\n",
    "\n",
    "`````{tab-set}\n",
    "````{tab-item} OpenMDAO 2.x\n",
    "```\n",
    "self.nl_solver = om.NewtonSolver()\n",
    "self.ln_solver = om.DirectSolver()\n",
    "```\n",
    "````\n",
    "\n",
    "````{tab-item} OpenMDAO 3.0\n",
    "```\n",
    "self.nonlinear_solver = om.NewtonSolver()\n",
    "self.linear_solver = om.DirectSolver()\n",
    "```\n",
    "````\n",
    "`````\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "9a034884",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:50.401646Z",
     "iopub.status.busy": "2026-10-02T14:46:50.401482Z",
     "iopub.status.idle": "2026-10-02T14:46:50.404113Z",
     "shell.execute_reply": "2026-10-02T14:46:50.403610Z"
    },
    "papermill": {
     "duration": 0.008569,
     "end_time": "2026-10-02T14:46:50.404556+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:50.395987+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "nl_solver = om.NewtonSolver()\n",
    "ln_solver = om.DirectSolver()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "f8824358",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:50.414527Z",
     "iopub.status.busy": "2026-10-02T14:46:50.414379Z",
     "iopub.status.idle": "2026-10-02T14:46:50.417388Z",
     "shell.execute_reply": "2026-10-02T14:46:50.416843Z"
    },
    "papermill": {
     "duration": 0.008676,
     "end_time": "2026-10-02T14:46:50.417887+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:50.409211+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "nonlinear_solver = om.NewtonSolver()\n",
    "linear_solver = om.DirectSolver()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "aac8d222",
   "metadata": {
    "papermill": {
     "duration": 0.005204,
     "end_time": "2026-10-02T14:46:50.428632+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:50.423428+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "### Declare an option with an explicit type\n",
    "\n",
    "`````{tab-set}\n",
    "````{tab-item} OpenMDAO 2.x\n",
    "```\n",
    "def initialize(self):\n",
    "    \"\"\"\n",
    "    Declare options.\n",
    "    \"\"\"\n",
    "    self.options.declare('vec_size', type_=int, default=1,\n",
    "                         desc='The number of points at which the vector magnitude is computed')\n",
    "```\n",
    "````\n",
    "\n",
    "````{tab-item} OpenMDAO 3.0\n",
    "```\n",
    "def initialize(self):\n",
    "    \"\"\"\n",
    "    Declare options.\n",
    "    \"\"\"\n",
    "    self.options.declare('vec_size', types=int, default=1,\n",
    "                         desc='The number of points at which the vector magnitude is computed')\n",
    "```\n",
    "````\n",
    "`````\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "dbe0a2f7",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:50.489008Z",
     "iopub.status.busy": "2026-10-02T14:46:50.488783Z",
     "iopub.status.idle": "2026-10-02T14:46:50.492750Z",
     "shell.execute_reply": "2026-10-02T14:46:50.491842Z"
    },
    "papermill": {
     "duration": 0.057644,
     "end_time": "2026-10-02T14:46:50.493286+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:50.435642+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "def initialize(self):\n",
    "    \"\"\"\n",
    "    Declare options.\n",
    "    \"\"\"\n",
    "    self.options.declare('vec_size', type_=int, default=1,\n",
    "                         desc='The number of points at which the vector magnitude is computed')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "68e08cd7",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:50.501113Z",
     "iopub.status.busy": "2026-10-02T14:46:50.500960Z",
     "iopub.status.idle": "2026-10-02T14:46:50.503464Z",
     "shell.execute_reply": "2026-10-02T14:46:50.502805Z"
    },
    "papermill": {
     "duration": 0.006897,
     "end_time": "2026-10-02T14:46:50.503923+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:50.497026+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "def initialize(self):\n",
    "    \"\"\"\n",
    "    Declare options.\n",
    "    \"\"\"\n",
    "    self.options.declare('vec_size', types=int, default=1,\n",
    "                         desc='The number of points at which the vector magnitude is computed')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f2e69960",
   "metadata": {
    "papermill": {
     "duration": 0.003307,
     "end_time": "2026-10-02T14:46:50.510529+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:50.507222+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "## Component Library\n",
    "### Create an interpolating component using Akima spline with uniform grid\n",
    "\n",
    "`````{tab-set}\n",
    "````{tab-item} OpenMDAO 2.x\n",
    "```\n",
    "import openmdao.api as om\n",
    "\n",
    "ycp = np.array([5.0, 12.0, 14.0, 16.0, 21.0, 29.0])\n",
    "ncp = len(ycp)\n",
    "n = 11\n",
    "\n",
    "prob = om.Problem()\n",
    "\n",
    "comp = om.AkimaSplineComp(num_control_points=ncp, num_points=n,\n",
    "                          name='chord')\n",
    "\n",
    "prob.model.add_subsystem('comp1', comp)\n",
    "\n",
    "prob.setup()\n",
    "prob['akima.chord:y_cp'] = ycp.reshape((1, ncp))\n",
    "prob.run_model()\n",
    "```\n",
    "````\n",
    "\n",
    "````{tab-item} OpenMDAO 3.0\n",
    "```\n",
    "ycp = np.array([5.0, 12.0, 14.0, 16.0, 21.0, 29.0])\n",
    "ncp = len(ycp)\n",
    "n = 11\n",
    "\n",
    "prob = om.Problem()\n",
    "\n",
    "akima_option = {'delta_x': 0.1}\n",
    "comp = om.SplineComp(method='akima', num_cp=ncp, x_interp_val=np.linspace(0.0, 1.0, n),\n",
    "                     interp_options=akima_option)\n",
    "\n",
    "prob.model.add_subsystem('comp1', comp)\n",
    "\n",
    "comp.add_spline(y_cp_name='chord_cp', y_interp_name='chord', y_cp_val=ycp)\n",
    "\n",
    "prob.setup()\n",
    "prob.run_model()\n",
    "```\n",
    "````\n",
    "`````\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "97dd8928",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:50.517762Z",
     "iopub.status.busy": "2026-10-02T14:46:50.517561Z",
     "iopub.status.idle": "2026-10-02T14:46:50.520064Z",
     "shell.execute_reply": "2026-10-02T14:46:50.519501Z"
    },
    "papermill": {
     "duration": 0.006826,
     "end_time": "2026-10-02T14:46:50.520569+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:50.513743+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "# import numpy as np\n",
    "# AkimaSplineComp is no longer a valid class\n",
    "\n",
    "\n",
    "# ycp = np.array([5.0, 12.0, 14.0, 16.0, 21.0, 29.0])\n",
    "# ncp = len(ycp)\n",
    "# n = 11\n",
    "\n",
    "# prob = om.Problem()\n",
    "\n",
    "# comp = om.AkimaSplineComp(num_control_points=ncp, num_points=n,\n",
    "#                           name='chord')\n",
    "\n",
    "# prob.model.add_subsystem('comp1', comp)\n",
    "\n",
    "# prob.setup()\n",
    "# prob['akima.chord:y_cp'] = ycp.reshape((1, ncp))\n",
    "# prob.run_model()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "9335b817",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:50.527755Z",
     "iopub.status.busy": "2026-10-02T14:46:50.527562Z",
     "iopub.status.idle": "2026-10-02T14:46:50.538551Z",
     "shell.execute_reply": "2026-10-02T14:46:50.537990Z"
    },
    "papermill": {
     "duration": 0.015258,
     "end_time": "2026-10-02T14:46:50.539000+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:50.523742+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "\n",
    "ycp = np.array([5.0, 12.0, 14.0, 16.0, 21.0, 29.0])\n",
    "ncp = len(ycp)\n",
    "n = 11\n",
    "\n",
    "prob = om.Problem()\n",
    "\n",
    "akima_option = {'delta_x': 0.1}\n",
    "comp = om.SplineComp(method='akima', num_cp=ncp, x_interp_val=np.linspace(0.0, 1.0, n),\n",
    "                     interp_options=akima_option)\n",
    "\n",
    "prob.model.add_subsystem('comp1', comp)\n",
    "\n",
    "comp.add_spline(y_cp_name='chord_cp', y_interp_name='chord', y_cp_val=ycp)\n",
    "\n",
    "prob.setup()\n",
    "prob.run_model()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "06820df9",
   "metadata": {
    "papermill": {
     "duration": 0.003194,
     "end_time": "2026-10-02T14:46:50.545556+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:50.542362+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "### Create an interpolating component using Akima spline with custom grid\n",
    "\n",
    "`````{tab-set}\n",
    "````{tab-item} OpenMDAO 2.x\n",
    "```\n",
    "xcp = np.array([1.0, 2.0, 4.0, 6.0, 10.0, 12.0])\n",
    "ycp = np.array([5.0, 12.0, 14.0, 16.0, 21.0, 29.0])\n",
    "ncp = len(xcp)\n",
    "n = 50\n",
    "x = np.linspace(1.0, 12.0, n)\n",
    "\n",
    "prob = om.Problem()\n",
    "\n",
    "comp = om.AkimaSplineComp(num_control_points=ncp, num_points=n,\n",
    "                          name='chord', input_x=True,\n",
    "                          input_xcp=True)\n",
    "\n",
    "prob.model.add_subsystem('akima', comp)\n",
    "\n",
    "prob.setup(force_alloc_complex=True)\n",
    "\n",
    "prob['akima.chord:x_cp'] = xcp\n",
    "prob['akima.chord:y_cp'] = ycp.reshape((1, ncp))\n",
    "prob['akima.chord:x'] = x\n",
    "\n",
    "prob.run_model()\n",
    "```\n",
    "````\n",
    "\n",
    "````{tab-item} OpenMDAO 3.0\n",
    "```\n",
    "xcp = np.array([1.0, 2.0, 4.0, 6.0, 10.0, 12.0])\n",
    "ycp = np.array([5.0, 12.0, 14.0, 16.0, 21.0, 29.0])\n",
    "n = 50\n",
    "x = np.linspace(1.0, 12.0, n)\n",
    "\n",
    "prob = om.Problem()\n",
    "\n",
    "akima_option = {'delta_x': 0.1}\n",
    "comp = om.SplineComp(method='akima', x_cp_val=xcp, x_interp_val=x,\n",
    "                     interp_options=akima_option)\n",
    "\n",
    "prob.model.add_subsystem('akima1', comp)\n",
    "\n",
    "comp.add_spline(y_cp_name='ycp', y_interp_name='y_val', y_cp_val=ycp)\n",
    "\n",
    "prob.setup(force_alloc_complex=True)\n",
    "prob.run_model()\n",
    "```\n",
    "````\n",
    "`````\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "6b4e973c",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:50.552819Z",
     "iopub.status.busy": "2026-10-02T14:46:50.552633Z",
     "iopub.status.idle": "2026-10-02T14:46:50.555598Z",
     "shell.execute_reply": "2026-10-02T14:46:50.554912Z"
    },
    "papermill": {
     "duration": 0.007224,
     "end_time": "2026-10-02T14:46:50.556031+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:50.548807+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "# AkimaSplineComp is no longer a valid class\n",
    "\n",
    "\n",
    "# xcp = np.array([1.0, 2.0, 4.0, 6.0, 10.0, 12.0])\n",
    "# ycp = np.array([5.0, 12.0, 14.0, 16.0, 21.0, 29.0])\n",
    "# ncp = len(xcp)\n",
    "# n = 50\n",
    "# x = np.linspace(1.0, 12.0, n)\n",
    "\n",
    "# prob = om.Problem()\n",
    "\n",
    "# comp = om.AkimaSplineComp(num_control_points=ncp, num_points=n,\n",
    "#                           name='chord', input_x=True,\n",
    "#                           input_xcp=True)\n",
    "\n",
    "# prob.model.add_subsystem('akima', comp)\n",
    "\n",
    "# prob.setup(force_alloc_complex=True)\n",
    "\n",
    "# prob['akima.chord:x_cp'] = xcp\n",
    "# prob['akima.chord:y_cp'] = ycp.reshape((1, ncp))\n",
    "# prob['akima.chord:x'] = x\n",
    "\n",
    "# prob.run_model()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "20a077ba",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:50.563450Z",
     "iopub.status.busy": "2026-10-02T14:46:50.563322Z",
     "iopub.status.idle": "2026-10-02T14:46:50.572938Z",
     "shell.execute_reply": "2026-10-02T14:46:50.572161Z"
    },
    "papermill": {
     "duration": 0.014163,
     "end_time": "2026-10-02T14:46:50.573399+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:50.559236+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "xcp = np.array([1.0, 2.0, 4.0, 6.0, 10.0, 12.0])\n",
    "ycp = np.array([5.0, 12.0, 14.0, 16.0, 21.0, 29.0])\n",
    "n = 50\n",
    "x = np.linspace(1.0, 12.0, n)\n",
    "\n",
    "prob = om.Problem()\n",
    "\n",
    "akima_option = {'delta_x': 0.1}\n",
    "comp = om.SplineComp(method='akima', x_cp_val=xcp, x_interp_val=x,\n",
    "                     interp_options=akima_option)\n",
    "\n",
    "prob.model.add_subsystem('akima1', comp)\n",
    "\n",
    "comp.add_spline(y_cp_name='ycp', y_interp_name='y_val', y_cp_val=ycp)\n",
    "\n",
    "prob.setup(force_alloc_complex=True)\n",
    "prob.run_model()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1b3702ac",
   "metadata": {
    "papermill": {
     "duration": 0.003201,
     "end_time": "2026-10-02T14:46:50.579840+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:50.576639+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "### Create an interpolating component using Bsplines\n",
    "\n",
    "`````{tab-set}\n",
    "````{tab-item} OpenMDAO 2.x\n",
    "```\n",
    "prob = om.Problem()\n",
    "model = prob.model\n",
    "\n",
    "n_cp = 5\n",
    "n_point = 10\n",
    "\n",
    "t = np.linspace(0, 0.5*np.pi, n_cp)\n",
    "x = np.empty((2, n_cp))\n",
    "x[0, :] = np.sin(t)\n",
    "x[1, :] = 2.0*np.sin(t)\n",
    "\n",
    "comp = om.BsplinesComp(num_control_points=n_cp,\n",
    "                       num_points=n_point,\n",
    "                       bspline_order=4,\n",
    "                       distribution='sine',\n",
    "                       vec_size=2,\n",
    "                       in_name='h_cp',\n",
    "                       out_name='h')\n",
    "\n",
    "model.add_subsystem('interp', comp)\n",
    "\n",
    "prob.setup()\n",
    "prob.run_model()\n",
    "```\n",
    "````\n",
    "\n",
    "````{tab-item} OpenMDAO 3.0\n",
    "```\n",
    "from openmdao.utils.spline_distributions import sine_distribution\n",
    "\n",
    "prob = om.Problem()\n",
    "model = prob.model\n",
    "\n",
    "n_cp = 5\n",
    "n_point = 10\n",
    "\n",
    "t = np.linspace(0, 0.5 * np.pi, n_cp)\n",
    "x = np.empty((2, n_cp))\n",
    "x[0, :] = np.sin(t)\n",
    "x[1, :] = 2.0 * np.sin(t)\n",
    "\n",
    "# In 2.x, the BsplinesComp had a built-in sinusoidal distribution.\n",
    "t_sin = sine_distribution(n_point) * np.pi * 0.5\n",
    "\n",
    "bspline_options = {'order': 4}\n",
    "comp = om.SplineComp(method='bsplines',\n",
    "                     x_interp_val=t_sin,\n",
    "                     num_cp=n_cp,\n",
    "                     vec_size=2,\n",
    "                     interp_options=bspline_options)\n",
    "\n",
    "prob.model.add_subsystem('interp', comp)\n",
    "\n",
    "comp.add_spline(y_cp_name='h_cp', y_interp_name='h', y_cp_val=x, y_units='km')\n",
    "\n",
    "prob.setup()\n",
    "prob.run_model()\n",
    "```\n",
    "````\n",
    "`````\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "3ae33b39",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:50.587200Z",
     "iopub.status.busy": "2026-10-02T14:46:50.587074Z",
     "iopub.status.idle": "2026-10-02T14:46:50.589650Z",
     "shell.execute_reply": "2026-10-02T14:46:50.589074Z"
    },
    "papermill": {
     "duration": 0.007202,
     "end_time": "2026-10-02T14:46:50.590284+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:50.583082+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "# BSplineComp is no longer a valid class\n",
    "\n",
    "# prob = om.Problem()\n",
    "# model = prob.model\n",
    "\n",
    "# n_cp = 5\n",
    "# n_point = 10\n",
    "\n",
    "# t = np.linspace(0, 0.5*np.pi, n_cp)\n",
    "# x = np.empty((2, n_cp))\n",
    "# x[0, :] = np.sin(t)\n",
    "# x[1, :] = 2.0*np.sin(t)\n",
    "\n",
    "# comp = om.BsplinesComp(num_control_points=n_cp,\n",
    "#                        num_points=n_point,\n",
    "#                        bspline_order=4,\n",
    "#                        distribution='sine',\n",
    "#                        vec_size=2,\n",
    "#                        in_name='h_cp',\n",
    "#                        out_name='h')\n",
    "\n",
    "# model.add_subsystem('interp', comp)\n",
    "\n",
    "# prob.setup()\n",
    "# prob.run_model()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "76db9b92",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:50.602349Z",
     "iopub.status.busy": "2026-10-02T14:46:50.602201Z",
     "iopub.status.idle": "2026-10-02T14:46:50.608958Z",
     "shell.execute_reply": "2026-10-02T14:46:50.608408Z"
    },
    "papermill": {
     "duration": 0.012705,
     "end_time": "2026-10-02T14:46:50.609389+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:50.596684+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "from openmdao.utils.spline_distributions import sine_distribution\n",
    "\n",
    "prob = om.Problem()\n",
    "model = prob.model\n",
    "\n",
    "n_cp = 5\n",
    "n_point = 10\n",
    "\n",
    "t = np.linspace(0, 0.5 * np.pi, n_cp)\n",
    "x = np.empty((2, n_cp))\n",
    "x[0, :] = np.sin(t)\n",
    "x[1, :] = 2.0 * np.sin(t)\n",
    "\n",
    "# In 2.x, the BsplinesComp had a built-in sinusoidal distribution.\n",
    "t_sin = sine_distribution(n_point) * np.pi * 0.5\n",
    "\n",
    "bspline_options = {'order': 4}\n",
    "comp = om.SplineComp(method='bsplines',\n",
    "                     x_interp_val=t_sin,\n",
    "                     num_cp=n_cp,\n",
    "                     vec_size=2,\n",
    "                     interp_options=bspline_options)\n",
    "\n",
    "prob.model.add_subsystem('interp', comp)\n",
    "\n",
    "comp.add_spline(y_cp_name='h_cp', y_interp_name='h', y_cp_val=x, y_units='km')\n",
    "\n",
    "prob.setup()\n",
    "prob.run_model()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5baf99ed",
   "metadata": {
    "papermill": {
     "duration": 0.045835,
     "end_time": "2026-10-02T14:46:50.660308+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:50.614473+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "### Create an ExecComp with diagonal partials\n",
    "\n",
    "`````{tab-set}\n",
    "````{tab-item} OpenMDAO 2.x\n",
    "```\n",
    "model.add_subsystem('comp', ExecComp('y=3.0*x + 2.5',\n",
    "                                     vectorize=True,\n",
    "                                     x=np.ones(5), y=np.ones(5)))\n",
    "```\n",
    "````\n",
    "\n",
    "````{tab-item} OpenMDAO 3.0\n",
    "```\n",
    "model.add_subsystem('comp', om.ExecComp('y=3.0*x + 2.5',\n",
    "                                        has_diag_partials=True,\n",
    "                                        x=np.ones(5), y=np.ones(5)))\n",
    "```\n",
    "````\n",
    "`````\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "59fdfeb1",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:50.671538Z",
     "iopub.status.busy": "2026-10-02T14:46:50.671313Z",
     "iopub.status.idle": "2026-10-02T14:46:50.676231Z",
     "shell.execute_reply": "2026-10-02T14:46:50.675637Z"
    },
    "papermill": {
     "duration": 0.011398,
     "end_time": "2026-10-02T14:46:50.676846+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:50.665448+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'comp' <class ExecComp>"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p = om.Problem()\n",
    "model = p.model\n",
    "\n",
    "model.add_subsystem('comp', om.ExecComp('y=3.0*x + 2.5',\n",
    "                                     vectorize=True,\n",
    "                                     x=np.ones(5), y=np.ones(5)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "5ecf4b94",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:50.687142Z",
     "iopub.status.busy": "2026-10-02T14:46:50.686969Z",
     "iopub.status.idle": "2026-10-02T14:46:50.692132Z",
     "shell.execute_reply": "2026-10-02T14:46:50.691550Z"
    },
    "papermill": {
     "duration": 0.011068,
     "end_time": "2026-10-02T14:46:50.692595+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:50.681527+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'comp' <class ExecComp>"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p = om.Problem()\n",
    "model = p.model\n",
    "\n",
    "model.add_subsystem('comp', om.ExecComp('y=3.0*x + 2.5',\n",
    "                                        has_diag_partials=True,\n",
    "                                        x=np.ones(5), y=np.ones(5)))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0de10b7a",
   "metadata": {
    "papermill": {
     "duration": 0.006352,
     "end_time": "2026-10-02T14:46:50.703974+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:50.697622+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "### Create an IndepVarComp with multiple outputs\n",
    "\n",
    "`````{tab-set}\n",
    "````{tab-item} OpenMDAO 2.x\n",
    "```\n",
    "comp = om.IndepVarComp((\n",
    "    ('indep_var_1', 1.0, {'lower': 0, 'upper': 10}),\n",
    "    ('indep_var_2', 2.0, {'lower': 1., 'upper': 20}),\n",
    "))\n",
    "```\n",
    "````\n",
    "\n",
    "````{tab-item} OpenMDAO 3.0\n",
    "```\n",
    "comp = om.IndepVarComp()\n",
    "comp.add_output('indep_var_1', val=1.0)\n",
    "comp.add_output('indep_var_2', val=2.0)\n",
    "```\n",
    "````\n",
    "`````\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "857fee03",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:50.718283Z",
     "iopub.status.busy": "2026-10-02T14:46:50.718143Z",
     "iopub.status.idle": "2026-10-02T14:46:50.720993Z",
     "shell.execute_reply": "2026-10-02T14:46:50.720460Z"
    },
    "papermill": {
     "duration": 0.01038,
     "end_time": "2026-10-02T14:46:50.721550+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:50.711170+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "# comp = om.IndepVarComp((\n",
    "#     ('indep_var_1', 1.0, {'lower': 0, 'upper': 10}),\n",
    "#     ('indep_var_2', 2.0, {'lower': 1., 'upper': 20}),\n",
    "# ))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "523f9d1d",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:50.770025Z",
     "iopub.status.busy": "2026-10-02T14:46:50.769865Z",
     "iopub.status.idle": "2026-10-02T14:46:50.773600Z",
     "shell.execute_reply": "2026-10-02T14:46:50.772978Z"
    },
    "papermill": {
     "duration": 0.045098,
     "end_time": "2026-10-02T14:46:50.774193+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:50.729095+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'val': array([2.]),\n",
       " 'shape': (1,),\n",
       " 'size': 1,\n",
       " 'units': None,\n",
       " 'res_units': None,\n",
       " 'desc': '',\n",
       " 'distributed': False,\n",
       " 'tags': {'openmdao:allow_desvar', 'openmdao:indep_var'},\n",
       " 'ref': 1.0,\n",
       " 'ref0': 0.0,\n",
       " 'res_ref': 1.0,\n",
       " 'lower': None,\n",
       " 'upper': None,\n",
       " 'shape_by_conn': False,\n",
       " 'compute_shape': None,\n",
       " 'copy_shape': None,\n",
       " 'units_by_conn': False,\n",
       " 'compute_units': None,\n",
       " 'copy_units': None}"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "comp = om.IndepVarComp()\n",
    "comp.add_output('indep_var_1', val=1.0)\n",
    "comp.add_output('indep_var_2', val=2.0)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5a6cfd8b",
   "metadata": {
    "papermill": {
     "duration": 0.003534,
     "end_time": "2026-10-02T14:46:50.781404+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:50.777870+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "### Create an ExternalCodeComp\n",
    "\n",
    "`````{tab-set}\n",
    "````{tab-item} OpenMDAO 2.x\n",
    "```\n",
    "class ParaboloidExternalCodeCompDerivs(om.ExternalCode):\n",
    "```\n",
    "````\n",
    "\n",
    "````{tab-item} OpenMDAO 3.0\n",
    "```\n",
    "class ParaboloidExternalCodeCompDerivs(om.ExternalCodeComp):\n",
    "```\n",
    "````\n",
    "`````\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "6364103e",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:50.789297Z",
     "iopub.status.busy": "2026-10-02T14:46:50.789088Z",
     "iopub.status.idle": "2026-10-02T14:46:50.791566Z",
     "shell.execute_reply": "2026-10-02T14:46:50.790948Z"
    },
    "papermill": {
     "duration": 0.0072,
     "end_time": "2026-10-02T14:46:50.792050+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:50.784850+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "# class ParaboloidExternalCodeCompDerivs(om.ExternalCode):\n",
    "#     pass"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "e299d51f",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:50.799783Z",
     "iopub.status.busy": "2026-10-02T14:46:50.799576Z",
     "iopub.status.idle": "2026-10-02T14:46:50.802297Z",
     "shell.execute_reply": "2026-10-02T14:46:50.801558Z"
    },
    "papermill": {
     "duration": 0.007586,
     "end_time": "2026-10-02T14:46:50.802984+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:50.795398+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "class ParaboloidExternalCodeCompDerivs(om.ExternalCodeComp):\n",
    "    pass"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8821a1eb",
   "metadata": {
    "papermill": {
     "duration": 0.003389,
     "end_time": "2026-10-02T14:46:50.809800+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:50.806411+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "### Create a KSComponent\n",
    "\n",
    "`````{tab-set}\n",
    "````{tab-item} OpenMDAO 2.x\n",
    "```\n",
    "model.add_subsystem('ks', om.KSComponent(width=2))\n",
    "```\n",
    "````\n",
    "\n",
    "````{tab-item} OpenMDAO 3.0\n",
    "```\n",
    "model.add_subsystem('ks', om.KSComp(width=2))\n",
    "```\n",
    "````\n",
    "`````\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "b57be3bc",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:50.817921Z",
     "iopub.status.busy": "2026-10-02T14:46:50.817778Z",
     "iopub.status.idle": "2026-10-02T14:46:50.820060Z",
     "shell.execute_reply": "2026-10-02T14:46:50.819411Z"
    },
    "papermill": {
     "duration": 0.007334,
     "end_time": "2026-10-02T14:46:50.820577+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:50.813243+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "# model = om.Problem().model\n",
    "# model.add_subsystem('ks', om.KSComponent(width=2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "dc457f01",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:50.828396Z",
     "iopub.status.busy": "2026-10-02T14:46:50.828266Z",
     "iopub.status.idle": "2026-10-02T14:46:50.831860Z",
     "shell.execute_reply": "2026-10-02T14:46:50.831070Z"
    },
    "papermill": {
     "duration": 0.008133,
     "end_time": "2026-10-02T14:46:50.832308+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:50.824175+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'ks' <class KSComp>"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model = om.Problem().model\n",
    "model.add_subsystem('ks', om.KSComp(width=2))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "025ec6d1",
   "metadata": {
    "papermill": {
     "duration": 0.003544,
     "end_time": "2026-10-02T14:46:50.839315+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:50.835771+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "### Create a MetaModel\n",
    "\n",
    "`````{tab-set}\n",
    "````{tab-item} OpenMDAO 2.x\n",
    "```\n",
    "sin_mm = om.MetaModel()\n",
    "```\n",
    "````\n",
    "\n",
    "````{tab-item} OpenMDAO 3.0\n",
    "```\n",
    "sin_mm = om.MetaModelUnStructuredComp()\n",
    "```\n",
    "````\n",
    "`````\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "f2cef68c",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:50.886963Z",
     "iopub.status.busy": "2026-10-02T14:46:50.886689Z",
     "iopub.status.idle": "2026-10-02T14:46:50.889286Z",
     "shell.execute_reply": "2026-10-02T14:46:50.888718Z"
    },
    "papermill": {
     "duration": 0.007479,
     "end_time": "2026-10-02T14:46:50.889855+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:50.882376+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "# sin_mm = om.MetaModel()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "b05850ed",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:50.904691Z",
     "iopub.status.busy": "2026-10-02T14:46:50.904561Z",
     "iopub.status.idle": "2026-10-02T14:46:50.906862Z",
     "shell.execute_reply": "2026-10-02T14:46:50.906206Z"
    },
    "papermill": {
     "duration": 0.009724,
     "end_time": "2026-10-02T14:46:50.907315+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:50.897591+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "sin_mm = om.MetaModelUnStructuredComp()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a68d937d",
   "metadata": {
    "papermill": {
     "duration": 0.004808,
     "end_time": "2026-10-02T14:46:50.940442+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:50.935634+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "### Create a MetaModelUnstructured\n",
    "\n",
    "`````{tab-set}\n",
    "````{tab-item} OpenMDAO 2.x\n",
    "```\n",
    "sin_mm = om.MetaModelUnstructured()\n",
    "```\n",
    "````\n",
    "\n",
    "````{tab-item} OpenMDAO 3.0\n",
    "```\n",
    "sin_mm = om.MetaModelUnStructuredComp()\n",
    "```\n",
    "````\n",
    "`````\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "a834fe85",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:50.950850Z",
     "iopub.status.busy": "2026-10-02T14:46:50.950678Z",
     "iopub.status.idle": "2026-10-02T14:46:50.952988Z",
     "shell.execute_reply": "2026-10-02T14:46:50.952342Z"
    },
    "papermill": {
     "duration": 0.00821,
     "end_time": "2026-10-02T14:46:50.953522+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:50.945312+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "# sin_mm = om.MetaModelUnstructured()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "257a34f1",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:50.964130Z",
     "iopub.status.busy": "2026-10-02T14:46:50.963970Z",
     "iopub.status.idle": "2026-10-02T14:46:50.966345Z",
     "shell.execute_reply": "2026-10-02T14:46:50.965828Z"
    },
    "papermill": {
     "duration": 0.008252,
     "end_time": "2026-10-02T14:46:50.966987+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:50.958735+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "sin_mm = om.MetaModelUnStructuredComp()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3b017a24",
   "metadata": {
    "papermill": {
     "duration": 0.003538,
     "end_time": "2026-10-02T14:46:50.975204+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:50.971666+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "### Create a MetaModelStructured\n",
    "\n",
    "`````{tab-set}\n",
    "````{tab-item} OpenMDAO 2.x\n",
    "```\n",
    "interp = om.MetaModelStructured(method='scipy_cubic', vec_size=2)\n",
    "```\n",
    "````\n",
    "\n",
    "````{tab-item} OpenMDAO 3.0\n",
    "```\n",
    "interp = om.MetaModelStructuredComp(method='scipy_cubic', vec_size=2)\n",
    "```\n",
    "````\n",
    "`````\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "9c9f87eb",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:50.983129Z",
     "iopub.status.busy": "2026-10-02T14:46:50.983013Z",
     "iopub.status.idle": "2026-10-02T14:46:50.987845Z",
     "shell.execute_reply": "2026-10-02T14:46:50.984773Z"
    },
    "papermill": {
     "duration": 0.009447,
     "end_time": "2026-10-02T14:46:50.988416+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:50.978969+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "# interp = om.MetaModelStructured(method='scipy_cubic', vec_size=2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "afb157de",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:51.000281Z",
     "iopub.status.busy": "2026-10-02T14:46:51.000123Z",
     "iopub.status.idle": "2026-10-02T14:46:51.003369Z",
     "shell.execute_reply": "2026-10-02T14:46:51.002775Z"
    },
    "papermill": {
     "duration": 0.013173,
     "end_time": "2026-10-02T14:46:51.006186+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:50.993013+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "interp = om.MetaModelStructuredComp(method='scipy_cubic', vec_size=2)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "98bdff16",
   "metadata": {
    "papermill": {
     "duration": 0.005278,
     "end_time": "2026-10-02T14:46:51.016517+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:51.011239+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "### Create a MultiFiMetaModel\n",
    "\n",
    "`````{tab-set}\n",
    "````{tab-item} OpenMDAO 2.x\n",
    "```\n",
    "mm = om.MultiFiMetaModel(nfi=2)\n",
    "```\n",
    "````\n",
    "\n",
    "````{tab-item} OpenMDAO 3.0\n",
    "```\n",
    "mm = om.MultiFiMetaModelUnStructuredComp(nfi=2)\n",
    "```\n",
    "````\n",
    "`````\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "76e03ce4",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:51.029969Z",
     "iopub.status.busy": "2026-10-02T14:46:51.029766Z",
     "iopub.status.idle": "2026-10-02T14:46:51.032106Z",
     "shell.execute_reply": "2026-10-02T14:46:51.031603Z"
    },
    "papermill": {
     "duration": 0.009979,
     "end_time": "2026-10-02T14:46:51.032541+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:51.022562+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "# mm = om.MultiFiMetaModel(nfi=2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "52e9dfcc",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:51.046004Z",
     "iopub.status.busy": "2026-10-02T14:46:51.045815Z",
     "iopub.status.idle": "2026-10-02T14:46:51.049107Z",
     "shell.execute_reply": "2026-10-02T14:46:51.048451Z"
    },
    "papermill": {
     "duration": 0.010665,
     "end_time": "2026-10-02T14:46:51.049574+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:51.038909+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "mm = om.MultiFiMetaModelUnStructuredComp(nfi=2)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bd2dd43e",
   "metadata": {
    "papermill": {
     "duration": 0.005582,
     "end_time": "2026-10-02T14:46:51.060793+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:51.055211+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "### Create a MultiFiMetaModelUnStructured\n",
    "\n",
    "`````{tab-set}\n",
    "````{tab-item} OpenMDAO 2.x\n",
    "```\n",
    "mm = om.MultiFiMetaModelUnStructured(nfi=2)\n",
    "```\n",
    "````\n",
    "\n",
    "````{tab-item} OpenMDAO 3.0\n",
    "```\n",
    "mm = om.MultiFiMetaModelUnStructuredComp(nfi=2)\n",
    "```\n",
    "````\n",
    "`````\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "3a88adf3",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:51.072870Z",
     "iopub.status.busy": "2026-10-02T14:46:51.072662Z",
     "iopub.status.idle": "2026-10-02T14:46:51.075889Z",
     "shell.execute_reply": "2026-10-02T14:46:51.075026Z"
    },
    "papermill": {
     "duration": 0.010456,
     "end_time": "2026-10-02T14:46:51.076438+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:51.065982+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "# mm = om.MultiFiMetaModelUnStructured(nfi=2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "0adf30bd",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:51.103440Z",
     "iopub.status.busy": "2026-10-02T14:46:51.103291Z",
     "iopub.status.idle": "2026-10-02T14:46:51.106211Z",
     "shell.execute_reply": "2026-10-02T14:46:51.105238Z"
    },
    "papermill": {
     "duration": 0.026084,
     "end_time": "2026-10-02T14:46:51.106874+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:51.080790+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "mm = om.MultiFiMetaModelUnStructuredComp(nfi=2)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6c3cd52a",
   "metadata": {
    "papermill": {
     "duration": 0.0335,
     "end_time": "2026-10-02T14:46:51.146254+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:51.112754+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "### Add a FloatKrigingSurrogate to a MetaModelStructuredComp\n",
    "\n",
    "`````{tab-set}\n",
    "````{tab-item} OpenMDAO 2.x\n",
    "```\n",
    "sin_mm.add_output('f_x', 0., surrogate=om.FloatKrigingSurrogate())\n",
    "```\n",
    "````\n",
    "\n",
    "````{tab-item} OpenMDAO 3.0\n",
    "```\n",
    "sin_mm.add_output('f_x', 0., surrogate=om.KrigingSurrogate())\n",
    "```\n",
    "````\n",
    "`````\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "7cc550b3",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:51.163797Z",
     "iopub.status.busy": "2026-10-02T14:46:51.163628Z",
     "iopub.status.idle": "2026-10-02T14:46:51.165972Z",
     "shell.execute_reply": "2026-10-02T14:46:51.165276Z"
    },
    "papermill": {
     "duration": 0.006954,
     "end_time": "2026-10-02T14:46:51.166390+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:51.159436+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "# sin_mm.add_output('f_x', 0., surrogate=om.FloatKrigingSurrogate())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "022a0186",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:51.353899Z",
     "iopub.status.busy": "2026-10-02T14:46:51.353560Z",
     "iopub.status.idle": "2026-10-02T14:46:51.359628Z",
     "shell.execute_reply": "2026-10-02T14:46:51.358821Z"
    },
    "papermill": {
     "duration": 0.015807,
     "end_time": "2026-10-02T14:46:51.360276+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:51.344469+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'val': array([0.]),\n",
       " 'shape': (1,),\n",
       " 'size': 1,\n",
       " 'units': None,\n",
       " 'res_units': None,\n",
       " 'desc': '',\n",
       " 'distributed': False,\n",
       " 'tags': set(),\n",
       " 'ref': 1.0,\n",
       " 'ref0': 0.0,\n",
       " 'res_ref': 1.0,\n",
       " 'lower': None,\n",
       " 'upper': None,\n",
       " 'shape_by_conn': False,\n",
       " 'compute_shape': None,\n",
       " 'copy_shape': None,\n",
       " 'units_by_conn': False,\n",
       " 'compute_units': None,\n",
       " 'copy_units': None,\n",
       " 'surrogate': <openmdao.surrogate_models.kriging.KrigingSurrogate at 0x7f3da82cd2b0>,\n",
       " 'default_surrogate': False,\n",
       " 'surrogate_name': 'KrigingSurrogate'}"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sin_mm.add_output('f_x', 0., surrogate=om.KrigingSurrogate())"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bc69c22f",
   "metadata": {
    "papermill": {
     "duration": 0.006272,
     "end_time": "2026-10-02T14:46:51.373113+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:51.366841+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "### Specify a default surrogate model for MetaModelStructuredComp\n",
    "\n",
    "`````{tab-set}\n",
    "````{tab-item} OpenMDAO 2.x\n",
    "```\n",
    "trig = om.MetaModelUnStructuredComp(vec_size=size)\n",
    "trig.default_surrogate = om.KrigingSurrogate()\n",
    "```\n",
    "````\n",
    "\n",
    "````{tab-item} OpenMDAO 3.0\n",
    "```\n",
    "trig = om.MetaModelUnStructuredComp(vec_size=size, default_surrogate=om.KrigingSurrogate())\n",
    "```\n",
    "````\n",
    "`````\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "4f75cc5b",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:51.387302Z",
     "iopub.status.busy": "2026-10-02T14:46:51.387044Z",
     "iopub.status.idle": "2026-10-02T14:46:51.390230Z",
     "shell.execute_reply": "2026-10-02T14:46:51.389563Z"
    },
    "papermill": {
     "duration": 0.011346,
     "end_time": "2026-10-02T14:46:51.390722+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:51.379376+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "trig = om.MetaModelUnStructuredComp(vec_size=2)\n",
    "trig.default_surrogate = om.KrigingSurrogate()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "e56127d5",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:51.404149Z",
     "iopub.status.busy": "2026-10-02T14:46:51.403945Z",
     "iopub.status.idle": "2026-10-02T14:46:51.406901Z",
     "shell.execute_reply": "2026-10-02T14:46:51.406259Z"
    },
    "papermill": {
     "duration": 0.011065,
     "end_time": "2026-10-02T14:46:51.407571+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:51.396506+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "trig = om.MetaModelUnStructuredComp(vec_size=2, default_surrogate=om.KrigingSurrogate())"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f0a6c4bf",
   "metadata": {
    "papermill": {
     "duration": 0.006429,
     "end_time": "2026-10-02T14:46:51.420233+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:51.413804+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "## Solvers\n",
    "### Declare a NewtonSolver with solve_subsystems set to False\n",
    "\n",
    "`````{tab-set}\n",
    "````{tab-item} OpenMDAO 2.x\n",
    "```\n",
    "newton = model.nonlinear_solver = om.NewtonSolver()\n",
    "```\n",
    "````\n",
    "\n",
    "````{tab-item} OpenMDAO 3.0\n",
    "```\n",
    "newton = model.nonlinear_solver = om.NewtonSolver(solve_subsystems=False)\n",
    "```\n",
    "````\n",
    "`````\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "e5072438",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:51.434212Z",
     "iopub.status.busy": "2026-10-02T14:46:51.434013Z",
     "iopub.status.idle": "2026-10-02T14:46:51.436709Z",
     "shell.execute_reply": "2026-10-02T14:46:51.436131Z"
    },
    "papermill": {
     "duration": 0.010706,
     "end_time": "2026-10-02T14:46:51.437353+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:51.426647+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "newton = model.nonlinear_solver = om.NewtonSolver()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "c1ba555a",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:51.450467Z",
     "iopub.status.busy": "2026-10-02T14:46:51.450280Z",
     "iopub.status.idle": "2026-10-02T14:46:51.453191Z",
     "shell.execute_reply": "2026-10-02T14:46:51.452484Z"
    },
    "papermill": {
     "duration": 0.010403,
     "end_time": "2026-10-02T14:46:51.453846+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:51.443443+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "newton = model.nonlinear_solver = om.NewtonSolver(solve_subsystems=False)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "232e2a11",
   "metadata": {
    "papermill": {
     "duration": 0.006028,
     "end_time": "2026-10-02T14:46:51.465970+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:51.459942+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "### Control how a solver handles an error raised in a subsolver\n",
    "\n",
    "`````{tab-set}\n",
    "````{tab-item} OpenMDAO 2.x\n",
    "```\n",
    "newton = model.nonlinear_solver = NewtonSolver()\n",
    "newton.options['maxiter'] = 1\n",
    "newton.options['err_on_maxiter'] = True\n",
    "```\n",
    "````\n",
    "\n",
    "````{tab-item} OpenMDAO 3.0\n",
    "```\n",
    "newton = model.nonlinear_solver = om.NewtonSolver(solve_subsystems=False)\n",
    "newton.options['maxiter'] = 1\n",
    "newton.options['err_on_non_converge'] = True\n",
    "```\n",
    "````\n",
    "`````\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "8d9a1c04",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:51.514611Z",
     "iopub.status.busy": "2026-10-02T14:46:51.514383Z",
     "iopub.status.idle": "2026-10-02T14:46:51.516939Z",
     "shell.execute_reply": "2026-10-02T14:46:51.516252Z"
    },
    "papermill": {
     "duration": 0.045593,
     "end_time": "2026-10-02T14:46:51.517508+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:51.471915+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "# newton = model.nonlinear_solver = om.NewtonSolver()\n",
    "# newton.options['maxiter'] = 1\n",
    "# newton.options['err_on_maxiter'] = True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "d2e8504a",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:51.529646Z",
     "iopub.status.busy": "2026-10-02T14:46:51.529492Z",
     "iopub.status.idle": "2026-10-02T14:46:51.531903Z",
     "shell.execute_reply": "2026-10-02T14:46:51.531534Z"
    },
    "papermill": {
     "duration": 0.009553,
     "end_time": "2026-10-02T14:46:51.532672+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:51.523119+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "newton = model.nonlinear_solver = om.NewtonSolver(solve_subsystems=False)\n",
    "newton.options['maxiter'] = 1\n",
    "newton.options['err_on_non_converge'] = True"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1026251e",
   "metadata": {
    "papermill": {
     "duration": 0.00556,
     "end_time": "2026-10-02T14:46:51.543795+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:51.538235+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "### Declare a BroydenSolver with the BoundsEnforceLS line search\n",
    "\n",
    "`````{tab-set}\n",
    "````{tab-item} OpenMDAO 2.x\n",
    "```\n",
    "model.circuit.nonlinear_solver = om.BroydenSolver()\n",
    "model.circuit.nonlinear_solver.linesearch = om.BoundsEnforceLS()\n",
    "```\n",
    "````\n",
    "\n",
    "````{tab-item} OpenMDAO 3.0\n",
    "```\n",
    "model.nonlinear_solver = om.BroydenSolver()\n",
    "```\n",
    "````\n",
    "`````\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "e32c1b20",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:51.555953Z",
     "iopub.status.busy": "2026-10-02T14:46:51.555781Z",
     "iopub.status.idle": "2026-10-02T14:46:51.558771Z",
     "shell.execute_reply": "2026-10-02T14:46:51.558308Z"
    },
    "papermill": {
     "duration": 0.009698,
     "end_time": "2026-10-02T14:46:51.559156+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:51.549458+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "model = om.Problem().model\n",
    "model.nonlinear_solver = om.BroydenSolver()\n",
    "model.nonlinear_solver.linesearch = om.BoundsEnforceLS()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "9a324c88",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:51.571000Z",
     "iopub.status.busy": "2026-10-02T14:46:51.570687Z",
     "iopub.status.idle": "2026-10-02T14:46:51.573577Z",
     "shell.execute_reply": "2026-10-02T14:46:51.573068Z"
    },
    "papermill": {
     "duration": 0.009354,
     "end_time": "2026-10-02T14:46:51.573989+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:51.564635+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "model = om.Problem().model\n",
    "model.nonlinear_solver = om.BroydenSolver()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b188ca15",
   "metadata": {
    "papermill": {
     "duration": 0.005495,
     "end_time": "2026-10-02T14:46:51.585355+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:51.579860+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "### Declare a NewtonSolver with the BoundsEnforceLS line search\n",
    "\n",
    "`````{tab-set}\n",
    "````{tab-item} OpenMDAO 2.x\n",
    "```\n",
    "newton = model.nonlinear_solver = om.NewtonSolver(solve_subsystems=False)\n",
    "newton.linesearch = om.BoundsEnforceLS()\n",
    "```\n",
    "````\n",
    "\n",
    "````{tab-item} OpenMDAO 3.0\n",
    "```\n",
    "model.nonlinear_solver = om.NewtonSolver(solve_subsystems=False)\n",
    "```\n",
    "````\n",
    "`````\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "4bdc46f5",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:51.627258Z",
     "iopub.status.busy": "2026-10-02T14:46:51.627077Z",
     "iopub.status.idle": "2026-10-02T14:46:51.630024Z",
     "shell.execute_reply": "2026-10-02T14:46:51.629565Z"
    },
    "papermill": {
     "duration": 0.011091,
     "end_time": "2026-10-02T14:46:51.630386+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:51.619295+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "model = om.Problem().model\n",
    "newton = model.nonlinear_solver = om.NewtonSolver(solve_subsystems=False)\n",
    "newton.linesearch = om.BoundsEnforceLS()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "49473e7f",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:51.667729Z",
     "iopub.status.busy": "2026-10-02T14:46:51.667529Z",
     "iopub.status.idle": "2026-10-02T14:46:51.670452Z",
     "shell.execute_reply": "2026-10-02T14:46:51.669876Z"
    },
    "papermill": {
     "duration": 0.035338,
     "end_time": "2026-10-02T14:46:51.671194+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:51.635856+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "model = om.Problem().model\n",
    "model.nonlinear_solver = om.NewtonSolver(solve_subsystems=False)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "333f50e3",
   "metadata": {
    "papermill": {
     "duration": 0.00568,
     "end_time": "2026-10-02T14:46:51.682482+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:51.676802+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "### Add a preconditioner to PETScKrylov\n",
    "\n",
    "`````{tab-set}\n",
    "````{tab-item} OpenMDAO 2.x\n",
    "```\n",
    "model.linear_solver = om.PETScKrylov()\n",
    "model.linear_solver.preconditioner = om.LinearBlockGS()\n",
    "```\n",
    "````\n",
    "\n",
    "````{tab-item} OpenMDAO 3.0\n",
    "```\n",
    "model.linear_solver = om.PETScKrylov()\n",
    "model.linear_solver.precon = om.LinearBlockGS()\n",
    "```\n",
    "````\n",
    "`````\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "34181dbe",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:51.695083Z",
     "iopub.status.busy": "2026-10-02T14:46:51.694903Z",
     "iopub.status.idle": "2026-10-02T14:46:51.730991Z",
     "shell.execute_reply": "2026-10-02T14:46:51.730366Z"
    },
    "papermill": {
     "duration": 0.043148,
     "end_time": "2026-10-02T14:46:51.731482+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:51.688334+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "model = om.Problem().model\n",
    "\n",
    "# This try/except block is for our CI testing\n",
    "try:\n",
    "    model.linear_solver = om.PETScKrylov()\n",
    "    model.linear_solver.preconditioner = om.LinearBlockGS()\n",
    "except RuntimeError:\n",
    "    pass"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "1072eb06",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:51.744217Z",
     "iopub.status.busy": "2026-10-02T14:46:51.743822Z",
     "iopub.status.idle": "2026-10-02T14:46:51.747108Z",
     "shell.execute_reply": "2026-10-02T14:46:51.746572Z"
    },
    "papermill": {
     "duration": 0.010328,
     "end_time": "2026-10-02T14:46:51.747813+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:51.737485+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "model = om.Problem().model\n",
    "\n",
    "try:\n",
    "    model.linear_solver = om.PETScKrylov()\n",
    "    model.linear_solver.precon = om.LinearBlockGS()\n",
    "except RuntimeError:\n",
    "    pass"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c8171486",
   "metadata": {
    "papermill": {
     "duration": 0.005943,
     "end_time": "2026-10-02T14:46:51.759265+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:51.753322+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "### Add a preconditioner to ScipyKrylov\n",
    "\n",
    "`````{tab-set}\n",
    "````{tab-item} OpenMDAO 2.x\n",
    "```\n",
    "model.linear_solver.preconditioner = om.LinearBlockGS()\n",
    "```\n",
    "````\n",
    "\n",
    "````{tab-item} OpenMDAO 3.0\n",
    "```\n",
    "model.linear_solver.precon = om.LinearBlockGS()\n",
    "```\n",
    "````\n",
    "`````\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "20ac64df",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:51.771190Z",
     "iopub.status.busy": "2026-10-02T14:46:51.771031Z",
     "iopub.status.idle": "2026-10-02T14:46:51.773866Z",
     "shell.execute_reply": "2026-10-02T14:46:51.773210Z"
    },
    "papermill": {
     "duration": 0.009459,
     "end_time": "2026-10-02T14:46:51.774295+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:51.764836+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "model = om.Problem().model\n",
    "\n",
    "model.linear_solver.preconditioner = om.LinearBlockGS()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "3b6fc318",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:51.786634Z",
     "iopub.status.busy": "2026-10-02T14:46:51.786382Z",
     "iopub.status.idle": "2026-10-02T14:46:51.789195Z",
     "shell.execute_reply": "2026-10-02T14:46:51.788529Z"
    },
    "papermill": {
     "duration": 0.009755,
     "end_time": "2026-10-02T14:46:51.789666+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:51.779911+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "model = om.Problem().model\n",
    "\n",
    "model.linear_solver.precon = om.LinearBlockGS()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7ac1ec8a",
   "metadata": {
    "papermill": {
     "duration": 0.005775,
     "end_time": "2026-10-02T14:46:51.801260+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:51.795485+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "### Add a ArmijoGoldsteinLS to a NewtonSolver\n",
    "\n",
    "`````{tab-set}\n",
    "````{tab-item} OpenMDAO 2.x\n",
    "```\n",
    "top.model.nonlinear_solver = om.NewtonSolver(solve_subsystems=False)\n",
    "top.model.nonlinear_solver.options['maxiter'] = 10\n",
    "top.model.linear_solver = om.ScipyKrylov()\n",
    "\n",
    "ls = top.model.nonlinear_solver.line_search = om.ArmijoGoldsteinLS(bound_enforcement='vector')\n",
    "```\n",
    "````\n",
    "\n",
    "````{tab-item} OpenMDAO 3.0\n",
    "```\n",
    "top.model.nonlinear_solver = om.NewtonSolver(solve_subsystems=False)\n",
    "top.model.nonlinear_solver.options['maxiter'] = 10\n",
    "top.model.linear_solver = om.ScipyKrylov()\n",
    "\n",
    "ls = top.model.nonlinear_solver.linesearch = om.ArmijoGoldsteinLS(bound_enforcement='vector')\n",
    "```\n",
    "````\n",
    "`````\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "id": "7696b30d",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:51.814080Z",
     "iopub.status.busy": "2026-10-02T14:46:51.813920Z",
     "iopub.status.idle": "2026-10-02T14:46:51.817735Z",
     "shell.execute_reply": "2026-10-02T14:46:51.817171Z"
    },
    "papermill": {
     "duration": 0.011362,
     "end_time": "2026-10-02T14:46:51.818505+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:51.807143+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "top = om.Problem()\n",
    "\n",
    "top.model.nonlinear_solver = om.NewtonSolver(solve_subsystems=False)\n",
    "top.model.nonlinear_solver.options['maxiter'] = 10\n",
    "top.model.linear_solver = om.ScipyKrylov()\n",
    "\n",
    "ls = top.model.nonlinear_solver.line_search = om.ArmijoGoldsteinLS(bound_enforcement='vector')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "f75eb980",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:51.833766Z",
     "iopub.status.busy": "2026-10-02T14:46:51.833564Z",
     "iopub.status.idle": "2026-10-02T14:46:51.836878Z",
     "shell.execute_reply": "2026-10-02T14:46:51.836392Z"
    },
    "papermill": {
     "duration": 0.010432,
     "end_time": "2026-10-02T14:46:51.837270+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:51.826838+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "top = om.Problem()\n",
    "\n",
    "top.model.nonlinear_solver = om.NewtonSolver(solve_subsystems=False)\n",
    "top.model.nonlinear_solver.options['maxiter'] = 10\n",
    "top.model.linear_solver = om.ScipyKrylov()\n",
    "\n",
    "ls = top.model.nonlinear_solver.linesearch = om.ArmijoGoldsteinLS(bound_enforcement='vector')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "95b75e46",
   "metadata": {
    "papermill": {
     "duration": 0.005795,
     "end_time": "2026-10-02T14:46:51.848765+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:51.842970+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "### Create a NonLinearRunOnce\n",
    "\n",
    "`````{tab-set}\n",
    "````{tab-item} OpenMDAO 2.x\n",
    "```\n",
    "model.nonlinear_solver = om.NonLinearRunOnce()\n",
    "```\n",
    "````\n",
    "\n",
    "````{tab-item} OpenMDAO 3.0\n",
    "```\n",
    "model.nonlinear_solver = om.NonlinearRunOnce()\n",
    "```\n",
    "````\n",
    "`````\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "39774517",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:51.861043Z",
     "iopub.status.busy": "2026-10-02T14:46:51.860757Z",
     "iopub.status.idle": "2026-10-02T14:46:51.862863Z",
     "shell.execute_reply": "2026-10-02T14:46:51.862414Z"
    },
    "papermill": {
     "duration": 0.008764,
     "end_time": "2026-10-02T14:46:51.863273+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:51.854509+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "# model = om.Problem().model\n",
    "# model.nonlinear_solver = om.NonLinearRunOnce()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "b854a61b",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:51.885835Z",
     "iopub.status.busy": "2026-10-02T14:46:51.885639Z",
     "iopub.status.idle": "2026-10-02T14:46:51.888463Z",
     "shell.execute_reply": "2026-10-02T14:46:51.887916Z"
    },
    "papermill": {
     "duration": 0.019565,
     "end_time": "2026-10-02T14:46:51.888907+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:51.869342+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "model = om.Problem().model\n",
    "model.nonlinear_solver = om.NonlinearRunOnce()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b1719f49",
   "metadata": {
    "papermill": {
     "duration": 0.005798,
     "end_time": "2026-10-02T14:46:51.900529+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:51.894731+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "### Create a PetscKSP\n",
    "\n",
    "`````{tab-set}\n",
    "````{tab-item} OpenMDAO 2.x\n",
    "```\n",
    "model.linear_solver = om.PetscKSP()\n",
    "```\n",
    "````\n",
    "\n",
    "````{tab-item} OpenMDAO 3.0\n",
    "```\n",
    "model.linear_solver = om.PETScKrylov()\n",
    "```\n",
    "````\n",
    "`````\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "43a43818",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:51.913442Z",
     "iopub.status.busy": "2026-10-02T14:46:51.913150Z",
     "iopub.status.idle": "2026-10-02T14:46:51.915303Z",
     "shell.execute_reply": "2026-10-02T14:46:51.914838Z"
    },
    "papermill": {
     "duration": 0.00942,
     "end_time": "2026-10-02T14:46:51.915737+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:51.906317+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "# model = om.Problem().model\n",
    "\n",
    "# model.linear_solver = om.PetscKSP()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "e6a92153",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:51.928590Z",
     "iopub.status.busy": "2026-10-02T14:46:51.928424Z",
     "iopub.status.idle": "2026-10-02T14:46:51.931822Z",
     "shell.execute_reply": "2026-10-02T14:46:51.931223Z"
    },
    "papermill": {
     "duration": 0.010344,
     "end_time": "2026-10-02T14:46:51.932330+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:51.921986+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "model = om.Problem().model\n",
    "try:\n",
    "    model.linear_solver = om.PETScKrylov()\n",
    "except RuntimeError:\n",
    "    pass"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2708f685",
   "metadata": {
    "papermill": {
     "duration": 0.005707,
     "end_time": "2026-10-02T14:46:51.943881+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:51.938174+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "### Create a ScipyIterativeSolver\n",
    "\n",
    "`````{tab-set}\n",
    "````{tab-item} OpenMDAO 2.x\n",
    "```\n",
    "model.linear_solver = om.ScipyIterativeSolver()\n",
    "```\n",
    "````\n",
    "\n",
    "````{tab-item} OpenMDAO 3.0\n",
    "```\n",
    "model.linear_solver = om.ScipyKrylov()\n",
    "```\n",
    "````\n",
    "`````\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "a39bcc8c",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:51.956358Z",
     "iopub.status.busy": "2026-10-02T14:46:51.956196Z",
     "iopub.status.idle": "2026-10-02T14:46:51.959163Z",
     "shell.execute_reply": "2026-10-02T14:46:51.958366Z"
    },
    "papermill": {
     "duration": 0.009882,
     "end_time": "2026-10-02T14:46:51.959679+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:51.949797+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "# model = om.Problem().model\n",
    "# model.linear_solver = om.ScipyIterativeSolver()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "24f36e45",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:51.972329Z",
     "iopub.status.busy": "2026-10-02T14:46:51.972168Z",
     "iopub.status.idle": "2026-10-02T14:46:51.975413Z",
     "shell.execute_reply": "2026-10-02T14:46:51.974835Z"
    },
    "papermill": {
     "duration": 0.010371,
     "end_time": "2026-10-02T14:46:51.975865+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:51.965494+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "model = om.Problem().model\n",
    "model.linear_solver = om.ScipyKrylov()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "671f1964",
   "metadata": {
    "papermill": {
     "duration": 0.005926,
     "end_time": "2026-10-02T14:46:51.987430+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:51.981504+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "## Drivers\n",
    "### Activate dynamic coloring on a Driver\n",
    "\n",
    "`````{tab-set}\n",
    "````{tab-item} OpenMDAO 2.x\n",
    "```\n",
    "p.driver.options['dynamic_simul_derivs'] = True\n",
    "```\n",
    "````\n",
    "\n",
    "````{tab-item} OpenMDAO 3.0\n",
    "```\n",
    "p.driver.declare_coloring()\n",
    "```\n",
    "````\n",
    "`````\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "id": "3a3aa7ed",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:52.000600Z",
     "iopub.status.busy": "2026-10-02T14:46:52.000410Z",
     "iopub.status.idle": "2026-10-02T14:46:52.002782Z",
     "shell.execute_reply": "2026-10-02T14:46:52.002150Z"
    },
    "papermill": {
     "duration": 0.009622,
     "end_time": "2026-10-02T14:46:52.003234+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:51.993612+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "# p = om.Problem()\n",
    "# p.driver.options['dynamic_simul_derivs'] = True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "c2485da4",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:52.017096Z",
     "iopub.status.busy": "2026-10-02T14:46:52.016926Z",
     "iopub.status.idle": "2026-10-02T14:46:52.019630Z",
     "shell.execute_reply": "2026-10-02T14:46:52.019178Z"
    },
    "papermill": {
     "duration": 0.010928,
     "end_time": "2026-10-02T14:46:52.020087+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:52.009159+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "p = om.Problem()\n",
    "p.driver.declare_coloring()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8bdb4603",
   "metadata": {
    "papermill": {
     "duration": 0.06113,
     "end_time": "2026-10-02T14:46:52.086571+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:52.025441+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "### Add a ScipyOptimizer to a Problem\n",
    "\n",
    "`````{tab-set}\n",
    "````{tab-item} OpenMDAO 2.x\n",
    "```\n",
    "prob.driver = om.ScipyOptimizer()\n",
    "```\n",
    "````\n",
    "\n",
    "````{tab-item} OpenMDAO 3.0\n",
    "```\n",
    "prob.driver = om.ScipyOptimizeDriver()\n",
    "```\n",
    "````\n",
    "`````\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "id": "8893f22f",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:52.114303Z",
     "iopub.status.busy": "2026-10-02T14:46:52.114068Z",
     "iopub.status.idle": "2026-10-02T14:46:52.116541Z",
     "shell.execute_reply": "2026-10-02T14:46:52.115996Z"
    },
    "papermill": {
     "duration": 0.010208,
     "end_time": "2026-10-02T14:46:52.116956+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:52.106748+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "# prob = om.Problem()\n",
    "# prob.driver = om.ScipyOptimizer()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "id": "12c35caa",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:52.130405Z",
     "iopub.status.busy": "2026-10-02T14:46:52.130206Z",
     "iopub.status.idle": "2026-10-02T14:46:52.134345Z",
     "shell.execute_reply": "2026-10-02T14:46:52.133725Z"
    },
    "papermill": {
     "duration": 0.011974,
     "end_time": "2026-10-02T14:46:52.134935+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:52.122961+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "prob = om.Problem()\n",
    "prob.driver = om.ScipyOptimizeDriver()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a0bd2dd3",
   "metadata": {
    "papermill": {
     "duration": 0.006451,
     "end_time": "2026-10-02T14:46:52.229717+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:52.223266+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "## Working with Derivatives\n",
    "### Use a pre-computed coloring on a model\n",
    "\n",
    "`````{tab-set}\n",
    "````{tab-item} OpenMDAO 2.x\n",
    "```\n",
    "p.driver.set_simul_deriv_color()\n",
    "```\n",
    "````\n",
    "\n",
    "````{tab-item} OpenMDAO 3.0\n",
    "```\n",
    "p.driver.use_fixed_coloring()\n",
    "```\n",
    "````\n",
    "`````\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "8547a262",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:52.242738Z",
     "iopub.status.busy": "2026-10-02T14:46:52.242477Z",
     "iopub.status.idle": "2026-10-02T14:46:52.245051Z",
     "shell.execute_reply": "2026-10-02T14:46:52.244415Z"
    },
    "papermill": {
     "duration": 0.010553,
     "end_time": "2026-10-02T14:46:52.245991+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:52.235438+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "# p = om.Problem()\n",
    "# p.driver = om.ScipyOptimizeDriver()\n",
    "# p.driver.set_simul_deriv_color()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "65631940",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:52.258328Z",
     "iopub.status.busy": "2026-10-02T14:46:52.258145Z",
     "iopub.status.idle": "2026-10-02T14:46:52.262133Z",
     "shell.execute_reply": "2026-10-02T14:46:52.261451Z"
    },
    "papermill": {
     "duration": 0.010871,
     "end_time": "2026-10-02T14:46:52.262644+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:52.251773+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "p = om.Problem()\n",
    "p.driver = om.ScipyOptimizeDriver()\n",
    "p.driver.use_fixed_coloring()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3bbf6eb5",
   "metadata": {
    "papermill": {
     "duration": 0.005611,
     "end_time": "2026-10-02T14:46:52.273898+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:52.268287+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "## Case Reading\n",
    "### Query the iteration coordinate for a case\n",
    "\n",
    "`````{tab-set}\n",
    "````{tab-item} OpenMDAO 2.x\n",
    "```\n",
    "cr = om.CaseReader(self.filename)\n",
    "\n",
    "for i, c in enumerate(cr.list_cases()):\n",
    "    case = cr.get_case(c)\n",
    "\n",
    "    coord = case.iteration_coordinate\n",
    "```\n",
    "````\n",
    "\n",
    "````{tab-item} OpenMDAO 3.0\n",
    "```\n",
    "cr = om.CaseReader(filename)\n",
    "\n",
    "for i, c in enumerate(cr.list_cases(out_stream=None)):\n",
    "    case = cr.get_case(c)\n",
    "\n",
    "    coord = case.name\n",
    "```\n",
    "````\n",
    "`````\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "id": "b0068db8",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:52.294485Z",
     "iopub.status.busy": "2026-10-02T14:46:52.294257Z",
     "iopub.status.idle": "2026-10-02T14:46:53.702530Z",
     "shell.execute_reply": "2026-10-02T14:46:53.701914Z"
    },
    "papermill": {
     "duration": 1.415717,
     "end_time": "2026-10-02T14:46:53.703166+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:52.287449+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "NL: NewtonSolver 'NL: Newton' on system '' failed to converge in 3 iterations.\n"
     ]
    }
   ],
   "source": [
    "# This is to create a CaseRecorder\n",
    "from openmdao.test_suite.components.implicit_newton_linesearch import ImplCompTwoStates\n",
    "\n",
    "filename = \"sqlite_test\"\n",
    "recorder = om.SqliteRecorder(filename, record_viewer_data=False)\n",
    "\n",
    "prob = om.Problem()\n",
    "\n",
    "model = prob.model\n",
    "\n",
    "model.add_subsystem('px', om.IndepVarComp('x', 1.0))\n",
    "model.add_subsystem('comp', ImplCompTwoStates())\n",
    "model.connect('px.x', 'comp.x')\n",
    "\n",
    "model.nonlinear_solver = om.NewtonSolver(solve_subsystems=False)\n",
    "model.nonlinear_solver.options['maxiter'] = 3\n",
    "model.nonlinear_solver.options['iprint'] = 2\n",
    "model.linear_solver = om.ScipyKrylov()\n",
    "\n",
    "ls = model.nonlinear_solver.linesearch = om.ArmijoGoldsteinLS(bound_enforcement='vector')\n",
    "ls.options['maxiter'] = 3\n",
    "ls.options['alpha'] = 1.0\n",
    "\n",
    "# add recorder to nonlinear solver, linesearch solver and model\n",
    "model.nonlinear_solver.add_recorder(recorder)\n",
    "model.nonlinear_solver.linesearch.add_recorder(recorder)\n",
    "model.comp.add_recorder(recorder)\n",
    "model.add_recorder(recorder)\n",
    "\n",
    "prob.setup()\n",
    "prob.set_solver_print(0)\n",
    "\n",
    "prob['px.x'] = 2.0\n",
    "prob['comp.y'] = 0.0\n",
    "prob['comp.z'] = 1.6\n",
    "prob.run_model()\n",
    "prob.cleanup()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "id": "90842505",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:53.713123Z",
     "iopub.status.busy": "2026-10-02T14:46:53.712956Z",
     "iopub.status.idle": "2026-10-02T14:46:53.715272Z",
     "shell.execute_reply": "2026-10-02T14:46:53.714554Z"
    },
    "papermill": {
     "duration": 0.007806,
     "end_time": "2026-10-02T14:46:53.715716+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:53.707910+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "# cr = om.CaseReader(filename)\n",
    "\n",
    "# for i, c in enumerate(cr.list_cases()):\n",
    "#     case = cr.get_case(c)\n",
    "\n",
    "#     coord = case.iteration_coordinate"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "47d641ee",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:53.784655Z",
     "iopub.status.busy": "2026-10-02T14:46:53.784411Z",
     "iopub.status.idle": "2026-10-02T14:46:53.794955Z",
     "shell.execute_reply": "2026-10-02T14:46:53.794294Z"
    },
    "papermill": {
     "duration": 0.018789,
     "end_time": "2026-10-02T14:46:53.795881+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:53.777092+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "cr = om.CaseReader(prob.get_outputs_dir() / filename)\n",
    "\n",
    "for i, c in enumerate(cr.list_cases(out_stream=None)):\n",
    "    case = cr.get_case(c)\n",
    "\n",
    "    coord = case.name"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b79c37f5",
   "metadata": {
    "papermill": {
     "duration": 0.052064,
     "end_time": "2026-10-02T14:46:53.867145+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:53.815081+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "## Running a Model\n",
    "### Run a Driver\n",
    "\n",
    "`````{tab-set}\n",
    "````{tab-item} OpenMDAO 2.x\n",
    "```\n",
    "prob.run()\n",
    "```\n",
    "````\n",
    "\n",
    "````{tab-item} OpenMDAO 3.0\n",
    "```\n",
    "prob.run_driver()\n",
    "```\n",
    "````\n",
    "`````\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "id": "88ade9f3",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:53.885480Z",
     "iopub.status.busy": "2026-10-02T14:46:53.885238Z",
     "iopub.status.idle": "2026-10-02T14:46:53.887727Z",
     "shell.execute_reply": "2026-10-02T14:46:53.887072Z"
    },
    "papermill": {
     "duration": 0.009834,
     "end_time": "2026-10-02T14:46:53.888283+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:53.878449+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "# prob = om.Problem()\n",
    "# prob.run()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "id": "3f84adf2",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:53.900786Z",
     "iopub.status.busy": "2026-10-02T14:46:53.900568Z",
     "iopub.status.idle": "2026-10-02T14:46:53.905467Z",
     "shell.execute_reply": "2026-10-02T14:46:53.904958Z"
    },
    "papermill": {
     "duration": 0.012278,
     "end_time": "2026-10-02T14:46:53.906228+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:53.893950+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "prob = om.Problem()\n",
    "prob.setup()\n",
    "prob.run_driver();"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9a438bc4",
   "metadata": {
    "papermill": {
     "duration": 0.154271,
     "end_time": "2026-10-02T14:46:54.066118+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:53.911847+00:00",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "### Run a Model without Running the Driver\n",
    "\n",
    "`````{tab-set}\n",
    "````{tab-item} OpenMDAO 2.x\n",
    "```\n",
    "prob.run_once()\n",
    "```\n",
    "````\n",
    "\n",
    "````{tab-item} OpenMDAO 3.0\n",
    "```\n",
    "prob.run_model()\n",
    "```\n",
    "````\n",
    "`````\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "id": "36edb080",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:54.079442Z",
     "iopub.status.busy": "2026-10-02T14:46:54.079189Z",
     "iopub.status.idle": "2026-10-02T14:46:54.081791Z",
     "shell.execute_reply": "2026-10-02T14:46:54.081124Z"
    },
    "papermill": {
     "duration": 0.009901,
     "end_time": "2026-10-02T14:46:54.082191+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:54.072290+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "# prob = om.Problem()\n",
    "# prob.run_once()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "id": "c002f57f",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-02T14:46:54.094552Z",
     "iopub.status.busy": "2026-10-02T14:46:54.094358Z",
     "iopub.status.idle": "2026-10-02T14:46:54.098840Z",
     "shell.execute_reply": "2026-10-02T14:46:54.098264Z"
    },
    "papermill": {
     "duration": 0.011493,
     "end_time": "2026-10-02T14:46:54.099344+00:00",
     "exception": false,
     "start_time": "2026-10-02T14:46:54.087851+00:00",
     "status": "completed"
    },
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "prob = om.Problem()\n",
    "prob.setup()\n",
    "prob.run_model()"
   ]
  }
 ],
 "metadata": {
  "celltoolbar": "Tags",
  "kernelspec": {
   "display_name": "Python 3",
   "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"
  },
  "papermill": {
   "default_parameters": {},
   "duration": 7.901993,
   "end_time": "2026-10-02T14:46:54.720882+00:00",
   "environment_variables": {},
   "exception": null,
   "input_path": "/home/runner/work/OpenMDAO/OpenMDAO/openmdao/docs/openmdao_book/other_useful_docs/api_translation.ipynb",
   "output_path": "/home/runner/work/OpenMDAO/OpenMDAO/openmdao/docs/_executed_book/other_useful_docs/api_translation.ipynb",
   "parameters": {},
   "start_time": "2026-10-02T14:46:46.818889+00:00",
   "version": "2.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}