Пример #1
0
print(r'\bm{\mbox{Metric tensor (cartesian coordinates - norm = False)}}')
from sympy import cos, sin, symbols
g3coords = (x, y, z) = symbols('x y z')
g3 = Ga('ex ey ez', g=[1, 1, 1], coords=g3coords, norm=False)  # Create g3
(e_x, e_y, e_z) = g3.mv()

print('g =', g3.g)
print('\\')

print(r'\bm{\mbox{Two dimensioanal submanifold - Unit sphere}}')
print(r'\text{Basis not normalised}')

sp2coords = (theta, phi) = symbols('theta phi', real=True)
sp2param = [sin(theta) * cos(phi), sin(theta) * sin(phi), cos(theta)]

sp2 = g3.sm(sp2param, sp2coords, norm=False)  # submanifold

(etheta, ephi) = sp2.mv()  # sp2 basis vectors
(rtheta, rphi) = sp2.mvr()  # sp2 reciprocal basis vectors

sp2grad = sp2.grad

sph_map = [1, theta, phi]  # Coordinate map for sphere of r = 1
print(r'(\theta,\phi)\rightarrow (r,\theta,\phi) = ', latex(sph_map))

(etheta, ephi) = sp2.mv()
print(r'e_\theta | e_\theta = ', etheta | etheta)
print(r'e_\phi | e_\phi = ', ephi | ephi)

print('g =', sp2.g)
print(r'\text{g\_inv = }', latex(sp2.g_inv))
Пример #2
0
sp3d = Ga('e_r,e_th,e_ph', g=[1, r**2, r**2 * sin(th)**2], coords=coords)
(er, eth, ephi) = sp3d.mv()

#Define coordinates for 2-d (u,v) and 1-d (s) manifolds

u, v, s, alpha = symbols('u v s alpha', real=True)

sub_coords = (u, v)

smap = [1, u, v]  # Coordinate map for sphere of r = 1 in 3-d

print(r'(u,v)\rightarrow (r,\theta,\phi) = ', smap)

#Define unit sphere manifold

sph2d = sp3d.sm(smap, sub_coords)

print('#Unit Sphere Manifold:')

print('g =', sph2d.g)

(eu, ev) = sph2d.mv()

#Define vector and vector field on unit sphere tangent space

a = sph2d.mv('a', 'vector')
b = sph2d.mv('b', 'vector')
c = sph2d.mv('c', 'vector')
f = sph2d.mv('f', 'vector', f=True)

print('a =', a)
Пример #3
0
from __future__ import absolute_import, division
from __future__ import print_function
from sympy import symbols, sin, pi, latex
from galgebra.ga import Ga
from galgebra.printer import Format, xpdf

Format()
coords = (r, th, phi) = symbols('r,theta,phi', real=True)
sp3d = Ga('e_r e_th e_ph', g=[1, r**2, r**2 * sin(th)**2],
          coords=coords, norm=True)

sph_uv = (u, v) = symbols('u,v', real=True)
sph_map = [1, u, v]  # Coordinate map for sphere of r = 1
sph2d = sp3d.sm(sph_map, sph_uv)

print(r'(u,v)\rightarrow (r,\theta,\phi) = ', latex(sph_map))
# FIXME submanifold basis vectors are not normalized, g is incorrect
print('g =', latex(sph2d.g))
F = sph2d.mv('F', 'vector', f=True)  # scalar function
f = sph2d.mv('f', 'scalar', f=True)  # vector function
print(r'\nabla f =', sph2d.grad * f)
print('F =', F)
print(r'\nabla F = ', sph2d.grad * F)

cir_s = s = symbols('s', real=True)
cir_map = [pi /  8, s]
cir1d = sph2d.sm(cir_map, (cir_s,))

print('g =', latex(cir1d.g))
h = cir1d.mv('h', 'scalar', f=True)
H = cir1d.mv('H', 'vector', f=True)