physics/gravitational_field_earth.i...

102 lines
22 KiB
Plaintext
Raw Normal View History

2022-11-19 22:41:30 +00:00
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"\"\"\"Gravitational field strength vs range (Earth).\"\"\"\n",
"\n",
"import math\n",
"import matplotlib.pyplot as plt\n",
"\n",
"IN_STEPS = 20\n",
"OUT_STEP = 0.25\n",
"OUT_COUNT = 40\n",
"G = 6.67 * 10e-11\n",
"M = 5.97 * 10e24\n",
"R = 6.38 * 10e6\n",
"\n",
"density = M / ((4/3) * math.pi * R**3)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"inside_x = []\n",
"inside_y = []\n",
"for i in range(IN_STEPS):\n",
" r = R * i / IN_STEPS\n",
" g = (4/3) * math.pi * G * r * density\n",
" inside_x.append(r)\n",
" inside_y.append(g)\n",
"\n",
"outside_x = []\n",
"outside_y = []\n",
"for i in range(OUT_COUNT):\n",
" r = R * (1 + i*OUT_STEP)\n",
" g = G * M / r**2\n",
" outside_x.append(r)\n",
" outside_y.append(g)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjoAAAGwCAYAAACgi8/jAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/av/WaAAAACXBIWXMAAA9hAAAPYQGoP6dpAAA8GElEQVR4nO3de3zT9b3H8XcapHHSRouUpligYyoLFaRAGaCbF9AyTpXtzNvgyMHNs9PBEcYuXjbt6dkFLzvOeXnUydk6Xb0xPSDdHhaVOcQDs0jtRpepyDJgkFK1kha0RZPf+SNrJbShSZvkl/zyej4efWB++eaXD1HJm+/VZhiGIQAAAAvKMrsAAACARCHoAAAAyyLoAAAAyyLoAAAAyyLoAAAAyyLoAAAAyyLoAAAAyxpmdgFmCwaDOnD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uu9ygQ7K8FAADWRNCxiEZve5+enGMZknz+LjV625NXFAAAJiPoWERbZ+SQM5h2AABYAUHHIvJzHAM3iqEdAABWQNCxiLLiPLmcDkVaRG5TaPVVWXFeMssCAMBUBB2LsGfZVFXhlqQ+YafncVWFm/10AAAZhaBjIeUlLtUsLlWBM3x4qsDpUM3iUvbRAQBkHDYMtJjyEpfmuQvYGRkAABF0LMmeZdOsCSPNLgMAANMxdAUAACyLoAMAACyLoAMAACyLoAMAACyLoAMAACyLVVcWEQgaLCkHAOA4BB0LaGjxqbreE3Z6ucvpUFWFm00CAQAZjaGrNNfQ4lNlXVNYyJGkVn+XKuua1NDiM6kyAAD
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.scatter(inside_x, inside_y)\n",
"plt.scatter(outside_x, outside_y)\n",
"\n",
"plt.xlabel(\"r (m)\")\n",
"plt.ylabel(\"$g \\/ (N \\cdot kg^{-1})$\")\n",
"\n",
"plt.show()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.9.2 64-bit",
"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.9.2 (default, Feb 28 2021, 17:03:44) \n[GCC 10.2.1 20210110]"
},
"orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}