Hi,

I need the div and curl operators in sympy, 3D is enough. I am
attaching a simple script, that takes the vector potential A,
calculates B and then div B:

A:
[0, 0, 16*x**2*y**2*(1 - x)**2*(1 - y)**2]
B:
[-16*x**2*y**2*(1 - x)**2*(2 - 2*y) + 32*y*x**2*(1 - x)**2*(1 - y)**2,
16*x**2*y**2*(1 - y)**2*(2 - 2*x) - 32*x*y**2*(1 - x)**2*(1 - y)**2,
0]
div B:
0


Alan, how could this be done using the geometric algebra in sympy?

Besides that, I need some way to represent curl and div as operators,
so that I can write a weak formulation of any PDE using sympy.
Has anyone on this list have any experience with that in Maple or Mathematica?

So far it seems I'll just create a new class Curl and Div, then I also
need a class to represent a vector and a scalar. In principle, vector
and scalar can be just a Symbol.

What I would like to do is to substitute some particular vector/scalar
field in some particular coordinate system and I would like sympy to
output how the weak formulation looks like. So of course everything
should be in a coordinate free manner (not like my attached script,
that only works in cartesian coordinates).

Another option is to work with indices directly, and I might go that
route. That would mean to implement tensor support in sympy, which is
our 3rd oldest open issue:

http://code.google.com/p/sympy/issues/detail?id=16

:) and we have to fix it anyways. There is even some code to start
from in the issue.

Ondrej

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to sympy@googlegroups.com
To unsubscribe from this group, send email to sympy+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sympy?hl=en
-~----------~----~----~----~------~----~------~--~---

from sympy import var, S, pprint, Eq, Symbol

var("x y z")

def curl_3d(A):
    Ax = S(A[0])
    Ay = S(A[1])
    Az = S(A[2])
    return [Az.diff(y)-Ay.diff(z), Ax.diff(z)-Az.diff(x), Ay.diff(x)-Ax.diff(y)]

def div_3d(A):
    Ax = S(A[0])
    Ay = S(A[1])
    Az = S(A[2])
    return Ax.diff(x) + Ay.diff(y) + Az.diff(z)

A = [0, 0, x**2*(1-x)**2 * y**2 * (1-y)**2 * 16]

print "A:"
print(A)
B = curl_3d(A)
print "B:"
print(B)
print "div B:"
print(div_3d(B))

Reply via email to