diff --git a/Project.toml b/Project.toml index ff13a335..39d353be 100644 --- a/Project.toml +++ b/Project.toml @@ -3,6 +3,9 @@ uuid = "8068df5b-8501-4530-bd82-d24d3c9619db" authors = ["Joey Carpinelli "] version = "0.11.0" +[workspace] +projects = ["docs", "test", "lib/AstrodynamicalCalculations", "lib/AstrodynamicalModels", "lib/AstrodynamicalSolvers"] + [deps] AstrodynamicalCalculations = "c0cf9fb7-f496-4999-a425-c50785d1b88b" AstrodynamicalModels = "4282b555-f590-4262-b575-3e516e1493a7" @@ -12,11 +15,6 @@ EphemerisSources = "858900df-f7ae-402a-aa8c-3e4ef85aa271" Reexport = "189a3867-3050-52da-a836-e630ba90ab69" SPICE = "5bab7191-041a-5c2e-a744-024b9c3a5062" -[sources] -AstrodynamicalCalculations = {path="lib/AstrodynamicalCalculations"} -AstrodynamicalModels = {path="lib/AstrodynamicalModels"} -AstrodynamicalSolvers = {path="lib/AstrodynamicalSolvers"} - [compat] AstrodynamicalCalculations = "0.5, 1" AstrodynamicalModels = "3.4" @@ -25,11 +23,4 @@ DocStringExtensions = "0.9" EphemerisSources = "1.0.0" Reexport = "1.2" SPICE = "0.2" -julia = "1.7" - -[extras] -Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" -Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" - -[targets] -test = ["Test", "Pkg"] +julia = "1.10" diff --git a/lib/AstrodynamicalCalculations/Project.toml b/lib/AstrodynamicalCalculations/Project.toml index 8aea4a9a..d9de4b89 100644 --- a/lib/AstrodynamicalCalculations/Project.toml +++ b/lib/AstrodynamicalCalculations/Project.toml @@ -3,6 +3,9 @@ uuid = "c0cf9fb7-f496-4999-a425-c50785d1b88b" authors = ["Joey Carpinelli "] version = "1.0.0" +[workspace] +projects = ["docs", "test"] + [deps] DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" @@ -15,10 +18,4 @@ DocStringExtensions = "0.9" Reexport = "1.2" StaticArrays = "1.6" Roots = "2.0" -julia = "1.6" - -[extras] -Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" - -[targets] -test = ["Test"] +julia = "1.10" diff --git a/lib/AstrodynamicalCalculations/test/CR3BPCalculations.jl b/lib/AstrodynamicalCalculations/test/CR3BPCalculations.jl new file mode 100644 index 00000000..b5df656c --- /dev/null +++ b/lib/AstrodynamicalCalculations/test/CR3BPCalculations.jl @@ -0,0 +1,734 @@ +using AstrodynamicalCalculations: + converge, + diverge, + jacobi_constant, + richardson_ic, + richardson_halo + +@testset "CR3BP Calculations" begin + r = [ + 1.007988 + 0.0 + 0.001864 + ] + + v = zeros(3, 1) + + μ = 3.003480593992993e-6 + + @test jacobi_constant(r..., v..., μ) ≈ 3.000907212196274 +end + +@testset "Near-periodic Orbits" begin + μ = 0.012150584395829193 + u = richardson_ic(μ, 2) + (; x, y, z, ẋ, ẏ, ż, Δt) = u + + @test x ≈ 1.124357139749168 + @test y ≈ 0.0 + @test z ≈ 0.0 + @test ẋ ≈ 0.0 + @test ẏ ≈ 0.1716444216936595 + @test ż ≈ -0.0 + @test Δt ≈ 3.253854900204856 + + u = richardson_halo(μ, 1) + for variable in (:x, :y, :z, :ẋ, :ẏ, :ż) + @test isapprox( + getproperty(u[begin], variable), + getproperty(u[end], variable), + atol = 1e-12, + ) + end +end + +@testset "Manifold Computations" begin + + # + # Conditions for tests below: + # julia> μ = 0.012150584395829193 + # julia> u, T = halo(μ, 1; amplitude=0.005) + # + + Φ = [ + 1317.472125300217 -339.26725145920585 -22.23471304682866 388.2455372345198 126.49047353668445 -3.3779594177227 + -429.7764385389933 111.53280315746214 7.269431052432993 -126.49047353678779 -41.404653982215095 1.0977750840404263 + -11.440384647744368 2.9348175664641527 1.1929568568249131 -3.3779594177162653 -1.0977750840374354 -0.05845992955397675 + 3612.12986893901 -929.3271447079647 -60.998106970610365 1064.4911782262984 346.9671305741014 -9.244834479682378 + -1482.5514995781887 382.0700769975138 25.039782109090023 -437.2238230101127 -141.4481439160884 3.8211012689780377 + -75.5369690753493 19.429643984545518 1.2797982252155324 -22.23471304678537 -7.269431052412963 1.1929568568243507 + ] + + ics = [ + [ + 0.823388563881332, + 0.0, + 0.005553604696093592, + 0.0, + 0.12683910108732768, + 0.0, + 1.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + ], + [ + 0.8273403859561881, + 0.03259254695615611, + 0.004655244516514311, + 0.027320231122920834, + 0.10312408143143087, + -0.006368351099157183, + 1.3786797126365464, + -0.08824308385714617, + -0.009143474674588519, + 2.826623191577671, + -0.9767705092124925, + -0.06678667433841168, + -0.041844969630018845, + 0.8820353502805051, + 0.0007013669623268068, + -0.45278244255732314, + -0.7835124078992787, + 0.0073360448800629365, + -0.008855612000587742, + 0.002327804586816214, + 0.838573983007699, + -0.06290404981028867, + 0.02486880981909553, + -1.144418551135245, + 0.29476786414533784, + -0.07907382422170534, + -0.0008101636936140204, + 1.2265481296819574, + -0.604917980406487, + -0.008685295114209327, + 0.07388202008165795, + 0.2492072545027064, + -1.4738222079088099e-5, + 0.5293937831553415, + 0.7281497497436548, + -0.00023580443544974562, + -0.0007858587607819898, + 0.00020348487224860056, + 0.25939140376611963, + -0.008269842352818602, + 0.0028734095281463595, + 0.8384737725375465, + ], + [ + 0.8369339005610434, + 0.05308879581928126, + 0.002245931439623135, + 0.03925760359490229, + 0.04164563292173339, + -0.010722629489038576, + 2.633666680439342, + -0.7476233640873686, + -0.036115619838154166, + 6.59317685013257, + -4.305178122455261, + -0.12567569616107588, + -0.32236550652146106, + 0.6479359223648997, + 0.004637853579299471, + -1.718449648616434, + -0.7249471649546353, + 0.021058591017896974, + -0.03358790594797937, + 0.01714406169353313, + 0.40552901171028016, + -0.1175501978131001, + 0.08850970435530003, + -1.9276108228616495, + 0.7232939839971113, + -0.36584119809468774, + -0.005825038522167102, + 2.0164150719091194, + -1.588312972089223, + -0.02821711404806066, + 0.2835849868569326, + 0.3549141154538107, + -0.00031947991899352273, + 0.9912017667556496, + -0.033028457627487386, + -0.0024977304687910985, + -0.005384939024007069, + 0.00272987184176848, + 0.4345059352772165, + -0.025760320739897816, + 0.01772446341402129, + 0.3998442189060235, + ], + [ + 0.8470241424999021, + 0.05395424966031193, + -0.0009080043524526027, + 0.031419954303289845, + -0.036048701160724284, + -0.011590792835804302, + 5.2751979177709245, + -2.8002759306940206, + -0.06970307574708806, + 13.575834570928198, + -11.52199157988803, + -0.08191686885532921, + -1.0650447822856468, + 0.6234811067801149, + 0.010733752984669538, + -3.905785161291004, + 0.866145889611684, + 0.016124697957608767, + -0.07643671410242639, + 0.05458515963145915, + -0.16164597656191948, + -0.2095060221160001, + 0.19489307781221327, + -2.0855174774020258, + 1.5018686968935528, + -1.0383366134481509, + -0.014310928273230595, + 3.9574099493625914, + -3.5470463790411046, + -0.02296768894075728, + 0.6253995245350682, + 0.18722436787118188, + -0.0013253485604900028, + 1.5577619859991105, + -1.2832341322229566, + -0.0027644056993001167, + -0.014907405477056719, + 0.010799843345176774, + 0.4631273703125115, + -0.043829837552022737, + 0.04200385021401396, + -0.20848785169720335, + ], + [ + 0.8532353425901987, + 0.03409350294370255, + -0.003693332419778437, + 0.0136102558436333, + -0.10493897930691469, + -0.007897889399969823, + 11.061936482274414, + -7.689747752640067, + -0.03153665012283715, + 31.785749672658245, + -25.44043221945118, + 0.5332758341624475, + -2.6858333294059364, + 1.3445895697563528, + 0.002854429918083852, + -8.652720643412609, + 4.866690329415817, + -0.113864600921434, + -0.16640832220212004, + 0.1333566308356175, + -0.6638852788093453, + -0.5058642813219177, + 0.40239589734920744, + -1.431763849780302, + 3.195745363280542, + -2.4844942161704124, + -0.00386208695123994, + 9.339460840937965, + -7.368022339704923, + 0.1499688501028994, + 1.223461957527104, + -0.41159173922619013, + 0.002536978196004755, + 3.113085020093486, + -3.2037573059636526, + 0.04850882843406646, + -0.0306140680948119, + 0.02606395260902634, + 0.3190695726681844, + -0.07676967973326097, + 0.06982698735410356, + -0.823253631643632, + ], + [ + 0.854955140499413, + 2.2843913370187256e-15, + -0.004841260493981484, + -8.426065623187225e-15, + -0.1344033872050793, + -2.3393929523281094e-16, + 25.670001169891876, + -17.290935930959833, + 0.3735915323822458, + 82.56024329676991, + -44.66052062847337, + 2.744550087867072, + -6.549914989117929, + 3.515781165459679, + -0.09045012326731859, + -21.560863766695647, + 11.122750444783911, + -0.65681735247777, + -0.4081906725844075, + 0.28639114669384175, + -0.8777886212624451, + -1.3960821106365155, + 0.7204334759076325, + -0.04847727067031394, + 7.495647097356273, + -5.235090649386511, + 0.11199867561047291, + 24.307495565860556, + -12.730790263231905, + 0.7894471966986759, + 2.6328847934916584, + -1.602867310555306, + 0.041320768129938484, + 7.950197124746471, + -5.4159521324395765, + 0.26854701213925986, + -0.06452008851439175, + 0.049418531406256176, + 0.03736159910558069, + -0.19318325888690766, + 0.10035816116241962, + -1.1539010608138158, + ], + [ + 0.8532353425901938, + -0.03409350294369572, + -0.0036933324197787306, + -0.013610255843655042, + -0.10493897930691656, + 0.007897889399968805, + 61.783725674727414, + -31.809460366393743, + 1.5639194613448177, + 192.5622814708414, + -60.811745821785316, + 5.790230207958852, + -15.9467057502335, + 7.366098751441629, + -0.3866391287246332, + -50.036359202730644, + 16.771181856064608, + -1.474065945922604, + -1.0242029826389052, + 0.5249458158655891, + -0.6919274956044533, + -3.288510633984684, + 1.0165171629160492, + 1.321471791772166, + 18.12710682888481, + -9.376464402158039, + 0.4560226259807858, + 56.69804470264641, + -17.397205275984405, + 1.6789260061002176, + 6.108694482836869, + -3.292222472289838, + 0.15851822297241477, + 18.49715015775276, + -6.775733307775279, + 0.5687877877351285, + -0.1529731671956582, + 0.08076178851334609, + -0.2644398496513836, + -0.4861071061444217, + 0.12936352157783781, + -0.9612148163601355, + ], + [ + 0.8470241424998886, + -0.053954249660305716, + -0.0009080043524529912, + -0.031419954303331776, + -0.036048701160720203, + 0.011590792835803694, + 139.81168166322985, + -51.900248046349844, + 3.271613747195812, + 397.8858051004851, + -91.85758770599232, + 5.821945264799484, + -36.17535833489009, + 12.967888420563526, + -0.8279061449068151, + -102.92655322720218, + 25.534744119150396, + -1.5228161048932043, + -2.3513343309735673, + 0.866235468830786, + -0.2198726250639241, + -6.7447477075950895, + 1.5755137371116215, + 1.987134962713231, + 41.11521926552655, + -15.166743448559673, + 0.9526780029549172, + 117.27289978925529, + -26.666892209713573, + 1.6975459397425652, + 13.579339684552384, + -5.4115134792664845, + 0.32466549527180183, + 38.02628330961531, + -9.24871447769774, + 0.5601717489178005, + -0.35373005498093574, + 0.12514521971200396, + -0.45673669921893095, + -1.0315564554873287, + 0.2132601376815499, + -0.4067512272598734, + ], + [ + 0.8369339005610131, + -0.05308879581927243, + 0.0022459314396227116, + -0.03925760359498695, + 0.04164563292175057, + 0.010722629489038737, + 298.1536849578567, + -88.79218713147596, + 4.108212352069355, + 805.8842647516645, + -197.03199719416259, + -1.3587839120057053, + -77.0304035805354, + 23.008804194914685, + -1.051997832312519, + -207.58784021007904, + 52.69517331340727, + 0.31433070459529, + -5.028116277146918, + 1.4986245228726873, + 0.3336885466879633, + -13.604470125477365, + 3.3661481657079335, + 1.9537305723180947, + 87.79671835004706, + -25.956894579473673, + 1.196556663820022, + 237.60479660840883, + -57.88401149438683, + -0.4014318236821094, + 28.712231594102008, + -8.994281477261307, + 0.40346490381046596, + 77.0693721005221, + -18.784314465348764, + -0.14157890224819605, + -0.7638066834236382, + 0.21608393326675798, + -0.4802205363194697, + -2.081496212262708, + 0.5023315171518498, + 0.23330573472502658, + ], + [ + 0.8273403859561236, + -0.032592546956138974, + 0.004655244516514174, + -0.027320231123097893, + 0.1031240814314825, + 0.006368351099159685, + 624.1563531688901, + -178.97128138129779, + 1.2034561562153203, + 1685.807676266411, + -518.1477491379977, + -23.313639430926575, + -160.92062399834495, + 46.705824906057714, + -0.31350301921564855, + -433.6254768006774, + 134.82826866054083, + 5.971159098990085, + -10.529645901486171, + 3.0305772015792436, + 0.8168304281567269, + -28.450876102792893, + 8.77375084473596, + 1.5423565889576247, + 183.90492595796482, + -52.51978660929593, + 0.34248355473230047, + 496.93345370466517, + -152.78832660830577, + -6.855854030546668, + 59.93604732520242, + -17.543497122306604, + 0.12072458185754525, + 161.65110999609013, + -49.108411393866255, + -2.2542758104173393, + -1.6023417655780476, + 0.4493519667693413, + -0.33589553197288335, + -4.324479481929502, + 1.3446971876129539, + 0.797006208427492, + ], + [ + 0.8233885638811947, + 4.33547133764043e-14, + 0.00555360469609479, + -3.778286963052016e-13, + 0.12683910108748223, + 7.86884919269592e-15, + 1317.472125300217, + -429.7764385389933, + -11.440384647744368, + 3612.12986893901, + -1482.5514995781887, + -75.5369690753493, + -339.26725145920585, + 111.53280315746214, + 2.9348175664641527, + -929.3271447079647, + 382.0700769975138, + 19.429643984545518, + -22.23471304682866, + 7.269431052432993, + 1.1929568568249131, + -60.998106970610365, + 25.039782109090023, + 1.2797982252155324, + 388.2455372345198, + -126.49047353678779, + -3.3779594177162653, + 1064.4911782262984, + -437.2238230101127, + -22.23471304678537, + 126.49047353668445, + -41.404653982215095, + -1.0977750840374354, + 346.9671305741014, + -141.4481439160884, + -7.269431052412963, + -3.3779594177227, + 1.0977750840404263, + -0.05845992955397675, + -9.244834479682378, + 3.8211012689780377, + 1.1929568568243507, + ], + ] + + unstable = [diverge(ic[1:6], reshape(ic[7:end], 6, 6), Φ; eps = 1e-8) for ic in ics] + + @test unstable ≈ [ + [ + 0.8233885670604992, + -1.0366541345478615e-9, + 0.005553604668461628, + 8.715859137046784e-9, + 0.12683909750709388, + -1.8222484329190235e-10, + ], + [ + 0.8273403889974105, + 0.03259254570178936, + 0.004655244468062643, + 0.027320239369938236, + 0.1031240768350659, + -0.006368351287082361, + ], + [ + 0.8369339034694137, + 0.05308879425915669, + 0.0022459313856777996, + 0.039257611236035383, + 0.04164562738118049, + -0.010722629629902078, + ], + [ + 0.8470241452302693, + 0.05395424782876832, + -0.0009080043935676615, + 0.031419961538898866, + -0.036048707229790644, + -0.011590792871138664, + ], + [ + 0.8532353451489048, + 0.03409350102660894, + -0.0036933324275151497, + 0.013610263353121406, + -0.10493898508343963, + -0.00789788926934211, + ], + [ + 0.8549551430909017, + -1.7690279810307236e-9, + -0.0048412604557870696, + 8.408547056141493e-9, + -0.13440339160640008, + 2.7897965198713934e-10, + ], + [ + 0.8532353454774562, + -0.03409350442176633, + -0.003693332346613867, + -0.013610246811438523, + -0.104938982103295, + 0.007897889670159345, + ], + [ + 0.8470241457112383, + -0.053954250841694876, + -0.000908004277468657, + -0.03141994514599701, + -0.036048703261041745, + 0.01159079296921633, + ], + [ + 0.8369339039236694, + -0.05308879681438595, + 0.0022459314858005795, + -0.03925759449829196, + 0.041645630696876774, + 0.010722629473653931, + ], + [ + 0.8273403892761712, + -0.032592547905735625, + 0.004655244522837673, + -0.0273202221542787, + 0.10312407867097084, + 0.0063683509751929325, + ], + [ + 0.823388567060362, + -1.036610779834484e-9, + 0.005553604668462826, + 8.71548130835048e-9, + 0.12683909750724842, + -1.8221697444270972e-10, + ], + ] + + stable = [converge(ic[1:6], reshape(ic[7:end], 6, 6), Φ; eps = 1e-8) for ic in ics] + + @test stable ≈ [ + [ + 0.8233885607021647, + -1.036654134541258e-9, + 0.005553604723725555, + 8.715859137047568e-9, + 0.1268391046675615, + -1.8222484329220807e-10, + ], + [ + 0.8273403826361405, + 0.03259254600655946, + 0.004655244510190812, + 0.027320240091740028, + 0.10312408419194252, + -0.0063683512231239355, + ], + [ + 0.8369338971983872, + 0.05308879482416774, + 0.002245931393445267, + 0.03925761269159728, + 0.041645635146607185, + -0.010722629504423382, + ], + [ + 0.8470241392885524, + 0.05395424847892277, + -0.0009080044274369369, + 0.03141996346062461, + -0.03604869906040274, + -0.011590792702391666, + ], + [ + 0.8532353397029364, + 0.03409350146563194, + -0.0036933324929433005, + 0.013610264875849818, + -0.10493897651053626, + -0.007897889129779283, + ], + [ + 0.8549551379079243, + -1.7690279812603002e-9, + -0.004841260532175899, + 8.408547056214322e-9, + -0.13440338280375852, + 2.7897965200664483e-10, + ], + [ + 0.8532353400314878, + -0.034093504860789325, + -0.003693332412042018, + -0.013610248334166937, + -0.10493897353039162, + 0.007897889530596518, + ], + [ + 0.8470241397695214, + -0.05395425149184933, + -0.0009080043113379323, + -0.03141994706772276, + -0.03604869509165384, + 0.011590792800469332, + ], + [ + 0.8369338976526429, + -0.053088797379397, + 0.0022459314935680467, + -0.039257595953853856, + 0.04164563846230347, + 0.010722629348175236, + ], + [ + 0.8273403829149012, + -0.03259254821050572, + 0.004655244564965842, + -0.027320222876080488, + 0.10312408602784746, + 0.006368350911234508, + ], + [ + 0.8233885607020275, + -1.0366107759879842e-9, + 0.005553604723726753, + 8.715481299812045e-9, + 0.12683910466771603, + -1.8221697411827795e-10, + ], + ] +end diff --git a/lib/AstrodynamicalCalculations/test/Project.toml b/lib/AstrodynamicalCalculations/test/Project.toml new file mode 100644 index 00000000..f625b565 --- /dev/null +++ b/lib/AstrodynamicalCalculations/test/Project.toml @@ -0,0 +1,6 @@ +[deps] +AstrodynamicalCalculations = "c0cf9fb7-f496-4999-a425-c50785d1b88b" +LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +ParallelTestRunner = "d3525ed8-44d0-4b2c-a655-542cee43accc" +StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/lib/AstrodynamicalCalculations/test/R2BPCalculations.jl b/lib/AstrodynamicalCalculations/test/R2BPCalculations.jl new file mode 100644 index 00000000..f8fdb7a8 --- /dev/null +++ b/lib/AstrodynamicalCalculations/test/R2BPCalculations.jl @@ -0,0 +1,261 @@ +using AstrodynamicalCalculations: + AstrodynamicalCalculations, + argument_of_periapsis, + cartesian_to_keplerian, + cartesian_to_perifocal, + conic, + inclination, + kepler, + keplerian_to_cartesian, + lambert, + orbital_period, + orbital_radius, + right_ascension_ascending_node, + specific_energy, + specific_angular_momentum, + specific_angular_momentum_vector, + semimajor_axis + +@testset "R2BP Calculations" begin + @test conic(0) == :Circular + @test conic(1) == :Parabolic + @test conic(0.999999) == :Elliptical + @test conic(1.000001) == :Hyperbolic + + @test collect(cartesian_to_perifocal( + 0.9000000000000004, + 100000.00000000055, + 2.2442063995416452, + 1.1139736859596856, + 5.964076767085505, + 0.786172648028967, + 4.140536323401264, + -2.892055315559945, + 6.2566039442009, + )) ≈ collect(( + x = -1.8727989006070282, + y = 2.645561295501541, + z = 5.188722983436087, + ẋ = 7.80864012260457, + ẏ = -0.8041738032535253, + ż = 1.7411380870180566, + )) + + @test semimajor_axis( + -1.8727989006070282, + 2.645561295501541, + 5.188722983436087, + 7.80864012260457, + -0.8041738032535248, + 1.7411380870180566, + 398600.4355070226, + ) == 3.060489599980775 + + @test inclination( + -1.8727989006070282, + 2.645561295501541, + 5.188722983436087, + 7.80864012260457, + -0.8041738032535248, + 1.7411380870180566, + 398600.4355070226, + ) == 1.976005846038532 + + @test right_ascension_ascending_node( + -1.8727989006070282, + 2.645561295501541, + 5.188722983436087, + 7.80864012260457, + -0.8041738032535248, + 1.7411380870180566, + 398600.4355070226, + ) == 2.943683444332231 + + @test argument_of_periapsis( + -1.8727989006070282, + 2.645561295501541, + 5.188722983436087, + 7.80864012260457, + -0.8041738032535248, + 1.7411380870180566, + 398600.4355070226, + ) == 4.316849536012919 + + @test specific_angular_momentum_vector( + -1.8727989006070282, + 2.645561295501541, + 5.188722983436087, + 7.80864012260457, + -0.8041738032535248, + 1.7411380870180566, + 398600.4355070226, + ) == specific_angular_momentum_vector( + -1.8727989006070282, + 2.645561295501541, + 5.188722983436087, + 7.80864012260457, + -0.8041738032535248, + 1.7411380870180566, + ) + + @test specific_angular_momentum( + -1.8727989006070282, + 2.645561295501541, + 5.188722983436087, + 7.80864012260457, + -0.8041738032535248, + 1.7411380870180566, + ) == norm( + specific_angular_momentum_vector( + -1.8727989006070282, + 2.645561295501541, + 5.188722983436087, + 7.80864012260457, + -0.8041738032535248, + 1.7411380870180566, + ), + ) + + @test specific_angular_momentum( + -1.8727989006070282, + 2.645561295501541, + 5.188722983436087, + 7.80864012260457, + -0.8041738032535248, + 1.7411380870180566, + 398600.4355070226, + ) == specific_angular_momentum( + -1.8727989006070282, + 2.645561295501541, + 5.188722983436087, + 7.80864012260457, + -0.8041738032535248, + 1.7411380870180566, + ) + + @test specific_energy(100000.00000000055, 398600.4355070226) == -1.993002177535102 + @test specific_angular_momentum_vector( + 7501.390893889291, + 7868.393278511291, + 4087.9520744171814, + 4.140536323401264, + -2.892055315559945, + 6.2566039442009, + 398600.4355070226, + ) == specific_angular_momentum_vector( + 7501.390893889291, + 7868.393278511291, + 4087.9520744171814, + 4.140536323401264, + -2.892055315559945, + 6.2566039442009, + ) + + @test specific_angular_momentum( + 7501.390893889291, + 7868.393278511291, + 4087.9520744171814, + 4.140536323401264, + -2.892055315559945, + 6.2566039442009, + 398600.4355070226, + ) == norm( + specific_angular_momentum_vector( + 7501.390893889291, + 7868.393278511291, + 4087.9520744171814, + 4.140536323401264, + -2.892055315559945, + 6.2566039442009, + ), + ) + + @test orbital_radius( + 7501.390893889291, + 7868.393278511291, + 4087.9520744171814, + 4.140536323401264, + -2.892055315559945, + 6.2566039442009, + 398600.4355070226, + ) == 11279.041186710254 + +end + +@testset "R2BP Determination" begin + r = [0.0, 11681.0, 0.0] + v = [5.134, 4.226, 2.787] + μ = 398600.4354360959 + + e, a, i, Ω, ω, ν = cartesian_to_keplerian(r..., v..., μ) + @test isapprox( + SVector(e, a, i, Ω, ω, ν), + SVector( + 0.723452708202361, + 24509.265399338536, + deg2rad(151.50460766373865), + π / 2, + deg2rad(270.0034742609256), + deg2rad(89.99652573907436), + ), + atol = 1e-6, + ) + + x, y, z, ẋ, ẏ, ż = keplerian_to_cartesian(e, a, i, Ω, ω, ν, μ) + @test isapprox(vcat(r, v), vcat(x, y, z, ẋ, ẏ, ż), atol = 1e-3) +end + +@testset "Kepler's Algorithm" begin + r = [0.0, 11681.0, 0.0] + v = [5.134, 4.226, 2.787] + μ = 398600.4354360959 + a = semimajor_axis(r, v, μ) + T = orbital_period(a, μ) + + (; x, y, z, ẋ, ẏ, ż) = kepler(r..., v..., μ, T) + + @test isapprox(vcat(r, v), vcat(x, y, z, ẋ, ẏ, ż), atol = 1e-3) +end + +@testset "Lambert Solvers" begin + @testset "Universal" begin + r = [0.0, 11681.0, 0.0] + v = [5.134, 4.226, 2.787] + Δt = 1000 + μ = 398600.4354360959 + + K = kepler(r..., v..., μ, Δt; atol = 1e-3) + + V1, V2 = lambert(r..., K.x, K.y, K.z, μ, Δt; trajectory = :short, atol = 1e-6) + + @test isapprox( + vcat(v, K.ẋ, K.ẏ, K.ż), + vcat(V1.ẋ, V1.ẏ, V1.ż, V2.ẋ, V2.ẏ, V2.ż), + atol = 1e-3, + ) + end + + @testset "Lancaster / Blanchard" begin + r = [0.0, 11681.0, 0.0] + v = [5.134, 4.226, 2.787] + Δt = 1000 + μ = 398600.4354360959 + + K = kepler(r..., v..., μ, Δt; atol = 1e-12) + # Unexported + V1, V2 = AstrodynamicalCalculations.R2BPCalculations.lambert_lancaster_blanchard( + r, + SVector(K.x, K.y, K.z), + Δt, + μ; + trajectory = :short, + atol = 1e-6, + ) + + @test_broken isapprox( + vcat(v, K.ẋ, K.ẏ, K.ż), + vcat(V1.ẋ, V1.ẏ, V1.ż, V2.ẋ, V2.ẏ, V2.ż), + atol = 1e-3, + ) + end +end diff --git a/lib/AstrodynamicalCalculations/test/runtests.jl b/lib/AstrodynamicalCalculations/test/runtests.jl index 3e5a9954..3c3987c9 100644 --- a/lib/AstrodynamicalCalculations/test/runtests.jl +++ b/lib/AstrodynamicalCalculations/test/runtests.jl @@ -3,980 +3,17 @@ Restricted Two-body Model tests. """ module AstrodynamicalCalculationsTests -using LinearAlgebra -using Test, AstrodynamicalCalculations -using StaticArrays - -@testset verbose = false "R2BP Calculations" begin - @test conic(0) == :Circular - @test conic(1) == :Parabolic - @test conic(0.999999) == :Elliptical - @test conic(1.000001) == :Hyperbolic - - @test collect(cartesian_to_perifocal( - 0.9000000000000004, - 100000.00000000055, - 2.2442063995416452, - 1.1139736859596856, - 5.964076767085505, - 0.786172648028967, - 4.140536323401264, - -2.892055315559945, - 6.2566039442009, - )) ≈ collect(( - x = -1.8727989006070282, - y = 2.645561295501541, - z = 5.188722983436087, - ẋ = 7.80864012260457, - ẏ = -0.8041738032535253, - ż = 1.7411380870180566, - )) - - @test semimajor_axis( - -1.8727989006070282, - 2.645561295501541, - 5.188722983436087, - 7.80864012260457, - -0.8041738032535248, - 1.7411380870180566, - 398600.4355070226, - ) == 3.060489599980775 - - @test inclination( - -1.8727989006070282, - 2.645561295501541, - 5.188722983436087, - 7.80864012260457, - -0.8041738032535248, - 1.7411380870180566, - 398600.4355070226, - ) == 1.976005846038532 - - @test right_ascension_ascending_node( - -1.8727989006070282, - 2.645561295501541, - 5.188722983436087, - 7.80864012260457, - -0.8041738032535248, - 1.7411380870180566, - 398600.4355070226, - ) == 2.943683444332231 - - @test argument_of_periapsis( - -1.8727989006070282, - 2.645561295501541, - 5.188722983436087, - 7.80864012260457, - -0.8041738032535248, - 1.7411380870180566, - 398600.4355070226, - ) == 4.316849536012919 - - @test specific_angular_momentum_vector( - -1.8727989006070282, - 2.645561295501541, - 5.188722983436087, - 7.80864012260457, - -0.8041738032535248, - 1.7411380870180566, - 398600.4355070226, - ) == specific_angular_momentum_vector( - -1.8727989006070282, - 2.645561295501541, - 5.188722983436087, - 7.80864012260457, - -0.8041738032535248, - 1.7411380870180566, - ) - - @test specific_angular_momentum( - -1.8727989006070282, - 2.645561295501541, - 5.188722983436087, - 7.80864012260457, - -0.8041738032535248, - 1.7411380870180566, - ) == norm( - specific_angular_momentum_vector( - -1.8727989006070282, - 2.645561295501541, - 5.188722983436087, - 7.80864012260457, - -0.8041738032535248, - 1.7411380870180566, - ), - ) - - @test specific_angular_momentum( - -1.8727989006070282, - 2.645561295501541, - 5.188722983436087, - 7.80864012260457, - -0.8041738032535248, - 1.7411380870180566, - 398600.4355070226, - ) == specific_angular_momentum( - -1.8727989006070282, - 2.645561295501541, - 5.188722983436087, - 7.80864012260457, - -0.8041738032535248, - 1.7411380870180566, - ) - - @test specific_energy(100000.00000000055, 398600.4355070226) == -1.993002177535102 - @test specific_angular_momentum_vector( - 7501.390893889291, - 7868.393278511291, - 4087.9520744171814, - 4.140536323401264, - -2.892055315559945, - 6.2566039442009, - 398600.4355070226, - ) == specific_angular_momentum_vector( - 7501.390893889291, - 7868.393278511291, - 4087.9520744171814, - 4.140536323401264, - -2.892055315559945, - 6.2566039442009, - ) - - @test specific_angular_momentum( - 7501.390893889291, - 7868.393278511291, - 4087.9520744171814, - 4.140536323401264, - -2.892055315559945, - 6.2566039442009, - 398600.4355070226, - ) == norm( - specific_angular_momentum_vector( - 7501.390893889291, - 7868.393278511291, - 4087.9520744171814, - 4.140536323401264, - -2.892055315559945, - 6.2566039442009, - ), - ) - - @test orbital_radius( - 7501.390893889291, - 7868.393278511291, - 4087.9520744171814, - 4.140536323401264, - -2.892055315559945, - 6.2566039442009, - 398600.4355070226, - ) == 11279.041186710254 +using ParallelTestRunner: runtests, find_tests, parse_args +import AstrodynamicalCalculations +const init_code = quote + using LinearAlgebra + using StaticArrays end -@testset verbose = false "R2BP Determination" begin - r = [0.0, 11681.0, 0.0] - v = [5.134, 4.226, 2.787] - μ = 398600.4354360959 - - e, a, i, Ω, ω, ν = cartesian_to_keplerian(r..., v..., μ) - @test isapprox( - SVector(e, a, i, Ω, ω, ν), - SVector( - 0.723452708202361, - 24509.265399338536, - deg2rad(151.50460766373865), - π / 2, - deg2rad(270.0034742609256), - deg2rad(89.99652573907436), - ), - atol = 1e-6, - ) - - x, y, z, ẋ, ẏ, ż = keplerian_to_cartesian(e, a, i, Ω, ω, ν, μ) - @test isapprox(vcat(r, v), vcat(x, y, z, ẋ, ẏ, ż), atol = 1e-3) -end - -@testset verbose = false "Kepler's Algorithm" begin - r = [0.0, 11681.0, 0.0] - v = [5.134, 4.226, 2.787] - μ = 398600.4354360959 - a = semimajor_axis(r, v, μ) - T = orbital_period(a, μ) - - (; x, y, z, ẋ, ẏ, ż) = kepler(r..., v..., μ, T) - - @test isapprox(vcat(r, v), vcat(x, y, z, ẋ, ẏ, ż), atol = 1e-3) -end - -@testset verbose = true "Lambert Solvers" begin - @testset "Universal" begin - r = [0.0, 11681.0, 0.0] - v = [5.134, 4.226, 2.787] - Δt = 1000 - μ = 398600.4354360959 - - K = kepler(r..., v..., μ, Δt; atol = 1e-3) - - V1, V2 = lambert(r..., K.x, K.y, K.z, μ, Δt; trajectory = :short, atol = 1e-6) - - @test isapprox( - vcat(v, K.ẋ, K.ẏ, K.ż), - vcat(V1.ẋ, V1.ẏ, V1.ż, V2.ẋ, V2.ẏ, V2.ż), - atol = 1e-3, - ) - end +args = parse_args(Base.ARGS) +testsuite = find_tests(@__DIR__) - @testset "Lancaster / Blanchard" begin - r = [0.0, 11681.0, 0.0] - v = [5.134, 4.226, 2.787] - Δt = 1000 - μ = 398600.4354360959 - - K = kepler(r..., v..., μ, Δt; atol = 1e-12) - V1, V2 = R2BPCalculations.lambert_lancaster_blanchard( - r, - SVector(K.x, K.y, K.z), - Δt, - μ; - trajectory = :short, - atol = 1e-6, - ) - - @test_broken isapprox( - vcat(v, K.ẋ, K.ẏ, K.ż), - vcat(V1.ẋ, V1.ẏ, V1.ż, V2.ẋ, V2.ẏ, V2.ż), - atol = 1e-3, - ) - end -end - -@testset "CR3BP Calculations" begin - r = [ - 1.007988 - 0.0 - 0.001864 - ] - - v = zeros(3, 1) - - μ = 3.003480593992993e-6 - - @test jacobi_constant(r..., v..., μ) ≈ 3.000907212196274 -end - -@testset "Near-periodic Orbits" begin - μ = 0.012150584395829193 - u = richardson_ic(μ, 2) - (; x, y, z, ẋ, ẏ, ż, Δt) = u - - @test x ≈ 1.124357139749168 - @test y ≈ 0.0 - @test z ≈ 0.0 - @test ẋ ≈ 0.0 - @test ẏ ≈ 0.1716444216936595 - @test ż ≈ -0.0 - @test Δt ≈ 3.253854900204856 - - u = richardson_halo(μ, 1) - for variable in (:x, :y, :z, :ẋ, :ẏ, :ż) - @test isapprox( - getproperty(u[begin], variable), - getproperty(u[end], variable), - atol = 1e-12, - ) - end -end - -@testset "Manifold Computations" begin - - # - # Conditions for tests below: - # julia> μ = 0.012150584395829193 - # julia> u, T = halo(μ, 1; amplitude=0.005) - # - - Φ = [ - 1317.472125300217 -339.26725145920585 -22.23471304682866 388.2455372345198 126.49047353668445 -3.3779594177227 - -429.7764385389933 111.53280315746214 7.269431052432993 -126.49047353678779 -41.404653982215095 1.0977750840404263 - -11.440384647744368 2.9348175664641527 1.1929568568249131 -3.3779594177162653 -1.0977750840374354 -0.05845992955397675 - 3612.12986893901 -929.3271447079647 -60.998106970610365 1064.4911782262984 346.9671305741014 -9.244834479682378 - -1482.5514995781887 382.0700769975138 25.039782109090023 -437.2238230101127 -141.4481439160884 3.8211012689780377 - -75.5369690753493 19.429643984545518 1.2797982252155324 -22.23471304678537 -7.269431052412963 1.1929568568243507 - ] - - ics = [ - [ - 0.823388563881332, - 0.0, - 0.005553604696093592, - 0.0, - 0.12683910108732768, - 0.0, - 1.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 1.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 1.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 1.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 1.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 1.0, - ], - [ - 0.8273403859561881, - 0.03259254695615611, - 0.004655244516514311, - 0.027320231122920834, - 0.10312408143143087, - -0.006368351099157183, - 1.3786797126365464, - -0.08824308385714617, - -0.009143474674588519, - 2.826623191577671, - -0.9767705092124925, - -0.06678667433841168, - -0.041844969630018845, - 0.8820353502805051, - 0.0007013669623268068, - -0.45278244255732314, - -0.7835124078992787, - 0.0073360448800629365, - -0.008855612000587742, - 0.002327804586816214, - 0.838573983007699, - -0.06290404981028867, - 0.02486880981909553, - -1.144418551135245, - 0.29476786414533784, - -0.07907382422170534, - -0.0008101636936140204, - 1.2265481296819574, - -0.604917980406487, - -0.008685295114209327, - 0.07388202008165795, - 0.2492072545027064, - -1.4738222079088099e-5, - 0.5293937831553415, - 0.7281497497436548, - -0.00023580443544974562, - -0.0007858587607819898, - 0.00020348487224860056, - 0.25939140376611963, - -0.008269842352818602, - 0.0028734095281463595, - 0.8384737725375465, - ], - [ - 0.8369339005610434, - 0.05308879581928126, - 0.002245931439623135, - 0.03925760359490229, - 0.04164563292173339, - -0.010722629489038576, - 2.633666680439342, - -0.7476233640873686, - -0.036115619838154166, - 6.59317685013257, - -4.305178122455261, - -0.12567569616107588, - -0.32236550652146106, - 0.6479359223648997, - 0.004637853579299471, - -1.718449648616434, - -0.7249471649546353, - 0.021058591017896974, - -0.03358790594797937, - 0.01714406169353313, - 0.40552901171028016, - -0.1175501978131001, - 0.08850970435530003, - -1.9276108228616495, - 0.7232939839971113, - -0.36584119809468774, - -0.005825038522167102, - 2.0164150719091194, - -1.588312972089223, - -0.02821711404806066, - 0.2835849868569326, - 0.3549141154538107, - -0.00031947991899352273, - 0.9912017667556496, - -0.033028457627487386, - -0.0024977304687910985, - -0.005384939024007069, - 0.00272987184176848, - 0.4345059352772165, - -0.025760320739897816, - 0.01772446341402129, - 0.3998442189060235, - ], - [ - 0.8470241424999021, - 0.05395424966031193, - -0.0009080043524526027, - 0.031419954303289845, - -0.036048701160724284, - -0.011590792835804302, - 5.2751979177709245, - -2.8002759306940206, - -0.06970307574708806, - 13.575834570928198, - -11.52199157988803, - -0.08191686885532921, - -1.0650447822856468, - 0.6234811067801149, - 0.010733752984669538, - -3.905785161291004, - 0.866145889611684, - 0.016124697957608767, - -0.07643671410242639, - 0.05458515963145915, - -0.16164597656191948, - -0.2095060221160001, - 0.19489307781221327, - -2.0855174774020258, - 1.5018686968935528, - -1.0383366134481509, - -0.014310928273230595, - 3.9574099493625914, - -3.5470463790411046, - -0.02296768894075728, - 0.6253995245350682, - 0.18722436787118188, - -0.0013253485604900028, - 1.5577619859991105, - -1.2832341322229566, - -0.0027644056993001167, - -0.014907405477056719, - 0.010799843345176774, - 0.4631273703125115, - -0.043829837552022737, - 0.04200385021401396, - -0.20848785169720335, - ], - [ - 0.8532353425901987, - 0.03409350294370255, - -0.003693332419778437, - 0.0136102558436333, - -0.10493897930691469, - -0.007897889399969823, - 11.061936482274414, - -7.689747752640067, - -0.03153665012283715, - 31.785749672658245, - -25.44043221945118, - 0.5332758341624475, - -2.6858333294059364, - 1.3445895697563528, - 0.002854429918083852, - -8.652720643412609, - 4.866690329415817, - -0.113864600921434, - -0.16640832220212004, - 0.1333566308356175, - -0.6638852788093453, - -0.5058642813219177, - 0.40239589734920744, - -1.431763849780302, - 3.195745363280542, - -2.4844942161704124, - -0.00386208695123994, - 9.339460840937965, - -7.368022339704923, - 0.1499688501028994, - 1.223461957527104, - -0.41159173922619013, - 0.002536978196004755, - 3.113085020093486, - -3.2037573059636526, - 0.04850882843406646, - -0.0306140680948119, - 0.02606395260902634, - 0.3190695726681844, - -0.07676967973326097, - 0.06982698735410356, - -0.823253631643632, - ], - [ - 0.854955140499413, - 2.2843913370187256e-15, - -0.004841260493981484, - -8.426065623187225e-15, - -0.1344033872050793, - -2.3393929523281094e-16, - 25.670001169891876, - -17.290935930959833, - 0.3735915323822458, - 82.56024329676991, - -44.66052062847337, - 2.744550087867072, - -6.549914989117929, - 3.515781165459679, - -0.09045012326731859, - -21.560863766695647, - 11.122750444783911, - -0.65681735247777, - -0.4081906725844075, - 0.28639114669384175, - -0.8777886212624451, - -1.3960821106365155, - 0.7204334759076325, - -0.04847727067031394, - 7.495647097356273, - -5.235090649386511, - 0.11199867561047291, - 24.307495565860556, - -12.730790263231905, - 0.7894471966986759, - 2.6328847934916584, - -1.602867310555306, - 0.041320768129938484, - 7.950197124746471, - -5.4159521324395765, - 0.26854701213925986, - -0.06452008851439175, - 0.049418531406256176, - 0.03736159910558069, - -0.19318325888690766, - 0.10035816116241962, - -1.1539010608138158, - ], - [ - 0.8532353425901938, - -0.03409350294369572, - -0.0036933324197787306, - -0.013610255843655042, - -0.10493897930691656, - 0.007897889399968805, - 61.783725674727414, - -31.809460366393743, - 1.5639194613448177, - 192.5622814708414, - -60.811745821785316, - 5.790230207958852, - -15.9467057502335, - 7.366098751441629, - -0.3866391287246332, - -50.036359202730644, - 16.771181856064608, - -1.474065945922604, - -1.0242029826389052, - 0.5249458158655891, - -0.6919274956044533, - -3.288510633984684, - 1.0165171629160492, - 1.321471791772166, - 18.12710682888481, - -9.376464402158039, - 0.4560226259807858, - 56.69804470264641, - -17.397205275984405, - 1.6789260061002176, - 6.108694482836869, - -3.292222472289838, - 0.15851822297241477, - 18.49715015775276, - -6.775733307775279, - 0.5687877877351285, - -0.1529731671956582, - 0.08076178851334609, - -0.2644398496513836, - -0.4861071061444217, - 0.12936352157783781, - -0.9612148163601355, - ], - [ - 0.8470241424998886, - -0.053954249660305716, - -0.0009080043524529912, - -0.031419954303331776, - -0.036048701160720203, - 0.011590792835803694, - 139.81168166322985, - -51.900248046349844, - 3.271613747195812, - 397.8858051004851, - -91.85758770599232, - 5.821945264799484, - -36.17535833489009, - 12.967888420563526, - -0.8279061449068151, - -102.92655322720218, - 25.534744119150396, - -1.5228161048932043, - -2.3513343309735673, - 0.866235468830786, - -0.2198726250639241, - -6.7447477075950895, - 1.5755137371116215, - 1.987134962713231, - 41.11521926552655, - -15.166743448559673, - 0.9526780029549172, - 117.27289978925529, - -26.666892209713573, - 1.6975459397425652, - 13.579339684552384, - -5.4115134792664845, - 0.32466549527180183, - 38.02628330961531, - -9.24871447769774, - 0.5601717489178005, - -0.35373005498093574, - 0.12514521971200396, - -0.45673669921893095, - -1.0315564554873287, - 0.2132601376815499, - -0.4067512272598734, - ], - [ - 0.8369339005610131, - -0.05308879581927243, - 0.0022459314396227116, - -0.03925760359498695, - 0.04164563292175057, - 0.010722629489038737, - 298.1536849578567, - -88.79218713147596, - 4.108212352069355, - 805.8842647516645, - -197.03199719416259, - -1.3587839120057053, - -77.0304035805354, - 23.008804194914685, - -1.051997832312519, - -207.58784021007904, - 52.69517331340727, - 0.31433070459529, - -5.028116277146918, - 1.4986245228726873, - 0.3336885466879633, - -13.604470125477365, - 3.3661481657079335, - 1.9537305723180947, - 87.79671835004706, - -25.956894579473673, - 1.196556663820022, - 237.60479660840883, - -57.88401149438683, - -0.4014318236821094, - 28.712231594102008, - -8.994281477261307, - 0.40346490381046596, - 77.0693721005221, - -18.784314465348764, - -0.14157890224819605, - -0.7638066834236382, - 0.21608393326675798, - -0.4802205363194697, - -2.081496212262708, - 0.5023315171518498, - 0.23330573472502658, - ], - [ - 0.8273403859561236, - -0.032592546956138974, - 0.004655244516514174, - -0.027320231123097893, - 0.1031240814314825, - 0.006368351099159685, - 624.1563531688901, - -178.97128138129779, - 1.2034561562153203, - 1685.807676266411, - -518.1477491379977, - -23.313639430926575, - -160.92062399834495, - 46.705824906057714, - -0.31350301921564855, - -433.6254768006774, - 134.82826866054083, - 5.971159098990085, - -10.529645901486171, - 3.0305772015792436, - 0.8168304281567269, - -28.450876102792893, - 8.77375084473596, - 1.5423565889576247, - 183.90492595796482, - -52.51978660929593, - 0.34248355473230047, - 496.93345370466517, - -152.78832660830577, - -6.855854030546668, - 59.93604732520242, - -17.543497122306604, - 0.12072458185754525, - 161.65110999609013, - -49.108411393866255, - -2.2542758104173393, - -1.6023417655780476, - 0.4493519667693413, - -0.33589553197288335, - -4.324479481929502, - 1.3446971876129539, - 0.797006208427492, - ], - [ - 0.8233885638811947, - 4.33547133764043e-14, - 0.00555360469609479, - -3.778286963052016e-13, - 0.12683910108748223, - 7.86884919269592e-15, - 1317.472125300217, - -429.7764385389933, - -11.440384647744368, - 3612.12986893901, - -1482.5514995781887, - -75.5369690753493, - -339.26725145920585, - 111.53280315746214, - 2.9348175664641527, - -929.3271447079647, - 382.0700769975138, - 19.429643984545518, - -22.23471304682866, - 7.269431052432993, - 1.1929568568249131, - -60.998106970610365, - 25.039782109090023, - 1.2797982252155324, - 388.2455372345198, - -126.49047353678779, - -3.3779594177162653, - 1064.4911782262984, - -437.2238230101127, - -22.23471304678537, - 126.49047353668445, - -41.404653982215095, - -1.0977750840374354, - 346.9671305741014, - -141.4481439160884, - -7.269431052412963, - -3.3779594177227, - 1.0977750840404263, - -0.05845992955397675, - -9.244834479682378, - 3.8211012689780377, - 1.1929568568243507, - ], - ] - - unstable = [diverge(ic[1:6], reshape(ic[7:end], 6, 6), Φ; eps = 1e-8) for ic in ics] - - @test unstable ≈ [ - [ - 0.8233885670604992, - -1.0366541345478615e-9, - 0.005553604668461628, - 8.715859137046784e-9, - 0.12683909750709388, - -1.8222484329190235e-10, - ], - [ - 0.8273403889974105, - 0.03259254570178936, - 0.004655244468062643, - 0.027320239369938236, - 0.1031240768350659, - -0.006368351287082361, - ], - [ - 0.8369339034694137, - 0.05308879425915669, - 0.0022459313856777996, - 0.039257611236035383, - 0.04164562738118049, - -0.010722629629902078, - ], - [ - 0.8470241452302693, - 0.05395424782876832, - -0.0009080043935676615, - 0.031419961538898866, - -0.036048707229790644, - -0.011590792871138664, - ], - [ - 0.8532353451489048, - 0.03409350102660894, - -0.0036933324275151497, - 0.013610263353121406, - -0.10493898508343963, - -0.00789788926934211, - ], - [ - 0.8549551430909017, - -1.7690279810307236e-9, - -0.0048412604557870696, - 8.408547056141493e-9, - -0.13440339160640008, - 2.7897965198713934e-10, - ], - [ - 0.8532353454774562, - -0.03409350442176633, - -0.003693332346613867, - -0.013610246811438523, - -0.104938982103295, - 0.007897889670159345, - ], - [ - 0.8470241457112383, - -0.053954250841694876, - -0.000908004277468657, - -0.03141994514599701, - -0.036048703261041745, - 0.01159079296921633, - ], - [ - 0.8369339039236694, - -0.05308879681438595, - 0.0022459314858005795, - -0.03925759449829196, - 0.041645630696876774, - 0.010722629473653931, - ], - [ - 0.8273403892761712, - -0.032592547905735625, - 0.004655244522837673, - -0.0273202221542787, - 0.10312407867097084, - 0.0063683509751929325, - ], - [ - 0.823388567060362, - -1.036610779834484e-9, - 0.005553604668462826, - 8.71548130835048e-9, - 0.12683909750724842, - -1.8221697444270972e-10, - ], - ] - - stable = [converge(ic[1:6], reshape(ic[7:end], 6, 6), Φ; eps = 1e-8) for ic in ics] - - @test stable ≈ [ - [ - 0.8233885607021647, - -1.036654134541258e-9, - 0.005553604723725555, - 8.715859137047568e-9, - 0.1268391046675615, - -1.8222484329220807e-10, - ], - [ - 0.8273403826361405, - 0.03259254600655946, - 0.004655244510190812, - 0.027320240091740028, - 0.10312408419194252, - -0.0063683512231239355, - ], - [ - 0.8369338971983872, - 0.05308879482416774, - 0.002245931393445267, - 0.03925761269159728, - 0.041645635146607185, - -0.010722629504423382, - ], - [ - 0.8470241392885524, - 0.05395424847892277, - -0.0009080044274369369, - 0.03141996346062461, - -0.03604869906040274, - -0.011590792702391666, - ], - [ - 0.8532353397029364, - 0.03409350146563194, - -0.0036933324929433005, - 0.013610264875849818, - -0.10493897651053626, - -0.007897889129779283, - ], - [ - 0.8549551379079243, - -1.7690279812603002e-9, - -0.004841260532175899, - 8.408547056214322e-9, - -0.13440338280375852, - 2.7897965200664483e-10, - ], - [ - 0.8532353400314878, - -0.034093504860789325, - -0.003693332412042018, - -0.013610248334166937, - -0.10493897353039162, - 0.007897889530596518, - ], - [ - 0.8470241397695214, - -0.05395425149184933, - -0.0009080043113379323, - -0.03141994706772276, - -0.03604869509165384, - 0.011590792800469332, - ], - [ - 0.8369338976526429, - -0.053088797379397, - 0.0022459314935680467, - -0.039257595953853856, - 0.04164563846230347, - 0.010722629348175236, - ], - [ - 0.8273403829149012, - -0.03259254821050572, - 0.004655244564965842, - -0.027320222876080488, - 0.10312408602784746, - 0.006368350911234508, - ], - [ - 0.8233885607020275, - -1.0366107759879842e-9, - 0.005553604723726753, - 8.715481299812045e-9, - 0.12683910466771603, - -1.8221697411827795e-10, - ], - ] - -end +runtests(AstrodynamicalCalculations, args; testsuite, init_code) end # module diff --git a/lib/AstrodynamicalModels/Project.toml b/lib/AstrodynamicalModels/Project.toml index 65a14aa9..335ce423 100644 --- a/lib/AstrodynamicalModels/Project.toml +++ b/lib/AstrodynamicalModels/Project.toml @@ -1,7 +1,10 @@ name = "AstrodynamicalModels" uuid = "4282b555-f590-4262-b575-3e516e1493a7" -version = "3.8.0" authors = ["Joseph D Carpinelli "] +version = "3.8.0" + +[workspace] +projects = ["docs", "test"] [deps] DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" @@ -28,14 +31,4 @@ ModelingToolkit = "9" SciMLBase = "2" StaticArrays = "1" Symbolics = "5, 6" -julia = "1.7" - -[extras] -Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" -AstrodynamicalCalculations = "c0cf9fb7-f496-4999-a425-c50785d1b88b" - -[targets] -test = ["Test", "SPICEBodies", "AstrodynamicalCalculations"] - -[sources] -AstrodynamicalCalculations = {path="../AstrodynamicalCalculations"} +julia = "1.10" diff --git a/lib/AstrodynamicalModels/test/Attitude.jl b/lib/AstrodynamicalModels/test/Attitude.jl index b50324c1..f38acf64 100644 --- a/lib/AstrodynamicalModels/test/Attitude.jl +++ b/lib/AstrodynamicalModels/test/Attitude.jl @@ -3,7 +3,15 @@ Tests for R2BP dynamics. """ module AttitudeTests -using AstrodynamicalModels, ModelingToolkit, LinearAlgebra, Test +using AstrodynamicalModels: + AttitudeFunction, + AttitudeParameters, + AttitudeState, + AttitudeSystem, + dynamics, + system + +using LinearAlgebra, ModelingToolkit, Test @testset "Attitude Model Constructors" begin model = AttitudeSystem() diff --git a/lib/AstrodynamicalModels/test/CR3BP.jl b/lib/AstrodynamicalModels/test/CR3BP.jl index f760ff77..1a7116f5 100644 --- a/lib/AstrodynamicalModels/test/CR3BP.jl +++ b/lib/AstrodynamicalModels/test/CR3BP.jl @@ -3,7 +3,15 @@ Tests for CR3BP dynamics. """ module CR3BPTests -using AstrodynamicalModels, ModelingToolkit, Test +using AstrodynamicalModels: + CR3BFunction, + CR3BParameters, + CR3BState, + CR3BSystem, + dynamics, + system + +using ModelingToolkit, Test @testset "CR3BP Model Constructors" begin @test CR3BSystem(; stm=false) isa System diff --git a/lib/AstrodynamicalModels/test/Entry.jl b/lib/AstrodynamicalModels/test/Entry.jl index ade0afad..bd86ba61 100644 --- a/lib/AstrodynamicalModels/test/Entry.jl +++ b/lib/AstrodynamicalModels/test/Entry.jl @@ -3,7 +3,15 @@ Tests for R2BP dynamics. """ module EntryTests -using AstrodynamicalModels, ModelingToolkit, Test +using AstrodynamicalModels: + PlanarEntryFunction, + PlanarEntryParameters, + PlanarEntryState, + PlanarEntrySystem, + system, + dynamics + +using ModelingToolkit, Test @testset "Entry Model Constructors" begin model = PlanarEntrySystem() diff --git a/lib/AstrodynamicalModels/test/NBP.jl b/lib/AstrodynamicalModels/test/NBP.jl index e83aa439..a69390d7 100644 --- a/lib/AstrodynamicalModels/test/NBP.jl +++ b/lib/AstrodynamicalModels/test/NBP.jl @@ -3,7 +3,11 @@ Tests for NBP dynamics. """ module NBPTests -using AstrodynamicalModels, ModelingToolkit, Test +using AstrodynamicalModels: + NBSystem, + NBFunction + +using ModelingToolkit, Test @testset "NBP Model Constructors" begin @test NBSystem(10; stm=false) isa System diff --git a/lib/AstrodynamicalModels/test/Orbits.jl b/lib/AstrodynamicalModels/test/Orbits.jl index c2aa9fa5..7d7c0da7 100644 --- a/lib/AstrodynamicalModels/test/Orbits.jl +++ b/lib/AstrodynamicalModels/test/Orbits.jl @@ -3,7 +3,20 @@ Tests for orbit types. """ module OrbitTests -using AstrodynamicalModels, ModelingToolkit, AstrodynamicalCalculations, Test +using AstrodynamicalModels: + AstrodynamicalModels, + CartesianState, + CR3BParameters, + KeplerianOrbit, + KeplerianParameters, + KeplerianState, + Orbit, + R2BOrbit, + R2BParameters, + dynamics, + system + +using AstrodynamicalCalculations, ModelingToolkit, Test @testset "CartesianState Constructors" begin @test rand(CartesianState) isa CartesianState diff --git a/lib/AstrodynamicalModels/test/Project.toml b/lib/AstrodynamicalModels/test/Project.toml new file mode 100644 index 00000000..bb5c2ccb --- /dev/null +++ b/lib/AstrodynamicalModels/test/Project.toml @@ -0,0 +1,7 @@ +[deps] +AstrodynamicalCalculations = "c0cf9fb7-f496-4999-a425-c50785d1b88b" +AstrodynamicalModels = "4282b555-f590-4262-b575-3e516e1493a7" +LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78" +ParallelTestRunner = "d3525ed8-44d0-4b2c-a655-542cee43accc" +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/lib/AstrodynamicalModels/test/R2BP.jl b/lib/AstrodynamicalModels/test/R2BP.jl index e681c622..7bd7a58d 100644 --- a/lib/AstrodynamicalModels/test/R2BP.jl +++ b/lib/AstrodynamicalModels/test/R2BP.jl @@ -3,7 +3,15 @@ Tests for R2BP dynamics. """ module R2BPTests -using AstrodynamicalModels, ModelingToolkit, Test +using AstrodynamicalModels: + R2BFunction, + R2BParameters, + R2BState, + R2BSystem, + dynamics, + system + +using ModelingToolkit, Test @testset "R2BP Model Constructors" begin @test R2BSystem(; stm=false) isa System diff --git a/lib/AstrodynamicalModels/test/runtests.jl b/lib/AstrodynamicalModels/test/runtests.jl index 095327a6..70cb9cb2 100644 --- a/lib/AstrodynamicalModels/test/runtests.jl +++ b/lib/AstrodynamicalModels/test/runtests.jl @@ -1,10 +1,18 @@ -# -# Unit tests for AstrodynamicalModels.jl -# - -include("R2BP.jl") -include("CR3BP.jl") -include("NBP.jl") -include("Orbits.jl") -include("Entry.jl") -include("Attitude.jl") +""" +Unit tests for AstrodynamicalModels.jl +""" +module AstrodynamicalModelsTests + +using ParallelTestRunner: runtests, find_tests, parse_args +import AstrodynamicalModels + +const init_code = quote + # Shared modules here +end + +args = parse_args(Base.ARGS) +testsuite = find_tests(@__DIR__) + +runtests(AstrodynamicalModels, args; testsuite, init_code) + +end # module diff --git a/lib/AstrodynamicalSolvers/Project.toml b/lib/AstrodynamicalSolvers/Project.toml index 1876c9a7..5c616b00 100644 --- a/lib/AstrodynamicalSolvers/Project.toml +++ b/lib/AstrodynamicalSolvers/Project.toml @@ -3,6 +3,9 @@ uuid = "636ee813-9c9e-4a0a-af07-88b3043dcb77" authors = ["Joseph Carpinelli "] version = "1.0.0" +[workspace] +projects = ["docs", "test", "../AstrodynamicalCalculations", "../AstrodynamicalModels"] + [deps] AstrodynamicalCalculations = "c0cf9fb7-f496-4999-a425-c50785d1b88b" AstrodynamicalModels = "4282b555-f590-4262-b575-3e516e1493a7" @@ -14,10 +17,6 @@ Reexport = "189a3867-3050-52da-a836-e630ba90ab69" SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" -[sources] -AstrodynamicalModels = {path="../AstrodynamicalModels"} -AstrodynamicalCalculations = {path="../AstrodynamicalCalculations"} - [compat] AstrodynamicalCalculations = "1" AstrodynamicalModels = "3.8" @@ -27,10 +26,4 @@ OrdinaryDiffEqVerner = "1.1.1" Reexport = "1" SciMLBase = "2" StaticArrays = "1.6" -julia = "1.7" - -[extras] -Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" - -[targets] -test = ["Test"] +julia = "1.10" diff --git a/lib/AstrodynamicalSolvers/test/Project.toml b/lib/AstrodynamicalSolvers/test/Project.toml new file mode 100644 index 00000000..e14e0576 --- /dev/null +++ b/lib/AstrodynamicalSolvers/test/Project.toml @@ -0,0 +1,9 @@ +[deps] +AstrodynamicalCalculations = "c0cf9fb7-f496-4999-a425-c50785d1b88b" +AstrodynamicalModels = "4282b555-f590-4262-b575-3e516e1493a7" +AstrodynamicalSolvers = "636ee813-9c9e-4a0a-af07-88b3043dcb77" +LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +OrdinaryDiffEqVerner = "79d7bb75-1356-48c1-b8c0-6832512096c2" +ParallelTestRunner = "d3525ed8-44d0-4b2c-a655-542cee43accc" +StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/lib/AstrodynamicalSolvers/test/manifolds.jl b/lib/AstrodynamicalSolvers/test/manifolds.jl new file mode 100644 index 00000000..9f271de8 --- /dev/null +++ b/lib/AstrodynamicalSolvers/test/manifolds.jl @@ -0,0 +1,648 @@ +using AstrodynamicalSolvers: + halo, + monodromy + +@testset "Manifold Computations" begin + + μ = 3.0034805945423635e-6 + u = halo(μ, 1; amplitude = 0.005) + + @test u.x ≈ 0.9894058673149723 + @test u.z ≈ 0.005986079972943528 + @test u.ẏ ≈ 0.01250973206745133 + @test u.Δt ≈ 3.0247281222825437 + + T = u.Δt + u = CartesianState(u) + Φ = monodromy(u, μ, T, CR3BFunction(stm = true)) + + @test Φ ≈ [ + 363.5695646260086 -150.84678203289957 -110.89785303818041 147.89291423249102 39.776655263625734 -19.506758521645583 + -98.06514156622599 41.30059843066769 30.40698418319986 -39.776655263719505 -11.022980358853847 5.037110248654976 + -47.32080144069423 19.504183945583154 15.347602546829501 -19.506758521547493 -5.037110248617916 2.2693997822749954 + 697.403493226936 -288.5621336671776 -212.7440873239205 284.01625409850567 76.01918084826457 -37.246580943614184 + -355.9757987239261 148.34069711110283 109.04417094750771 -144.93904643230533 -38.25271209672777 19.509333097636393 + -273.5580556895539 112.7515351286987 83.74272666784147 -110.89785303784609 -30.406984183046543 15.347602546859227 + ] + + ics = let + problem = ODEProblem(CR3BFunction(stm = true), vcat(u, vec(I(6))), (0, T), (μ,)) + solution = + solve(problem, Vern9(), reltol = 1e-12, abstol = 1e-12, saveat = (T / 10)) + + solution.u[begin:begin+9] + end + + @test ics ≈ [ + [ + 0.9894058673149723, + 0.0, + 0.005986079972943528, + 0.0, + 0.01250973206745133, + 0.0, + 1.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + ], + [ + 0.9898744278702267, + 0.0035899577966164516, + 0.005258145836456971, + 0.0029834070095247816, + 0.010601176566460811, + -0.004737084798616238, + 1.2371458411768335, + -0.0695323761780384, + -0.09847482817935505, + 1.5670044822929252, + -0.6978155777157768, + -0.6591788390257907, + -0.035434947222201855, + 0.9316804373498873, + 0.011356684405103354, + -0.3467997416963855, + -0.3896842189464582, + 0.11054943644691602, + -0.09395345250960796, + 0.030697477319750244, + 0.9321583672024584, + -0.6007887072141127, + 0.3009033764290183, + -0.4464993538639933, + 0.308242649904382, + -0.09438488946911146, + -0.009837529520694738, + 1.0591107163922577, + -0.6442600720711773, + -0.09773198568283194, + 0.088131316473712, + 0.2767705969926594, + 0.00023169992649377062, + 0.5611428035212996, + 0.7487829717456858, + 0.0027324590487216266, + -0.009332241416375939, + 0.0031441665203776454, + 0.295364864880218, + -0.08956991747299407, + 0.040913095200603176, + 0.9279360834253226, + ], + [ + 0.9910796788130449, + 0.006066347272099451, + 0.0032124402157081276, + 0.0046840867671740635, + 0.005271523308608312, + -0.008559051744536353, + 1.950040239465447, + -0.5899540353747552, + -0.40535975374341493, + 3.164386111879475, + -3.0927704802812737, + -1.3725873609363672, + -0.26843184364042577, + 0.8374953199128866, + 0.08343688204016234, + -1.2726857507607194, + -0.053624055517039464, + 0.3808968730554891, + -0.34391493779148813, + 0.2355718050038613, + 0.7337936721629754, + -1.018572831318294, + 1.1365901126247782, + -0.8528469298727669, + 0.6581421492414853, + -0.4199981787375973, + -0.07819233335820817, + 1.296363278219651, + -1.6024827121626852, + -0.3800784071360596, + 0.3163004973499631, + 0.4108044051437538, + 0.0016055058382268882, + 0.898197886993142, + 0.07948286238182267, + 0.002678040639188702, + -0.06481411101658309, + 0.04588962838569348, + 0.5426402313760416, + -0.2821160224582451, + 0.28560464167961974, + 0.667837207225828, + ], + [ + 0.9924953609558557, + 0.006527893673766641, + 0.00027703311101019744, + 0.004308405329300428, + -0.0025418931279188855, + -0.010403893071012492, + 3.194979782068513, + -2.2480244592658707, + -0.8912901561737726, + 5.260531462882106, + -8.629748694340314, + -1.6131421475527377, + -0.8480334714756765, + 1.051120901341595, + 0.23328760581650157, + -2.6444533370499497, + 1.8137063921561256, + 0.5366273688482629, + -0.7042926255865667, + 0.7799660829349495, + 0.4234742102702738, + -1.4067052181979423, + 2.6169072350232443, + -1.2068964645667555, + 1.1360123079440265, + -1.169120882563875, + -0.23731765154027032, + 1.9926119503214768, + -3.6422821167111397, + -0.5954430923230926, + 0.6017020436501692, + 0.2894337604412833, + -0.0024364332298012063, + 0.9513391643697624, + -0.9600543630574989, + -0.031952547093191674, + -0.17594483247914564, + 0.20206265728008083, + 0.6681165100769222, + -0.4390532271528181, + 0.78324225648997, + 0.09362900661603259, + ], + [ + 0.9934985373534506, + 0.004414493412947694, + -0.002691682347757935, + 0.0021433455930179954, + -0.011393931006874056, + -0.008319425757109752, + 5.490003988184001, + -6.487014689628338, + -0.8875841662056261, + 11.302082651153246, + -20.6917674268284, + 3.631168290269304, + -1.9880804273779376, + 2.231086179719102, + 0.24089957990992225, + -5.357497029086754, + 6.581690137390508, + -1.1855913442432098, + -1.309840956076913, + 1.977719338435574, + -0.07622512726413008, + -3.064737419133734, + 5.656005016906049, + -2.517216773282615, + 2.0428301884897455, + -2.8931589692820436, + -0.24254153002609002, + 4.620462672370931, + -8.271485402807551, + 1.3685197351272902, + 0.9017837097616304, + -0.25264672130310206, + 0.015551302170489048, + 1.1676475337624053, + -2.821743441950994, + 0.35282832145644405, + -0.32809129465828046, + 0.5293704124595559, + 0.5416243419739394, + -0.5956212745474034, + 1.358220989856255, + -1.0608489042619311, + ], + [ + 0.9938018000948632, + 3.3814004664628033e-16, + -0.004091056650145035, + -1.5713283266960783e-15, + -0.01638585277717688, + -1.3586014618110917e-15, + 11.747249011272089, + -14.478469379121254, + 3.5877588628656816, + 33.92593778407872, + -27.57659845017894, + 29.9164518117297, + -4.718395501501515, + 5.047894587113171, + -1.3552904353555262, + -14.253386838881683, + 10.544629652277052, + -11.079226610892352, + -3.1371461505739706, + 4.163339859874222, + -1.6641718993686987, + -10.324059030179551, + 7.616817895784776, + -9.057160270532727, + 4.635450259594342, + -6.044958610263879, + 1.5056456364454869, + 14.029780852500256, + -10.722766001172136, + 11.748164468177174, + 1.536462255983425, + -1.421038054235922, + 0.5070088326456889, + 3.600270813484911, + -4.334194398507778, + 3.495249696857971, + -0.6039468437963879, + 0.9459379702817146, + -0.05896360053465793, + -1.4370597187069243, + 1.110717948772804, + -2.9657277873069456, + ], + [ + 0.9934985373534488, + -0.004414493412947038, + -0.002691682347758814, + -0.002143345593023276, + -0.011393931006874526, + 0.008319425757106409, + 27.57759248770883, + -19.172242333275435, + 16.311421629570358, + 72.18267416063888, + -0.5217071771052122, + 47.17874452640869, + -11.340443337730555, + 7.047344305454021, + -6.297176883156646, + -30.26726229627077, + 1.2161844662072916, + -18.973437822540653, + -8.071483120027205, + 5.474388542930831, + -5.324321068514165, + -22.672475850776927, + 0.20393609974423393, + -13.184980940723491, + 11.118981342445453, + -7.811335199137715, + 6.498398319499484, + 29.399620552354797, + 0.14240562800692375, + 18.498373101895407, + 3.2910208635699147, + -2.296036749641137, + 2.046348060177439, + 8.079637992426136, + -0.9590910848556188, + 5.741127700197823, + -1.3335010300736867, + 1.0231776131283727, + -1.1156153587866342, + -3.5820118833628345, + -0.6679709374220457, + -3.564673805710898, + ], + [ + 0.9924953609558516, + -0.006527893673766245, + 0.00027703311100841577, + -0.004308405329310747, + -0.0025418931279196384, + 0.01040389307101022, + 57.181133640704, + -16.449867036121947, + 27.93439296013566, + 128.6079397443349, + 12.671869857737473, + 24.502246328517415, + -23.759695823973058, + 6.304150081118974, + -11.100619162382069, + -53.86522120299188, + -3.8482982939686394, + -10.515733266818891, + -17.31335910736424, + 4.773489630454567, + -8.455598228679394, + -39.86056875482027, + -3.118645953595972, + -6.051829092328109, + 23.153417082539452, + -6.635970433902056, + 11.051184168659917, + 52.26235486966227, + 5.293684620687887, + 9.554469389008181, + 6.559940802699193, + -2.1869174797907305, + 3.4351989345430938, + 14.03599732681375, + 0.9722818404698685, + 2.8365521687132196, + -2.8986711961763487, + 0.6731600249549142, + -1.968672216943043, + -7.028498918954745, + -1.2720733545245055, + -1.7866195396268072, + ], + [ + 0.9910796788130367, + -0.006066347272098975, + 0.003212440215706125, + -0.004684086767192054, + 0.005271523308610293, + 0.008559051744537721, + 109.60942630891857, + -15.717566986242204, + 28.48576764394318, + 227.13204414846317, + -16.067706286794227, + -25.486055887477125, + -45.63564975599253, + 6.432439099160851, + -11.495435787072722, + -94.48845805804095, + 8.089793565062266, + 9.893609778856955, + -33.43705608933802, + 4.824834637056938, + -8.223622040706017, + -69.50428987878391, + 5.887194656137066, + 8.94800729228516, + 44.47337250008668, + -6.301270722022312, + 11.207898598128924, + 92.4220929447515, + -6.419105350976998, + -10.413143142373471, + 12.237916296308878, + -2.1875950941690143, + 3.4824234136026435, + 24.51470799457985, + -1.8729279460958983, + -2.995290734346036, + -5.788225941827381, + 0.5091307093232996, + -2.0570560656612114, + -12.510339847465445, + 0.6597236178178729, + 1.4334143722627077, + ], + [ + 0.9898744278702115, + -0.003589957796614368, + 0.005258145836456293, + -0.0029834070095553396, + 0.010601176566470631, + 0.004737084798624322, + 201.86456801433138, + -32.79371839578189, + 8.778449492317803, + 398.7473687287775, + -112.20521765826136, + -113.34271959731471, + -83.91562772874882, + 13.925566566146511, + -3.5406485779734918, + -165.18626828653407, + 47.779213285258685, + 46.26199010349747, + -61.59279313916355, + 10.310376359525133, + -1.9205492291693678, + -121.55675882377591, + 35.015239886510024, + 35.31449273448445, + 82.03383012577265, + -13.217635207287676, + 3.220378725418548, + 162.39550677996976, + -45.58234688180706, + -45.886714273972885, + 22.204797865448924, + -4.032943867089017, + 1.2329333115454304, + 43.16784495801038, + -11.990747315552705, + -12.788440637646016, + -10.823837837259962, + 1.4311210347644943, + -0.9158767631079093, + -21.58671912250025, + 6.241725963443699, + 6.540160859407583, + ], + ] + + unstable = [diverge(ic[1:6], reshape(ic[7:end], 6, 6), Φ; eps = 1e-8) for ic in ics] + + @test unstable ≈ [ + [ + 0.9894058633306991, + 1.072047306563596e-9, + 0.0059860804945415895, + -7.645981012482653e-9, + 0.012509735977210676, + 2.9928203953031123e-9, + ], + [ + 0.989874424256154, + 0.0035899593869439046, + 0.0052581467844121385, + 0.0029834002996964354, + 0.010601181942007543, + -0.004737081701453126, + ], + [ + 0.9910796756645479, + 0.00606634941623854, + 0.003212441327024458, + 0.004684081166578108, + 0.005271530075233423, + -0.00855904907981877, + ], + [ + 0.9924953583827216, + 0.0065278962838587464, + 0.0002770340761658626, + 0.004308400722444655, + -0.0025418852194094683, + -0.010403891704544876, + ], + [ + 0.9934985353165007, + 0.004414496217085891, + -0.002691681954480171, + 0.002143341012609228, + -0.011393922984824075, + -0.008319427338105041, + ], + [ + 0.9938017980401521, + 2.6371735230836064e-9, + -0.004091057288364902, + -6.142464108479443e-9, + -0.01638584808508263, + -5.3544911573575455e-9, + ], + [ + 0.993498534435403, + -0.00441449138559817, + -0.0026916840713611884, + -0.0021433533182417105, + -0.011393931055161136, + 0.00831942078491083, + ], + [ + 0.9924953570858336, + -0.006527892583528865, + 0.00027703123670332134, + -0.0043084140948845, + -0.0025418940141105554, + 0.010403891427627623, + ], + [ + 0.9910796745451873, + -0.006066346677634581, + 0.0032124391214571626, + -0.004684095647243339, + 0.005271523936204335, + 0.008559052737265285, + ], + [ + 0.9898744236327127, + -0.003589957116708843, + 0.005258145660315078, + -0.002983415395102339, + 0.010601178931901838, + 0.004737087172996553, + ], + ] + + stable = [converge(ic[1:6], reshape(ic[7:end], 6, 6), Φ; eps = 1e-8) for ic in ics] + + @test stable ≈ [ + [ + 0.9894058633306991, + -1.0720473066993234e-9, + 0.005986080494541589, + 7.645981012462348e-9, + 0.012509735977210676, + -2.992820395381124e-9, + ], + [ + 0.9898744236327279, + 0.003589957116710926, + 0.005258145660315757, + 0.002983415395071781, + 0.010601178931892018, + -0.004737087172988469, + ], + [ + 0.9910796745451955, + 0.006066346677635056, + 0.003212439121459165, + 0.004684095647225347, + 0.0052715239362023545, + -0.008559052737263916, + ], + [ + 0.9924953570858377, + 0.006527892583529262, + 0.0002770312367051028, + 0.004308414094874181, + -0.0025418940141098013, + -0.010403891427629895, + ], + [ + 0.9934985344354048, + 0.004414491385598826, + -0.0026916840713603093, + 0.00214335331823643, + -0.011393931055160662, + -0.008319420784914173, + ], + [ + 0.9938017980401521, + -2.637172844206485e-9, + -0.004091057288364902, + 6.142460966514267e-9, + -0.016385848085082626, + 5.354488437345373e-9, + ], + [ + 0.9934985353164989, + -0.00441449621708523, + -0.002691681954481052, + -0.0021433410126145015, + -0.011393922984824547, + 0.008319427338101697, + ], + [ + 0.9924953583827175, + -0.006527896283858341, + 0.0002770340761640776, + -0.004308400722454952, + -0.002541885219410229, + 0.010403891704542608, + ], + [ + 0.9910796756645397, + -0.006066349416238057, + 0.003212441327022454, + -0.004684081166596076, + 0.005271530075235392, + 0.008559049079820144, + ], + [ + 0.9898744242561389, + -0.00358995938694182, + 0.005258146784411463, + -0.0029834002997269726, + 0.01060118194201734, + 0.004737081701461207, + ], + ] +end diff --git a/lib/AstrodynamicalSolvers/test/orbits.jl b/lib/AstrodynamicalSolvers/test/orbits.jl new file mode 100644 index 00000000..d516ca00 --- /dev/null +++ b/lib/AstrodynamicalSolvers/test/orbits.jl @@ -0,0 +1,77 @@ +using AstrodynamicalSolvers: + AstrodynamicalSolvers, + halo, + monodromy, + propagate, + propagate! + + +@testset "Orbit Propagation" begin + + orbit = Orbit(rand(CartesianState), rand(R2BParameters)) + @test propagate(orbit, 1e-3) isa ODESolution + + state = copy(orbit.state) + @test isnothing(propagate!(orbit, 1e-3)) + @test orbit.state != state + +end + +@testset "Lyapunov Orbit Correction" begin + + μ = 0.012150584395829193 + u = richardson_ic(μ, 1) + u = AstrodynamicalSolvers.CR3BSolvers.lyapunov(u.x, u.ẏ, μ, u.Δt) + + + @test u.x ≈ 0.8222791798525636 + @test u.ẏ ≈ 0.13799313228400178 + @test u.Δt ≈ 2.7536820160579087 + +end + +@testset "Halo Orbit Correction" begin + + μ = 0.012150584395829193 + u = richardson_ic(μ, 2; Z = 0.005) + u = AstrodynamicalSolvers.CR3BSolvers.halo(u.x, u.z, u.ẏ, μ, u.Δt) + + @test u.x ≈ 1.1202340567932783 + @test u.z ≈ 0.004589679675825104 + @test u.ẏ ≈ 0.17648270824601714 + @test u.Δt ≈ 3.4152029027146815 + +end + +@testset "Semantic Orbit Correction" begin + + μ = 0.012150584395829193 + u = halo(μ, 2) + + @test u.x ≈ 1.124357139749168 + @test u.ẏ ≈ 0.15714566174026515 + @test u.Δt ≈ 3.4068306866985814 + + u = halo(μ, 1; amplitude = 0.005) + @test u.x ≈ 0.823388563881332 + @test u.z ≈ 0.005553604696093592 + @test u.ẏ ≈ 0.12683910108732768 + @test u.Δt ≈ 2.7432058155507653 + +end + +@testset "Monodromy Matrices" begin + + μ = 0.012150584395829193 + ic = halo(μ, 1; amplitude = 0.005) + u = CartesianState(ic) + + @test monodromy(u, μ, ic.Δt, CR3BFunction(stm = true)) ≈ [ + 1317.472125300217 -339.26725145920585 -22.23471304682866 388.2455372345198 126.49047353668445 -3.3779594177227 + -429.7764385389933 111.53280315746214 7.269431052432993 -126.49047353678779 -41.404653982215095 1.0977750840404263 + -11.440384647744368 2.9348175664641527 1.1929568568249131 -3.3779594177162653 -1.0977750840374354 -0.05845992955397675 + 3612.12986893901 -929.3271447079647 -60.998106970610365 1064.4911782262984 346.9671305741014 -9.244834479682378 + -1482.5514995781887 382.0700769975138 25.039782109090023 -437.2238230101127 -141.4481439160884 3.8211012689780377 + -75.5369690753493 19.429643984545518 1.2797982252155324 -22.23471304678537 -7.269431052412963 1.1929568568243507 + ] +end diff --git a/lib/AstrodynamicalSolvers/test/runtests.jl b/lib/AstrodynamicalSolvers/test/runtests.jl index 77431f91..04b86fc4 100644 --- a/lib/AstrodynamicalSolvers/test/runtests.jl +++ b/lib/AstrodynamicalSolvers/test/runtests.jl @@ -3,726 +3,20 @@ Unit tests for various solvers. """ module AstrodynamicalSolversTests -using Test, AstrodynamicalSolvers -using AstrodynamicalCalculations -using StaticArrays -using OrdinaryDiffEqVerner -using AstrodynamicalModels -using LinearAlgebra - -@testset "Orbit Propagation" begin - - orbit = Orbit(rand(CartesianState), rand(R2BParameters)) - @test propagate(orbit, 1e-3) isa ODESolution - - state = copy(orbit.state) - @test isnothing(propagate!(orbit, 1e-3)) - @test orbit.state != state - -end - -@testset "Lyapunov Orbit Correction" begin - - μ = 0.012150584395829193 - u = richardson_ic(μ, 1) - u = AstrodynamicalSolvers.CR3BSolvers.lyapunov(u.x, u.ẏ, μ, u.Δt) - - - @test u.x ≈ 0.8222791798525636 - @test u.ẏ ≈ 0.13799313228400178 - @test u.Δt ≈ 2.7536820160579087 - +using ParallelTestRunner: runtests, find_tests, parse_args +import AstrodynamicalSolvers + +const init_code = quote + using AstrodynamicalCalculations + using AstrodynamicalModels + using LinearAlgebra + using OrdinaryDiffEqVerner + using StaticArrays end -@testset "Halo Orbit Correction" begin +args = parse_args(Base.ARGS) +testsuite = find_tests(@__DIR__) - μ = 0.012150584395829193 - u = richardson_ic(μ, 2; Z = 0.005) - u = AstrodynamicalSolvers.CR3BSolvers.halo(u.x, u.z, u.ẏ, μ, u.Δt) - - @test u.x ≈ 1.1202340567932783 - @test u.z ≈ 0.004589679675825104 - @test u.ẏ ≈ 0.17648270824601714 - @test u.Δt ≈ 3.4152029027146815 - -end - -@testset "Semantic Orbit Correction" begin - - μ = 0.012150584395829193 - u = halo(μ, 2) - - @test u.x ≈ 1.124357139749168 - @test u.ẏ ≈ 0.15714566174026515 - @test u.Δt ≈ 3.4068306866985814 - - u = halo(μ, 1; amplitude = 0.005) - @test u.x ≈ 0.823388563881332 - @test u.z ≈ 0.005553604696093592 - @test u.ẏ ≈ 0.12683910108732768 - @test u.Δt ≈ 2.7432058155507653 - -end +runtests(AstrodynamicalSolvers, args; testsuite, init_code) -@testset "Monodromy Matrices" begin - - μ = 0.012150584395829193 - ic = halo(μ, 1; amplitude = 0.005) - u = CartesianState(ic) - - @test monodromy(u, μ, ic.Δt, CR3BFunction(stm = true)) ≈ [ - 1317.472125300217 -339.26725145920585 -22.23471304682866 388.2455372345198 126.49047353668445 -3.3779594177227 - -429.7764385389933 111.53280315746214 7.269431052432993 -126.49047353678779 -41.404653982215095 1.0977750840404263 - -11.440384647744368 2.9348175664641527 1.1929568568249131 -3.3779594177162653 -1.0977750840374354 -0.05845992955397675 - 3612.12986893901 -929.3271447079647 -60.998106970610365 1064.4911782262984 346.9671305741014 -9.244834479682378 - -1482.5514995781887 382.0700769975138 25.039782109090023 -437.2238230101127 -141.4481439160884 3.8211012689780377 - -75.5369690753493 19.429643984545518 1.2797982252155324 -22.23471304678537 -7.269431052412963 1.1929568568243507 - ] -end - -@testset "Manifold Computations" begin - - μ = 3.0034805945423635e-6 - u = halo(μ, 1; amplitude = 0.005) - - @test u.x ≈ 0.9894058673149723 - @test u.z ≈ 0.005986079972943528 - @test u.ẏ ≈ 0.01250973206745133 - @test u.Δt ≈ 3.0247281222825437 - - T = u.Δt - u = CartesianState(u) - Φ = monodromy(u, μ, T, CR3BFunction(stm = true)) - - @test Φ ≈ [ - 363.5695646260086 -150.84678203289957 -110.89785303818041 147.89291423249102 39.776655263625734 -19.506758521645583 - -98.06514156622599 41.30059843066769 30.40698418319986 -39.776655263719505 -11.022980358853847 5.037110248654976 - -47.32080144069423 19.504183945583154 15.347602546829501 -19.506758521547493 -5.037110248617916 2.2693997822749954 - 697.403493226936 -288.5621336671776 -212.7440873239205 284.01625409850567 76.01918084826457 -37.246580943614184 - -355.9757987239261 148.34069711110283 109.04417094750771 -144.93904643230533 -38.25271209672777 19.509333097636393 - -273.5580556895539 112.7515351286987 83.74272666784147 -110.89785303784609 -30.406984183046543 15.347602546859227 - ] - - ics = let - problem = ODEProblem(CR3BFunction(stm = true), vcat(u, vec(I(6))), (0, T), (μ,)) - solution = - solve(problem, Vern9(), reltol = 1e-12, abstol = 1e-12, saveat = (T / 10)) - - solution.u[begin:begin+9] - end - - @test ics ≈ [ - [ - 0.9894058673149723, - 0.0, - 0.005986079972943528, - 0.0, - 0.01250973206745133, - 0.0, - 1.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 1.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 1.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 1.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 1.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 1.0, - ], - [ - 0.9898744278702267, - 0.0035899577966164516, - 0.005258145836456971, - 0.0029834070095247816, - 0.010601176566460811, - -0.004737084798616238, - 1.2371458411768335, - -0.0695323761780384, - -0.09847482817935505, - 1.5670044822929252, - -0.6978155777157768, - -0.6591788390257907, - -0.035434947222201855, - 0.9316804373498873, - 0.011356684405103354, - -0.3467997416963855, - -0.3896842189464582, - 0.11054943644691602, - -0.09395345250960796, - 0.030697477319750244, - 0.9321583672024584, - -0.6007887072141127, - 0.3009033764290183, - -0.4464993538639933, - 0.308242649904382, - -0.09438488946911146, - -0.009837529520694738, - 1.0591107163922577, - -0.6442600720711773, - -0.09773198568283194, - 0.088131316473712, - 0.2767705969926594, - 0.00023169992649377062, - 0.5611428035212996, - 0.7487829717456858, - 0.0027324590487216266, - -0.009332241416375939, - 0.0031441665203776454, - 0.295364864880218, - -0.08956991747299407, - 0.040913095200603176, - 0.9279360834253226, - ], - [ - 0.9910796788130449, - 0.006066347272099451, - 0.0032124402157081276, - 0.0046840867671740635, - 0.005271523308608312, - -0.008559051744536353, - 1.950040239465447, - -0.5899540353747552, - -0.40535975374341493, - 3.164386111879475, - -3.0927704802812737, - -1.3725873609363672, - -0.26843184364042577, - 0.8374953199128866, - 0.08343688204016234, - -1.2726857507607194, - -0.053624055517039464, - 0.3808968730554891, - -0.34391493779148813, - 0.2355718050038613, - 0.7337936721629754, - -1.018572831318294, - 1.1365901126247782, - -0.8528469298727669, - 0.6581421492414853, - -0.4199981787375973, - -0.07819233335820817, - 1.296363278219651, - -1.6024827121626852, - -0.3800784071360596, - 0.3163004973499631, - 0.4108044051437538, - 0.0016055058382268882, - 0.898197886993142, - 0.07948286238182267, - 0.002678040639188702, - -0.06481411101658309, - 0.04588962838569348, - 0.5426402313760416, - -0.2821160224582451, - 0.28560464167961974, - 0.667837207225828, - ], - [ - 0.9924953609558557, - 0.006527893673766641, - 0.00027703311101019744, - 0.004308405329300428, - -0.0025418931279188855, - -0.010403893071012492, - 3.194979782068513, - -2.2480244592658707, - -0.8912901561737726, - 5.260531462882106, - -8.629748694340314, - -1.6131421475527377, - -0.8480334714756765, - 1.051120901341595, - 0.23328760581650157, - -2.6444533370499497, - 1.8137063921561256, - 0.5366273688482629, - -0.7042926255865667, - 0.7799660829349495, - 0.4234742102702738, - -1.4067052181979423, - 2.6169072350232443, - -1.2068964645667555, - 1.1360123079440265, - -1.169120882563875, - -0.23731765154027032, - 1.9926119503214768, - -3.6422821167111397, - -0.5954430923230926, - 0.6017020436501692, - 0.2894337604412833, - -0.0024364332298012063, - 0.9513391643697624, - -0.9600543630574989, - -0.031952547093191674, - -0.17594483247914564, - 0.20206265728008083, - 0.6681165100769222, - -0.4390532271528181, - 0.78324225648997, - 0.09362900661603259, - ], - [ - 0.9934985373534506, - 0.004414493412947694, - -0.002691682347757935, - 0.0021433455930179954, - -0.011393931006874056, - -0.008319425757109752, - 5.490003988184001, - -6.487014689628338, - -0.8875841662056261, - 11.302082651153246, - -20.6917674268284, - 3.631168290269304, - -1.9880804273779376, - 2.231086179719102, - 0.24089957990992225, - -5.357497029086754, - 6.581690137390508, - -1.1855913442432098, - -1.309840956076913, - 1.977719338435574, - -0.07622512726413008, - -3.064737419133734, - 5.656005016906049, - -2.517216773282615, - 2.0428301884897455, - -2.8931589692820436, - -0.24254153002609002, - 4.620462672370931, - -8.271485402807551, - 1.3685197351272902, - 0.9017837097616304, - -0.25264672130310206, - 0.015551302170489048, - 1.1676475337624053, - -2.821743441950994, - 0.35282832145644405, - -0.32809129465828046, - 0.5293704124595559, - 0.5416243419739394, - -0.5956212745474034, - 1.358220989856255, - -1.0608489042619311, - ], - [ - 0.9938018000948632, - 3.3814004664628033e-16, - -0.004091056650145035, - -1.5713283266960783e-15, - -0.01638585277717688, - -1.3586014618110917e-15, - 11.747249011272089, - -14.478469379121254, - 3.5877588628656816, - 33.92593778407872, - -27.57659845017894, - 29.9164518117297, - -4.718395501501515, - 5.047894587113171, - -1.3552904353555262, - -14.253386838881683, - 10.544629652277052, - -11.079226610892352, - -3.1371461505739706, - 4.163339859874222, - -1.6641718993686987, - -10.324059030179551, - 7.616817895784776, - -9.057160270532727, - 4.635450259594342, - -6.044958610263879, - 1.5056456364454869, - 14.029780852500256, - -10.722766001172136, - 11.748164468177174, - 1.536462255983425, - -1.421038054235922, - 0.5070088326456889, - 3.600270813484911, - -4.334194398507778, - 3.495249696857971, - -0.6039468437963879, - 0.9459379702817146, - -0.05896360053465793, - -1.4370597187069243, - 1.110717948772804, - -2.9657277873069456, - ], - [ - 0.9934985373534488, - -0.004414493412947038, - -0.002691682347758814, - -0.002143345593023276, - -0.011393931006874526, - 0.008319425757106409, - 27.57759248770883, - -19.172242333275435, - 16.311421629570358, - 72.18267416063888, - -0.5217071771052122, - 47.17874452640869, - -11.340443337730555, - 7.047344305454021, - -6.297176883156646, - -30.26726229627077, - 1.2161844662072916, - -18.973437822540653, - -8.071483120027205, - 5.474388542930831, - -5.324321068514165, - -22.672475850776927, - 0.20393609974423393, - -13.184980940723491, - 11.118981342445453, - -7.811335199137715, - 6.498398319499484, - 29.399620552354797, - 0.14240562800692375, - 18.498373101895407, - 3.2910208635699147, - -2.296036749641137, - 2.046348060177439, - 8.079637992426136, - -0.9590910848556188, - 5.741127700197823, - -1.3335010300736867, - 1.0231776131283727, - -1.1156153587866342, - -3.5820118833628345, - -0.6679709374220457, - -3.564673805710898, - ], - [ - 0.9924953609558516, - -0.006527893673766245, - 0.00027703311100841577, - -0.004308405329310747, - -0.0025418931279196384, - 0.01040389307101022, - 57.181133640704, - -16.449867036121947, - 27.93439296013566, - 128.6079397443349, - 12.671869857737473, - 24.502246328517415, - -23.759695823973058, - 6.304150081118974, - -11.100619162382069, - -53.86522120299188, - -3.8482982939686394, - -10.515733266818891, - -17.31335910736424, - 4.773489630454567, - -8.455598228679394, - -39.86056875482027, - -3.118645953595972, - -6.051829092328109, - 23.153417082539452, - -6.635970433902056, - 11.051184168659917, - 52.26235486966227, - 5.293684620687887, - 9.554469389008181, - 6.559940802699193, - -2.1869174797907305, - 3.4351989345430938, - 14.03599732681375, - 0.9722818404698685, - 2.8365521687132196, - -2.8986711961763487, - 0.6731600249549142, - -1.968672216943043, - -7.028498918954745, - -1.2720733545245055, - -1.7866195396268072, - ], - [ - 0.9910796788130367, - -0.006066347272098975, - 0.003212440215706125, - -0.004684086767192054, - 0.005271523308610293, - 0.008559051744537721, - 109.60942630891857, - -15.717566986242204, - 28.48576764394318, - 227.13204414846317, - -16.067706286794227, - -25.486055887477125, - -45.63564975599253, - 6.432439099160851, - -11.495435787072722, - -94.48845805804095, - 8.089793565062266, - 9.893609778856955, - -33.43705608933802, - 4.824834637056938, - -8.223622040706017, - -69.50428987878391, - 5.887194656137066, - 8.94800729228516, - 44.47337250008668, - -6.301270722022312, - 11.207898598128924, - 92.4220929447515, - -6.419105350976998, - -10.413143142373471, - 12.237916296308878, - -2.1875950941690143, - 3.4824234136026435, - 24.51470799457985, - -1.8729279460958983, - -2.995290734346036, - -5.788225941827381, - 0.5091307093232996, - -2.0570560656612114, - -12.510339847465445, - 0.6597236178178729, - 1.4334143722627077, - ], - [ - 0.9898744278702115, - -0.003589957796614368, - 0.005258145836456293, - -0.0029834070095553396, - 0.010601176566470631, - 0.004737084798624322, - 201.86456801433138, - -32.79371839578189, - 8.778449492317803, - 398.7473687287775, - -112.20521765826136, - -113.34271959731471, - -83.91562772874882, - 13.925566566146511, - -3.5406485779734918, - -165.18626828653407, - 47.779213285258685, - 46.26199010349747, - -61.59279313916355, - 10.310376359525133, - -1.9205492291693678, - -121.55675882377591, - 35.015239886510024, - 35.31449273448445, - 82.03383012577265, - -13.217635207287676, - 3.220378725418548, - 162.39550677996976, - -45.58234688180706, - -45.886714273972885, - 22.204797865448924, - -4.032943867089017, - 1.2329333115454304, - 43.16784495801038, - -11.990747315552705, - -12.788440637646016, - -10.823837837259962, - 1.4311210347644943, - -0.9158767631079093, - -21.58671912250025, - 6.241725963443699, - 6.540160859407583, - ], - ] - - unstable = [diverge(ic[1:6], reshape(ic[7:end], 6, 6), Φ; eps = 1e-8) for ic in ics] - - @test unstable ≈ [ - [ - 0.9894058633306991, - 1.072047306563596e-9, - 0.0059860804945415895, - -7.645981012482653e-9, - 0.012509735977210676, - 2.9928203953031123e-9, - ], - [ - 0.989874424256154, - 0.0035899593869439046, - 0.0052581467844121385, - 0.0029834002996964354, - 0.010601181942007543, - -0.004737081701453126, - ], - [ - 0.9910796756645479, - 0.00606634941623854, - 0.003212441327024458, - 0.004684081166578108, - 0.005271530075233423, - -0.00855904907981877, - ], - [ - 0.9924953583827216, - 0.0065278962838587464, - 0.0002770340761658626, - 0.004308400722444655, - -0.0025418852194094683, - -0.010403891704544876, - ], - [ - 0.9934985353165007, - 0.004414496217085891, - -0.002691681954480171, - 0.002143341012609228, - -0.011393922984824075, - -0.008319427338105041, - ], - [ - 0.9938017980401521, - 2.6371735230836064e-9, - -0.004091057288364902, - -6.142464108479443e-9, - -0.01638584808508263, - -5.3544911573575455e-9, - ], - [ - 0.993498534435403, - -0.00441449138559817, - -0.0026916840713611884, - -0.0021433533182417105, - -0.011393931055161136, - 0.00831942078491083, - ], - [ - 0.9924953570858336, - -0.006527892583528865, - 0.00027703123670332134, - -0.0043084140948845, - -0.0025418940141105554, - 0.010403891427627623, - ], - [ - 0.9910796745451873, - -0.006066346677634581, - 0.0032124391214571626, - -0.004684095647243339, - 0.005271523936204335, - 0.008559052737265285, - ], - [ - 0.9898744236327127, - -0.003589957116708843, - 0.005258145660315078, - -0.002983415395102339, - 0.010601178931901838, - 0.004737087172996553, - ], - ] - - stable = [converge(ic[1:6], reshape(ic[7:end], 6, 6), Φ; eps = 1e-8) for ic in ics] - - @test stable ≈ [ - [ - 0.9894058633306991, - -1.0720473066993234e-9, - 0.005986080494541589, - 7.645981012462348e-9, - 0.012509735977210676, - -2.992820395381124e-9, - ], - [ - 0.9898744236327279, - 0.003589957116710926, - 0.005258145660315757, - 0.002983415395071781, - 0.010601178931892018, - -0.004737087172988469, - ], - [ - 0.9910796745451955, - 0.006066346677635056, - 0.003212439121459165, - 0.004684095647225347, - 0.0052715239362023545, - -0.008559052737263916, - ], - [ - 0.9924953570858377, - 0.006527892583529262, - 0.0002770312367051028, - 0.004308414094874181, - -0.0025418940141098013, - -0.010403891427629895, - ], - [ - 0.9934985344354048, - 0.004414491385598826, - -0.0026916840713603093, - 0.00214335331823643, - -0.011393931055160662, - -0.008319420784914173, - ], - [ - 0.9938017980401521, - -2.637172844206485e-9, - -0.004091057288364902, - 6.142460966514267e-9, - -0.016385848085082626, - 5.354488437345373e-9, - ], - [ - 0.9934985353164989, - -0.00441449621708523, - -0.002691681954481052, - -0.0021433410126145015, - -0.011393922984824547, - 0.008319427338101697, - ], - [ - 0.9924953583827175, - -0.006527896283858341, - 0.0002770340761640776, - -0.004308400722454952, - -0.002541885219410229, - 0.010403891704542608, - ], - [ - 0.9910796756645397, - -0.006066349416238057, - 0.003212441327022454, - -0.004684081166596076, - 0.005271530075235392, - 0.008559049079820144, - ], - [ - 0.9898744242561389, - -0.00358995938694182, - 0.005258146784411463, - -0.0029834002997269726, - 0.01060118194201734, - 0.004737081701461207, - ], - ] -end - -end +end # module diff --git a/test/Project.toml b/test/Project.toml new file mode 100644 index 00000000..172aceb9 --- /dev/null +++ b/test/Project.toml @@ -0,0 +1,4 @@ +[deps] +GeneralAstrodynamics = "8068df5b-8501-4530-bd82-d24d3c9619db" +Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"