An open API service indexing awesome lists of open source software.

https://github.com/projecttorreypines/coordinatessystems.jl


https://github.com/projecttorreypines/coordinatessystems.jl

Last synced: 6 months ago
JSON representation

Awesome Lists containing this project

README

          

# CoordinatesSystems

[![CI](https://github.com/ProjectTorreyPines/CoordinatesSystems.jl/actions/workflows/CI.yml/badge.svg?branch=master)](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))
```