本文整理汇总了Python中sympy.galgebra.MV类的典型用法代码示例。如果您正苦于以下问题:Python MV类的具体用法?Python MV怎么用?Python MV使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MV类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: basic_multivector_operations
def basic_multivector_operations():
Print_Function()
(ex, ey, ez) = MV.setup('e*x|y|z')
A = MV('A', 'mv')
A.Fmt(1, 'A')
A.Fmt(2, 'A')
A.Fmt(3, 'A')
X = MV('X', 'vector')
Y = MV('Y', 'vector')
print('g_{ij} =\n', MV.metric)
X.Fmt(1, 'X')
Y.Fmt(1, 'Y')
(X*Y).Fmt(2, 'X*Y')
(X ^ Y).Fmt(2, 'X^Y')
(X | Y).Fmt(2, 'X|Y')
(ex, ey) = MV.setup('e*x|y')
print('g_{ij} =\n', MV.metric)
X = MV('X', 'vector')
A = MV('A', 'spinor')
X.Fmt(1, 'X')
A.Fmt(1, 'A')
(X | A).Fmt(2, 'X|A')
(X < A).Fmt(2, 'X<A')
(A > X).Fmt(2, 'A>X')
(ex, ey) = MV.setup('e*x|y', metric='[1,1]')
print('g_{ii} =\n', MV.metric)
X = MV('X', 'vector')
A = MV('A', 'spinor')
X.Fmt(1, 'X')
A.Fmt(1, 'A')
(X*A).Fmt(2, 'X*A')
(X | A).Fmt(2, 'X|A')
(X < A).Fmt(2, 'X<A')
(X > A).Fmt(2, 'X>A')
(A*X).Fmt(2, 'A*X')
(A | X).Fmt(2, 'A|X')
(A < X).Fmt(2, 'A<X')
(A > X).Fmt(2, 'A>X')
return
示例2: basic_multivector_operations
def basic_multivector_operations():
Print_Function()
(ex, ey, ez) = MV.setup("e*x|y|z")
A = MV("A", "mv")
A.Fmt(1, "A")
A.Fmt(2, "A")
A.Fmt(3, "A")
X = MV("X", "vector")
Y = MV("Y", "vector")
print("g_{ij} =\n", MV.metric)
X.Fmt(1, "X")
Y.Fmt(1, "Y")
(X * Y).Fmt(2, "X*Y")
(X ^ Y).Fmt(2, "X^Y")
(X | Y).Fmt(2, "X|Y")
(ex, ey) = MV.setup("e*x|y")
print("g_{ij} =\n", MV.metric)
X = MV("X", "vector")
A = MV("A", "spinor")
X.Fmt(1, "X")
A.Fmt(1, "A")
(X | A).Fmt(2, "X|A")
(X < A).Fmt(2, "X<A")
(A > X).Fmt(2, "A>X")
(ex, ey) = MV.setup("e*x|y", metric="[1,1]")
print("g_{ii} =\n", MV.metric)
X = MV("X", "vector")
A = MV("A", "spinor")
X.Fmt(1, "X")
A.Fmt(1, "A")
(X * A).Fmt(2, "X*A")
(X | A).Fmt(2, "X|A")
(X < A).Fmt(2, "X<A")
(X > A).Fmt(2, "X>A")
(A * X).Fmt(2, "A*X")
(A | X).Fmt(2, "A|X")
(A < X).Fmt(2, "A<X")
(A > X).Fmt(2, "A>X")
return
示例3: extracting_vectors_from_conformal_2_blade
def extracting_vectors_from_conformal_2_blade():
Print_Function()
print(r'B = P1\W P2')
metric = ' 0 -1 #,' + \
'-1 0 #,' + \
' # # #,'
(P1, P2, a) = MV.setup('P1 P2 a', metric)
print('g_{ij} =', MV.metric)
B = P1 ^ P2
Bsq = B*B
print('%B^{2} =', Bsq)
ap = a - (a ^ B)*B
print("a' = a-(a^B)*B =", ap)
Ap = ap + ap*B
Am = ap - ap*B
print("A+ = a'+a'*B =", Ap)
print("A- = a'-a'*B =", Am)
print('%(A+)^{2} =', Ap*Ap)
print('%(A-)^{2} =', Am*Am)
aB = a | B
print('a|B =', aB)
return
示例4: derivatives_in_spherical_coordinates
def derivatives_in_spherical_coordinates():
Print_Function()
X = (r, th, phi) = symbols('r theta phi')
curv = [[r *
cos(phi) *
sin(th), r *
sin(phi) *
sin(th), r *
cos(th)], [1, r, r *
sin(th)]]
(er,
eth,
ephi,
grad) = MV.setup('e_r e_theta e_phi',
metric='[1,1,1]',
coords=X,
curv=curv)
f = MV('f', 'scalar', fct=True)
A = MV('A', 'vector', fct=True)
B = MV('B', 'grade2', fct=True)
print('f =', f)
print('A =', A)
print('B =', B)
print('grad*f =', grad*f)
print('grad|A =', grad | A)
print('-I*(grad^A) =', -MV.I*(grad ^ A))
print('grad^B =', grad ^ B)
return
示例5: Simple_manifold_with_scalar_function_derivative
def Simple_manifold_with_scalar_function_derivative():
Print_Function()
coords = (x, y, z) = symbols('x y z')
basis = (e1, e2, e3, grad) = MV.setup('e_1 e_2 e_3', metric='[1,1,1]', coords=coords)
# Define surface
mfvar = (u, v) = symbols('u v')
X = u*e1 + v*e2 + (u**2 + v**2)*e3
print('\\f{X}{u,v} =', X)
MF = Manifold(X, mfvar)
(eu, ev) = MF.Basis()
# Define field on the surface.
g = (v + 1)*log(u)
print('\\f{g}{u,v} =', g)
# Method 1: Using old Manifold routines.
VectorDerivative = (MF.rbasis[0]/MF.E_sq)*diff(g, u) + (MF.rbasis[1]/MF.E_sq)*diff(g, v)
print('\\eval{\\nabla g}{u=1,v=0} =', VectorDerivative.subs({u: 1, v: 0}))
# Method 2: Using new Manifold routines.
dg = MF.Grad(g)
print('\\eval{\\f{Grad}{g}}{u=1,v=0} =', dg.subs({u: 1, v: 0}))
dg = MF.grad*g
print('\\eval{\\nabla g}{u=1,v=0} =', dg.subs({u: 1, v: 0}))
return
示例6: Distorted_manifold_with_scalar_function
def Distorted_manifold_with_scalar_function():
Print_Function()
coords = symbols('x y z')
(ex, ey, ez, grad) = MV.setup('e_x e_y e_z', metric='[1,1,1]', coords=coords)
mfvar = (u, v) = symbols('u v')
X = 2*u*ex + 2*v*ey + (u**3 + v**3/2)*ez
MF = Manifold(X, mfvar, I=MV.I)
(eu, ev) = MF.Basis()
g = (v + 1)*log(u)
dg = MF.Grad(g)
print('g =', g)
print('dg =', dg)
print('\\eval{dg}{u=1,v=0} =', dg.subs({u: 1, v: 0}))
G = u*eu + v*ev
dG = MF.Grad(G)
print('G =', G)
print('P(G) =', MF.Proj(G))
print('dG =', dG)
print('P(dG) =', MF.Proj(dG))
PS = u*v*eu ^ ev
print('P(S) =', PS)
print('dP(S) =', MF.Grad(PS))
print('P(dP(S)) =', MF.Proj(MF.Grad(PS)))
return
示例7: Simple_manifold_with_vector_function_derivative
def Simple_manifold_with_vector_function_derivative():
Print_Function()
coords = (x, y, z) = symbols('x y z')
basis = (ex, ey, ez, grad) = \
MV.setup('e_x e_y e_z', metric='[1,1,1]', coords=coords)
# Define surface
mfvar = (u, v) = symbols('u v')
X = u*ex + v*ey + (u**2 + v**2)*ez
print('\\f{X}{u,v} =', X)
MF = Manifold(X, mfvar)
(eu, ev) = MF.Basis()
# Define field on the surface.
g = (v + 1)*log(u)
print('\\mbox{Scalar Function: } g =', g)
dg = MF.grad*g
dg.Fmt(3, '\\mbox{Scalar Function Derivative: } \\nabla g')
print('\\eval{\\nabla g}{(1,0)} =', dg.subs({u: 1, v: 0}))
# Define vector field on the surface
G = v**2*eu + u**2*ev
print('\\mbox{Vector Function: } G =', G)
dG = MF.grad*G
dG.Fmt(3, '\\mbox{Vector Function Derivative: } \\nabla G')
print('\\eval{\\nabla G}{(1,0)} =', dG.subs({u: 1, v: 0}))
return
示例8: Test_Reciprocal_Frame
def Test_Reciprocal_Frame():
Print_Function()
Format()
coords = symbols('x y z')
(ex, ey, ez, grad) = MV.setup('e_x e_y e_z', metric='[1,1,1]', coords=coords)
mfvar = (u, v) = symbols('u v')
eu = ex + ey
ev = ex - ey
(eu_r, ev_r) = ReciprocalFrame([eu, ev])
oprint('\\mbox{Frame}', (eu, ev), '\\mbox{Reciprocal Frame}', (eu_r, ev_r))
print(r'%\bm{e}_{u}\cdot\bm{e}^{u} =', (eu | eu_r))
print(r'%\bm{e}_{u}\cdot\bm{e}^{v} =', eu | ev_r)
print(r'%\bm{e}_{v}\cdot\bm{e}^{u} =', ev | eu_r)
print(r'%\bm{e}_{v}\cdot\bm{e}^{v} =', ev | ev_r)
eu = ex + ey + ez
ev = ex - ey
(eu_r, ev_r) = ReciprocalFrame([eu, ev])
oprint('\\mbox{Frame}', (eu, ev), '\\mbox{Reciprocal Frame}', (eu_r, ev_r))
print(r'%\bm{e}_{u}\cdot\bm{e}^{u} =', eu | eu_r)
print(r'%\bm{e}_{u}\cdot\bm{e}^{v} =', eu | ev_r)
print(r'%\bm{e}_{v}\cdot\bm{e}^{u} =', ev | eu_r)
print(r'%\bm{e}_{v}\cdot\bm{e}^{v} =', ev | ev_r)
return
示例9: check_generalized_BAC_CAB_formulas
def check_generalized_BAC_CAB_formulas():
Print_Function()
(a, b, c, d, e) = MV.setup('a b c d e')
print('g_{ij} =\n', MV.metric)
print('a|(b*c) =', a | (b*c))
print('a|(b^c) =', a | (b ^ c))
print('a|(b^c^d) =', a | (b ^ c ^ d))
print('a|(b^c)+c|(a^b)+b|(c^a) =', (a | (b ^ c)) +
(c | (a ^ b)) +
(b | (c ^ a)))
print('a*(b^c)-b*(a^c)+c*(a^b) =', a*(b ^ c) - b*(a ^ c) + c*(a ^ b))
print('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('(a^b)|(c^d) =', (a ^ b) | (c ^ d))
print('((a^b)|c)|d =', ((a ^ b) | c) | d)
print('(a^b)x(c^d) =', Com(a ^ b, c ^ d))
print('(a|(b^c))|(d^e) =', (a | (b ^ c)) | (d ^ e))
return
示例10: derivatives_in_rectangular_coordinates
def derivatives_in_rectangular_coordinates():
Print_Function()
X = (x, y, z) = symbols('x y z')
(ex, ey, ez, grad) = MV.setup('e_x e_y e_z', metric='[1,1,1]', coords=X)
f = MV('f', 'scalar', fct=True)
A = MV('A', 'vector', fct=True)
B = MV('B', 'grade2', fct=True)
C = MV('C', 'mv', fct=True)
print('f =', f)
print('A =', A)
print('B =', B)
print('C =', C)
print('grad*f =', grad*f)
print('grad|A =', grad | A)
print('grad*A =', grad*A)
print('-I*(grad^A) =', -MV.I*(grad ^ A))
print('grad*B =', grad*B)
print('grad^B =', grad ^ B)
print('grad|B =', grad | B)
print('grad<A =', grad < A)
print('grad>A =', grad > A)
print('grad<B =', grad < B)
print('grad>B =', grad > B)
print('grad<C =', grad < C)
print('grad>C =', grad > C)
return
示例11: Lorentz_Tranformation_in_Geometric_Algebra
def Lorentz_Tranformation_in_Geometric_Algebra():
Print_Function()
(alpha, beta, gamma) = symbols('alpha beta gamma')
(x, t, xp, tp) = symbols("x t x' t'")
(g0, g1) = MV.setup('gamma*t|x', metric='[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([xp, tp])
Xpp = Xpp.subs({2*sinh(alpha/2)*cosh(alpha/2): sinh(alpha), sinh(alpha/2)**2 + cosh(alpha/2)**2: cosh(alpha)})
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(gamma))
return
示例12: properties_of_geometric_objects
def properties_of_geometric_objects():
Print_Function()
metric = "# # # 0 0," + "# # # 0 0," + "# # # 0 0," + "0 0 0 0 2," + "0 0 0 2 0"
(p1, p2, p3, n, nbar) = MV.setup("p1 p2 p3 n nbar", metric)
print("g_{ij} =\n", MV.metric)
P1 = F(p1)
P2 = F(p2)
P3 = F(p3)
print("Extracting direction of line from L = P1^P2^n")
L = P1 ^ P2 ^ n
delta = (L | n) | nbar
print("(L|n)|nbar =", delta)
print("Extracting plane of circle from C = P1^P2^P3")
C = P1 ^ P2 ^ P3
delta = ((C ^ n) | n) | nbar
print("((C^n)|n)|nbar =", delta)
print("(p2-p1)^(p3-p1) =", (p2 - p1) ^ (p3 - p1))
示例13: main
def main():
enhance_print()
X = (x, y, z) = symbols('x y z')
(ex, ey, ez, grad) = MV.setup('e_x e_y e_z', metric='[1,1,1]', coords=(x, y, z))
A = x*(ey ^ ez) + y*(ez ^ ex) + z*(ex ^ ey)
print('A =', A)
print('grad^A =', (grad ^ A).simplify())
print()
f = MV('f', 'scalar', fct=True)
f = (x**2 + y**2 + z**2)**(-1.5)
print('f =', f)
print('grad*f =', (grad*f).expand())
print()
B = f*A
print('B =', B)
print()
Curl_B = grad ^ B
print('grad^B =', Curl_B.simplify())
def Symplify(A):
return(factor_terms(simplify(A)))
print(Curl_B.func(Symplify))
return
示例14: extracting_vectors_from_conformal_2_blade
def extracting_vectors_from_conformal_2_blade():
Print_Function()
metric = " 0 -1 #," + "-1 0 #," + " # # #,"
(P1, P2, a) = MV.setup("P1 P2 a", metric)
print("g_{ij} =\n", MV.metric)
B = P1 ^ P2
Bsq = B * B
print("B**2 =", Bsq)
ap = a - (a ^ B) * B
print("a' = a-(a^B)*B =", ap)
Ap = ap + ap * B
Am = ap - ap * B
print("A+ = a'+a'*B =", Ap)
print("A- = a'-a'*B =", Am)
print("(A+)^2 =", Ap * Ap)
print("(A-)^2 =", Am * Am)
aB = a | B
print("a|B =", aB)
return
示例15: derivatives_in_rectangular_coordinates
def derivatives_in_rectangular_coordinates():
Print_Function()
X = (x, y, z) = symbols("x y z")
(ex, ey, ez, grad) = MV.setup("e_x e_y e_z", metric="[1,1,1]", coords=X)
f = MV("f", "scalar", fct=True)
A = MV("A", "vector", fct=True)
B = MV("B", "grade2", fct=True)
C = MV("C", "mv", fct=True)
print("f =", f)
print("A =", A)
print("B =", B)
print("C =", C)
print("grad*f =", grad * f)
print("grad|A =", grad | A)
print("grad*A =", grad * A)
print("-I*(grad^A) =", -MV.I * (grad ^ A))
print("grad*B =", grad * B)
print("grad^B =", grad ^ B)
print("grad|B =", grad | B)
print("grad<A =", grad < A)
print("grad>A =", grad > A)
print("grad<B =", grad < B)
print("grad>B =", grad > B)
print("grad<C =", grad < C)
print("grad>C =", grad > C)
return