summaryrefslogtreecommitdiff
path: root/FSF-2020/calculus-of-several-variables/div-curl-grad-and-all-that/Curl and Div/DivCurl_file11_gravitational-filed.ipynb
diff options
context:
space:
mode:
Diffstat (limited to 'FSF-2020/calculus-of-several-variables/div-curl-grad-and-all-that/Curl and Div/DivCurl_file11_gravitational-filed.ipynb')
-rw-r--r--FSF-2020/calculus-of-several-variables/div-curl-grad-and-all-that/Curl and Div/DivCurl_file11_gravitational-filed.ipynb119
1 files changed, 119 insertions, 0 deletions
diff --git a/FSF-2020/calculus-of-several-variables/div-curl-grad-and-all-that/Curl and Div/DivCurl_file11_gravitational-filed.ipynb b/FSF-2020/calculus-of-several-variables/div-curl-grad-and-all-that/Curl and Div/DivCurl_file11_gravitational-filed.ipynb
new file mode 100644
index 0000000..4ad8c27
--- /dev/null
+++ b/FSF-2020/calculus-of-several-variables/div-curl-grad-and-all-that/Curl and Div/DivCurl_file11_gravitational-filed.ipynb
@@ -0,0 +1,119 @@
+{
+ "cells": [
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "%gui qt"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import numpy as np\n",
+ "from mayavi import mlab\n",
+ "import scipy\n",
+ "import time"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "/home/padmapriya/mohyavi/lib/python3.6/site-packages/ipykernel_launcher.py:3: RuntimeWarning: invalid value encountered in true_divide\n",
+ " This is separate from the ipykernel package so we can avoid doing imports until\n",
+ "/home/padmapriya/mohyavi/lib/python3.6/site-packages/ipykernel_launcher.py:4: RuntimeWarning: invalid value encountered in true_divide\n",
+ " after removing the cwd from sys.path.\n",
+ "/home/padmapriya/mohyavi/lib/python3.6/site-packages/ipykernel_launcher.py:5: RuntimeWarning: invalid value encountered in true_divide\n",
+ " \"\"\"\n"
+ ]
+ }
+ ],
+ "source": [
+ "x, y, z = np.mgrid[-2:3, -2:3, -2:3]\n",
+ "r = np.sqrt(x**2 + y**2 + z**2)\n",
+ "u = x/r**3\n",
+ "v = y/r**3\n",
+ "w = z/r**3\n",
+ "\n",
+ "a = mlab.quiver3d(x, y, z, u, v, w)\n",
+ "mlab.axes(a)\n",
+ "mlab.show()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "x, y, z = np.mgrid[-2:3, -2:3, -2:3]\n",
+ "u = y**3 - 9*y\n",
+ "v = x**3 - 9*x\n",
+ "w = x\n",
+ "\n",
+ "a = mlab.quiver3d(x, y, z, u, v, w, colormap = 'gist_earth')\n",
+ "mlab.fig(bgcolor = (0,0,0))\n",
+ "\n",
+ "for i in range(50):\n",
+ " mlab.view(65, -65)\n",
+ " mlab.view(azimuth= 3.6*i, elevation=-60, distance=10)\n",
+ " mlab.process_ui_events()\n",
+ " time.sleep = 0.005\n",
+ " mlab.savefig('curl_%02d.png' % i)\n",
+ " \n",
+ "\n",
+ "x, y, z = np.mgrid[-2:3, -2:3, -2:3]\n",
+ "p = x\n",
+ "q = y\n",
+ "r = 4.5*(x**2 - y**2)\n",
+ "\n",
+ "b = mlab.quiver3d(x, y, z, p, q, r, colormap = 'gist_earth')\n",
+ "for j in range(25):\n",
+ " mlab.view(65, -65)\n",
+ " mlab.view(azimuth= 3.6*j, elevation=-60, distance=10)\n",
+ " mlab.process_ui_events()\n",
+ " time.sleep = 0.005\n",
+ " mlab.savefig('curl2_%02d.png' % j)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ }
+ ],
+ "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.9"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 4
+}