<commit_before><commit_msg>Divergent, Gradient and Curl figures.<commit_after>{
 "metadata": {
  "name": "",
  "signature": "sha256:b4772f6c02480eec8a4a47dddef66b141313e40bf934ea6b08870958fa0117db"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from IPython.core.display import HTML\n",
      "\n",
      "with open('../common/creativecommons.html', 'r') as f:\n",
      "    html = f.read()\n",
      "    \n",
      "with open('../common/custom.css', 'r') as f:\n",
      "    styles = f.read()\n",
      "    \n",
      "HTML(styles)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": null
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import numpy as np\n",
      "import matplotlib.pyplot as plt\n",
      "\n",
      "from sympy import init_printing, symbols, pi\n",
      "from sympy.plotting import plot3d_parametric_surface\n",
      "\n",
      "init_printing() "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": null
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "r, h, u = symbols('r h u')\n",
      "V = (r**2 * h * pi) / 3\n",
      "V"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": null
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "circ = V.diff(r)\n",
      "circ"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": null
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "area = V.diff(h)\n",
      "area"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": null
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "## Gradient"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "x, y = np.mgrid[-100:101:25., -100:101:25.]\n",
      "\n",
      "V = 2 * x ** 2 + 3 * y ** 2\n",
      "\n",
      "Ex, Ey = np.gradient(V)\n",
      "Ex = - Ex\n",
      "Ey = - Ey\n",
      "\n",
      "fig, ax = plt.subplots(figsize=(4, 4))\n",
      "ax.contourf(x, y, V, cmap=plt.cm.Greys_r)\n",
      "_ = ax.quiver(x, y, Ex, Ey, color='b')\n",
      "# fig.savefig('gradient.png')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": null
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "## Divergence (Fake!)\n",
      "### Horizontally non-divergent (u=U_ox, v=U_oy)"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "dx = 0.5\n",
      "x = np.arange(-4, 4 + dx, dx)\n",
      "y = x.copy()\n",
      "\n",
      "X, Y = np.meshgrid(x, y)\n",
      "f = X ** 2 - Y ** 2\n",
      "Dx, Dy = np.gradient(f)\n",
      "\n",
      "fig, ax = plt.subplots(figsize=(4, 4))\n",
      "ax.contourf(x, y, f, cmap=plt.cm.Greys)\n",
      "_ = ax.quiver(x, y, Dy, Dx, color='b')\n",
      "\n",
      "# fig.savefig('divergence.png')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": null
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "## Curl (Fake!)\n",
      "### z-component of curl = constant\n",
      "### (u=-U_oy, v=U_ox)"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "fig, ax = plt.subplots(figsize=(4, 4))\n",
      "_ = ax.quiver(x, y, Dx, Dy, color='b')\n",
      "# fig.savefig('curl.png')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": null
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "HTML(html)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": null
    }
   ],
   "metadata": {}
  }
 ]
}
{'fraction_non_alphanumeric': 0.23067544501341136, 'fraction_numerical': 0.01950743721043648, 'mean_word_length': 1.882642304989459, 'pattern_counts': {'":': 80, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5910291', 'n_tokens_mistral': 1656, 'n_tokens_neox': 1582, 'n_words': 287}