Propagation with SPICE Ephemeris and Integrator
-
- Posts: 5
- Joined: Thu May 16, 2024 2:53 am
Propagation with SPICE Ephemeris and Integrator
Once the end of a SPICE Ephemeris file is reached, it may be desirable to continue propagation using one of FreeFlyer's built in Integrators. The Spacecraft.SetPropagatorType() Method can be used to switch from SpiceEphemeris Propagation to an Integrator such as RK89
Step 1: Create & Configure Spacecraft for Spice Ephemeris Propagation, then Step for 10 days
Step 2: Set PropagatorType to RK89, then Step for 10 days
Step 1: Create & Configure Spacecraft for Spice Ephemeris Propagation, then Step for 10 days
Code: Select all
// Create & Configure SpiceEphemeris object
SpiceEphemeris SpiceEphem;
SpiceEphem.NumberOfSpiceFiles = 1;
SpiceEphem.SpiceFiles[0] = "C:\Users\UserName\Documents\FreeFlyer\FreeFlyer 7.8.1.50021 (64-Bit)\Sample Mission Plans\_Support_Files\090421BP_SCPSE_09109_09130.bsp";
SpiceEphem.Observer = "SATURN";
SpiceEphem.Target = "CASSINI";
SpiceEphem.StepSize = TIMESPAN(120 seconds);
// Create Spacecraft object using SpiceEphemeris object
// Spacecraft central body must match SpiceEphemeris Observer
Spacecraft Cassini(SpiceEphem);
Cassini.CentralBody = "Saturn";
// Since Spice Files contain polynomials instead of vectors, a starting epoch must be specified
// Set starting epoch based on start date in file name (using file naming convention for Cassini SPK files)
// Add 30 minutes to avoid discontinuity at beginning of span (may not be required for all spice files)
StringArray StringArray1;
SpiceEphem.SpiceFiles[0].Split("_",StringArray1);
Cassini.Epoch = StringArray1[4].ParseCalendarDate("YYDOY") + TimeSpan.FromMinutes(30);
// Propagate using SPICE ephemeris for 10 days
While (Cassini.ElapsedTime < TIMESPAN(10 days));
Step Cassini;
End;
Code: Select all
// Switch PropagatorType to RK89
Cassini.SetPropagatorType("RK89");
(Cassini.Propagator AsType RK89).StepSize = TIMESPAN(120 seconds);
// Propagate using Integrator for 10 days
While (Cassini.ElapsedTime < TIMESPAN(10 days));
Step Cassini;
End;