Skip to content

Commit

Permalink
Merge pull request #106 from cadojo/dev
Browse files Browse the repository at this point in the history
ThreeBody Cleanup
  • Loading branch information
cadojo authored Nov 23, 2020
2 parents 174724a + 8ddea4f commit 181a2c4
Show file tree
Hide file tree
Showing 32 changed files with 637 additions and 246 deletions.
22 changes: 11 additions & 11 deletions Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ version = "0.5.1"

[[ChainRulesCore]]
deps = ["LinearAlgebra", "MuladdMacro", "SparseArrays"]
git-tree-sha1 = "d41ca57a864c23444ad80e9d30beeea192fe9446"
git-tree-sha1 = "007f084f0136c0e2d87d3ac53e9d8eab06cec27f"
uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
version = "0.9.18"
version = "0.9.19"

[[ColorSchemes]]
deps = ["ColorTypes", "Colors", "FixedPointNumbers", "Random", "StaticArrays"]
Expand Down Expand Up @@ -89,9 +89,9 @@ version = "0.3.4+0"

[[ComponentArrays]]
deps = ["ArrayInterface", "LinearAlgebra", "Requires"]
git-tree-sha1 = "dfc7dd5393d4f789019ccdc73e04bed61ab31903"
git-tree-sha1 = "bcf26bd8d7cfd54dd064e4c653767125439af595"
uuid = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66"
version = "0.8.8"
version = "0.8.10"

[[ConstructionBase]]
git-tree-sha1 = "a2a6a5fea4d6f730ec4c18a76d27ec10e8ec1c50"
Expand Down Expand Up @@ -531,9 +531,9 @@ uuid = "2774e3e8-f4cf-5e23-947b-6d7e65073b56"
version = "4.4.1"

[[NaNMath]]
git-tree-sha1 = "c84c576296d0e2fbb3fc134d3e09086b3ea617cd"
git-tree-sha1 = "bfe47e760d60b82b66b61d2d44128b62e3a369fb"
uuid = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3"
version = "0.3.4"
version = "0.3.5"

[[OffsetArrays]]
deps = ["Adapt"]
Expand Down Expand Up @@ -572,9 +572,9 @@ version = "1.3.2"

[[OrdinaryDiffEq]]
deps = ["Adapt", "ArrayInterface", "DataStructures", "DiffEqBase", "ExponentialUtilities", "FastClosures", "FiniteDiff", "ForwardDiff", "GenericSVD", "LinearAlgebra", "Logging", "MacroTools", "MuladdMacro", "NLsolve", "RecursiveArrayTools", "Reexport", "SparseArrays", "SparseDiffTools", "StaticArrays", "UnPack"]
git-tree-sha1 = "7ea4d187575fb5256409d755819afb66e1812f2b"
git-tree-sha1 = "e782c1ff432a6ba8677b6fced19a92a6878a5c68"
uuid = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
version = "5.45.0"
version = "5.45.1"

[[PCRE_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
Expand Down Expand Up @@ -639,10 +639,10 @@ uuid = "784f63db-0788-585a-bace-daefebcd302b"
version = "2019.1.0+2"

[[Qt_jll]]
deps = ["Fontconfig_jll", "Glib_jll", "Libdl", "Pkg", "Xorg_libXext_jll", "Xorg_libxcb_jll", "Xorg_xcb_util_image_jll", "Xorg_xcb_util_keysyms_jll", "Xorg_xcb_util_renderutil_jll", "Xorg_xcb_util_wm_jll", "Zlib_jll", "xkbcommon_jll"]
git-tree-sha1 = "b3979580c712b167a131bd1a4152a840d6df89cb"
deps = ["Artifacts", "Fontconfig_jll", "Glib_jll", "JLLWrappers", "Libdl", "Pkg", "Xorg_libXext_jll", "Xorg_libxcb_jll", "Xorg_xcb_util_image_jll", "Xorg_xcb_util_keysyms_jll", "Xorg_xcb_util_renderutil_jll", "Xorg_xcb_util_wm_jll", "Zlib_jll", "xkbcommon_jll"]
git-tree-sha1 = "72244a8e084251aea25968c61bbf5c001aaa7d5a"
uuid = "ede63266-ebff-546c-83e0-1c6fb6d0efc8"
version = "5.15.0+3"
version = "5.15.1+0"

[[REPL]]
deps = ["InteractiveUtils", "Markdown", "Sockets"]
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "UnitfulAstrodynamics"
uuid = "673e7d9c-15b0-48d3-bce0-fab551f3a174"
authors = ["Joe Carpinelli <[email protected]>"]
version = "0.6.4"
version = "0.6.5"

[deps]
ComponentArrays = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66"
Expand Down
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,28 @@ plot(sols; title="Plots.jl keywords work!", xlabel="Woo")
sols.step[end] orbit_later
```

#### Three-Body Problem

The `ThreeBody` module helps to solve the Circular Restricted `ThreeBody` problem.

```julia
# Hardcode Gravity parameters for the Sun,
# and the Earth-Moon System
μₛ = 1.32712440018e20u"m^3/s^2"
μₑ = 4.035032351966808e14u"m^3/s^2"

# Dimensional initial conditions for spacecraft
r = [2e9, 7000, 2000]u"km"
v = [0.001, 0.08, 0.02]u"km/s"
t = 500u"d"

# Construct nondimensional state
sys = ThreeBodySystem(1.0u"AU", μₛ, μₑ, r, v, t);

# Propagate!
sols = propagate(sys)
```

#### N-Body Problem

The `NBody` module helps to solve the classical gravitational `NBody` problem.
Expand Down
8 changes: 4 additions & 4 deletions docs/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ version = "0.3.4+0"

[[ComponentArrays]]
deps = ["ArrayInterface", "LinearAlgebra", "Requires"]
git-tree-sha1 = "98328102aec602c5d95bdb5bbc1b59f48d378e79"
git-tree-sha1 = "bcf26bd8d7cfd54dd064e4c653767125439af595"
uuid = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66"
version = "0.8.9"
version = "0.8.10"

[[ConstructionBase]]
git-tree-sha1 = "a2a6a5fea4d6f730ec4c18a76d27ec10e8ec1c50"
Expand Down Expand Up @@ -175,9 +175,9 @@ version = "0.8.3"

[[Documenter]]
deps = ["Base64", "Dates", "DocStringExtensions", "IOCapture", "InteractiveUtils", "JSON", "LibGit2", "Logging", "Markdown", "REPL", "Test", "Unicode"]
git-tree-sha1 = "e7b7acd1d25ffdc1fe6226a3c2fd807fe64f898d"
git-tree-sha1 = "a4875e0763112d6d017126f3944f4133abb342ae"
uuid = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
version = "0.25.4"
version = "0.25.5"

[[EarCut_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
Expand Down
16 changes: 10 additions & 6 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,30 @@ makedocs(modules=[UnitfulAstrodynamics],
"About" => "Overview/about.md",
"Getting Stated" => "Overview/getting-started.md"
],
"`TwoBody`" => Any[
"Two-body" => Any[
"Data Structures and Types" => "TwoBody/types.md",
"Functions" => "TwoBody/functions.md"
],
"`NBody`" => Any[
"Three-body" => Any[
"Data Structures and Types" => "ThreeBody/types.md",
"Functions" => "ThreeBody/functions.md"
],
"N-body" => Any[
"Data Structures and Types" => "NBody/types.md",
"Functions" => "NBody/functions.md"
],
"`Propagators`" => Any[
"Propagators" => Any[
"Data Structures and Types" => "Propagators/types.md",
"Functions" => "Propagators/functions.md"
],
"`Maneuvers`" => Any[
"Maneuvers" => Any[
"Data Structures and Types" => "Maneuvers/types.md",
"Functions" => "Maneuvers/functions.md"
],
"`AstroPlots`" => Any[
"Plotting" => Any[
"Functions" => "AstroPlots/functions.md"
],
"Common `CommonTypes`" => Any[
"Common Types" => Any[
"Types" => "CommonTypes/types.md"
]
]
Expand Down
28 changes: 26 additions & 2 deletions docs/src/Overview/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ Pkg.add("UnitfulAstrodynamics")

## Units are Required!

`UnitfulAstrodynamics.jl` uses `Reexport.jl` to expose `Unitful`, `UnitfulAstro`, and `UnitfulAngles`. Units are required for all `TwoBody` and `NBody` computations, and all required types in `Unitful`, `UnitfulAstro`, and `UnitfulAngles` are included _with_ `UnitfulAstrodynamics` when you call `using UnitfulAstrodynamics`.
`UnitfulAstrodynamics.jl` uses `Reexport.jl` to expose `Unitful`, `UnitfulAstro`, and `UnitfulAngles`. Units are required for all `TwoBody`, `ThreeBody`, and `NBody` data structures. Functions often have non-unit equivalents --
check the docstrings!

## Two-body Problem
## TwoBody

The `TwoBody` module handles Astrodynamics scenarios within the two-body problem. You can make a `Orbit` by specifying a `CelestialBody` (Sun, Earth, Moon, Mars, etc.), and a Cartesian or Keplerian state.

Expand Down Expand Up @@ -76,6 +77,29 @@ search: eccentricity eccentricity_vector
Returns orbital eccentricity, e.
```

## ThreeBody

The `ThreeBody` module helps to solve the Circular Restricted `ThreeBody` problem.

```julia
# Hardcode Gravity parameters for the Sun,
# and the Earth-Moon System
μₛ = 1.32712440018e20u"m^3/s^2"
μₑ = 4.035032351966808e14u"m^3/s^2"

# Dimensional initial conditions for spacecraft
r = [2e9, 7000, 2000]u"km"
v = [0.001, 0.08, 0.02]u"km/s"
t = 500u"d"

# Construct nondimensional state
sys = ThreeBodySystem(1.0u"AU", μₛ, μₑ, r, v, t);

# Propagate!
sols = propagate(sys)
```


## NBody

The `NBody` module helps to solve the classical gravitational `NBody` problem. This is the baby version - point mass bodies, and no relativity. But it's still useful!
Expand Down
39 changes: 39 additions & 0 deletions docs/src/ThreeBody/functions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# `ThreeBody` Calculations

Common `ThreeBody` problem calculations are provided through functions.

## Frame Representations

You can convert between the Inertial and Rotating (Synodic) reference frames through
the `inertial` and `synodic` functions.

```@docs
inertial
synodic
```

## Dimensionalization

Functions to nondimensionalize spacecraft states, and re-dimensionalize spacecraft
states are provided.

```@docs
time_scale_factor
nondimensionalize_length
nondimensionalize_velocity
nondimensionalize_time
nondimensionalize_mass_parameter
nondimensionalize
redimensionalize_length
redimensionalize_velocity
redimensionalize_time
redimensionalize
```

## Other Common Calculations

```@docs
potential_energy
jacobi_constant
nondimensional_radius
```
8 changes: 8 additions & 0 deletions docs/src/ThreeBody/types.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# `ThreeBody` Data Structures

The `ThreeBody` module contains one key structure: `ThreeBodySystem`. A `ThreeBodySystem` holds the
nondimensional state of the spacecraft within the Circular Restricted Three-body Problem.

```@docs
ThreeBodySystem
```
3 changes: 0 additions & 3 deletions docs/src/TwoBody/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ You can convert between Cartesian and Keplerian `TwoBody` orbital representation
```@docs
cartesian
keplerian
inertial
perifocal
```

Expand Down Expand Up @@ -57,6 +56,4 @@ specific_angular_momentum_vector
specific_energy
conic
isinvalid
isapprox
isequal
```
7 changes: 7 additions & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ Pages = ["TwoBody/types.md", "TwoBody/functions.md"]
Depth = 1
```

## ThreeBody

```@contents
Pages = ["ThreeBody/types.md", "ThreeBody/functions.md"]
Depth = 1
```

## NBody

```@contents
Expand Down
12 changes: 4 additions & 8 deletions src/AstroPlots/AstroPlots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,16 @@ and the two-body problem. Uses `Plots.jl`
"""
module AstroPlots

using Reexport
@reexport using ..CommonTypes

include("../Misc/DocStringExtensions.jl")
include("../Misc/UnitfulAliases.jl")

using ..CommonTypes
using ..TwoBody
using ..NBody
using ..Propagators

using Reexport

using Logging
using Base: isapprox, isequal
using LinearAlgebra: ×, , norm
using ComponentArrays
using StaticArrays
using Plots
using Plots.PlotMeasures

Expand Down
6 changes: 3 additions & 3 deletions src/CommonTypes/CommonTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ Implementations are provided in TwoBody, and NBody.
"""
module CommonTypes

include("../Misc/DocStringExtensions.jl")

using Reexport
@reexport using Unitful, UnitfulAngles, UnitfulAstro

@reexport using Unitful, UnitfulAstro
include("../Misc/DocStringExtensions.jl")
include("../Misc/UnitfulAliases.jl")

export AbstractBody, OrbitalSystem, PropagationResult

Expand Down
10 changes: 5 additions & 5 deletions src/Maneuvers/Maneuvers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ Provides calculations for orbit maneuvers.
"""
module Maneuvers

using Reexport
@reexport using ..CommonTypes

include("../Misc/DocStringExtensions.jl")
include("../Misc/UnitfulAliases.jl")

using ..CommonTypes
using ..NBody
using ..TwoBody

using Reexport

using Logging
using LinearAlgebra: norm, cross, ×, dot,

export AbstractManeuver, TwoBodyManeuver, ConstantManeuver
export escape_radius, escape_velocity, escape_time, escape_path_length
Expand Down
28 changes: 25 additions & 3 deletions src/Misc/DocStringExtensions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,30 @@

using DocStringExtensions

struct TerseMethods <: DocStringExtensions.Abbreviation end
const TERSEMETHODS = TerseMethods()

function DocStringExtensions.format(::TerseMethods, buf, doc)
local binding = doc.data[:binding]
local typesig = doc.data[:typesig]
local modname = doc.data[:module]
local func = Docs.resolve(binding)
local groups = DocStringExtensions.methodgroups(func, typesig, modname; exact = false)
if !isempty(groups)
println(buf)
println(buf, "```julia")
for group in groups
for method in group
DocStringExtensions.printmethod(buf, binding, func, method)
println(buf)
end
end
println(buf, "```\n")
println(buf)
end
return nothing
end

struct SourceCode <: DocStringExtensions.Abbreviation end
const SOURCECODE = SourceCode()

Expand Down Expand Up @@ -39,8 +63,6 @@ include_sourcecode(b::Bool) = include_source_in_docstring = b

@template (FUNCTIONS, METHODS, MACROS) =
"""
$(METHODLIST)
$(TERSEMETHODS)
$(DOCSTRING)
"""

# export SOURCECODE
10 changes: 10 additions & 0 deletions src/Misc/UnitfulAliases.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#
# Aliases for Unitful dimension singletons
#

Unitful.@derived_dimension MassParameter Unitful.𝐋^3/Unitful.𝐓^2
const MassParameter = MassParameter
const Length = Unitful.Length
const Velocity = Unitful.Velocity
const Time = Unitful.Time
const Mass = Unitful.Mass
Loading

2 comments on commit 181a2c4

@cadojo
Copy link
Collaborator Author

@cadojo cadojo commented on 181a2c4 Nov 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register branch=main

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/25175

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.6.5 -m "<description of version>" 181a2c46a662dd0c8cfb6ca8ad3b1448d19a3d02
git push origin v0.6.5

Please sign in to comment.