Esempio n. 1
0
from sympy import symbols, sin, cos, pi, Function
from sympy.diffgeom import Manifold, Patch, CoordSystem
from sympy.diffgeom import BaseVectorField, Differential, TensorProduct, WedgeProduct
from sympy import pprint
r, phi, theta = symbols('r, phi, theta')
m = Manifold('M', 3)
patch = Patch('P', m)
rect = CoordSystem('rect', patch, ['x', 'y', 'z'])
polar = CoordSystem('polar', patch, ['r', 'phi', 'theta'])
polar.connect_to(
    rect, [r, phi, theta],
    [r * cos(phi) * sin(theta), r * sin(phi) * sin(theta), r * cos(theta)])
# define coordfuntions
m.x = rect.coord_function(0)
m.y = rect.coord_function(1)
m.z = rect.coord_function(2)
m.e_x = BaseVectorField(rect, 0)
m.e_y = BaseVectorField(rect, 1)
m.e_z = BaseVectorField(rect, 2)
m.dx = Differential(m.x)
m.dy = Differential(m.y)
m.dz = Differential(m.z)
omega_x = Function('omega_x')
omega_y = Function('omega_y')
omega_z = Function('omega_z')

m.r = polar.coord_function(0)
m.phi = polar.coord_function(1)
m.theta = polar.coord_function(2)
m.e_r = BaseVectorField(polar, 0)
m.e_phi = BaseVectorField(polar, 1)
Esempio n. 2
0
rect = CoordSystem('rect', patch)
polar = CoordSystem('polar', patch)

print(rect in patch.coord_systems)

polar.connect_to(rect, [r, theta], [r*cos(theta), r*sin(theta)])

print(polar.coord_tuple_transform_to(rect, [0, 2]))
print(polar.coord_tuple_transform_to(rect, [2, pi/2]))
print(rect.coord_tuple_transform_to(polar, [1, 1]).applyfunc(simplify))

print(polar.jacobian(rect, [r, theta]))

p = polar.point([1, 3*pi/4])
print(rect.point_to_coords(p))
print(rect.coord_function(0)(p))
print(rect.coord_function(1)(p))

v_x = rect.base_vector(0)
x = rect.coord_function(0)
print(v_x(x))
print(v_x(v_x(x)))

v_r = polar.base_vector(0)
print(v_r(x))
# ^ ????

dx = rect.base_oneform(0)
print(dx(v_x))
# ????
Esempio n. 3
0
from sympy.diffgeom import Manifold, Patch, CoordSystem
r, theta = symbols('r, theta')
m = Manifold('M', 2)
patch = Patch('P', m)
rect = CoordSystem('rect', patch)
polar = CoordSystem('polar', patch)
rect in patch.coord_systems
polar.connect_to(rect, [r, theta], [r*cos(theta), r*sin(theta)])
polar.coord_tuple_transform_to(rect, [0, 2])
polar.coord_tuple_transform_to(rect, [2, pi/2])
rect.coord_tuple_transform_to(polar, [1, 1])
polar.jacobian(rect, [r, theta])
p = polar.point([1, 3*pi/4])
rect.point_to_coords(p)
#Define a basis scalar field (i.e. a coordinate function), that takes a point and returns its coordinates. It is an instance of BaseScalarField.
rect.coord_function(0)(p)
rect.coord_function(1)(p)
#Define a basis vector field (i.e. a unit vector field along the coordinate line). Vectors are also differential operators on scalar fields. It is an instance of BaseVectorField.
v_x = rect.base_vector(0)
x = rect.coord_function(0)
v_x(x)
v_x(v_x(x))
#Define a basis oneform field:
dx = rect.base_oneform(0)
dx(v_x)
#If you provide a list of names the fields will print nicely: - without provided names:
x, v_x, dx
#with provided names
rect = CoordSystem('rect', patch, ['x', 'y'])
rect.coord_function(0), rect.base_vector(0), rect.base_oneform(0)
# Examples