{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "hide_input": true,
    "tags": [
     "active-ipynb",
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "try:\n",
    "    from openmdao.utils.notebook_utils import notebook_mode\n",
    "except ImportError:\n",
    "    !python -m pip install openmdao[notebooks]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# How to Cite OpenMDAO\n",
    "\n",
    "There is a general OpenMDAO paper that includes a high-level overview of the framework,\n",
    "including how implicit and explicit components leverage the underlying core APIs to support multidisciplinary modeling.\n",
    "There is a walk-through example of how some of the key underlying mathematics of the framework are used and how analytic derivatives are computed.\n",
    "Lastly, there are  examples of how and when to use some of the specialized algorithms for computing derivatives efficiently for different kinds of problems.\n",
    "\n",
    "We hope the paper helps you understand the framework better, and most importantly,\n",
    "helps you to solve some really nice MDO problems! If you do make use of OpenMDAO, please cite this paper.\n",
    "\n",
    "```\n",
    "@article{openmdao_2019,\n",
    "Author={Justin S. Gray and John T. Hwang and Joaquim R. R. A. Martins and Kenneth T. Moore and Bret A. Naylor},\n",
    "Title=\"{OpenMDAO: An Open-Source Framework for Multidisciplinary Design, Analysis, and Optimization}\",\n",
    "Journal=\"{Structural and Multidisciplinary Optimization}\",\n",
    "Year={2019},\n",
    "Volume={59},\n",
    "pages={1075-1104},\n",
    "issue={4},\n",
    "Publisher={Springer},\n",
    "pdf={http://www.umich.edu/~mdolaboratory/pdf/Gray2019a.pdf},\n",
    "Doi={10.1007/s00158-019-02211-z},\n",
    "}\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##  With the `openmdao` command\n",
    "\n",
    "Depending on which parts of OpenMDAO you are using, there are also a few other papers that are appropriate to cite.\n",
    "OpenMDAO can tell you which citations are appropriate, accounting for what classes you're actually using in your model.\n",
    "\n",
    "If you copy the following script into a file called `paraboloid.py`,\n",
    "then you can get the citations from the command line using the [openmdao command-line script](../other_useful_docs/om_command.ipynb).\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "tags": [
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "import openmdao.api as om\n",
    "\n",
    "# build the model\n",
    "prob = om.Problem()\n",
    "\n",
    "prob.model.add_subsystem('paraboloid', om.ExecComp('f = (x-3)**2 + x*y + (y+4)**2 - 3'))\n",
    "\n",
    "# setup the optimization\n",
    "prob.driver = om.ScipyOptimizeDriver()\n",
    "prob.driver.options['optimizer'] = 'SLSQP'\n",
    "\n",
    "prob.model.add_design_var('paraboloid.x', lower=-50, upper=50)\n",
    "prob.model.add_design_var('paraboloid.y', lower=-50, upper=50)\n",
    "prob.model.add_objective('paraboloid.f')\n",
    "\n",
    "prob.setup()\n",
    "\n",
    "# Set initial values.\n",
    "prob.set_val('paraboloid.x', 3.0)\n",
    "prob.set_val('paraboloid.y', -4.0)\n",
    "\n",
    "# run the optimization\n",
    "prob.run_driver();"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "hide_input": true,
    "tags": [
     "remove-input",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "# Test the results of the code above.\n",
    "from openmdao.utils.assert_utils import assert_near_equal\n",
    "\n",
    "# minimum value\n",
    "assert_near_equal(prob.get_val('paraboloid.f'), -27.33333, 1e-6);\n",
    "\n",
    "# location of the minimum\n",
    "assert_near_equal(prob.get_val('paraboloid.x'), 6.6667, 1e-4);\n",
    "assert_near_equal(prob.get_val('paraboloid.y'), -7.33333, 1e-4);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The following cell issues the `openmdao cite paraboloid.py` command within a notebook.  \n",
    "The same capability exists in the command-line without the preceding !."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "tags": [
     "remove-input"
    ]
   },
   "source": [
    "If you are in colab, the shell command will not find the file because it is a single notebook without the included file."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "!openmdao cite paraboloid.py"
   ]
  }
 ],
 "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.8.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
