<commit_before><commit_msg>New notebook for calculating orbital angular momentum<commit_after>{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Always run this first\n",
      "# NOTE: Do not define new basic variables in this notebook;\n",
      "#       define them in Variables.ipynb.  Use this notebook\n",
      "#       to define new expressions built from those variables.\n",
      "\n",
      "from __future__ import division # This needs to be here, even though it's in Variables.ipynb\n",
      "import sys\n",
      "sys.path.insert(0, '..') # Look for modules in directory above this one\n",
      "execfile('../Utilities/ExecNotebook.ipy')\n",
      "try: execnotebook(VariablesNotebook)\n",
      "except: execnotebook('Variables.ipynb')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 1
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "The following `PNCollection` objects will contain all the terms in the different parts of the binding energy."
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "AngularMomentum_NoSpin = PNCollection()\n",
      "AngularMomentum_Spin = PNCollection()"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Individual energy terms"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "In this notebook, every term will be multiplied by the following coefficient."
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "AngularMomentum_NoSpin.AddDerivedVariable('L_coeff', m**2*nu/v)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 3
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Note that fractions need to be entered as, e.g., `frac(3,4)` so that they are not converted to finite-precision decimals."
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "The nonspinning orbital binding energy is known through 4pN.  The 5pN term has a known relationship to the 5pN binding energy term $e_5(\\nu)$, though the latter is still incomplete.  We set it to zero here.  These expressions come from Eq. (230) and related footnotes of [Blanchet (2006)](http://www.livingreviews.org/lrr-2006-4).  Note that his calculation is for nonspinning systems, so he writes the quantity as $J$, which is assumed to be the component along $\\hat{\\ell}$."
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "e_5 = 0 # Placeholder for unknown term in energy expression."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 4
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "AngularMomentum_NoSpin.AddDerivedConstant('L_0', ellHat,\n",
      "    datatype=ellHat.datatype)\n",
      "# L_1 is 0\n",
      "AngularMomentum_NoSpin.AddDerivedConstant('L_2', (frac(3,2) + frac(1,6)*nu)*ellHat,\n",
      "    datatype=ellHat.datatype)\n",
      "# L_3 is 0\n",
      "AngularMomentum_NoSpin.AddDerivedConstant('L_4', (frac(27,8) - frac(19,8)*nu + frac(1,24)*nu**2)*ellHat,\n",
      "    datatype=ellHat.datatype)\n",
      "# L_5 is 0\n",
      "AngularMomentum_NoSpin.AddDerivedConstant('L_6', (frac(135,16) + (-frac(6889,144) + frac(41,24)*pi**2)*nu\n",
      "    + frac(31,24)*nu**2 + frac(7,1296)*nu**3)*ellHat,\n",
      "    datatype=ellHat.datatype)\n",
      "# L_7 is 0\n",
      "AngularMomentum_NoSpin.AddDerivedConstant('L_8',\n",
      "    (frac(2835,128) - frac(5,7)*nu*((-frac(123671,5760)+frac(9037,1536)*pi**2+frac(1792,15)*ln(2)+frac(896,15)*EulerGamma)\n",
      "                                   + (-frac(498449,3456) + frac(3157,576)*pi**2)*nu\n",
      "                                   + frac(301,1728)*nu**2 + frac(77,31104)*nu**3) + frac(64,35)*nu)*ellHat,\n",
      "    datatype=ellHat.datatype)\n",
      "AngularMomentum_NoSpin.AddDerivedConstant('L_lnv_8', (-frac(128,3)*nu)*ellHat,\n",
      "    datatype=ellHat.datatype)\n",
      "# L_9 is 0\n",
      "\n",
      "# Below are the incomplete terms\n",
      "AngularMomentum_NoSpin.AddDerivedConstant('L_10',\n",
      "    (frac(15309,256) + nu*(-frac(2,3)*e_5 - frac(4988,945) - frac(656,135)*nu))*ellHat,\n",
      "    datatype=ellHat.datatype)\n",
      "AngularMomentum_NoSpin.AddDerivedConstant('L_lnv_10', ((frac(9976,105) + frac(1312,15)*nu)*nu*2)*ellHat,\n",
      "    datatype=ellHat.datatype)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 5
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "***(Look for spin-squared terms.)***"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "The spin-orbit terms in the angular momentum are complete to 3.5pN.  These terms come from Eq. (4.7) of [Boh\u00e9 et al. (2012)](http://arxiv.org/abs/1212.5520v2):"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Lower-order terms are 0\n",
      "AngularMomentum_Spin.AddDerivedVariable('L_SO_3',\n",
      "    (-(35*S_l + 15*Sigma_l*delta)/(6*m**2))*ellHat\n",
      "    + ((S_n + Sigma_n*delta)/(2*m**2))*nHat\n",
      "    + (-(3*S_la + Sigma_la*delta)/m**2)*lambdaHat,\n",
      "    datatype=ellHat.datatype)\n",
      "# L_SO_4 is 0\n",
      "AngularMomentum_Spin.AddDerivedVariable('L_SO_5',\n",
      "    (7*(61*S_l*nu - 99*S_l + 30*Sigma_l*delta*nu - 27*Sigma_l*delta)/(72*m**2))*ellHat\n",
      "    + ((-19*S_n*nu + 33*S_n - 10*Sigma_n*delta*nu + 33*Sigma_n*delta)/(24*m**2))*nHat\n",
      "    + ((18*S_la*nu - 21*S_la + 8*Sigma_la*delta*nu - 3*Sigma_la*delta)/(6*m**2))*lambdaHat,\n",
      "    datatype=ellHat.datatype)\n",
      "# L_SO_6 is 0\n",
      "AngularMomentum_Spin.AddDerivedVariable('L_SO_7',\n",
      "    ((-29*S_l*nu**2 + 1101*S_l*nu - 405*S_l - 15*Sigma_l*delta*nu**2 + 468*Sigma_l*delta*nu\n",
      "      - 81*Sigma_l*delta)/(16*m**2))*ellHat\n",
      "    + ((11*S_n*nu**2 - 1331*S_n*nu + 183*S_n + 5*Sigma_n*delta*nu**2 - 734*Sigma_n*delta*nu\n",
      "        + 183*Sigma_n*delta)/(48*m**2))*nHat\n",
      "    + ((-32*S_la*nu**2 + 2*S_la*nu - 174*S_la - 16*Sigma_la*delta*nu**2 - 79*Sigma_la*delta*nu\n",
      "        - 12*Sigma_la*delta)/(24*m**2))*lambdaHat,\n",
      "    datatype=ellHat.datatype)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Collected terms"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "def AngularMomentumExpression(AngularMomentumTerms=[AngularMomentum_NoSpin, AngularMomentum_Spin], PNOrder=frac(7,2)):\n",
      "    # We have to play some tricks with the log terms so that `horner` works\n",
      "    def logterm(key,val):\n",
      "        if 'lnv' in val:\n",
      "            return logv\n",
      "        else:\n",
      "            return 1\n",
      "    return L_coeff*horner(sum([key*(v**n)*logterm(key,val)\n",
      "                               for Terms in AngularMomentumTerms\n",
      "                               for n in range(2*PNOrder+1)\n",
      "                               for key,val in Terms.items()\n",
      "                               if val.endswith('_{0}'.format(n))])).subs(logv, ln(v))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 7
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# display(AngularMomentumExpression(PNOrder=frac(8,2)))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "latex": [
        "$$L_{coeff} \\left(L_{0} + v^{2} \\left(L_{2} + v \\left(L_{SO 3} + v \\left(L_{4} + v \\left(L_{SO 5} + v \\left(L_{6} + v \\left(L_{SO 7} + v \\left(L_{8} + L_{lnv 8} \\log{\\left (v \\right )}\\right)\\right)\\right)\\right)\\right)\\right)\\right)\\right)$$"
       ],
       "metadata": {},
       "output_type": "display_data",
       "png": "iVBORw0KGgoAAAANSUhEUgAAA2cAAAAcBAMAAAAXaNrJAAAAMFBMVEX///8AAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAAD3RSTlMAZqvNRIkQuyJ2mTLd\n71QBb6A9AAAJsUlEQVRoBe1Ze4xcVRn/zc7cu/OeUdLwMI1jSwGFyMpWE0XpiBgTrOzwWOPuH/Rm\nm4IiZMf9Q6oxeEUDiQl00GzINiJTyLZpxThWEV+4W9Joa6OssRBNExiNpkGwXWG71q5m/L7zuHPm\n7r13pqFL+sd+yXl953d/3+Pcc+7ZWeBNy+iXnTfNsUrw1mbAcvsG3lqLq9a6Z+DH0ZCsmzkdjVid\nPYcZSPXElalGw3Ll5EI0YnX2HGYgUeqFLO50Q+UXBeKH3XBAptgdYyJ6oEQvGIOzFxdWgNLwIKSr\njL6DpmON8IKbxfNvb10Tlcu9zHL1G+8KsUXqbI3nktVuOOBBwnUxx1RamLIbvhezmo/bHlw4l5Rh\nmdv/ftMp6otYqe1rUHVlRMk6NAm8IeqQKim2UWEgZJrVo2Iu7lATiQM+wMhIcwzwJO5wNxovMF3M\nMouWHlyIOwQ+V5QhPPZz2iHVxh3V4UzHI0qqzsDEKa7DxKrzzFCFa08+6/WoE6uL0STXUTggxSwR\n5myXOdoiKH34QIzPbJsB6HA12IUVpQxzbcJ0kvoiVtZxhxMVVpLzjLIi7xG5JmO2lLn25BWvR52P\n45M8/BNXUTgg5xIkwly+xhxtEZQ+fCDGZ7bNAHS4GuzCilKGueZfNBErO34PFXsuvOAAo+Ji6bgX\nJDMOazd1TpmZyFx34os0m5hlSASOZjczJMKcL3uS0ocPxPjMshktpqukC3JhRSnDXPMtmoyVnY43\nqbououyhuS6n91qG+L8rKhP2aM0+kGu1eNWtOlVROJoVH7+QQ56f1tnbthd3FzWlD68wwjQ9YtWp\n8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qbc5oPRcS1fyAoTe6wZT4gwHp6HqUcReXdczo\nwXwtOY+Dr+JIsolO0N0U/30M00ZtdmprRLHlrZ6fSe692Ll/sokxukTKX1U3s5r+2TwnW6qt6d1e\nf3knWdW6l1st3fW19JZJSf+cfwqx33NLhcZPT16h9Z1tmxKxr763c06P2pjv8U8hGJveQFPWKBMH\niecCLmF4kART0jYJEY/Snp50AzHT5UQJk0Vc/wgF3QGyh6dGG/yMNioWj1+DsBIr0WSAiK2q92tI\nspY/9rXlKr8mWfRrosc9UKIXjGGlFxdWgNLwIKSrjF5E0zE3vCAr1ngZyfuuJJWoeIq36qqcPxlY\nE+zKSI30ouL5fJ3rVTlPMqCP0S7u0K1sVc6bDKSd88aVVUfOJgP/B+H1RTfmOSXhAAAAAElFTkSu\nQmCC\n",
       "text": [
        "        \u239b      2                                                              \n",
        "L_coeff\u22c5\u239dL\u2080 + v \u22c5(L\u2082 + v\u22c5(L_SO_3 + v\u22c5(L\u2084 + v\u22c5(L_SO_5 + v\u22c5(L\u2086 + v\u22c5(L_SO_7 + v\u22c5(\n",
        "\n",
        "                          \u239e\n",
        "L\u2088 + L_lnv_8\u22c5log(v))))))))\u23a0"
       ]
      }
     ],
     "prompt_number": 8
    }
   ],
   "metadata": {}
  }
 ]
}
{'fraction_non_alphanumeric': 0.15094041409830883, 'fraction_numerical': 0.07341552078394184, 'mean_word_length': 3.427921623512946, 'pattern_counts': {'":': 94, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 13, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2858709', 'n_tokens_mistral': 6548, 'n_tokens_neox': 6007, 'n_words': 574}