# ============================================================================= ### 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
# Script # ============================================================================= ### 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
atmdata.sort(order='Hgtkm') # put in ascending altitude order params.atmdat = np.array([atmdata['Hgtkm'], atmdata['DensMean']]) # alter altitude if requested if params.atmMod == 'nom': pass elif params.atmMod == '20% high': params.atmdat[1, :] = 1.2 * params.atmdat[1, :] elif params.atmMod == '20% low': params.atmdat[1, :] = 0.8 * params.atmdat[1, :] else: sys.exit('atmMod not recognized') ### VEHICLE PARAMS (NOT CHANGED DURING GRID SEARCH) params.m = 2920 # kg, roughly MSL mass params.CD = params.m / (115 * np.pi * (4.5 / 2)**2) # roughly MSL CD params.LD = 0.25 ### WIND-RELATIVE INITIAL STATE (COMPONENTS NOT CHANGED DURING GRID SEARCH) params.inputType = 'wind-relative angles' params.lat = 40 params.lon = 100 params.alt = params.p.halt params.hdaWR = 0 params.vmagWR = 11 ### CONTROL STATE params.bank = 40 # deg ### TIME VECTOR AND EXIT CONDITIONS
events = (event1, event2) # ============================================================================= # 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:
params.dMode = 'table' # ============================================================================= # 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 # =============================================================================
outname = './results/' + params.p.name + '_' + str(Nmc) + '_' + datestring for i_trial in range(Nmc): # generate density function for this trial params.dFun, params.atm_Ys = getKLEdensfun(evals, evecs, densSampMean, d, h) # generate input realizations params.efpa_Y = norm.rvs(size = 1).item(0) params.efpaWR = efpamean + efpastd * params.efpa_Y params.vmag_Y = norm.rvs(size = 1).item(0) params.vmagWR = vmagmean + vmagstd * params.vmag_Y params.CD_Y = norm.rvs(size = 1).item(0) params.CD = CDmean + CDstd * params.CD_Y params.m_Y = norm.rvs(size = 1).item(0) params.m = mmean + mstd * params.m_Y params.BC = params.m / (params.CD * Anom) params.A = Anom # run sim print('\nTrial {}'.format(i_trial+1)) outs = Outs() outsList.append(mainAD(params, tspan, events, outs)) paramsList.append(getQoIParams(params)) m_YList.append(params.m_Y) CD_YList.append(params.CD_Y)