this is for holding javascript data
Adam Ginsburg added introduction ipynb
about 11 years ago
Commit id: 739ffcc2a22f8230a786bb52bff8faa8d64beef1
deletions | additions
diff --git a/IntroductionMath.ipynb b/IntroductionMath.ipynb
new file mode 100644
index 0000000..a79510a
--- /dev/null
+++ b/IntroductionMath.ipynb
...
{
"metadata": {
"name": "IntroductionMath"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"[Bondi-Hoyle Accretion](http://en.wikipedia.org/wiki/Bondi_accretion)\n",
"\n",
"$$\\dot{M}_{BH} = \\frac{4 \\pi \\rho G^2 M^2 }{c_s^3} $$"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"import astropy.units as units\n",
"import astropy.constants as constants"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 1
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# mdot for some fiducial numbers\n",
"mdot = (4 * pi * constants.G**2 * (10**4 * 2.8 * constants.m_p/units.cm**3) * constants.M_sun**2 / (1. * units.km/units.s)**3).cgs\n",
"mdot # Why does ipython pretty-print this, but \"print mdot\" ugly-prints it?"
],
"language": "python",
"metadata": {},
"outputs": [
{
"latex": [
"$1.03712\\times 10^{+19} \\; \\mathrm{\\frac{g}{s}}$"
],
"output_type": "pyout",
"prompt_number": 16,
"text": [
""
]
}
],
"prompt_number": 16
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# mdot in msun / year\n",
"mdot_msunperyr = (mdot / constants.M_sun * units.year).decompose()\n",
"mdot_msunperyr # \"$M_\\odot \\text{yr}^{-1}$\""
],
"language": "python",
"metadata": {},
"outputs": [
{
"latex": [
"$1.64542\\times 10^{-07} \\; \\mathrm{}$"
],
"output_type": "pyout",
"prompt_number": 28,
"text": [
""
]
}
],
"prompt_number": 28
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$\\dot{M}_{BH} = 1.6\\times10^{-7} \\left(\\frac{M}{M_\\odot}\\right)^2 \\left(\\frac{n}{10^4 \\text{cm}^{-3}}\\right) \\left(\\frac{c_s}{1 \\text{km s}^{-1}}\\right)^{-3} $$"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"def m_bh(mass,density,soundspeed):\n",
" return ((4 * pi * constants.G**2 * (density* 2.8 * constants.m_p/units.cm**3) * (mass*constants.M_sun)**2 / (soundspeed * units.km/units.s)**3) / constants.M_sun * units.year).decompose()"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 18
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Some fiducial numbers:"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"m_bh(1,1e4,1)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"latex": [
"$1.64542\\times 10^{-07} \\; \\mathrm{}$"
],
"output_type": "pyout",
"prompt_number": 19,
"text": [
""
]
}
],
"prompt_number": 19
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"10/m_bh(10,1e5,1)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"latex": [
"$60774.6 \\; \\mathrm{}$"
],
"output_type": "pyout",
"prompt_number": 24,
"text": [
""
]
}
],
"prompt_number": 24
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"10/m_bh(10,1e6,1)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"latex": [
"$6077.46 \\; \\mathrm{}$"
],
"output_type": "pyout",
"prompt_number": 25,
"text": [
""
]
}
],
"prompt_number": 25
},
{
"cell_type": "code",
"collapsed": false,
"input": [],
"language": "python",
"metadata": {},
"outputs": []
}
],
"metadata": {}
}
]
}