{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Generate an N2 and XDSM from an Excel description of the MDO problem\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "from __future__ import division, unicode_literals\n\nfrom os import mkdir\nfrom os.path import exists, join\n\nfrom gemseo.api import configure_logger\nfrom gemseo.utils.study_analysis import StudyAnalysis\n\nconfigure_logger()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Describe your MDO problem in an Excel file\n\n<img src=\"file://_images/study_prototyping_example/disciplines_spec.png\">\n\n\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Visualize this study\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "study = StudyAnalysis(\"disciplines_spec.xlsx\")\nif not exists(\"outputs\"):\n    mkdir(\"outputs\")"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "### Generate N2 chrt\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "study.generate_n2(file_path=join(\"outputs\", \"n2.png\"), save=False, show=True)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "### Generate XDSM\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "study.generate_xdsm(\"outputs\")"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "<img src=\"file://_images/study_prototyping_example/xdsm.png\">\n\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Visualize this study from command line\n\nWe can create the same figures using command line inputs:\n\n.. code::\n\n   gemseo-study disciplines_spec.xlsx -o outputs -s '(5,5)' -x -l\n\nwhere:\n\n- :code:`gemseo-study` is an executable provided by |g|,\n- :code:`disciplines_spec.xlsx` is the Excel file path,\n- :code:`-o outputs` is the output directory,\n- :code:`-s '(5,5)'` is the size of the N2 chart,\n- :code:`-x` is an option to create of the XDSM,\n- :code:`-l` is an option to create a PDF file with the creation of the XDSM.\n\n"
      ]
    }
  ],
  "metadata": {
    "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.13"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}