1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
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
}
|