Hi Everyone,
I am writing a Python code which propagates a constellation of 4 satellites for a duration of 7 days using TLE propagator and saves the sub-satellite points of each satellite at an interval of 1 seconds. My goal is to propagate multiple satellites parallelly in a way which takes the least amount of time. Hence, I have considered using multi-threading via PropagatorParallelizer to propagate each satellite independently.
Below is the code I’ve written so far :
### STEP 1 - Setup Parallel Propagation ###
# Initialize arrays
...
total_sats = 4
selected_tles = get_tle_data(total_sats) #Function to get TLE data of all satellites
# For each satellite, setup propagator
for satellite_no in range(0, total_sats):
tle_data = selected_tles[satellite_no] # Get TLE Data for current satellite
tle_line1 = tle_data[0]
tle_line2 = tle_data[1]
inertialFrame = FramesFactory.getTEME()
mytle = TLE(tle_line1, tle_line2)
propagator = TLEPropagator.selectExtrapolator(mytle)
propagator_list.append(propagator)
inertialFrame_list.append(inertialFrame)
propagators = Arrays.asList(propagator_list)
class CustomStepHandler(PythonMultiSatStepHandler):
def init(self, states0, t):
pass
def handleStep(self, currentState):
pass
def finish(self, s):
pass
my_handler = CustomStepHandler()
parallelizer = PropagatorsParallelizer(propagators, my_handler)
### STEP 3 - Propagate Satellites ###
t = [initialDate.shiftedBy(float(dt)) \
for dt in np.arange(0, duration+step_time, step_time)] # Datetime array - [ start date , end date , step = interval ]
print(f"Propagating {total_sats} satellites...")
states = [ parallelizer.propagate(initialDate, tt) for tt in t ] # Calculate states after each 1 second interval ( **Bottle-neck step )
plist = [[xstate.getPVCoordinates().getPosition() for xstate in state] for state in states]
#Function to extract LLA from position and write all SSP to individual csv file for each satellite
...
I have a couple of questions :
-
The current parallel implementation is taking more time ( approximately 8 mins ) than propagating each satellite sequentially in a loop ( which takes 2 mins in total ) .I wanted to understand why that might be happening.
-
Is there a way to synchronize the individual propagators with the same propagation timestep to reduce the wait time taken by the global handler at the end of each step?
-
Is there a way to improve the current code to reduce the computation time ? Or if anyone can suggest any alternate method, it would be very helpful.
For clarity, each satellite is propagated for a duration of 7 days with same start date and different initial TLEs.
Thanks in advance!