{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# De Saint Venant displacement diagrams\n\nDefine a :class:`BarSet` bar configuration and use it with :class:`WP2` reproduce\nthe displacement diagrams of de Saint Venant in:\n\n* de Saint-Venant, A. J. C. B. (1867). M\u00e9moire sur le choc longitudinal de deux \n  barres \u00e9lastiques de grosseurs et de mati\u00e8res semblables ou diff\u00e9rentes, \n  et sur la proportion de leur force vive qui est perdue pour la translation ult\u00e9rieure; \n  et g\u00e9n\u00e9ralement sur le mouvement longitudinal d\u2019un syst\u00e8me de deux ou plusieurs \n  prismes \u00e9lastiques. *Journal de math\u00e9matiques pures et appliqu\u00e9es 2e s\u00e9rie*, 12, 237\u2011376. \n  https://gallica.bnf.fr/ark:/12148/bpt6k16411c\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "# sphinx_gallery_thumbnail_number = 4\nimport numpy as np\nfrom elwaspatid import WP2, BarSet\nimport matplotlib.pyplot as plt"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Define a few parameters\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "E = 201e9  # Young modulus [Pa]\nrho = 7800  # Density [kg/m3]\nd = 0.020  # diameter [m]\nk = 2.4  # diamters ratio [-]"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Create the bar configuration\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "bc4 = BarSet([E, E], [rho, rho], [.4, 1.], [d, d], nmin=10)\n\ntest2v = WP2(bc4, nstep=160, left='free', right='free', Vinit=10)\ntest2v.plot('2b_veloc')"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Plot de Saint Venant displacement diagram and compare it with the orignal one.\nThe only difference is that the second bar is at rest, whereas in de Saint Venant\nit has a velocity smaller than the initial velocity of the impactor.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "test2v.plotDeSaintVenant(figname='deStV')\nplt.figure('deStV').set_figwidth(10)\nplt.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        ".. figure:: ../_static/deSaintVenant_img-040.png\n\n   Diagram 42, page 277, de Saint Venant\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.6.15"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}