def set_coe(self, coe, units = None, rv = True): if units != None: from unit_conversions import converter coe[2] = converter(coe[2], units, 'Radians') coe[3] = converter(coe[3], units, 'Radians') coe[4] = converter(coe[4], units, 'Radians') coe[5] = converter(coe[5], units, 'Radians') # reset coe self.sma = coe[0] self.e = coe[1] self.i = coe[2] self.RAAN = coe[3] self.AOP = coe[4] self.f = coe[5] self.coe = [self.sma, self.e, self.i, self.RAAN, \ self.AOP, self.f] # reset r, v if rv: from auxiliary import coe2rv self.r, self.v = coe2rv(self.coe, self.Mu) # recalculate additional useful orbital parameters #+ E: eccentricy anomaly #+ M: mean anomaly #+ T: orbital period #+ n: mean motion from auxiliary import f2E, E2M, orbitalperiod from math import pi self.E = f2E(self.e, self.f) self.M = E2M(self.e, self.E) self.T = orbitalperiod(self.Mu, self.sma) self.n = 2.0*pi / self.T
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
def set_AOP(self, AOP, units = None): if units != None: from unit_conversions import converter AOP = converter(AOP, units, 'Radians') self.AOP = AOP # reset AOP in coe list self.coe[4] = AOP # reset the r and v vectors from auxiliary import coe2rv self.r, self.v = coe2rv(self.coe, self.Mu)
def set_RAAN(self, RAAN, units = None): if units != None: from unit_conversions import converter RAAN = converter(RAAN, units, 'Radians') self.RAAN = RAAN # reset RAAN in coe list self.coe[3] = RAAN # reset the r and v vectors from auxiliary import coe2rv self.r, self.v = coe2rv(self.coe, self.Mu)
def set_i(self, i, units = None): if units != None: from unit_conversions import converter i = converter(i, units, 'Radians') self.i = i # reset i in coe list self.coe[2] = i # reset the r and v vectors from auxiliary import coe2rv self.r, self.v = coe2rv(self.coe, self.Mu)
def set_e(self, e): self.e = e # reset e in coe list self.coe[1] = e # reset the r and v vectors from auxiliary import coe2rv self.r, self.v = coe2rv(self.coe, self.Mu) # reset #+ E: eccentricy anomaly #+ M: mean anomaly from auxiliary import f2E, E2M self.E = f2E(self.e, self.f) self.M = E2M(self.e, self.E)
def set_sma(self, sma): self.sma = sma # reset sma in coe list self.coe[0] = sma # reset the r and v vectors from auxiliary import coe2rv self.r, self.v = coe2rv(self.coe, self.Mu) # reset the orbital period from auxiliary import orbitalperiod self.T = orbitalperiod(self.Mu, self.sma) # reset the mean motion from math import pi self.n = 2.0*pi / self.T
def set_f(self, f, units = None): if units != None: from unit_conversions import converter f = converter(f, units, 'Radians') self.f = f # reset f in coe list self.coe[5] = f # reset the r and v vectors from auxiliary import coe2rv self.r, self.v = coe2rv(self.coe, self.Mu) # reset #+ E: eccentricy anomaly #+ M: mean anomaly from auxiliary import f2E, E2M self.E = f2E(self.e, self.f) self.M = E2M(self.e, self.E)
def set_parameters(self, body, altitude = 400.0): import solarsystem_objects_parameters as ss # setup parameters for the requested body if available # first see if the user is requesting the 'Earth' or #+ if the body is not on the given list, then default #+ to the 'Earth' if body == 'earth' or body not in ss.list: self.name = 'earth' # default classical orbital elements is #+ earth about sun self.sma = ss.earth['SemiMajor'] self.e = ss.earth['Eccentricity'] self.i = ss.earth['Inclination'] self.RAAN = 0.0 self.AOP = 0.0 self.f = 0.0 # epoch (Julian Date), default January 3rd 2014 #+ which is roughly when the Earth is at periapsis self.epoch = 2456660.500000 * 86400.0 # mass and mu of the body self.mass = ss.earth['Mass'] self.mu = ss.earth['Mu'] # radius of body self.radius = ss.earth['Radius'] # set the gravitational constant of 'self' #+ central body self.Mu = ss.sun['Mu'] if body == 'sun': self.name = 'sun' # default classical orbital elements is #+ earth about sun self.sma = 0.0 self.e = 0.0 self.i = 0.0 self.RAAN = 0.0 self.AOP = 0.0 self.f = 0.0 # epoch (Julian Date), default January 3rd 2014 #+ which is roughly when the Earth is at periapsis self.epoch = 2456660.500000 * 86400.0 # mass and mu of the body self.mass = ss.sun['Mass'] self.mu = ss.sun['Mu'] # radius of body self.radius = ss.sun['Radius'] # set the gravitational constant of 'self' #+ central body self.Mu = ss.sun['Mu'] if body == 'moon': self.name = 'moon' # default classical orbital elements is #+ earth about sun self.sma = ss.moon['SemiMajor'] self.e = ss.moon['Eccentricity'] self.i = ss.moon['Inclination'] self.RAAN = 0.0 self.AOP = 0.0 self.f = 0.0 # epoch (Julian Date), default January 3rd 2014 #+ which is roughly when the Earth is at periapsis self.epoch = 2456660.500000 * 86400.0 # mass and mu of the body self.mass = ss.moon['Mass'] self.mu = ss.moon['Mu'] # radius of body self.radius = ss.moon['Radius'] # set the gravitational constant of 'self' #+ central body self.Mu = ss.earth['Mu'] if body == 'mars': self.name = 'mars' # default classical orbital elements is #+ earth about sun self.sma = ss.mars['SemiMajor'] self.e = ss.mars['Eccentricity'] self.i = ss.mars['Inclination'] self.RAAN = 0.0 self.AOP = 0.0 self.f = 0.0 # epoch (Julian Date), default January 3rd 2014 #+ which is roughly when the Earth is at periapsis self.epoch = 2456660.500000 * 86400.0 # mass and mu of the body self.mass = ss.mars['Mass'] self.mu = ss.mars['Mu'] # radius of body self.radius = ss.mars['Radius'] # set the gravitational constant of 'self' #+ central body self.Mu = ss.sun['Mu'] if body == 'LEO': self.name = 'leo_spacecraft' # default classical orbital elements is #+ spacecraft about earth from math import pi self.sma = ss.earth['Radius'] + altitude self.e = 0.0 self.i = 28.5 * pi / 180.0 self.RAAN = 0.0 self.AOP = 0.0 self.f = 0.0 # epoch (Julian Date), default January 3rd 2014 #+ which is roughly when the Earth is at periapsis self.epoch = 2456660.500000 * 86400.0 # mass and mu of the body self.mass = 1000.0 self.mu = 0.0 # set the gravitational constant of 'self' #+ central body self.Mu = ss.earth['Mu'] # place the classical orbital elements into an array self.coe = [self.sma, self.e, self.i, self.RAAN, \ self.AOP, self.f] # calculate the r, v vectors for 'self' #+ based on the classical orbital elements 'coe' from auxiliary import coe2rv self.r, self.v = coe2rv(self.coe, self.Mu) # calculate additional useful orbital parameters #+ E: eccentricy anomaly #+ M: mean anomaly #+ T: orbital period #+ n: mean motion from auxiliary import f2E, E2M, orbitalperiod from math import pi self.E = f2E(self.e, self.f) self.M = E2M(self.e, self.E) self.T = orbitalperiod(self.Mu, self.sma) self.n = 2.0*pi / self.T