Example #1
0
import sys
import sympy.galgebra.GA as GA
import sympy.galgebra.latex_ex as tex

GA.set_main(sys.modules[__name__])

if __name__ == '__main__':

    tex.Format()
    GA.make_symbols('xbm alpha_1 delta__nugamma_r')
    
    x = alpha_1*xbm/delta__nugamma_r
    
    print 'x =',x
    
    tex.xdvi()
Example #2
0
#!/usr/bin/python
#Dirac.py

import sympy.galgebra.GA as GA
import sympy.galgebra.latex_ex as tex
import sys

if __name__ == '__main__':

    metric = '1  0  0  0,'+\
             '0 -1  0  0,'+\
             '0  0 -1  0,'+\
             '0  0  0 -1'

    vars = GA.make_symbols('t x y z')
    GA.MV.setup('gamma_t gamma_x gamma_y gamma_z',metric,True,vars)

    parms = GA.make_symbols('m e')
    tex.Format()
    I = GA.MV(GA.ONE,'pseudo')
    nvars = len(vars)
    psi = GA.MV('psi','spinor',fct=True)
    psi.convert_to_blades()
    A = GA.MV('A','vector',fct=True)
    sig_x = gamma_x*gamma_t
    sig_y = gamma_y*gamma_t
    sig_z = gamma_z*gamma_t
    print '$A$ is 4-vector potential'
    print A
    print r'$\bm{\psi}$ is 8-component real spinor (even multi-vector)'
    print psi
Example #3
0
#!/usr/bin/python

import sys
import sympy.galgebra.GA as GA
import sympy.galgebra.latex_ex as tex

GA.set_main(sys.modules[__name__])

if __name__ == '__main__':

    metric = '1  0  0  0,'+\
             '0 -1  0  0,'+\
             '0  0 -1  0,'+\
             '0  0  0 -1'

    vars = GA.make_symbols('t x y z')
    GA.MV.setup('gamma_t gamma_x gamma_y gamma_z',metric,True,vars)
    tex.Format()
    I = GA.MV(1,'pseudo')
    I.convert_to_blades()
    print '$I$ Pseudo-Scalar'
    print 'I =',I
    B = GA.MV('B','vector',fct=True)
    E = GA.MV('E','vector',fct=True)
    B.set_coef(1,0,0)
    E.set_coef(1,0,0)
    B *= gamma_t
    E *= gamma_t
    B.convert_to_blades()
    E.convert_to_blades()
    J = GA.MV('J','vector',fct=True)
Example #4
0
#EandM.py

import sys
import sympy.galgebra.GA as GA
import sympy.galgebra.latex_ex as tex
import sympy,numpy,time

if __name__ == '__main__':
    metric = '1 0 0,'+\
             '0 1 0,'+\
             '0 0 1'

    GA.MV.setup('gamma_x gamma_y gamma_z',metric,True)
    tex.Format()

    coords = GA.make_symbols('r theta phi')
    x = r*(sympy.cos(theta)*gamma_z+sympy.sin(theta)*\
        (sympy.cos(phi)*gamma_x+sympy.sin(phi)*gamma_y))
    x.set_name('x')

    GA.MV.rebase(x,coords,'e',True)

    psi = GA.MV('psi','scalar',fct=True)

    dpsi = psi.grad()
    print 'Gradient of Scalar Function $\\psi$'
    print '\\nabla\\psi =',dpsi

    A = GA.MV('A','vector',fct=True)

    print 'Div and Curl of Vector Function $A$'
Example #5
0
#Dirac.py

import sympy.galgebra.GA as GA
import sympy.galgebra.latex_ex as tex
import sys

GA.set_main(sys.modules[__name__])

if __name__ == '__main__':

    metric = '1  0  0  0,'+\
             '0 -1  0  0,'+\
             '0  0 -1  0,'+\
             '0  0  0 -1'

    vars = GA.make_symbols('t x y z')
    GA.MV.setup('gamma_t gamma_x gamma_y gamma_z', metric, True, vars)

    parms = GA.make_symbols('m e')
    tex.Format()
    I = GA.MV(GA.ONE, 'pseudo')
    nvars = len(vars)
    psi = GA.MV('psi', 'spinor', fct=True)
    psi.convert_to_blades()
    A = GA.MV('A', 'vector', fct=True)
    sig_x = gamma_x * gamma_t
    sig_y = gamma_y * gamma_t
    sig_z = gamma_z * gamma_t
    print '$A$ is 4-vector potential'
    print A
    print r'$\bm{\psi}$ is 8-component real spinor (even multi-vector)'
Example #6
0
import sys
import sympy.galgebra.GA as GA
import sympy.galgebra.latex_ex as tex
import sympy,numpy,time

GA.set_main(sys.modules[__name__])

if __name__ == '__main__':
    metric = '1 0 0,'+\
             '0 1 0,'+\
             '0 0 1'

    GA.MV.setup('gamma_x gamma_y gamma_z',metric,True)
    tex.Format()

    coords = GA.make_symbols('r theta phi')
    x = r*(sympy.cos(theta)*gamma_z+sympy.sin(theta)*\
        (sympy.cos(phi)*gamma_x+sympy.sin(phi)*gamma_y))
    x.set_name('x')

    GA.MV.rebase(x,coords,'e',True)

    psi = GA.MV('psi','scalar',fct=True)

    dpsi = psi.grad()
    print 'Gradient of Scalar Function $\\psi$'
    print '\\nabla\\psi =',dpsi

    A = GA.MV('A','vector',fct=True)

    print 'Div and Curl of Vector Function $A$'
Example #7
0
#!/usr/bin/python

import sys
import sympy.galgebra.GA as GA
import sympy.galgebra.latex_ex as tex

GA.set_main(sys.modules[__name__])

if __name__ == '__main__':

    metric = '1  0  0  0,'+\
             '0 -1  0  0,'+\
             '0  0 -1  0,'+\
             '0  0  0 -1'

    vars = GA.make_symbols('t x y z')
    GA.MV.setup('gamma_t gamma_x gamma_y gamma_z',metric,True,vars)
    tex.Format()
    I = GA.MV(1,'pseudo')
    I.convert_to_blades()
    print '$I$ Pseudo-Scalar'
    print 'I =',I
    B = GA.MV('B','vector',fct=True)
    E = GA.MV('E','vector',fct=True)
    B.set_coef(1,0,0)
    E.set_coef(1,0,0)
    B *= gamma_t
    E *= gamma_t
    B.convert_to_blades()
    E.convert_to_blades()
    J = GA.MV('J','vector',fct=True)
Example #8
0
#!/usr/local/bin/python
# Dirac.py

import sympy.galgebra.GA as GA
import sympy.galgebra.latex_ex as tex
import sys

GA.set_main(sys.modules[__name__])

if __name__ == "__main__":

    metric = "1  0  0  0," + "0 -1  0  0," + "0  0 -1  0," + "0  0  0 -1"

    vars = GA.make_symbols("t x y z")
    GA.MV.setup("gamma_t gamma_x gamma_y gamma_z", metric, True, vars)

    parms = GA.make_symbols("m e")
    tex.Format()
    I = GA.MV(GA.ONE, "pseudo")
    nvars = len(vars)
    psi = GA.MV("psi", "spinor", fct=True)
    psi.convert_to_blades()
    A = GA.MV("A", "vector", fct=True)
    sig_x = gamma_x * gamma_t
    sig_y = gamma_y * gamma_t
    sig_z = gamma_z * gamma_t
    print "$A$ is 4-vector potential"
    print A
    print r"$\bm{\psi}$ is 8-component real spinor (even multi-vector)"
    print psi
    dirac_eq = psi.grad() * I * sig_z - e * A * psi - m * psi * gamma_t
Example #9
0
import sys
import sympy.galgebra.GA as GA
import sympy.galgebra.latex_ex as tex

GA.set_main(sys.modules[__name__])

if __name__ == '__main__':

    tex.Format()
    GA.make_symbols('xbm alpha_1 delta__nugamma_r')

    x = alpha_1 * xbm / delta__nugamma_r

    print 'x =', x

    tex.xdvi()