Here is a example of Maxwell's equation using the galgebra module from
github

import sys
from sympy import symbols,sin,cos,exp,I,Matrix,simplify,Eq,S
from sympy.solvers import solve
from printer import Format,xpdf,Get_Program,Print_Function,Fmt
from ga import Ga
from metric import linear_expand

def Maxwell_in_Geom_Calculus():
    Print_Function()
    X = (t,x,y,z) = 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=X)

    i = st4d.I()

    B = st4d.mv('B','vector',f=True)
    B = B.proj([g1,g2,g3])  # Make vector from spatial components of B
    print 'B =',B

    E = st4d.mv('E','vector',f=True)
    E = E.proj([g1,g2,g3])  # Make vector from spatial components of E
    print 'E =',E

    F = g0*E+i*g0*B
    print 'F =', F

    J = st4d.mv('J','vector',f=True)
    print 'J =', J

    gradF = st4d.grad*F

    print 'grad*F =', gradF.Fmt(2)

    W = gradF-J

    print 'grad*F - J = 0 =', W.Fmt(2)

    return

def dummy():
    return

def main():
    Get_Program()
    Format()

    Maxwell_in_Geom_Calculus()

    xpdf()
    return

if __name__ == "__main__":
    main()


Attached is the pdf output of the above code.

On Wed, Feb 15, 2017 at 7:47 AM, Alan Bromborsky <[email protected]>
wrote:

> When you get galgebra from git in the galgebra/doc directory is
> galgebra.pdf.  In section 1.3 of the document are instructions of how to
> install galgebra including how to set the python path so that other python
> programs can find galgebra.
>
> On Wed, Feb 15, 2017 at 5:35 AM, Henri Girard <[email protected]>
> wrote:
>
>> Hi,
>> I am new to sympy and I wanted to try it on maxwell's equations examples
>> so I installed galgebra from git but it doesn't work ? the import is not
>> found... ANy help ?
>> regards
>> Henri
>>
>> import sys
>> import sympy.galgebra.GAsympy 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)
>>     print ('$B$ Magnetic Field Bi-Vector')
>>     print ('B = Bvec gamma_0 =',B)
>>     print ('$E$ Electric Field Bi-Vector')
>>     print ('E = Evec gamma_0 =',E)
>>     F = E+I*B
>>     print ('$E+IB$ Electo-Magnetic Field Bi-Vector')
>>     print ('F = E+IB =',F)
>>     print ('$J$ Four Current')
>>     print ('J =',J)
>>     gradF = F.grad()
>>     gradF.convert_to_blades()
>>     print ('Geometric Derivative of EM Bi-Vector')
>>     tex.MV_format(3)
>>     print ('\\nabla F =',gradF)
>>     print ('All Maxwell Equations are')
>>     print ('\\nabla F = J')
>>     print ('Div $E$ and Curl $H$ Equations')
>>     print ('<\\nabla F>_1 -J =',gradF.project(1)-J,' = 0')
>>     print ('Curl $E$ and Div $B$ equations')
>>     print ('<\\nabla F>_3 =',gradF.project(3),' = 0')
>>     tex.xdvi(filename='Maxwell.tex')
>>
>> ---------------------------------------------------------------------------ImportError
>>                                Traceback (most recent call 
>> last)<ipython-input-1-45c89331d82f> in <module>()      1 import sys----> 2 
>> import sympy.galgebra.GAsympy as GA      3 import sympy.galgebra.latex_ex as 
>> tex      4       5 GA.set_main(sys.modules[__name__])
>> /home/pi/git/sage/local/lib/python2.7/site-packages/sympy/galgebra.py in 
>> <module>()----> 1 raise ImportError("""As of SymPy 1.0 the galgebra module 
>> is maintained separately at https://github.com/brombo/galgebra""";)
>> ImportError: As of SymPy 1.0 the galgebra module is maintained separately at 
>> https://github.com/brombo/galgebra
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "sympy" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at https://groups.google.com/group/sympy.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/sympy/6b917548-f055-4ee6-8310-259cd0bb93f1%40googlegroups.com
>> <https://groups.google.com/d/msgid/sympy/6b917548-f055-4ee6-8310-259cd0bb93f1%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CALOxT-kv6S3TC77OxdfWMWdjniz-Hda7Jyv1M28r%2BhLLMmC6zQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Attachment: maxwell.pdf
Description: Adobe PDF document

Reply via email to