def test_orbit_lowfidelity(self): np.random.seed(1234) sat_params = system.setup() n = 10000 x = utils.mvn(['H', 'phi'], n) qoi = orbit(x, sat_params, fidelity=0) qoi_means_true = np.array( [4045.81892, 37913.0974, 3191.54502, 1.30984041e-5]) qoi_means = np.mean(qoi, axis=1) for i, q in enumerate(qoi_means): npt.assert_approx_equal(q, qoi_means_true[i])
def test_orbit_medfidelity(self): np.random.seed(1234) sat_params = system.setup() n = 10 x = utils.mvn(['H', 'phi'], n) qoi = orbit(x, sat_params, fidelity=1) qoi_means = np.mean(qoi, axis=1) qoi_means_true = np.array( [3999.73915, 39189.6937, 6291.00484, 1.23764331e-5]) for i, q in enumerate(qoi_means): npt.assert_approx_equal(q, qoi_means_true[i])
def run(x, **kwargs): """Run full coupled fire satellite multiphysics problem Parameters ---------- x : np.ndarray (7, n) Input design vars x[0] = H x[1] = phi x[2] = Po x[3] = F_s x[4] = L_sp x[5] = q x[6] = L_a x[7] = C_d **kwargs : Optional keyword arguments usehifi = (True, FALSE) select hifidelity calculations var_info = firesat.setup(), dictionary containing fixed parameters feedforward = (TRUE, False) select feedforward or feedback implementation Returns ------- q : np.ndarray (3, n) Quantities of interest for system q[0] = P_tot q[1] = A_sa q[2] = tau_tot """ # Get optional arguments usehifi = kwargs.get("hifi", False) # use hifi calculations sat_params = kwargs.get("var_info", setup()) # fixed parameters feedforward = kwargs.get("feedforward", True) debug = kwargs.get("debug") # Compute orbit discipline x_orb = x[[0, 1]] q_orb = firesat.orbit(x_orb, sat_params) if feedforward: # Feed-forward implementation of Fire Satellite problem # Compute attitude control discipline x_atd = np.vstack((x[[0, 3, 4, 5, 6, 7]])) # H, F_s, L_sp, q, L_a, C_d y_atd = np.vstack((q_orb[[0, 1, 3]])) # v, dt_orbit, theta_slew q_atd = firesat.attitude(x_atd, y_atd, sat_params) # Compute power discipline x_pow = x[[2, 3]] # Po, F_s y_pow = np.vstack((q_atd[1], q_orb[[1, 2]])) # PACS, dt_orbit, dt_eclipse q_pow = firesat.power(x_pow, y_pow, sat_params, usehifi=usehifi) else: # Feedback coupling not implemented yet raise NotImplementedError if debug: print("\n") cplvars = { "PACS": q_atd[1], "dt_orbit": q_orb[1], "dt_eclipse": q_orb[2], "theta_slew": q_orb[3], "v": q_orb[0], } for var, vals in cplvars.items(): print( f"{var:12s} min={vals.min():17.10f} max={vals.max():17.10f}") n = x.shape[1] # number of samples q = np.zeros((3, n)) q[0] = q_pow[0] q[1] = q_pow[1] q[2] = q_atd[0] return q
def prof_orbit(): orbit(x, sat_params)
x = utils.mvn(['H', 'phi'], n) def prof_orbit(): orbit(x, sat_params) if __name__ == "__main__": import cProfile np.random.seed(1234) sat_params = system.setup() n = 100 x = utils.mvn(['H', 'phi'], n) # print(x) pf = cProfile.Profile() pf.enable() orbit(x, sat_params, fidelity=1) pf.disable() pf.dump_stats('orbit_prof_cython.pf') # T = Test_Orbit() # T.test_orbit_medfidelity() # suite = unittest.TestSuite() # loader = unittest.TestLoader() # tests = loader.loadTestsFromTestCase(Test_Orbit) # suite.addTests(tests) # unittest.TextTestRunner(verbosity=2).run(suite)