Exemplo n.º 1
0
def main():
    #Get_Program()
    Format()

    EM_Waves_in_Geom_Calculus()

    xpdf()
    return
Exemplo n.º 2
0
def main():
    #Get_Program()
    Format()

    EM_Waves_in_Geom_Calculus()

    xpdf()
    return
Exemplo n.º 3
0
def main():
    Get_Program()
    Format()

    EM_Waves_in_Geom_Calculus_Complex()
    EM_Waves_in_Geom_Calculus_Real()
    xpdf()
    return
Exemplo n.º 4
0
def main():
    #Get_Program()
    Format()

    #EM_Waves_in_Geom_Calculus_Complex()
    EM_Waves_in_Geom_Calculus_Real()
    xpdf()
    return
Exemplo n.º 5
0
def main():
    Get_Program(True)
    Format()

    basic_multivector_operations_3D()
    basic_multivector_operations_2D()

    xpdf('simple_test_latex.tex')
    return
Exemplo n.º 6
0
def main():
    Get_Program(True)
    Format()

    basic_multivector_operations_3D()
    basic_multivector_operations_2D()

    xpdf('simple_test_latex.tex')
    return
Exemplo n.º 7
0
def main():
    Get_Program()
    Format()

    Maxwells_Equations_in_Geom_Calculus()
    Dirac_Equation_in_Geog_Calculus()
    Lorentz_Tranformation_in_Geog_Algebra()

    xpdf()
    return
Exemplo n.º 8
0
def main():
    Get_Program()
    Format()

    #Maxwells_Equations_in_Geom_Calculus()
    #Dirac_Equation_in_Geom_Calculus()
    #Lorentz_Tranformation_in_Geog_Algebra()
    Lie_Group()

    xpdf()
    return
Exemplo n.º 9
0
def main():
    Get_Program()
    Format()

    # Maxwells_Equations_in_Geom_Calculus()
    # Dirac_Equation_in_Geom_Calculus()
    # Lorentz_Tranformation_in_Geog_Algebra()
    General_Lorentz_Tranformation()
    # Lie_Group()

    xpdf()
    return
Exemplo n.º 10
0
def main():
    #Get_Program()
    #Eprint()
    Format()
    derivatives_in_spherical_coordinates()
    derivatives_in_paraboloidal_coordinates()
    derivatives_in_elliptic_cylindrical_coordinates()
    derivatives_in_prolate_spheroidal_coordinates()
    #derivatives_in_oblate_spheroidal_coordinates()
    #derivatives_in_bipolar_coordinates()
    #derivatives_in_toroidal_coordinates()

    xpdf()
    return
Exemplo n.º 11
0
def main():
    #Get_Program()
    #Eprint()
    Format()
    derivatives_in_spherical_coordinates()
    derivatives_in_paraboloidal_coordinates()
    derivatives_in_elliptic_cylindrical_coordinates()
    derivatives_in_prolate_spheroidal_coordinates()
    #derivatives_in_oblate_spheroidal_coordinates()
    #derivatives_in_bipolar_coordinates()
    #derivatives_in_toroidal_coordinates()

    xpdf()
    return
Exemplo n.º 12
0
def main():
    Format()
    a = Matrix(2, 2, (1, 2, 3, 4))
    b = Matrix(2, 1, (5, 6))
    c = a * b
    print a, b, '=', c

    x, y = symbols('x, y')

    d = Matrix(1, 2, (x**3, y**3))
    e = Matrix(2, 2, (x**2, 2 * x * y, 2 * x * y, y**2))
    f = d * e

    print '%', d, e, '=', f

    xpdf()
    return
Exemplo n.º 13
0
def main():
    Format()
    a = Matrix ( 2, 2, ( 1, 2, 3, 4 ) )
    b = Matrix ( 2, 1, ( 5, 6 ) )
    c = a * b
    print a,b,'=',c

    x, y = symbols ('x, y')

    d = Matrix ( 1, 2, ( x ** 3, y ** 3 ))
    e = Matrix ( 2, 2, ( x ** 2, 2 * x * y, 2 * x * y, y ** 2 ) )
    f = d * e

    print '%',d,e,'=',f

    xpdf()
    return
Exemplo n.º 14
0
def main():
    Get_Program()

    Format()
    basic_multivector_operations_3D()
    basic_multivector_operations_2D()
    basic_multivector_operations_2D_orthogonal()
    check_generalized_BAC_CAB_formulas()
    rounding_numerical_components()
    derivatives_in_rectangular_coordinates()
    derivatives_in_spherical_coordinates()
    noneuclidian_distance_calculation()
    conformal_representations_of_circles_lines_spheres_and_planes()
    properties_of_geometric_objects()
    extracting_vectors_from_conformal_2_blade()
    reciprocal_frame_test()

    xpdf(debug=True)
    return
Exemplo n.º 15
0
def main():
    Get_Program()

    Format()
    basic_multivector_operations_3D()
    basic_multivector_operations_2D()
    basic_multivector_operations_2D_orthogonal()
    check_generalized_BAC_CAB_formulas()
    rounding_numerical_components()
    derivatives_in_rectangular_coordinates()
    derivatives_in_spherical_coordinates()
    noneuclidian_distance_calculation()
    conformal_representations_of_circles_lines_spheres_and_planes()
    properties_of_geometric_objects()
    extracting_vectors_from_conformal_2_blade()
    reciprocal_frame_test()

    xpdf()
    return
Exemplo n.º 16
0
def main():
    Format()
    snr=1
    g = '0 0 1 0 ,0 0 0 1 ,1 0 0 0 ,0 1 0 0'
    sk4coords = (e1,e2,e3,e4) = symbols('e1 e2 e3 e4')
    sk4 = Ga('e_1 e_2 e_3 e_4', g=g, coords=sk4coords)
    (e1,e2,e3,e4) = sk4.mv()
    print 'g_{ii} =',sk4.g

    v = symbols('v', real=True)
    x1=(e1+e3)/sqrt(2)
    x2=(e2+e4)/sqrt(2)
    print 'x_1<x_1==',x1<x1
    print 'x_1<x_2==',x1<x2
    print 'x_2<x_1==',x2<x1
    print 'x_2<x_2==',x2<x2
    print r'#$-\infty < v < \infty$'
    print '(-v*(x_1^x_2)/2).exp()==',(-v*(x1^x2)/2).exp()
    v = symbols('v', real=True, positive=True)
    print r'#$0\le v < \infty$'
    print '(-v*(x_1^x_2)/2).exp()==',(-v*(x1^x2)/2).exp()

    xpdf()
    return
Exemplo n.º 17
0
print '\\f{\\det}{A} =', A2d.det()
print '\\f{\\Tr}{A} =', A2d.tr()

B2d = g2d.lt('B')

print 'B =', B2d
print 'A + B =', A2d + B2d
print 'AB =', A2d * B2d
print 'A - B =', A2d - B2d

a = g2d.mv('a','vector')
b = g2d.mv('b','vector')

print r'a|\f{\overline{A}}{b}-b|\f{\underline{A}}{a} =',((a|A2d.adj()(b))-(b|A2d(a))).simplify()

m4d = Ga('e_t e_x e_y e_z', g=[1, -1, -1, -1],coords=symbols('t,x,y,z',real=True))

T = m4d.lt('T')

print '#$T$ is a linear transformation in Minkowski space'
print r'\underline{T} =',T
print r'\overline{T} =',T.adj()
print r'\f{\mbox{tr}}{\underline{T}} =',T.tr()

a = m4d.mv('a','vector')
b = m4d.mv('b','vector')

print r'a|\f{\overline{T}}{b}-b|\f{\underline{T}}{a} =',((a|T.adj()(b))-(b|T(a))).simplify()

xpdf(paper='landscape',crop=True)
Exemplo n.º 18
0
Format()
xyz_coords = (x, y, z) = symbols('x y z', real=True)
(o3d, ex, ey, ez) = Ga.build('e', g=[1, 1, 1], coords=xyz_coords, norm=True)
f = o3d.mv('f', 'scalar', f=True)
lap = o3d.grad * o3d.grad
print r'%\nabla^{2} = \nabla\cdot\nabla =', lap
print r'%\lp\nabla^{2}\rp f =', lap * f
print r'%\nabla\cdot\lp\nabla f\rp =', o3d.grad | (o3d.grad * f)

sph_coords = (r, th, phi) = symbols('r theta phi', real=True)
(sp3d, er, eth, ephi) = Ga.build('e',
                                 g=[1, r**2, r**2 * sin(th)**2],
                                 coords=sph_coords,
                                 norm=True)
f = sp3d.mv('f', 'scalar', f=True)
lap = sp3d.grad * sp3d.grad
print r'%\nabla^{2} = \nabla\cdot\nabla =', lap
print r'%\lp\nabla^{2}\rp f =', lap * f
print r'%\nabla\cdot\lp\nabla f\rp =', sp3d.grad | (sp3d.grad * f)
print Fmt([o3d.grad, o3d.grad])
F = sp3d.mv('F', 'vector', f=True)
print F.title
print F
F.fmt = 3
print F.title
print F
print F.title
print Fmt((F, F))
xpdf(paper=(6, 7))
Exemplo n.º 19
0
def main():
    Format()

    coords = (x,y,z) = symbols('x y z',real=True)

    (o3d,ex,ey,ez) = Ga.build('e*x|y|z',g=[1,1,1],coords=coords)

    s = o3d.mv('s','scalar')
    v = o3d.mv('v','vector')
    b = o3d.mv('b','bivector')

    print(r'#3D Orthogonal Metric\newline')

    print('#Multvectors:')
    print('s =',s)
    print('v =',v)
    print('b =',b)

    print('#Products:')

    X = ((s,'s'),(v,'v'),(b,'b'))

    for xi in X:
        print('')
        for yi in X:
            print(xi[1]+' * '+yi[1]+' =',xi[0]*yi[0])
            print(xi[1]+' ^ '+yi[1]+' =',xi[0]^yi[0])
            if xi[1] != 's' and yi[1] != 's':
                print(xi[1]+' | '+yi[1]+' =',xi[0]|yi[0])
            print(xi[1]+' < '+yi[1]+' =',xi[0]<yi[0])
            print(xi[1]+' > '+yi[1]+' =',xi[0]>yi[0])

    fs = o3d.mv('s','scalar',f=True)
    fv = o3d.mv('v','vector',f=True)
    fb = o3d.mv('b','bivector',f=True)

    print('#Multivector Functions:')

    print('s(X) =',fs)
    print('v(X) =',fv)
    print('b(X) =',fb)

    print('#Products:')

    fX = ((o3d.grad,'grad'),(fs,'s'),(fv,'v'),(fb,'b'))

    for xi in fX:
        print('')
        for yi in fX:
            if xi[1] == 'grad' and yi[1] == 'grad':
                pass
            else:
                print(xi[1]+' * '+yi[1]+' =',xi[0]*yi[0])
                print(xi[1]+' ^ '+yi[1]+' =',xi[0]^yi[0])
                if xi[1] != 's' and yi[1] != 's':
                    print(xi[1]+' | '+yi[1]+' =',xi[0]|yi[0])
                print(xi[1]+' < '+yi[1]+' =' ,xi[0]<yi[0])
                print(xi[1]+' > '+yi[1]+' =' ,xi[0]>yi[0])


    (g2d,ex,ey) = Ga.build('e',coords=(x,y))

    print(r'#General 2D Metric\newline')
    print('#Multivector Functions:')

    s = g2d.mv('s','scalar',f=True)
    v = g2d.mv('v','vector',f=True)
    b = g2d.mv('v','bivector',f=True)

    print('s(X) =',s)
    print('v(X) =',v)
    print('b(X) =',b)

    X = ((g2d.grad,'grad'),(s,'s'),(v,'v'))

    print('#Products:')

    for xi in X:
        print('')
        for yi in X:
            if xi[1] == 'grad' and yi[1] == 'grad':
                pass
            else:
                print(xi[1]+' * '+yi[1]+' =',xi[0]*yi[0])
                print(xi[1]+' ^ '+yi[1]+' =',xi[0]^yi[0])
                if xi[1] != 's' and yi[1] != 's':
                    print(xi[1]+' | '+yi[1]+' =',xi[0]|yi[0])
                else:
                    print(xi[1]+' | '+yi[1]+' = Not Allowed')
                print(xi[1]+' < '+yi[1]+' =',xi[0]<yi[0])
                print(xi[1]+' > '+yi[1]+' ='  ,xi[0]>yi[0])

    xpdf(paper='letter')
    return
Exemplo n.º 20
0
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))
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)
print(r'(s)\rightarrow (u,v) = ', latex(cir_map))
print('H =', H)
print(latex(H))
print(r'\nabla h =', cir1d.grad * h)
print(r'\nabla H =', cir1d.grad * H)
xpdf(filename='submanifold.tex', paper=(6, 5), crop=True)
Exemplo n.º 21
0
gradF_reduced = (EBkst.grad*F)/(I*exp(I*KX))

gradF_reduced.Fmt(3,r'%\lp\bm{\nabla}F\rp/\lp ie^{iK\cdot X} \rp = 0')

print r'%\mbox{Previous equation requires that: }e_{E}\cdot e_{B} = 0'+\
       r'\mbox{ if }B\ne 0\mbox{ and }k\ne 0'

gradF_reduced = gradF_reduced.subs({EBkst.g[0,1]:0})
gradF_reduced.Fmt(3,r'%\lp\bm{\nabla}F\rp/\lp ie^{iK\cdot X} \rp = 0')

(coefs,bases) = linear_expand(gradF_reduced.obj)

eq1 = coefs[0]
eq2 = coefs[1]

B1 = solve(eq1,B)[0]
B2 = solve(eq2,B)[0]

print r'\mbox{eq1: }B =',B1
print r'\mbox{eq2: }B =',B2

eq3 = B1-B2

print r'\mbox{eq3 = eq1-eq2: }0 =',eq3
eq3 = simplify(eq3 / E)
print r'\mbox{eq3 = (eq1-eq2)/E: }0 =',eq3
print '#Solutions for $k$ and $B$ in terms of $\omega$ and $E$:'
print 'k =',Matrix(solve(eq3,k))
print 'B =',Matrix([B1.subs(w,k),B1.subs(-w,k)])
xpdf(paper='landscape',prog=True)
Exemplo n.º 22
0
from sympy import symbols, sin, cos, latex, Matrix
from ga import Ga
from printer import Format, xpdf

Format()
(x, y, z) = xyz = symbols('x,y,z', real=True)
(o3d, ex, ey, ez) = Ga.build('e_x e_y e_z', g=[1, 1, 1], coords=xyz)

A = o3d.lt('A')
print(r'\mbox{General Instantiation: }A =', A)
th = symbols('theta', real=True)
R = cos(th / 2) + (ex ^ ey) * sin(th / 2)
B = o3d.lt(R)
print(r'\mbox{Rotor: }R =', R)
print(r'\mbox{Rotor Instantiation: }B =', B)
dict1 = {ex: ey + ez, ez: ey + ez, ey: ex + ez}
C = o3d.lt(dict1)
print(r'\mbox{Dictionary} =', latex(dict1))
print(r'\mbox{Dictionary Instantiation: }C =', C)
lst1 = [[1, 0, 1], [0, 1, 0], [1, 0, 1]]
D = o3d.lt(lst1)
print(r'\mbox{List} =', latex(lst1))
print(r'\mbox{List Instantiation: }D =', D)
lst2 = [ey + ez, ex + ez, ex + ey]
E = o3d.lt(lst2)
print(r'\mbox{List} =', latex(lst2))
print(r'\mbox{List Instantiation: }E =', E)
xpdf(paper=(10, 12), crop=True)
Exemplo n.º 23
0
def main():
    Get_Program()
    Format()
    Product_of_Rotors()
    xpdf(paper=(8.5, 11), debug=True)
    return
Exemplo n.º 24
0
from printer import Format, xpdf
from ga import Ga
from mv import Com
Format()

(g4d,a,b,c,d) = Ga.build('a b c d')
print '\\bm{a|(b*c)} =',a|(b*c)
print '\\bm{a|(b^c)} =',a|(b^c)
print '\\bm{a|(b^c^d)} =',a|(b^c^d)
print '\\bm{a|(b^c)+c|(a^b)+b|(c^a)} =',(a|(b^c))+(c|(a^b))+(b|(c^a))
print '\\bm{a*(b^c)-b*(a^c)+c*(a^b)} =',a*(b^c)-b*(a^c)+c*(a^b)
print '\\bm{a*(b^c^d)-b*(a^c^d)+c*(a^b^d)-d*(a^b^c)} =',a*(b^c^d)-b*(a^c^d)+c*(a^b^d)-d*(a^b^c)
print '\\bm{(a^b)|(c^d)} =',(a^b)|(c^d)
print '\\bm{((a^b)|c)|d} =',((a^b)|c)|d
print '\\bm{(a^b)\\times (c^d)} =',Com(a^b,c^d)

xpdf(paper='letter')
Exemplo n.º 25
0
from sympy import symbols, sin
from printer import Format, xpdf, Fmt
from ga import Ga

Format()

g = '# 0 #, 0 # 0, # 0 #'

(g3d, ea, eab, eb) = Ga.build('e_a e_ab e_b', g=g)

print(g3d.g)

v = g3d.mv('v', 'vector')
B = g3d.mv('B', 'bivector')

print(v)
print(B)
xpdf()
Exemplo n.º 26
0
def main():
    Get_Program()
    Format()
    Product_of_Rotors()
    xpdf(paper=(8.5,11),debug=True)
    return
Exemplo n.º 27
0
print '#2d general ($A,\\;B$ are linear transformations)'
A2d = g2d.lt('A')
print 'A =', A2d
print '\\f{\\det}{A} =', A2d.det()
#A2d.adj().Fmt(4,'\\overline{A}')
print '\\f{\\Tr}{A} =', A2d.tr()
print '\\f{A}{e_u^e_v} =', A2d(eu^ev)
print '\\f{A}{e_u}^\\f{A}{e_v} =', A2d(eu)^A2d(ev)
B2d = g2d.lt('B')
print 'B =', B2d
print 'A + B =', A2d + B2d
print 'AB =', A2d * B2d
print 'A - B =', A2d - B2d
a = g2d.mv('a','vector')
b = g2d.mv('b','vector')
print r'a|\f{\overline{A}}{b}-b|\f{\underline{A}}{a} =',((a|A2d.adj()(b))-(b|A2d(a))).simplify()

print '#4d Minkowski spaqce (Space Time)'
m4d = Ga('e_t e_x e_y e_z', g=[1, -1, -1, -1],coords=symbols('t,x,y,z',real=True))
T = m4d.lt('T')
print 'g =', m4d.g
print r'\underline{T} =',T
print r'\overline{T} =',T.adj()
#m4d.mv(T.det()).Fmt(4,r'\f{\det}{\underline{T}}')
print r'\f{\mbox{tr}}{\underline{T}} =',T.tr()
a = m4d.mv('a','vector')
b = m4d.mv('b','vector')
print r'a|\f{\overline{T}}{b}-b|\f{\underline{T}}{a} =',((a|T.adj()(b))-(b|T(a))).simplify()
xpdf(paper='landscape')
Exemplo n.º 28
0
def main():
    #Eprint()
    Format()

    o3d = Ga.preset('o3d')
    print 'I =',o3d.I
    x,y,z = o3d.coords

    (ex,ey,ez) = o3d.mv()

    u, v, w = o3d.mv('u v w', 'vector')

    print '# 3D Orthogonal Rectangular Coordinates'

    print 'u =',u
    print 'v =',v
    print 'w =',w

    uv = u^v
    print 'u^v =',uv
    uvw = u^v^w
    print 'u^v^w =',uvw

    print '(e_x+e_y)(e_y+e_z) =',(ex+ey)*(ey+ez)

    print r'\nabla =',o3d.grad
    print r'\dot{\nabla} =',o3d.grad

    f= o3d.mv('F', 'vector',f=True)
    print 'F =',f
    print r'\nabla F =',o3d.grad*f
    print r'F \dot{\nabla} =',f*o3d.rgrad
    print r'F \nabla =',f*o3d.grad
    print r'\dot{\nabla} F =',o3d.rgrad*f
    print r'F | \nabla =',f | o3d.grad

    G = y * z * ex + y ** 2 * ey + z ** 3 * ez

    print 'G =',G
    print r'\nabla G =', o3d.grad * G
    print r'\nabla ^ G =', o3d.grad ^ G
    print '#3D Orthogonal Spherical Coordinates'

    sp3d = Ga.preset('sph3d')
    r, th, phi = sp3d.coords
    er, eth, ephi = sp3d.mv()
    f, F = sp3d.mv('f F','scalar vector',f=True)

    print 'f =',f
    print r'\nabla =',sp3d.grad
    print r'\nabla f =',sp3d.grad*f
    print 'F =',F
    print r'\nabla | F =',sp3d.grad|F
    print r'-I\nabla ^ F =',-sp3d.I*(sp3d.grad^F)

    Lap = sp3d.grad|sp3d.grad

    print r'%\nabla^{2} =',Lap
    print r'%\nabla^{2} f =',Lap*f

    print '#Parabolic submanifold $[u,v,u^{2}+v^{2}]$ of o3d'

    sm_coords = (u,v) = symbols('u,v',real=True)

    Ga.set_simp(1,1,1)  # Additionally turn on combining fractions

    para = o3d.sm([u,v,u**2+v**2],sm_coords)

    print 'g_{parabolic} =', para.g

    (eu,ev) = para.mv()
    para_grad = para.grad

    print r'\nabla_{parabolic} =',para_grad

    f,F = para.mv('f F','scalar vector',f=True)

    print 'f = ', f
    print 'F = ', F

    print r'\nabla_{parabolic} f =',para_grad*f
    print r'\nabla_{parabolic} | F =',para_grad|F
    print r'\nabla_{parabolic} ^ F =',para_grad^F
    print r'\nabla_{parabolic}  F =',para_grad*F

    Ga.set_simp(1,1,0)  # Additionally turn off combining fractions

    sph = o3d.sm([sin(u)*cos(v),sin(u)*sin(v),cos(u)],sm_coords)

    print '#Spherical submanifold $[sin(u)*cos(v),sin(u)*sin(v),cos(u)]$ of o3d'

    (eu,ev) = sph.mv()
    sph_grad = sph.grad

    print 'g_{sphere} =', sph.g

    print r'\nabla_{spherical} =',sph_grad

    f,F = sph.mv('f F','scalar vector',f=True)

    print r'\nabla_{sphere} f =',sph_grad*f
    print r'\nabla_{sphere} | F =',sph_grad|F
    print r'\nabla_{sphere} ^ F =',sph_grad^F
    print r'\nabla_{sphere}  F =',sph_grad*F

    s = symbols('s',real=True)

    circ = sph.sm([pi/4,s],(s,))

    print '#Circular submanifold $[pi/4,s]$ of sphere (latitude 45 deg North)'

    es = circ.mv()
    circ_grad = circ.grad

    print 'g_{circ} =',circ.g

    print r'\nabla_{circle} =',circ_grad

    f,F = circ.mv('f F','scalar vector',f=True)

    print r'\nabla_{circle} f =',circ_grad*f
    print r'\nabla_{circle} F =',circ_grad*F

    print r'#Unit Great Circle Manifold at $\pi/4$ radians to Equator'

    #Calculate great circle at 45 degs to equator through x-axis

    a = pi/4
    u = ey ^ ez
    X = cos(s) * ex + sin(s) * ey
    R = cos(a/2) + u * sin(a/2)

    RXRrev = R*X*R.rev()
    print 'X(s) =',RXRrev

    M_gc = o3d.sm(RXRrev.list(),(s,))
    es = M_gc.mv()
    print 'g =',M_gc.g
    print r'\nabla_{gc} =',M_gc.grad
    xpdf()

    return
Exemplo n.º 29
0
X = x * ex + y * ey + z * ez
I = o3d.i
v = o3d.mv("v", "vector")
f = o3d.mv("f", "scalar", f=True)
A = o3d.mv("A", "vector", f=True)
dd = v | o3d.grad
lap = o3d.grad * o3d.grad
print r"\bm{X} =", X
print r"\bm{v} =", v
print r"\bm{A} =", A
print r"%\bm{v}\cdot\nabla =", dd
print r"%\nabla^{2} =", lap
print r"%\bm{v}\cdot\nabla f =", dd * f
print r"%\nabla^{2} f =", lap * f
print r"%\nabla^{2} \bm{A} =", lap * A
print r"%\bar{\nabla}\cdot v =", o3d.rgrad | v
Xgrad = X | o3d.grad
rgradX = o3d.rgrad | X
print r"%\bm{X}\cdot \nabla =", Xgrad
print r"%\bar{\nabla}\cdot \bm{X} =", rgradX
com = Xgrad - rgradX
print r"%\bm{X}\cdot \nabla - \bar{\nabla}\cdot \bm{X} =", com
sph_coords = (r, th, phi) = symbols("r theta phi", real=True)
(sp3d, er, eth, ephi) = Ga.build("e", g=[1, r ** 2, r ** 2 * sin(th) ** 2], coords=sph_coords, norm=True)
f = sp3d.mv("f", "scalar", f=True)
lap = sp3d.grad * sp3d.grad
print r"%\nabla^{2} = \nabla\cdot\nabla =", lap
print r"%\lp\nabla^{2}\rp f =", lap * f
print r"%\nabla\cdot\lp\nabla f\rp =", sp3d.grad | (sp3d.grad * f)
xpdf(paper="landscape", crop=True)
Exemplo n.º 30
0
def main():
    Format()

    coords = (x,y,z) = symbols('x y z',real=True)

    (o3d,ex,ey,ez) = Ga.build('e*x|y|z',g=[1,1,1],coords=coords)

    s = o3d.mv('s','scalar')
    v = o3d.mv('v','vector')
    b = o3d.mv('b','bivector')

    print r'#3D Orthogonal Metric\newline'

    print '#Multvectors:'
    print 's =',s
    print 'v =',v
    print 'b =',b

    print '#Products:'

    X = ((s,'s'),(v,'v'),(b,'b'))

    for xi in X:
        print ''
        for yi in X:
            print xi[1]+' * '+yi[1]+' =',xi[0]*yi[0]
            print xi[1]+' ^ '+yi[1]+' =',xi[0]^yi[0]
            if xi[1] != 's' and yi[1] != 's':
                print xi[1]+' | '+yi[1]+' =',xi[0]|yi[0]
            print xi[1]+' < '+yi[1]+' =',xi[0]<yi[0]
            print xi[1]+' > '+yi[1]+' =',xi[0]>yi[0]

    fs = o3d.mv('s','scalar',f=True)
    fv = o3d.mv('v','vector',f=True)
    fb = o3d.mv('b','bivector',f=True)

    print '#Multivector Functions:'

    print 's(X) =',fs
    print 'v(X) =',fv
    print 'b(X) =',fb

    print '#Products:'

    fX = ((o3d.grad,'grad'),(fs,'s'),(fv,'v'),(fb,'b'))

    for xi in fX:
        print ''
        for yi in fX:
            if xi[1] == 'grad' and yi[1] == 'grad':
                pass
            else:
                print xi[1]+' * '+yi[1]+' =',xi[0]*yi[0]
                print xi[1]+' ^ '+yi[1]+' =',xi[0]^yi[0]
                if xi[1] != 's' and yi[1] != 's':
                    print xi[1]+' | '+yi[1]+' =',xi[0]|yi[0]
                print xi[1]+' < '+yi[1]+' =' ,xi[0]<yi[0]
                print xi[1]+' > '+yi[1]+' =' ,xi[0]>yi[0]


    (g2d,ex,ey) = Ga.build('e',coords=(x,y))

    print r'#General 2D Metric\newline'
    print '#Multivector Functions:'

    s = g2d.mv('s','scalar',f=True)
    v = g2d.mv('v','vector',f=True)
    b = g2d.mv('v','bivector',f=True)

    print 's(X) =',s
    print 'v(X) =',v
    print 'b(X) =',b

    X = ((g2d.grad,'grad'),(s,'s'),(v,'v'))

    print '#Products:'

    for xi in X:
        print ''
        for yi in X:
            if xi[1] == 'grad' and yi[1] == 'grad':
                pass
            else:
                print xi[1]+' * '+yi[1]+' =',xi[0]*yi[0]
                print xi[1]+' ^ '+yi[1]+' =',xi[0]^yi[0]
                if xi[1] != 's' and yi[1] != 's':
                    print xi[1]+' | '+yi[1]+' =',xi[0]|yi[0]
                else:
                    print xi[1]+' | '+yi[1]+' = Not Allowed'
                print xi[1]+' < '+yi[1]+' =',xi[0]<yi[0]
                print xi[1]+' > '+yi[1]+' ='  ,xi[0]>yi[0]

    xpdf(paper='letter')
    return
Exemplo n.º 31
0
from sympy import symbols
from printer import Format, xpdf
from ga import Ga

Format()

coords = symbols('t x y z',real=True)
(st4d,g0,g1,g2,g3) = Ga.build('gamma*t|x|y|z',g=[1,-1,-1,-1],coords=coords)
I = st4d.i

(m,e) = symbols('m e')

psi = st4d.mv('psi','spinor',f=True)
A = st4d.mv('A','vector',f=True)
sig_z = g3*g0

print '\\text{4-Vector Potential\\;\\;}\\bm{A} =',A
print '\\text{8-component real spinor\\;\\;}\\bm{\\psi} =',psi

dirac_eq = (st4d.grad*psi)*I*sig_z-e*A*psi-m*psi*g0
dirac_eq = dirac_eq.simplify()

dirac_eq.Fmt(3,r'%\text{Dirac Equation\;\;}\nabla \bm{\psi} I \sigma_{z}-e\bm{A}\bm{\psi}-m\bm{\psi}\gamma_{t} = 0')

xpdf(crop=True, png=True)
Exemplo n.º 32
0
from ga import Ga
import sys

Format()
xyz_coords = (x, y, z) = symbols("x y z", real=True)
(o3d, ex, ey, ez) = Ga.build("e", g=[1, 1, 1], coords=xyz_coords, norm=True)
f = o3d.mv("f", "scalar", f=True)
lap = o3d.grad * o3d.grad
print r"\nabla =", o3d.grad
print r"%\nabla^{2} = \nabla . \nabla =", lap
print r"%\lp\nabla^{2}\rp f =", lap * f
print r"%\nabla\cdot\lp\nabla f\rp =", o3d.grad | (o3d.grad * f)

sph_coords = (r, th, phi) = symbols("r theta phi", real=True)
(sp3d, er, eth, ephi) = Ga.build("e", g=[1, r ** 2, r ** 2 * sin(th) ** 2], coords=sph_coords, norm=True)
f = sp3d.mv("f", "scalar", f=True)
lap = sp3d.grad * sp3d.grad
print r"%\nabla^{2} = \nabla\cdot\nabla =", lap
print r"%\lp\nabla^{2}\rp f =", lap * f
print r"%\nabla\cdot\lp\nabla f\rp =", sp3d.grad | (sp3d.grad * f)
print Fmt([o3d.grad, o3d.grad])
F = sp3d.mv("F", "vector", f=True)
print F.title
print F
F.fmt = 3
print F.title
print F
print F.title
print Fmt((F, F))
xpdf(paper=(6, 7))
Exemplo n.º 33
0
print 'E3 = (e1^e2)*E =',E3
w = (E1|e2)
w = w.expand()
print 'E1|e2 =',w
w = (E1|e3)
w = w.expand()
print 'E1|e3 =',w
w = (E2|e1)
w = w.expand()
print 'E2|e1 =',w
w = (E2|e3)
w = w.expand()
print 'E2|e3 =',w
w = (E3|e1)
w = w.expand()
print 'E3|e1 =',w
w = (E3|e2)
w = w.expand()
print 'E3|e2 =',w
w = (E1|e1)
w = (w.expand()).scalar()
Esq = expand(Esq)
print '%(E1\\cdot e1)/E^{2} =',simplify(w/Esq)
w = (E2|e2)
w = (w.expand()).scalar()
print '%(E2\\cdot e2)/E^{2} =',simplify(w/Esq)
w = (E3|e3)
w = (w.expand()).scalar()
print '%(E3\\cdot e3)/E^{2} =',simplify(w/Esq)
xpdf(paper='letter',prog=True)
Exemplo n.º 34
0
X = x*ex+y*ey+z*ez
I = o3d.i
v = o3d.mv('v','vector')
f = o3d.mv('f','scalar',f=True)
A = o3d.mv('A','vector',f=True)
dd = v|o3d.grad
lap = o3d.grad*o3d.grad
print r'\bm{X} =',X
print r'\bm{v} =',v
print r'\bm{A} =', A
print r'%\bm{v}\cdot\nabla =', dd
print r'%\nabla^{2} =',lap
print r'%\bm{v}\cdot\nabla f =',dd*f
print r'%\nabla^{2} f =',lap*f
print r'%\nabla^{2} \bm{A} =',lap*A
print r'%\bar{\nabla}\cdot v =', o3d.rgrad|v
Xgrad = X|o3d.grad
rgradX = o3d.rgrad|X
print r'%\bm{X}\cdot \nabla =', Xgrad
print r'%\bar{\nabla}\cdot \bm{X} =', rgradX
com = Xgrad - rgradX
print r'%\bm{X}\cdot \nabla - \bar{\nabla}\cdot \bm{X} =', com
sph_coords = (r,th,phi) = symbols('r theta phi',real=True)
(sp3d,er,eth,ephi) = Ga.build('e',g=[1,r**2,r**2*sin(th)**2],coords=sph_coords,norm=True)
f = sp3d.mv('f','scalar',f=True)
lap = sp3d.grad*sp3d.grad
print r'%\nabla^{2} = \nabla\cdot\nabla =', lap
print r'%\lp\nabla^{2}\rp f =', lap*f
print r'%\nabla\cdot\lp\nabla f\rp =',sp3d.grad|(sp3d.grad*f)
xpdf(paper=(6,7),crop=True,png=True)
Exemplo n.º 35
0
print '\\f{\\det}{A} =', A2d.det()
#A2d.adj().Fmt(4,'\\overline{A}')
print '\\f{\\Tr}{A} =', A2d.tr()
print '\\f{A}{e_u^e_v} =', A2d(eu ^ ev)
print '\\f{A}{e_u}^\\f{A}{e_v} =', A2d(eu) ^ A2d(ev)
B2d = g2d.lt('B')
print 'B =', B2d
print 'A + B =', A2d + B2d
print 'AB =', A2d * B2d
print 'A - B =', A2d - B2d
a = g2d.mv('a', 'vector')
b = g2d.mv('b', 'vector')
print r'a|\f{\overline{A}}{b}-b|\f{\underline{A}}{a} =', (
    (a | A2d.adj()(b)) - (b | A2d(a))).simplify()

print '#4d Minkowski spaqce (Space Time)'
m4d = Ga('e_t e_x e_y e_z',
         g=[1, -1, -1, -1],
         coords=symbols('t,x,y,z', real=True))
T = m4d.lt('T')
print 'g =', m4d.g
print r'\underline{T} =', T
print r'\overline{T} =', T.adj()
#m4d.mv(T.det()).Fmt(4,r'\f{\det}{\underline{T}}')
print r'\f{\mbox{tr}}{\underline{T}} =', T.tr()
a = m4d.mv('a', 'vector')
b = m4d.mv('b', 'vector')
print r'a|\f{\overline{T}}{b}-b|\f{\underline{T}}{a} =', (
    (a | T.adj()(b)) - (b | T(a))).simplify()
xpdf(paper=(10, 12), debug=True)
Exemplo n.º 36
0
                         X=(r * cos(th), r * sin(th), r**2))

grad_rth = Mrth.grad
f = (r + 1) * er + r**2 * eth
print r'\Nabla =', grad_rth
print 'g =', Mrth.g

Du = (er | grad_rth).simplify()
Dv = (eth | grad_rth).simplify()

print r'\bm{e}_{u}\cdot grad =', Du
print r'\bm{e}_{v}\cdot grad =', Dv

print r'\partial_{u}\bm{e}_{u} =', Du * er
print r'\partial_{v}\bm{e}_{u} =', Dv * er
print r'\partial_{u}\bm{e}_{v} =', Du * eth
print r'\partial_{v}\bm{e}_{v} =', Dv * eth

print 'f =', f

print 'grad * f =', grad_rth * f
print 'grad | f =', grad_rth | f
print 'grad ^ f =', grad_rth ^ f

h = er + eth
hd = h | grad_rth

print r'((\eb_{r}+\eb_{\theta}) \cdot grad)f =', hd * f

xpdf(paper='landscape')
Exemplo n.º 37
0
from ga import Ga
from printer import Format, xpdf

Format()

(alpha, beta, gamma) = symbols("alpha beta gamma")
(x, t, xp, tp) = symbols("x t x' t'", real=True)
(st2d, g0, g1) = Ga.build("gamma*t|x", g=[1, -1])

from sympy import sinh, cosh

R = cosh(alpha / 2) + sinh(alpha / 2) * (g0 ^ g1)
X = t * g0 + x * g1
Xp = tp * g0 + xp * g1
print "R =", R

print r"#%t\bm{\gamma_{t}}+x\bm{\gamma_{x}} = t'\bm{\gamma'_{t}}+x'\bm{\gamma'_{x}} = R\lp t'\bm{\gamma_{t}}+x'\bm{\gamma_{x}}\rp R^{\dagger}"

Xpp = R * Xp * R.rev()
Xpp = Xpp.collect()
Xpp = Xpp.trigsimp()
print r"%t\bm{\gamma_{t}}+x\bm{\gamma_{x}} =", Xpp
Xpp = Xpp.subs({sinh(alpha): gamma * beta, cosh(alpha): gamma})

print r"%\f{\sinh}{\alpha} = \gamma\beta"
print r"%\f{\cosh}{\alpha} = \gamma"

print r"%t\bm{\gamma_{t}}+x\bm{\gamma_{x}} =", Xpp.collect()

xpdf(paper="letter")
Exemplo n.º 38
0
from printer import Format, xpdf
from ga import Ga
from sympy import symbols

Format()
X = (x,y,z) = symbols('x y z')
o3d = Ga('e_x e_y e_z',g=[1,1,1],coords=X)

f = o3d.mv('f','scalar',f=True)
A = o3d.mv('A','vector',f=True)
B = o3d.mv('B','bivector',f=True)

print r'\bm{A} =',A
print r'\bm{B} =',B

print 'grad*f =',o3d.grad*f
print r'grad|\bm{A} =',o3d.grad|A
(o3d.grad*A).Fmt(2,r'grad*\bm{A}')

print r'-I*(grad^\bm{A}) =',-o3d.mv_I*(o3d.grad^A)
(o3d.grad*B).Fmt(2,r'grad*\bm{B}')
print r'grad^\bm{B} =',o3d.grad^B
print r'grad|\bm{B} =',o3d.grad|B

xpdf(crop=True)
Exemplo n.º 39
0
from sympy import symbols, sin, cos, latex, Matrix
from ga import Ga
from printer import Format, xpdf

Format()
(x, y, z) = xyz = symbols('x,y,z',real=True)
(o3d, ex, ey, ez) = Ga.build('e_x e_y e_z', g=[1, 1, 1], coords=xyz)

A = o3d.lt('A')
print r'\mbox{General Instantiation: }A =', A
th = symbols('theta',real=True)
R = cos(th/2)+(ex^ey)*sin(th/2)
B = o3d.lt(R)
print r'\mbox{Rotor: }R =', R
print r'\mbox{Rotor Instantiation: }B =', B
dict1 = {ex:ey+ez,ez:ey+ez,ey:ex+ez}
C = o3d.lt(dict1)
print r'\mbox{Dictionary} =', latex(dict1)
print r'\mbox{Dictionary Instantiation: }C =', C
lst1 = [[1,0,1],[0,1,0],[1,0,1]]
D = o3d.lt(lst1)
print r'\mbox{List} =', latex(lst1)
print r'\mbox{List Instantiation: }D =', D
lst2 = [ey+ez,ex+ez,ex+ey]
E = o3d.lt(lst2)
print r'\mbox{List} =', latex(lst2)
print r'\mbox{List Instantiation: }E =', E
xpdf(paper=(10,12),crop=True)
Exemplo n.º 40
0
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)
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)
print r'(s)\rightarrow (u,v) = ',latex(cir_map)
print 'H =', H
print latex(H)
print r'\nabla h =', cir1d.grad * h
print r'\nabla H =', cir1d.grad * H
xpdf(filename='submanifold.tex',paper=(6,5),crop=True)
Exemplo n.º 41
0
def main():
    Format()
    (g3d,ex,ey,ez) = Ga.build('e*x|y|z')
    A = g3d.mv('A','mv')
    print r'\bm{A} =',A
    A.Fmt(2,r'\bm{A}')
    A.Fmt(3,r'\bm{A}')

    X = (x,y,z) = symbols('x y z',real=True)
    o3d = Ga('e_x e_y e_z',g=[1,1,1],coords=X)
    (ex,ey,ez) = o3d.mv()

    f = o3d.mv('f','scalar',f=True)
    A = o3d.mv('A','vector',f=True)
    B = o3d.mv('B','bivector',f=True)

    print r'\bm{A} =',A
    print r'\bm{B} =',B

    print 'grad*f =',o3d.grad*f
    print r'grad|\bm{A} =',o3d.grad|A
    print r'grad*\bm{A} =',o3d.grad*A

    print r'-I*(grad^\bm{A}) =',-o3d.i*(o3d.grad^A)
    print r'grad*\bm{B} =',o3d.grad*B
    print r'grad^\bm{B} =',o3d.grad^B
    print r'grad|\bm{B} =',o3d.grad|B

    g4d = Ga('a b c d')

    (a,b,c,d) = g4d.mv()

    print 'g_{ij} =',g4d.g

    print '\\bm{a|(b*c)} =',a|(b*c)
    print '\\bm{a|(b^c)} =',a|(b^c)
    print '\\bm{a|(b^c^d)} =',a|(b^c^d)
    print '\\bm{a|(b^c)+c|(a^b)+b|(c^a)} =',(a|(b^c))+(c|(a^b))+(b|(c^a))
    print '\\bm{a*(b^c)-b*(a^c)+c*(a^b)} =',a*(b^c)-b*(a^c)+c*(a^b)
    print '\\bm{a*(b^c^d)-b*(a^c^d)+c*(a^b^d)-d*(a^b^c)} =',a*(b^c^d)-b*(a^c^d)+c*(a^b^d)-d*(a^b^c)
    print '\\bm{(a^b)|(c^d)} =',(a^b)|(c^d)
    print '\\bm{((a^b)|c)|d} =',((a^b)|c)|d
    print '\\bm{(a^b)\\times (c^d)} =',Com(a^b,c^d)

    g = '1 # #,'+ \
         '# 1 #,'+ \
         '# # 1'

    ng3d = Ga('e1 e2 e3',g=g)
    (e1,e2,e3) = ng3d.mv()

    E = e1^e2^e3
    Esq = (E*E).scalar()
    print 'E =',E
    print '%E^{2} =',Esq
    Esq_inv = 1/Esq

    E1 = (e2^e3)*E
    E2 = (-1)*(e1^e3)*E
    E3 = (e1^e2)*E

    print 'E1 = (e2^e3)*E =',E1
    print 'E2 =-(e1^e3)*E =',E2
    print 'E3 = (e1^e2)*E =',E3

    print 'E1|e2 =',(E1|e2).expand()
    print 'E1|e3 =',(E1|e3).expand()
    print 'E2|e1 =',(E2|e1).expand()
    print 'E2|e3 =',(E2|e3).expand()
    print 'E3|e1 =',(E3|e1).expand()
    print 'E3|e2 =',(E3|e2).expand()
    w = ((E1|e1).expand()).scalar()
    Esq = expand(Esq)
    print '%(E1\\cdot e1)/E^{2} =',simplify(w/Esq)
    w = ((E2|e2).expand()).scalar()
    print '%(E2\\cdot e2)/E^{2} =',simplify(w/Esq)
    w = ((E3|e3).expand()).scalar()
    print '%(E3\\cdot e3)/E^{2} =',simplify(w/Esq)

    X = (r,th,phi) = symbols('r theta phi')
    s3d = Ga('e_r e_theta e_phi',g=[1,r**2,r**2*sin(th)**2],coords=X,norm=True)
    (er,eth,ephi) = s3d.mv()

    f = s3d.mv('f','scalar',f=True)
    A = s3d.mv('A','vector',f=True)
    B = s3d.mv('B','bivector',f=True)

    print 'A =',A
    print 'B =',B

    print 'grad*f =',s3d.grad*f
    print 'grad|A =',s3d.grad|A
    print '-I*(grad^A) =',-s3d.i*(s3d.grad^A)
    print 'grad^B =',s3d.grad^B

    coords = symbols('t x y z')
    m4d = Ga('gamma*t|x|y|z',g=[1,-1,-1,-1],coords=coords)
    (g0,g1,g2,g3) = m4d.mv()
    I = m4d.i

    B = m4d.mv('B','vector',f=True)
    E = m4d.mv('E','vector',f=True)
    B.set_coef(1,0,0)
    E.set_coef(1,0,0)
    B *= g0
    E *= g0
    J = m4d.mv('J','vector',f=True)
    F = E+I*B

    print 'B = \\bm{B\\gamma_{t}} =',B
    print 'E = \\bm{E\\gamma_{t}} =',E
    print 'F = E+IB =',F
    print 'J =',J
    gradF = m4d.grad*F
    gradF.Fmt(3,'grad*F')

    print 'grad*F = J'
    (gradF.get_grade(1)-J).Fmt(3,'%\\grade{\\nabla F}_{1} -J = 0')
    (gradF.get_grade(3)).Fmt(3,'%\\grade{\\nabla F}_{3} = 0')

    (alpha,beta,gamma) = symbols('alpha beta gamma')

    (x,t,xp,tp) = symbols("x t x' t'")
    m2d = Ga('gamma*t|x',g=[1,-1])
    (g0,g1) = m2d.mv()

    R = cosh(alpha/2)+sinh(alpha/2)*(g0^g1)
    X = t*g0+x*g1
    Xp = tp*g0+xp*g1
    print 'R =',R

    print r"#%t\bm{\gamma_{t}}+x\bm{\gamma_{x}} = t'\bm{\gamma'_{t}}+x'\bm{\gamma'_{x}} = R\lp t'\bm{\gamma_{t}}+x'\bm{\gamma_{x}}\rp R^{\dagger}"

    Xpp = R*Xp*R.rev()
    Xpp = Xpp.collect()
    Xpp = Xpp.trigsimp()
    print r"%t\bm{\gamma_{t}}+x\bm{\gamma_{x}} =",Xpp
    Xpp = Xpp.subs({sinh(alpha):gamma*beta,cosh(alpha):gamma})

    print r'%\f{\sinh}{\alpha} = \gamma\beta'
    print r'%\f{\cosh}{\alpha} = \gamma'

    print r"%t\bm{\gamma_{t}}+x\bm{\gamma_{x}} =",Xpp.collect()

    coords = symbols('t x y z')
    m4d = Ga('gamma*t|x|y|z',g=[1,-1,-1,-1],coords=coords)
    (g0,g1,g2,g3) = m4d.mv()
    I = m4d.i
    (m,e) = symbols('m e')

    psi = m4d.mv('psi','spinor',f=True)
    A = m4d.mv('A','vector',f=True)
    sig_z = g3*g0
    print '\\bm{A} =',A
    print '\\bm{\\psi} =',psi

    dirac_eq = (m4d.grad*psi)*I*sig_z-e*A*psi-m*psi*g0
    dirac_eq.simplify()

    dirac_eq.Fmt(3,r'\nabla \bm{\psi} I \sigma_{z}-e\bm{A}\bm{\psi}-m\bm{\psi}\gamma_{t} = 0')

    xpdf()
    return
Exemplo n.º 42
0
print 'A =', A2d
print '\\f{\\det}{A} =', A2d.det()
#A2d.adj().Fmt(4,'\\overline{A}')
print '\\f{\\Tr}{A} =', A2d.tr()
print '\\f{A}{e_u^e_v} =', A2d(eu^ev)
print '\\f{A}{e_u}^\\f{A}{e_v} =', A2d(eu)^A2d(ev)
B2d = g2d.lt('B')
print 'B =', B2d
print 'A + B =', A2d + B2d
print 'AB =', A2d * B2d
print 'A - B =', A2d - B2d
a = g2d.mv('a','vector')
b = g2d.mv('b','vector')
print r'a|\f{\overline{A}}{b}-b|\f{\underline{A}}{a} =',\
     ((a|A2d.adj()(b))-(b|A2d(a))).simplify()

print '#4d Minkowski spaqce (Space Time)'
m4d = Ga('e_t e_x e_y e_z', g=[1, -1, -1, -1],\
         coords=symbols('t,x,y,z',real=True))
T = m4d.lt('T')
print 'g =', m4d.g
print r'\underline{T} =',T
print r'\overline{T} =',T.adj()
#m4d.mv(T.det()).Fmt(4,r'\f{\det}{\underline{T}}')
print r'\f{\mbox{tr}}{\underline{T}} =',T.tr()
a = m4d.mv('a','vector')
b = m4d.mv('b','vector')
print r'a|\f{\overline{T}}{b}-b|\f{\underline{T}}{a} =',\
      ((a|T.adj()(b))-(b|T(a))).simplify()
xpdf(paper=(10,12),debug=True)
Exemplo n.º 43
0
print r'%\paren{a\cdot\nabla}f =',dd * f
print r'%\nabla f =', sph2d.grad * f

a1 = sph2d.mv('a_1','vector')
a2 = sph2d.mv('a_2','vector')

#Define curve on unit sphere manifold

us = Function('u__s')(s)
vs = Function('v__s')(s)

#Define 1-d submanifold on unit shpere manifold

crv1d = sph2d.sm([us,vs],[s])

(es,) = crv1d.mv()

print '#1-D Manifold On Unit Sphere:'

print r'%\nabla =', crv1d.grad

#Define scalar and vector fields on 1-d manifold tangent space

g = crv1d.mv('g','scalar',f=True)
h = crv1d.mv('h','vector',f=True)

print r'%\nabla g =', crv1d.grad * g
print r'%\nabla \cdot \bm{h} =', crv1d.grad | h

xpdf()
Exemplo n.º 44
0
I = o3d.i
v = o3d.mv('v', 'vector')
f = o3d.mv('f', 'scalar', f=True)
A = o3d.mv('A', 'vector', f=True)
dd = v | o3d.grad
lap = o3d.grad * o3d.grad
print(r'\bm{X} =', X)
print(r'\bm{v} =', v)
print(r'\bm{A} =', A)
print(r'%\bm{v}\cdot\nabla =', dd)
print(r'%\nabla^{2} =', lap)
print(r'%\bm{v}\cdot\nabla f =', dd * f)
print(r'%\nabla^{2} f =', lap * f)
print(r'%\nabla^{2} \bm{A} =', lap * A)
print(r'%\bar{\nabla}\cdot v =', o3d.rgrad | v)
Xgrad = X | o3d.grad
rgradX = o3d.rgrad | X
print(r'%\bm{X}\cdot \nabla =', Xgrad)
print(r'%\bar{\nabla}\cdot \bm{X} =', rgradX)
com = Xgrad - rgradX
print(r'%\bm{X}\cdot \nabla - \bar{\nabla}\cdot \bm{X} =', com)
sph_coords = (r, th, phi) = symbols('r theta phi', real=True)
(sp3d,er,eth,ephi) = Ga.build('e',g=[1,r**2,r**2*sin(th)**2],\
                              coords=sph_coords,norm=True)
f = sp3d.mv('f', 'scalar', f=True)
lap = sp3d.grad * sp3d.grad
print(r'%\nabla^{2} = \nabla\cdot\nabla =', lap)
print(r'%\lp\nabla^{2}\rp f =', lap * f)
print(r'%\nabla\cdot\lp\nabla f\rp =', sp3d.grad | (sp3d.grad * f))
xpdf(paper='landscape', crop=True)
Exemplo n.º 45
0
import sys
from sympy import symbols,sin,cos
from printer import Format,xpdf,Get_Program,Print_Function
from ga import Ga

Format()
coords = symbols('t x y z',real=True)
(st4d,g0,g1,g2,g3) = Ga.build('gamma*t|x|y|z',g=[1,-1,-1,-1],coords=coords)
I = st4d.i

(m,e) = symbols('m e')

psi = st4d.mv('psi','spinor',f=True)
A = st4d.mv('A','vector',f=True)
sig_z = g3*g0

print '\\text{4-Vector Potential\\;\\;}\\bm{A} =',A
print '\\text{8-component real spinor\\;\\;}\\bm{\\psi} =',psi

dirac_eq = (st4d.grad*psi)*I*sig_z-e*A*psi-m*psi*g0
dirac_eq = dirac_eq.simplify()

dirac_eq.Fmt(3,r'%\text{Dirac Equation\;\;}\nabla \bm{\psi}'+\
               r' I \sigma_{z}-e\bm{A}\bm{\psi}-m\bm{\psi}\gamma_{t} = 0')
xpdf(paper='landscape',prog=True)
Exemplo n.º 46
0
def main():
    Format()

    coords = (x, y, z) = symbols("x y z", real=True)

    (o3d, ex, ey, ez) = Ga.build("e*x|y|z", g=[1, 1, 1], coords=coords)

    s = o3d.mv("s", "scalar")
    v = o3d.mv("v", "vector")
    b = o3d.mv("b", "bivector")

    print r"#3D Orthogonal Metric\newline"

    print "#Multvectors:"
    print "s =", s
    print "v =", v
    print "b =", b

    print "#Products:"

    X = ((s, "s"), (v, "v"), (b, "b"))

    for xi in X:
        print ""
        for yi in X:
            print xi[1] + "*" + yi[1] + " =", xi[0] * yi[0]
            print xi[1] + "^" + yi[1] + " =", xi[0] ^ yi[0]
            if xi[1] != "s" and yi[1] != "s":
                print xi[1] + "|" + yi[1] + " =", xi[0] | yi[0]
            print xi[1] + "<" + yi[1] + " =", xi[0] < yi[0]
            print xi[1] + ">" + yi[1] + " =", xi[0] > yi[0]

    fs = o3d.mv("s", "scalar", f=True)
    fv = o3d.mv("v", "vector", f=True)
    fb = o3d.mv("b", "bivector", f=True)

    print "#Multivector Functions:"

    print "s(X) =", fs
    print "v(X) =", fv
    print "b(X) =", fb

    print "#Products:"

    fX = ((o3d.grad, "grad"), (fs, "s"), (fv, "v"), (fb, "b"))

    for xi in fX:
        print ""
        for yi in fX:
            if xi[1] == "grad" and yi[1] == "grad":
                pass
            else:
                print xi[1] + "*" + yi[1] + " =", xi[0] * yi[0]
                print xi[1] + "^" + yi[1] + " =", xi[0] ^ yi[0]
                if xi[1] != "s" and yi[1] != "s":
                    print xi[1] + "|" + yi[1] + " =", xi[0] | yi[0]
                print xi[1] + "<" + yi[1] + " =", xi[0] < yi[0]
                print xi[1] + ">" + yi[1] + " =", xi[0] > yi[0]

    (g2d, ex, ey) = Ga.build("e", coords=(x, y))

    print r"#General 2D Metric\newline"
    print "#Multivector Functions:"

    s = g2d.mv("s", "scalar", f=True)
    v = g2d.mv("v", "vector", f=True)
    b = g2d.mv("v", "bivector", f=True)

    print "s(X) =", s
    print "v(X) =", v
    print "b(X) =", b

    X = ((g2d.grad, "grad"), (s, "s"), (v, "v"))

    print "#Products:"

    for xi in X:
        print ""
        for yi in X:
            if xi[1] == "grad" and yi[1] == "grad":
                pass
            else:
                print xi[1] + "*" + yi[1] + " =", xi[0] * yi[0]
                print xi[1] + "^" + yi[1] + " =", xi[0] ^ yi[0]
                if xi[1] != "s" and yi[1] != "s":
                    print xi[1] + "|" + yi[1] + " =", xi[0] | yi[0]
                print xi[1] + "<" + yi[1] + " =", xi[0] < yi[0]
                print xi[1] + ">" + yi[1] + " =", xi[0] > yi[0]

    xpdf(paper="letter")
    return