Пример #1
0
 def flow(self, delta_time, SaveFlow = False):
     if self.eom == 'keplerian':
         from kepler import kepler
         from auxiliary import E2f, E2M, coe2rv
         #  create a list of the necessary orbital parameters
         #+ for ephemeris() and order them in the default order
         ephemeris_list = [self.e, self.n, self.E]
         ephemeris_list = kepler(ephemeris_list, delta_time)
         #  update other relevant orbital parameters
         self.epoch += delta_time
         self.E = ephemeris_list[2]
         self.f = E2f(self.e, self.E)
         self.M = E2M(self.e, self.E)
         #  update coe list
         self.coe[5] = self.f
         #  update the r, v vectors
         self.r, self.v = coe2rv(self.coe, self.Mu)
     elif self.eom == 'P2B':
         from utilities import rv2ic
         from flow import P2B
         ic = rv2ic(self.r[0:2], self.v[0:2], self.Mu, STM = False)
         flow = P2B(ic, [0, delta_time])
         self.epoch += delta_time
         self.r[0:2] = flow['y'][-1][0:2]
         self.v[0:2] = flow['y'][-1][2:4]
     elif self.eom == 'P2B_varEqns':
         from utilities import rv2ic
         from flow import P2B
         ic = rv2ic(self.r[0:2], self.v[0:2], self.Mu, STM = True)
         flow = P2B(ic, [0, delta_time], eom = 'P2BP_varEqns')
         self.epoch += delta_time
         self.r[0:2] = flow['y'][-1][0:2]
         self.v[0:2] = flow['y'][-1][2:4]
         self.STM = flow['y'][-1][5:]
     elif self.eom == 'S2B':
         from utilities import rv2ic
         from flow import S2B
         ic = rv2ic(self.r, self.v, self.Mu, STM = False)
         flow = S2B(ic, [0, delta_time])
         self.epoch += delta_time
         self.r = flow['y'][-1][0:3]
         self.v = flow['y'][-1][3:6]
     elif self.eom == 'S2B_varEqns':
         from utilities import rv2ic
         from flow import S2B
         ic = rv2ic(self.r, self.v, self.Mu, STM = True)
         flow = S2B(ic, [0, delta_time], tstep = delta_time/1E3, \
                    eom = 'S2BP_varEqns')
         self.epoch += delta_time
         self.r = flow['y'][-1][0:3]
         self.v = flow['y'][-1][3:6]
         self.STM = flow['y'][-1][6:]
     #  save the r, v and t history when not using 'keplerian'
     if self.eom != 'keplerian':
         n = len(self.r)
         from utilities import extract_elements
         extract_elements(flow['y'], 0, n - 1, self.r_history)
         extract_elements(flow['y'], n, 2*n - 1, self.v_history)
         self.t_history = flow['x']
         if SaveFlow: self.theflow = flow
Пример #2
0
 def transfer(self, target_position, target_velocity, flight_time = None, \
              r_history = None, v_history = None, t_history = None, \
              Minimize_Energy = False, SaveFlow = False):
     #  giving lists to r_history, v_history and t_history arguments will
     #+ populate them with the r, v state and time histories
     #  given export_flow will store the entire flow in export_flow
     #  Minimize_Energy = True will override 'flight_time' with the
     #  minimum energy time of flight given from lambert
     from utilities import rv2ic
     from shootingmodule import firstorder as shoot
     #  if no flight_time is given,
     #+ hopefully the user has switched on Minimize_Energy
     if flight_time == None: flight_time = 0.0
     #  create the initial conditions vector
     #  select an appropriate eom model that includes the
     #+ variational equations
     if len(target_position) == 2:
         ic = rv2ic(self.r[0:2], self.v[0:2], self.Mu, STM = True)
         temp_eom = 'P2BP_varEqns'
     elif len(target_position) == 3:
         ic = rv2ic(self.r, self.v, self.Mu, STM = True)
         temp_eom = 'S2BP_varEqns'
     #  Override 'flight_time' if Minimize_Energy = True
     if Minimize_Energy:
         from utilities import create_one_list
         from lambert   import prussing_conway
         from numpy     import array
         ic0 = create_one_list([self.r, self.v], 0, 1)
         icf = create_one_list([target_position, target_velocity], 0, 1)
         #  find the minimum time for a lambert solution
         lambert_solution = prussing_conway(ic0, icf, self.Mu, \
                                            FindMinEnergy = True, \
                                            NonDimUnits = False, \
                                            ScaleOutput = False)
         time_for_min_energy = lambert_solution['tm']
         #  use the minimum time as a flight time to compute
         #+ the lambert solution
         lambert_solution = prussing_conway(ic0, icf, self.Mu, \
                                            TransferTime = time_for_min_energy, \
                                            NonDimUnits = False, \
                                            ScaleOutput = False)
         #  calculate the delta-v
         dv1_guess = list(lambert_solution['v1'] - array(ic0[2:4]))
         dv1_guess.append(0.0)
         flight_time = lambert_solution['time']
     else:
         dv1_guess = None
     #  apply the first order shooting method
     trajectory = shoot(ic, target_position, [0, flight_time], temp_eom, \
                        tol = 1E-2, iLimit = 60, \
                        damping = 0.3, guess = dv1_guess, \
                        print_status = True)
     #  store the delta-v impulsive maneuvers needed
     #+ for the given transfer
     if len(target_position) == 2:
         self.dv1 = trajectory['y'][0][2:4] - self.v
         self.dv2 = target_velocity - trajectory['y'][-1][2:4]
     elif len(target_position) == 3:
         self.dv1 = trajectory['y'][0][3:6] - self.v
         self.dv2 = target_velocity - trajectory['y'][-1][3:6]
     #  save trajectory states if desired
     from utilities import extract_elements
     n = len(target_position)
     if r_history != None:
         extract_elements(trajectory['y'], 0, n - 1, r_history)
     else:
         extract_elements(trajectory['y'], 0, n - 1, self.r_history)
     if v_history != None:
         extract_elements(trajectory['y'], n, 2*n - 1, v_history)
     else:
         extract_elements(trajectory['y'], n, 2*n - 1, self.v_history)
     #  save the time history of the trajectory
     if t_history != None:
         t_history = trajectory['x']
     else:
         self.t_history = trajectory['x']
     #  if the user wants the entire flow history,
     #+ give it to them!
     if SaveFlow:
         self.theflow = trajectory