https://github.com/projecttorreypines/coordinatessystems.jl
https://github.com/projecttorreypines/coordinatessystems.jl
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/projecttorreypines/coordinatessystems.jl
- Owner: ProjectTorreyPines
- License: other
- Created: 2024-03-13T16:49:35.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-12-11T01:34:09.000Z (over 1 year ago)
- Last Synced: 2025-03-29T22:28:48.653Z (about 1 year ago)
- Language: Julia
- Size: 572 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CoordinatesSystems
[](https://github.com/ProjectTorreyPines/CoordinatesSystems.jl/actions/workflows/CI.yml)
This package provides support to do vectorial computations.
The first usage is the derivation of metric tensor and associated operators.
```julia
using CoordinatesSystems, Symbolics
đĖ = UnitBasisVectors(CartesianCS)
@variables r Ψ θ
đ = r * cos(Ψ) * sin(θ) * đĖ.x + r * sin(Ψ) * sin(θ) * đĖ.y + r * cos(θ) * đĖ.z
đŽ = BasisVectors{SphericalCS}(đ, [r, θ, Ψ])
gĖ
Ė
= MetricTensor(đŽ)
r_ = 3.0
θ_ = Ī / 3
g = gĖ
Ė
(r_, θ_, 8.0)
g.r.r == 1.0 && g.θ.θ == r_^2 && g.Ψ.Ψ == r_^2 * sin(θ_)^2
```
```julia
using CoordinatesSystems, Symbolics
@variables r Ī z
đ = BasisVectors{CylindricalCS}(r * cos(Ī), r * sin(Ī),z, [r, Ī, z])
đ¯ = PVector{CylindricalCS}(r^3, 0,0)
gĖ
Ė
= MetricTensor(đ)
â = Divergence(gĖ
Ė
)
d = â â
đ¯
r_ = abs(rand()) +0.0001
isapprox(d(r_, 2.0, 3.0),4 * r_^2, atol=1e-14)
```
The second usage is to perform vectorial calculations on mesh structures.
```julia
using CoordinatesSystems, Symbolics
nx = 100
ny = 90
arr_gen = ArrayGenerator(nx, ny)
a = 1.0
b = 2.0
đŽ = PVector{CartesianCS}(arr_gen; fill=a)
đ¯ = PVector{CartesianCS}(arr_gen; fill=b)
M = đŽ â
đ¯
all(M .== 3 * a * b)
A = rand(nx, ny)
B = rand(nx, ny)
C = rand(nx, ny)
đŽ = PVector{CartesianCS}(A, B, C)
all(norm(đŽ) .== sqrt.(A .^ 2 .+ B .^ 2 .+ C .^ 2))
```