Skip to content

Commit ade1a27

Browse files
Architecture/accuracy (#186)
* Check accuracy on LEO * Fix celestial item construction to include sun orbital parameters relative to SSB. Mitigate multithreaded tests * Add accuracy report * Propagation allows one iteration after the end to garanty full filled propagation windows in case of Step size doesn't match the windows length
1 parent 018db1a commit ade1a27

File tree

10 files changed

+320
-29
lines changed

10 files changed

+320
-29
lines changed

IO.Astrodynamics.Net/IO.Astrodynamics.Performance/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class Program
77
static void Main(string[] args)
88
{
99
var summary = BenchmarkRunner.Run(typeof(Program).Assembly);
10-
//var scenario=new Scenario();
10+
//var scenario=new VelocityScenario();
1111
//scenario.Propagator();
1212
// Console.ReadKey();
1313
}

IO.Astrodynamics.Net/IO.Astrodynamics.Performance/Scenario.cs renamed to IO.Astrodynamics.Net/IO.Astrodynamics.Performance/VelocityScenario.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace IO.Astrodynamics.Performance;
2323
[KurtosisColumn]
2424
[StatisticalTestColumn]
2525
[ShortRunJob]
26-
public class Scenario
26+
public class VelocityScenario
2727
{
2828
private readonly GeopotentialGravitationalField _geopotential;
2929
private readonly SolarRadiationPressure _srp;
@@ -35,7 +35,7 @@ public class Scenario
3535
private readonly Propagator.SpacecraftPropagator _spacecraftPropagator;
3636
// IO.Astrodynamics.Tests.Mission.ScenarioTests _scenario = new IO.Astrodynamics.Tests.Mission.ScenarioTests();
3737

38-
public Scenario()
38+
public VelocityScenario()
3939
{
4040
API.Instance.LoadKernels(new DirectoryInfo("Data"));
4141
_earth = new CelestialBody(399, new GeopotentialModelParameters("Data/SolarSystem/EGM2008_to70_TideFree", 30), new EarthAtmosphericModel());
11.2 KB
Binary file not shown.
Binary file not shown.

IO.Astrodynamics.Net/IO.Astrodynamics.Tests/Mission/ScenarioTests.cs

Lines changed: 241 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using System;
22
using System.IO;
33
using System.Linq;
4+
using System.Text;
5+
using System.Threading;
46
using System.Threading.Tasks;
57
using BenchmarkDotNet.Attributes;
68
using IO.Astrodynamics.Body;
@@ -195,8 +197,8 @@ public async Task PropagateSpacecraft()
195197
}
196198

197199
Assert.Equal(2281.6923637537593, summary.SpacecraftSummaries.First().FuelConsumption, 3);
198-
Assert.Equal("Sites",summary.SiteDirectoryInfo.Name);
199-
Assert.Equal("Spacecrafts",summary.SpacecraftDirectoryInfo.Name);
200+
Assert.Equal("Sites", summary.SiteDirectoryInfo.Name);
201+
Assert.Equal("Spacecrafts", summary.SpacecraftDirectoryInfo.Name);
200202
}
201203

202204
[Fact]
@@ -558,7 +560,7 @@ public async Task PropagateException()
558560
}
559561

560562
[Fact]
561-
public async Task DeepSpaceMoon()
563+
public async Task DeepSpaceMoon3Days()
562564
{
563565
var frame = Frames.Frame.ICRF;
564566
var start = TimeSystem.Time.J2000TDB;
@@ -593,5 +595,241 @@ public async Task DeepSpaceMoon()
593595
Assert.True(deltaP < 35);
594596
Assert.True(deltaV < 2.7E-04);
595597
}
598+
599+
SemaphoreSlim semaphore = new SemaphoreSlim(1, 1);
600+
601+
[Theory]
602+
[InlineData(1)]
603+
[InlineData(2)]
604+
[InlineData(5)]
605+
[InlineData(10)]
606+
[InlineData(20)]
607+
public async Task DeepSpaceMoon25D(int stepSize)
608+
{
609+
await semaphore.WaitAsync();
610+
611+
try
612+
{
613+
var step = TimeSpan.FromMinutes(stepSize);
614+
var frame = Frames.Frame.ICRF;
615+
var start = TimeSystem.Time.J2000TDB;
616+
var end = start.AddDays(25);
617+
var earth = new CelestialBody(PlanetsAndMoons.EARTH, frame, start);
618+
var moon = new CelestialBody(PlanetsAndMoons.MOON, frame, start);
619+
Astrodynamics.Mission.Mission mission = new Astrodynamics.Mission.Mission("missionsdeepspace");
620+
Scenario scenario = new Scenario("scn" + stepSize, mission, new Window(start, end));
621+
622+
StateVector testOrbit = moon.GetEphemeris(start, new CelestialBody(399), frame, Aberration.None).ToStateVector();
623+
Clock clk = new Clock("My clock", 256);
624+
Spacecraft spc = new Spacecraft(-1001, "MySpacecraft", 100.0, 10000.0, clk, testOrbit, 0.5);
625+
scenario.AddSpacecraft(spc);
626+
scenario.AddCelestialItem(new CelestialBody(10));
627+
scenario.AddCelestialItem(new CelestialBody(399));
628+
scenario.AddCelestialItem(new Barycenter(1));
629+
scenario.AddCelestialItem(new Barycenter(2));
630+
scenario.AddCelestialItem(new Barycenter(4));
631+
scenario.AddCelestialItem(new Barycenter(5));
632+
scenario.AddCelestialItem(new Barycenter(6));
633+
scenario.AddCelestialItem(new Barycenter(7));
634+
scenario.AddCelestialItem(new Barycenter(8));
635+
var summary = await scenario.SimulateAsync(new DirectoryInfo("Simulation"), false, false, step);
636+
637+
var spcSV = spc.GetEphemeris(end, earth, Frames.Frame.ICRF, Aberration.None).ToStateVector();
638+
var moonSV = moon.GetEphemeris(end, earth, Frames.Frame.ICRF, Aberration.None).ToStateVector();
639+
640+
var delta = spcSV - moonSV;
641+
var deltaP = delta.Position.Magnitude();
642+
var deltaV = delta.Velocity.Magnitude();
643+
644+
await File.AppendAllTextAsync("AccuracyDeepSpace.csv", $"{DateTime.Now},{step},{deltaP},{deltaV}{Environment.NewLine}");
645+
646+
if (stepSize == 1)
647+
{
648+
Assert.True(deltaP < 1203);
649+
Assert.True(deltaV < 2.7E-03);
650+
}
651+
else if (stepSize == 2)
652+
{
653+
Assert.True(deltaP < 1243);
654+
Assert.True(deltaV < 2.8E-03);
655+
}
656+
else if (stepSize == 5)
657+
{
658+
Assert.True(deltaP < 1524);
659+
Assert.True(deltaV < 3.5E-03);
660+
}
661+
else if (stepSize == 10)
662+
{
663+
Assert.True(deltaP < 2563);
664+
Assert.True(deltaV < 6.1E-03);
665+
}
666+
else if (stepSize == 20)
667+
{
668+
Assert.True(deltaP < 6818);
669+
Assert.True(deltaV < 1.7E-02);
670+
}
671+
}
672+
finally
673+
{
674+
semaphore.Release();
675+
}
676+
}
677+
678+
[Theory]
679+
[InlineData(1)]
680+
[InlineData(2)]
681+
[InlineData(3)]
682+
[InlineData(4)]
683+
[InlineData(5)]
684+
[InlineData(6)]
685+
[InlineData(7)]
686+
[InlineData(8)]
687+
[InlineData(9)]
688+
[InlineData(10)]
689+
[InlineData(20)]
690+
public async Task DeepSpaceMoon3D(int stepSize)
691+
{
692+
await semaphore.WaitAsync();
693+
694+
try
695+
{
696+
var step = TimeSpan.FromMinutes(stepSize);
697+
var frame = Frames.Frame.ICRF;
698+
var start = TimeSystem.Time.J2000TDB;
699+
var end = start.AddDays(3);
700+
var earth = new CelestialBody(PlanetsAndMoons.EARTH, frame, start);
701+
var moon = new CelestialBody(PlanetsAndMoons.MOON, frame, start);
702+
Astrodynamics.Mission.Mission mission = new Astrodynamics.Mission.Mission("missionsdeepspace");
703+
Scenario scenario = new Scenario("scn" + stepSize, mission, new Window(start, end));
704+
705+
StateVector testOrbit = moon.GetEphemeris(start, new CelestialBody(399), frame, Aberration.None).ToStateVector();
706+
Clock clk = new Clock("My clock", 256);
707+
Spacecraft spc = new Spacecraft(-1001, "MySpacecraft", 100.0, 10000.0, clk, testOrbit, 0.5);
708+
scenario.AddSpacecraft(spc);
709+
scenario.AddCelestialItem(new CelestialBody(10));
710+
scenario.AddCelestialItem(new CelestialBody(399));
711+
scenario.AddCelestialItem(new Barycenter(1));
712+
scenario.AddCelestialItem(new Barycenter(2));
713+
scenario.AddCelestialItem(new Barycenter(4));
714+
scenario.AddCelestialItem(new Barycenter(5));
715+
scenario.AddCelestialItem(new Barycenter(6));
716+
scenario.AddCelestialItem(new Barycenter(7));
717+
scenario.AddCelestialItem(new Barycenter(8));
718+
var summary = await scenario.SimulateAsync(new DirectoryInfo("Simulation"), false, false, step);
719+
720+
var spcSV = spc.GetEphemeris(end, earth, Frames.Frame.ICRF, Aberration.None).ToStateVector();
721+
var moonSV = moon.GetEphemeris(end, earth, Frames.Frame.ICRF, Aberration.None).ToStateVector();
722+
723+
var delta = spcSV - moonSV;
724+
var deltaP = delta.Position.Magnitude();
725+
var deltaV = delta.Velocity.Magnitude();
726+
727+
await File.AppendAllTextAsync("AccuracyDeepSpace.csv", $"{DateTime.Now},{step},{deltaP},{deltaV}{Environment.NewLine}");
728+
729+
if (stepSize == 1)
730+
{
731+
Assert.True(deltaP < 1203);
732+
Assert.True(deltaV < 2.7E-03);
733+
}
734+
else if (stepSize == 2)
735+
{
736+
Assert.True(deltaP < 1243);
737+
Assert.True(deltaV < 2.8E-03);
738+
}
739+
else if (stepSize == 5)
740+
{
741+
Assert.True(deltaP < 1524);
742+
Assert.True(deltaV < 3.5E-03);
743+
}
744+
else if (stepSize == 10)
745+
{
746+
Assert.True(deltaP < 2563);
747+
Assert.True(deltaV < 6.1E-03);
748+
}
749+
else if (stepSize == 20)
750+
{
751+
Assert.True(deltaP < 6818);
752+
Assert.True(deltaV < 1.7E-02);
753+
}
754+
}
755+
finally
756+
{
757+
semaphore.Release();
758+
}
759+
}
760+
761+
762+
[Theory]
763+
[InlineData(1)]
764+
[InlineData(2)]
765+
[InlineData(5)]
766+
[InlineData(10)]
767+
[InlineData(20)]
768+
public async Task LowEarthOrbitAccuracy(int stepSize)
769+
{
770+
try
771+
{
772+
await semaphore.WaitAsync();
773+
774+
var frame = Frames.Frame.ICRF;
775+
var start = TimeSystem.Time.J2000TDB;
776+
var end = start.AddHours(1.8);
777+
var earth = new CelestialBody(PlanetsAndMoons.EARTH, frame, start);
778+
Astrodynamics.Mission.Mission mission = new Astrodynamics.Mission.Mission("missAccuracyLEO");
779+
780+
StateVector testOrbit = new StateVector(new Vector3(6800000.0, 0, 0), new Vector3(0, 8000.0, 0), earth, start, frame);
781+
Clock clk = new Clock("My clock", 256);
782+
783+
//-----------Scenario 10 s-----------------------------------
784+
Scenario scenario10s = new Scenario($"scn{stepSize}", mission, new Window(start, end));
785+
Spacecraft spc10s = new Spacecraft(-1002 - stepSize, $"Spc{stepSize}", 100.0, 10000.0, clk, testOrbit, 0.5);
786+
scenario10s.AddSpacecraft(spc10s);
787+
scenario10s.AddCelestialItem(earth);
788+
scenario10s.AddCelestialItem(new CelestialBody(10));
789+
scenario10s.AddCelestialItem(new CelestialBody(301));
790+
scenario10s.AddCelestialItem(new Barycenter(5));
791+
scenario10s.AddCelestialItem(new Barycenter(6));
792+
var step = TimeSpan.FromSeconds(stepSize);
793+
var summary2 = await scenario10s.SimulateAsync(new DirectoryInfo("Simulation10s"), false, false, step);
794+
795+
var spcRefSV = testOrbit.ToStateVector(end);
796+
var spc10SV = spc10s.GetEphemeris(end, earth, Frames.Frame.ICRF, Aberration.None).ToStateVector();
797+
798+
var delta = spc10SV - spcRefSV;
799+
var deltaP = delta.Position.Magnitude();
800+
var deltaV = delta.Velocity.Magnitude();
801+
await File.AppendAllTextAsync("AccuracyLEO.csv", $"{DateTime.Now},{stepSize},{deltaP},{deltaV}{Environment.NewLine}");
802+
803+
if (stepSize == 1)
804+
{
805+
Assert.True(deltaP < 27);
806+
Assert.True(deltaV < 0.031);
807+
}
808+
else if (stepSize == 2)
809+
{
810+
Assert.True(deltaP < 84);
811+
Assert.True(deltaV < 0.095);
812+
}
813+
else if (stepSize == 5)
814+
{
815+
Assert.True(deltaP < 482);
816+
Assert.True(deltaV < 0.55);
817+
}
818+
else if (stepSize == 10)
819+
{
820+
Assert.True(deltaP < 1904);
821+
Assert.True(deltaV < 2.17);
822+
}
823+
else if (stepSize == 20)
824+
{
825+
Assert.True(deltaP < 7591);
826+
Assert.True(deltaV < 8.7);
827+
}
828+
}
829+
finally
830+
{
831+
semaphore.Release();
832+
}
833+
}
596834
}
597835
}

0 commit comments

Comments
 (0)