Coordinate systems and differential operators
Both symbolic (CoorSystemSym) and numerical (CoorSystemNum) coordinate systems are available. Symbolic systems support exact derivation; numerical systems evaluate differential operators pointwise via automatic differentiation — see the tutorial for examples.
julia> using TensND, SymPyjulia> Polar = coorsys_polar() ; r, θ = getcoords(Polar) ; 𝐞ʳ, 𝐞ᶿ = unitvec(Polar) ;julia> @set_coorsys Polarjulia> LAPLACE(SymFunction("f", real = true)(r, θ))2 ∂ ∂ ───(f(r, θ)) 2 ──(f(r, θ)) 2 ∂ ∂r ∂θ ───(f(r, θ)) + ─────────── + ──────────── 2 r 2 ∂r rjulia> n = symbols("n", integer = true)njulia> simplify(HESS(r^n))2×2 TensND.TensRotated{2, 2, Sym{PyCall.PyObject}, Tensors.SymmetricTensor{2, 2, Sym{PyCall.PyObject}, 3}}: n^2*r^n/r^2 - n*r^n/r^2 0 0 n*r^n/r^2
julia> using TensND, SymPyjulia> Spherical = coorsys_spherical() ; θ, ϕ, r = getcoords(Spherical) ; 𝐞ᶿ, 𝐞ᵠ, 𝐞ʳ = unitvec(Spherical) ;julia> @set_coorsys Sphericaljulia> Christoffel(Spherical)3×3×3 Array{Sym{PyCall.PyObject}, 3}: [:, :, 1] = 0 0 1/r 0 -sin(2*θ)/2 0 1/r 0 0 [:, :, 2] = 0 1/tan(θ) 0 1/tan(θ) 0 1/r 0 1/r 0 [:, :, 3] = -r 0 0 0 -r*sin(θ)^2 0 0 0 0julia> ℬˢ = normalized_basis(Spherical)3×3 RotatedBasis{3, Sym{PyCall.PyObject}}: cos(θ)⋅cos(ϕ) -sin(ϕ) sin(θ)⋅cos(ϕ) sin(ϕ)⋅cos(θ) cos(ϕ) sin(θ)⋅sin(ϕ) -sin(θ) 0 cos(θ)julia> σʳʳ = SymFunction("σʳʳ", real = true)(r) ;julia> σᶿᶿ = SymFunction("σᶿᶿ", real = true)(r) ;julia> σᵠᵠ = SymFunction("σᵠᵠ", real = true)(r) ;julia> 𝛔 = σʳʳ * 𝐞ʳ ⊗ 𝐞ʳ + σᶿᶿ * 𝐞ᶿ ⊗ 𝐞ᶿ + σᵠᵠ * 𝐞ᵠ ⊗ 𝐞ᵠ3×3 TensND.TensRotated{2, 3, Sym{PyCall.PyObject}, Tensors.SymmetricTensor{2, 3, Sym{PyCall.PyObject}, 6}}: σᶿᶿ(r) 0 0 0 σᵠᵠ(r) 0 0 0 σʳʳ(r)julia> div𝛔 = simplify(DIV(𝛔))3-element TensND.TensRotated{1, 3, Sym{PyCall.PyObject}, Tensors.Vec{3, Sym{PyCall.PyObject}}}: r*(-σᵠᵠ(r)*sin(2*θ)/(2*r^2*sin(θ)^2) + σᶿᶿ(r)/(r^2*tan(θ))) 0 Derivative(σʳʳ(r), r) + 2*σʳʳ(r)/r - σᵠᵠ(r)/r - σᶿᶿ(r)/r