def create_node_from_list(self, t_list, ind_list): """Returns a node, using the t_list and ind_list to specify the path. Args: t_list (list): Epochs (MJD) of depart/approach. ind_list (list): Indices of the asteroids to approach or depart from Returns: Node: Node that contains the full history of the path. """ # create the initial orbit: initial = Orbit(name='Initial', index=ind_list[0]) rv = select_asteroid(ind_list[0]).rv(t_list[0]) initial.from_rv(t_list[0], *rv) # create the initial node: node = Node(t_list[0], index=ind_list[0], approach_orbit=initial, parent=None) # create all the legs: for t, ind in zip(t_list[1:], ind_list[1:]): node = node.create_next_node(target_ind=ind, target_epoch=t) return node
def create_next_node(self, target_ind, target_epoch): """Function creates next node to be visited by solving Lambert, updating current sc mass Args: target_ind (int): next asteroid to be visited target_epoch (float): epoch at which next asteroid is to be visited [MJD] Returns: (node): node object of input asteroid to be visited at input epoch """ t0 = self.epoch r0, v0 = self.approach_orbit.rv() # find next ast and get its position (vel not needed) ast = select_asteroid(target_ind) r_target, v_target = ast.rv(target_epoch) # solve lamberts problem v1, v2 = lb.lambert(mu, r0, r_target, (target_epoch - t0) * day2s) # note that a maneouver is needed at the initial epoch to set us on a rendevousz path with target ast dv = v1 - v0 # only the initial change in velocity needed #incrememental cost (delta V, mass) if self.parent_node is None: # starting at earth inc_cost = max(0, norm(dv) - 4.0) # call mass_at_node to compute remaining mass after maneuver #m_node = mass_at_node(1500, inc_cost) # FIXME - SAYS THAT mass_at_node() is not defined... else: inc_cost = norm(dv) # call mass_at_node? # create new orbit, index=-2 since it is a transfer o_new = Orbit(name=f'Trx{self.len_of_chain()+1:2.0f}') o_new.from_rv(target_epoch, r_target, v2) # create new node new_Node = Node(epoch=target_epoch, index=target_ind, approach_orbit=o_new, parent=self) # update cost and manouever history new_Node.maneuvers = self.maneuvers + [(t0, dv)] new_Node.cost = self.cost + inc_cost return new_Node