本文整理汇总了Python中sympy.galgebra.MV.set_coef方法的典型用法代码示例。如果您正苦于以下问题:Python MV.set_coef方法的具体用法?Python MV.set_coef怎么用?Python MV.set_coef使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sympy.galgebra.MV
的用法示例。
在下文中一共展示了MV.set_coef方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Maxwells_Equations_in_Geometric_Calculus
# 需要导入模块: from sympy.galgebra import MV [as 别名]
# 或者: from sympy.galgebra.MV import set_coef [as 别名]
def Maxwells_Equations_in_Geometric_Calculus():
Print_Function()
X = symbols('t x y z')
(g0, g1, g2, g3, grad) = MV.setup('gamma*t|x|y|z', metric='[1,-1,-1,-1]', coords=X)
I = MV.I
B = MV('B', 'vector', fct=True)
E = MV('E', 'vector', fct=True)
B.set_coef(1, 0, 0)
E.set_coef(1, 0, 0)
B *= g0
E *= g0
J = MV('J', 'vector', fct=True)
F = E + I*B
print(r'\text{Pseudo Scalar\;\;}I =', I)
print('\\text{Magnetic Field Bi-Vector\\;\\;} B = \\bm{B\\gamma_{t}} =', B)
print('\\text{Electric Field Bi-Vector\\;\\;} E = \\bm{E\\gamma_{t}} =', E)
print('\\text{Electromagnetic Field Bi-Vector\\;\\;} F = E+IB =', F)
print('%\\text{Four Current Density\\;\\;} J =', J)
gradF = grad*F
print('#Geometric Derivative of Electomagnetic Field Bi-Vector')
gradF.Fmt(3, 'grad*F')
print('#Maxwell Equations')
print('grad*F = J')
print('#Div $E$ and Curl $H$ Equations')
(gradF.grade(1) - J).Fmt(3, '%\\grade{\\nabla F}_{1} -J = 0')
print('#Curl $E$ and Div $B$ equations')
(gradF.grade(3)).Fmt(3, '%\\grade{\\nabla F}_{3} = 0')
return
示例2: main
# 需要导入模块: from sympy.galgebra import MV [as 别名]
# 或者: from sympy.galgebra.MV import set_coef [as 别名]
def main():
Format()
(ex, ey, ez) = MV.setup('e*x|y|z')
A = 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')
(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)
print(r'\bm{A} =', A)
print(r'\bm{B} =', B)
print('grad*f =', grad*f)
print(r'grad|\bm{A} =', grad | A)
print(r'grad*\bm{A} =', grad*A)
print(r'-I*(grad^\bm{A}) =', -MV.I*(grad ^ A))
print(r'grad*\bm{B} =', grad*B)
print(r'grad^\bm{B} =', grad ^ B)
print(r'grad|\bm{B} =', grad | B)
(a, b, c, d) = MV.setup('a b c d')
print('g_{ij} =', MV.metric)
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))
metric = '1 # #,' + \
'# 1 #,' + \
'# # 1,'
(e1, e2, e3) = MV.setup('e1 e2 e3', metric)
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')
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('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)
vars = symbols('t x y z')
(g0, g1, g2, g3, grad) = MV.setup('gamma*t|x|y|z', metric='[1,-1,-1,-1]', coords=vars)
I = MV.I
B = MV('B', 'vector', fct=True)
E = MV('E', 'vector', fct=True)
B.set_coef(1, 0, 0)
E.set_coef(1, 0, 0)
#.........这里部分代码省略.........