Skip to content

Commit

Permalink
Merge pull request #4 from cadojo/dev
Browse files Browse the repository at this point in the history
Fixed typo in Canonical --> Cartesian
  • Loading branch information
cadojo authored Sep 19, 2020
2 parents b56a59d + 5ca3219 commit 84a1e77
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
julia-version: ['1.0', '1', 'nightly']
julia-version: ["1.5"]
julia-arch: [x64]
os: [ubuntu-latest, macOS-latest]

Expand Down
23 changes: 13 additions & 10 deletions src/TwoBody.jl
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ Returns a Cartesian representation of an orbital state.
"""
function CartesianOrbit(
orbit::CanonicalOrbit,
μ=SVector(UnitfulAstro.GMearth, UnitfulAstro.GMsun)[Int(orbit.body)+1])
μ=SVector(1.0*UnitfulAstro.GMearth, 1.0*UnitfulAstro.GMsun)[Int(orbit.body)+1])

# Find semilatus parameter
p = semi_parameter(orbit.a, orbit.e)
Expand All @@ -192,8 +192,8 @@ function CartesianOrbit(
=SVector{3, Float64}([0, 0, 1])

# Find state in Perifocal frame
r̅_perifocal = (r * cos(orbit.ν) *+ r * sin(orbit.ν) * Q̂)
v̅_perifocal = /p) * (-sin(orbit.ν) * + (orbit.e + cos(orbit.ν) * Q̂))
r̅_perifocal = (r * cos(orbit.ν) .*.+ r * sin(orbit.ν) .* Q̂)
v̅_perifocal = /p) * ((-sin(orbit.ν) *) .+ ((orbit.e + cos(orbit.ν)) .* Q̂))

# Set up Perifocal ⟶ Cartesian conversion # TODO - move this to a function
R_3Ω = SMatrix{3,3,Float64}(
Expand Down Expand Up @@ -712,8 +712,8 @@ end

function Base.isapprox(c1::CartesianOrbit, c2::CartesianOrbit; tolerance=1e-8)

return all(ustrip(c1.- c2.r̅) .< tolerance) &&
all(ustrip(c1.- c2.r̅) .< tolerance) &&
return all(ustrip.(c1.- c2.r̅) .< tolerance) &&
all(ustrip.(c1.- c2.r̅) .< tolerance) &&
(c1.body == c2.body)

end
Expand Down Expand Up @@ -751,9 +751,10 @@ function Base.isequal(c1::CanonicalOrbit, c2::CanonicalOrbit)
end

function propagate(orbit::AbstractOrbit;
μ=SVector(1*UnitfulAstro.GMearth, 1*UnitfulAstro.GMsun)[Int(orbit.body)+1],
μ=SVector(1.0*UnitfulAstro.GMearth, 1.0*UnitfulAstro.GMsun)[Int(orbit.body)+1],
tspan=(0.0u"s", upreferred(orbital_period(orbit))),
reltol=1e-8,
abstol=1e-13,
reltol=1e-13,
saveat=0.25u"s",
alg=Tsit5())

Expand All @@ -771,18 +772,20 @@ function propagate(orbit::AbstractOrbit;

# Ensure Cartesian representation
cart = CartesianOrbit(orbit)
r₀ = Array(ustrip.(uconvert.(u"m",cart.r̅)))
v₀ = Array(ustrip.(uconvert.(u"m/s", cart.v̅)))
r₀ = Array(ustrip.(uconvert.(u"km",cart.r̅)))
v₀ = Array(ustrip.(uconvert.(u"km/s", cart.v̅)))

# Define the problem
problem = ODEProblem(
orbit_tic,
ComponentArray((r̅=r₀, v̅=v₀)),
ustrip.(uconvert.(u"s",tspan)),
ComponentArray((μ=ustrip.(uconvert(u"m^3 / s^2", μ)))))
ComponentArray((μ=ustrip.(uconvert(u"km^3 / s^2", μ)))))

# Solve the problem!
solution = solve(problem, alg,
abstol=abstol,
reoltol=reltol,
saveat=ustrip(uconvert(u"s",saveat)))

return solution
Expand Down

0 comments on commit 84a1e77

Please sign in to comment.