-
Notifications
You must be signed in to change notification settings - Fork 62
/
curvi_linear_latex.py
198 lines (152 loc) · 5.7 KB
/
curvi_linear_latex.py
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
from __future__ import print_function
import sys
from sympy import symbols,sin,cos,sinh,cosh
from galgebra.ga import Ga
from galgebra.printer import Format, xpdf, Print_Function, Eprint
def derivatives_in_spherical_coordinates():
#Print_Function()
coords = (r,th,phi) = symbols('r theta phi', real=True)
(sp3d,er,eth,ephi) = Ga.build('e_r e_theta e_phi',g=[1,r**2,r**2*sin(th)**2],coords=coords)
grad = sp3d.grad
f = sp3d.mv('f','scalar',f=True)
A = sp3d.mv('A','vector',f=True)
B = sp3d.mv('B','bivector',f=True)
print('#Derivatives in Spherical Coordinates')
print('f =',f)
print('A =',A)
print('B =',B)
print('grad*f =',grad*f)
print('grad|A =',grad|A)
print('grad\\times A = -I*(grad^A) =',-sp3d.i*(grad^A))
print('%\\nabla^{2}f =',grad|(grad*f))
print('grad^B =',grad^B)
"""
print '( \\nabla\\W\\nabla )\\bm{e}_{r} =',((grad^grad)*er).trigsimp()
print '( \\nabla\\W\\nabla )\\bm{e}_{\\theta} =',((grad^grad)*eth).trigsimp()
print '( \\nabla\\W\\nabla )\\bm{e}_{\\phi} =',((grad^grad)*ephi).trigsimp()
"""
return
def derivatives_in_paraboloidal_coordinates():
#Print_Function()
coords = (u,v,phi) = symbols('u v phi', real=True)
(par3d,er,eth,ephi) = Ga.build('e_u e_v e_phi',X=[u*v*cos(phi),u*v*sin(phi),(u**2-v**2)/2],coords=coords,norm=True)
grad = par3d.grad
f = par3d.mv('f','scalar',f=True)
A = par3d.mv('A','vector',f=True)
B = par3d.mv('B','bivector',f=True)
print('#Derivatives in Paraboloidal Coordinates')
print('f =',f)
print('A =',A)
print('B =',B)
print('grad*f =',grad*f)
print('grad|A =',grad|A)
(-par3d.i*(grad^A)).Fmt(3,'grad\\times A = -I*(grad^A)')
print('grad^B =',grad^B)
return
def derivatives_in_elliptic_cylindrical_coordinates():
#Print_Function()
a = symbols('a', real=True)
coords = (u,v,z) = symbols('u v z', real=True)
(elip3d,er,eth,ephi) = Ga.build('e_u e_v e_z',X=[a*cosh(u)*cos(v),a*sinh(u)*sin(v),z],coords=coords,norm=True)
grad = elip3d.grad
f = elip3d.mv('f','scalar',f=True)
A = elip3d.mv('A','vector',f=True)
B = elip3d.mv('B','bivector',f=True)
print('#Derivatives in Elliptic Cylindrical Coordinates')
print('f =',f)
print('A =',A)
print('B =',B)
print('grad*f =',grad*f)
print('grad|A =',grad|A)
print('-I*(grad^A) =',-elip3d.i*(grad^A))
print('grad^B =',grad^B)
return
def derivatives_in_prolate_spheroidal_coordinates():
#Print_Function()
a = symbols('a', real=True)
coords = (xi,eta,phi) = symbols('xi eta phi', real=True)
(ps3d,er,eth,ephi) = Ga.build('e_xi e_eta e_phi',X=[a*sinh(xi)*sin(eta)*cos(phi),a*sinh(xi)*sin(eta)*sin(phi),
a*cosh(xi)*cos(eta)],coords=coords,norm=True)
grad = ps3d.grad
f = ps3d.mv('f','scalar',f=True)
A = ps3d.mv('A','vector',f=True)
B = ps3d.mv('B','bivector',f=True)
print('#Derivatives in Prolate Spheroidal Coordinates')
print('f =',f)
print('A =',A)
print('B =',B)
print('grad*f =',grad*f)
print('grad|A =',grad|A)
(-ps3d.i*(grad^A)).Fmt(3,'-I*(grad^A)')
(grad^B).Fmt(3,'grad^B')
return
def derivatives_in_oblate_spheroidal_coordinates():
Print_Function()
a = symbols('a', real=True)
coords = (xi,eta,phi) = symbols('xi eta phi', real=True)
(os3d,er,eth,ephi) = Ga.build('e_xi e_eta e_phi',X=[a*cosh(xi)*cos(eta)*cos(phi),a*cosh(xi)*cos(eta)*sin(phi),
a*sinh(xi)*sin(eta)],coords=coords,norm=True)
grad = os3d.grad
f = os3d.mv('f','scalar',f=True)
A = os3d.mv('A','vector',f=True)
B = os3d.mv('B','bivector',f=True)
print('f =',f)
print('A =',A)
print('B =',B)
print('grad*f =',grad*f)
print('grad|A =',grad|A)
print('-I*(grad^A) =',-os3d.i*(grad^A))
print('grad^B =',grad^B)
return
def derivatives_in_bipolar_coordinates():
Print_Function()
a = symbols('a', real=True)
coords = (u,v,z) = symbols('u v z', real=True)
(bp3d,eu,ev,ez) = Ga.build('e_u e_v e_z',X=[a*sinh(v)/(cosh(v)-cos(u)),a*sin(u)/(cosh(v)-cos(u)),z],coords=coords,norm=True)
grad = bp3d.grad
f = bp3d.mv('f','scalar',f=True)
A = bp3d.mv('A','vector',f=True)
B = bp3d.mv('B','bivector',f=True)
print('f =',f)
print('A =',A)
print('B =',B)
print('grad*f =',grad*f)
print('grad|A =',grad|A)
print('-I*(grad^A) =',-bp3d.i*(grad^A))
print('grad^B =',grad^B)
return
def derivatives_in_toroidal_coordinates():
Print_Function()
a = symbols('a', real=True)
coords = (u,v,phi) = symbols('u v phi', real=True)
(t3d,eu,ev,ephi) = Ga.build('e_u e_v e_phi',X=[a*sinh(v)*cos(phi)/(cosh(v)-cos(u)),
a*sinh(v)*sin(phi)/(cosh(v)-cos(u)),
a*sin(u)/(cosh(v)-cos(u))],coords=coords,norm=True)
grad = t3d.grad
f = t3d.mv('f','scalar',f=True)
A = t3d.mv('A','vector',f=True)
B = t3d.mv('B','bivector',f=True)
print('f =',f)
print('A =',A)
print('B =',B)
print('grad*f =',grad*f)
print('grad|A =',grad|A)
print('-I*(grad^A) =',-t3d.i*(grad^A))
print('grad^B =',grad^B)
return
def main():
#Eprint()
Format()
derivatives_in_spherical_coordinates()
derivatives_in_paraboloidal_coordinates()
# FIXME This takes ~600 seconds
# derivatives_in_elliptic_cylindrical_coordinates()
derivatives_in_prolate_spheroidal_coordinates()
#derivatives_in_oblate_spheroidal_coordinates()
#derivatives_in_bipolar_coordinates()
#derivatives_in_toroidal_coordinates()
# xpdf()
xpdf(pdfprog=None)
return
if __name__ == "__main__":
main()