def getQoIParams(params): paramsQ = Params() paramsQ.CD = params.CD paramsQ.BC = params.BC paramsQ.m = params.m paramsQ.efpaWR = params.efpaWR paramsQ.vmagWR = params.vmagWR paramsQ.atmdat = params.atmdat return paramsQ
def getQoIParams(params): paramsQ = Params() paramsQ.CD = params.CD paramsQ.BC = params.BC paramsQ.m = params.m paramsQ.efpaWR = params.efpaWR paramsQ.vmagWR = params.vmagWR paramsQ.m_Y = params.m_Y paramsQ.CD_Y = params.CD_Y paramsQ.efpa_Y = params.efpa_Y paramsQ.vmag_Y = params.vmag_Y paramsQ.atm_Ys = params.atm_Ys return paramsQ
### CREATE params INPUT CLASS params = Params() params.p = constants.MARS params.returnTimeVectors = True params.atmMod = 'nom' ### INPUT ATM TABLE - GET ATM TABLE FROM GRAM DATA FILE params.dMode = 'table' filename = '../data/dens_Mars_nom.txt' atmdata = np.genfromtxt(filename, names=True) params.atmdat = np.array([atmdata['Var_X'], atmdata['DENSAV']]) ### VEHICLE PARAMS (NOT CHANGED DURING GRID SEARCH) params.m = 2920 # kg, roughly MSL mass params.CD = 1.6 # roughly MSL CD params.BC = 10 # kg/m^2 params.LD = 0 params.bank = 0 # value doesn't matter since L/D = 0 ### WIND-RELATIVE INITIAL STATE (COMPONENTS NOT CHANGED DURING GRID SEARCH) params.inputType = 'wind-relative angles' params.lat = 18.38 params.lon = -77.58 params.alt = params.p.halt params.efpaWR = -12 params.hdaWR = 0 params.vmagWR = 6 ### SET DEFAULT SEPARATION DELTA-V AND TIMING DVnom = 1e-4 # km/s tbacknom = 1 * 24 * 60 * 60 # s
### CREATE params INPUT CLASS FOR NOMINAL VALUES paramsNom = Params() paramsNom.p = constants.MARS paramsNom.returnTimeVectors = True ### INPUT ATM TABLE - GET ATM TABLE FROM GRAM DATA FILE paramsNom.dMode = 'table' filename = '../data/dens_Mars_nom.txt' atmdata = np.genfromtxt(filename, names=True) paramsNom.atmdat = np.array([atmdata['Var_X'], atmdata['DENSAV']]) ### VEHICLE PARAMS paramsNom.m = 2920 # kg, roughly MSL mass paramsNom.CD = 1.6 # roughly MSL CD paramsNom.LD = 0.25 paramsNom.BC = 130 paramsNom.A = paramsNom.m / (paramsNom.BC * paramsNom.CD) paramsNom.CL = paramsNom.CD * paramsNom.LD paramsNom.Rn = np.sqrt(paramsNom.A / np.pi) / 2 ### WIND-RELATIVE INITIAL STATE paramsNom.lat = 18.38 paramsNom.lon = -77.58 paramsNom.alt = paramsNom.p.halt paramsNom.efpaWR = -12 paramsNom.hdaWR = 0 paramsNom.vmagWR = 6 ### GET OTHER STATE TYPES (and assume t0 = 0) paramsNom.x0, paramsNom.vInfvec_N = LLAEHV2RV(paramsNom.lat, paramsNom.lon,
# exit conditions: params.hmin = 30 params.hmax = params.p.halt + 1e-7 + 10 event1 = lambda t, y: ODEs.below_min_alt(t, y, params) event1.terminal = True event2 = lambda t, y: ODEs.above_max_alt(t, y, params) event2.terminal = True events = (event1, event2) ### SINGLE RUN params.efpaWR = -6 params.BC = 50 outs = Outs() outs = mainAD(params, tspan, events, outs) print(outs.fpaf) print(outs.engf) ### PLOTS alt = np.linalg.norm(outs.rvec_N, axis=0) - params.p.rad #/1e3 vmag = np.linalg.norm(outs.vvec_N, axis=0) fig = plt.figure(1) ax = fig.add_subplot(111) ax.plot(vmag, alt) ax.set_xlabel('Inertial velocity, km/s') ax.set_ylabel('Altitude, km')
# ============================================================================= # Monte Carlo trials # ============================================================================= paramsList = [] outsList = [] outname = './results/' + params.p.name + '_' + str(Nmc) + '_' + datestring for i_trial in range(Nmc): # generate input realizations params.efpaWR = norm.rvs(size=1, loc=efpanom, scale=efpa_sig)[0] params.vmagWR = norm.rvs(size=1, loc=vmagnom, scale=vmag_sig)[0] params.CD = uniform.rvs(size=1, loc=CD_LB, scale=2 * (CD_UB - CDnom))[0] params.m = uniform.rvs(size=1, loc=m_LB, scale=2 * (m_UB - mnom))[0] params.BC = params.m / (params.CD * Anom) # get atmosphere table for this trial params.atmdat = np.array([h, densAll[:, i_trial]]) params.atmdat = params.atmdat[:, params.atmdat[0, :].argsort()] # run sim print('\nTrial {}'.format(i_trial + 1)) outs = Outs() outsList.append(mainAD(params, tspan, events, outs)) paramsList.append(getQoIParams(params)) # every 50 trials, save all results to a file if not i_trial % 50: ## Save results to a file
# paramsNom.p.om = 0 paramsNom.returnTimeVectors = True ### INPUT ATM TABLE - GET ATM TABLE FROM GRAM DATA FILE paramsNom.dMode = 'table' filename = '../data/dens_Mars_nom.txt' atmdata = np.genfromtxt(filename, names=True) paramsNom.atmdat = np.array([atmdata['Var_X'], atmdata['DENSAV']]) ### VEHICLE PARAMS paramsNom.m = 2920 # kg, roughly MSL mass paramsNom.CD = 1.6 # roughly MSL CD # paramsNom.LD = 0.25 paramsNom.LD = 0 # paramsNom.BC = 130 paramsNom.BC = 35 paramsNom.A = paramsNom.m / (paramsNom.BC * paramsNom.CD) paramsNom.CL = paramsNom.CD * paramsNom.LD paramsNom.Rn = np.sqrt(paramsNom.A / np.pi) / 2 ### WIND-RELATIVE INITIAL STATE paramsNom.lat = 18.38 paramsNom.lon = -77.58 paramsNom.alt = paramsNom.p.halt paramsNom.efpaWR = -12 paramsNom.hdaWR = 0 paramsNom.vmagWR = 6 ### GET OTHER STATE TYPES (and assume t0 = 0) paramsNom.x0, paramsNom.vInfvec_N = LLAEHV2RV(paramsNom.lat, paramsNom.lon,
# ============================================================================= # Load atm table for this run # ============================================================================= i_trial = 0 params.atmdat = np.array([h,densAll[:,i_trial]]) # make sure atmdata is sorted by ascending altitude params.atmdat = params.atmdat[:,params.atmdat[0,:].argsort()] # ============================================================================= # Set vehicle params # ============================================================================= params.m = 3000 # kg params.CD = 1.59 params.LD = 0 # L/D = 0 --> CL= 0 params.BC = 120 # kg/m^2 # ============================================================================= # Wind-Relative initial state # ============================================================================= params.inputType = 'wind-relative angles' params.lat = 0 params.lon = 0 params.alt = params.p.halt params.efpaWR = -10.5 params.hdaWR = 0 params.vmagWR = 6 # km/s # ============================================================================= # Control state # =============================================================================
paramsNom_O.atol = 1e-10 paramsNom_O.errtol1 = 0 paramsNom_O.errtol2 = 0 paramsNom_O.dtGdn = 1 # s paramsNom_O.hmin = 3 paramsNom_O.hmax = paramsNom_O.p.halt + 1e-7 paramsNom_O.tf = 6000 # copy generic params for probe and ballistic probe paramsNom_P = copy.deepcopy(paramsNom_O) # ============================================================================= # Orbiter Setup # ============================================================================= # vehicle paramsNom_O.BC = 130 paramsNom_O.A = paramsNom_O.m / (paramsNom_O.BC * paramsNom_O.CD) paramsNom_O.CL = paramsNom_O.CD * paramsNom_O.LD paramsNom_O.Rn = np.sqrt(paramsNom_O.A / np.pi) / 2 # search brackets for Brent's Method paramsNom_O.sig1 = 0 paramsNom_O.sig2 = 180 paramsNom_O.ts1 = 1 paramsNom_O.ts2 = 300 # target state paramsNom_O.raStar = (250 + paramsNom_O.p.rad) * 1e3 paramsNom_O.rpStar = (250 + paramsNom_O.p.rad) * 1e3 # nominal simulation values
# exit conditions: params.hmin = 10 params.hmax = params.p.halt + 1e-7 event1 = lambda t, y: ODEs.below_min_alt(t, y, params) event1.terminal = True event2 = lambda t, y: ODEs.above_max_alt(t, y, params) event2.terminal = True events = (event1, event2) ### SINGLE RUN params.efpaWR = -12 params.BC = 130 ### SIMULATE ORBITER outsOrbiter = Outs() outsOrbiter = mainAD(params, tspan, events, outsOrbiter) print('\nORBITER:') print('Final energy: {:.3f} km^2/s^2'.format(outsOrbiter.engf)) print('Apoapsis altitude: {:.3f} km'.format(outsOrbiter.haf)) print('Bank angle set to {:.1f} deg\n'.format(params.bank)) ### SIMULATE PROBE params.LD = 0 params.BC = 35 outsProbe = Outs() outsProbe = mainAD(params, tspan, events, outsProbe) print('\nPROBE:')