34 """Flat mdot, constant exhaust velocity, constant Cd, 1976 atmosphere: impulse to apogee h."""
35 fluids = pytest.importorskip(
"fluids.atmosphere")
36 from scipy.integrate
import solve_ivp
43 atm = fluids.ATMOSPHERE_1976(elev +
max(z, 0.0))
44 T = c * md
if t < tb
else 0.0
45 return [v, (T - 0.5 * atm.rho * v * abs(v) * cd * area) / m - G0, -md
if t < tb
else 0.0]
47 burn = solve_ivp(rhs, (0, tb), [0, 0, m0], max_step=0.005, rtol=1e-10, atol=1e-9)
48 top =
lambda t, y: y[1]
49 top.terminal, top.direction =
True, -1
50 coast = solve_ivp(rhs, (tb, 400), burn.y[:, -1], events=top, max_step=0.05, rtol=1e-10, atol=1e-9)
51 return coast.y_events[0][0][0]
53 return brentq(
lambda c: apogee(c) - h, 500.0, 6000.0, xtol=1e-4) * mp
57 I = calculate_required_impulse_from_mass(3890.7, 81.647 - 11.015, 11.015, 3.8978)
58 assert I == pytest.approx(
_sutton_impulse(81.647, 11.015, 3.8978, 3890.7), rel=1e-4)
59 assert I == pytest.approx(22537.0, rel=5e-3)
62@pytest.mark.parametrize("m_dry,mp,tb,h", [(70.632, 11.015, 3.8978, 3890.7), (40.0, 40.0, 15.0, 9000.0)])
66 area, elev = math.pi * 0.078359**2, 626.67
67 const = DragCurves((0.0, 5.0), (0.45, 0.45), (0.45, 0.45),
"table",
"constant 0.45")
68 vehicle = {
"flight": {
"area_m2": area,
"drag": const,
"elevation_m": elev},
"gas_on_board_kg": 0.0}
69 I = calculate_required_impulse_from_mass(h, m_dry, mp, tb, vehicle=vehicle)
70 assert I == pytest.approx(
_ivp_impulse(m_dry + mp, mp, tb, h, 0.45, area, elev), rel=2e-3)
74 base = calculate_required_impulse_from_mass(3890.7, 69.320, 11.015, 3.8978)
75 gas = calculate_required_impulse_from_mass(3890.7, 69.320, 11.015, 3.8978, vehicle={
"gas_on_board_kg": 1.312})
76 assert gas == pytest.approx(
_sutton_impulse(69.320 + 1.312 + 11.015, 11.015, 3.8978, 3890.7), rel=1e-4)
81 """The same curve, drag and pad: the 1-DOF apogee and RocketPy's within 1 %."""
82 pytest.importorskip(
"rocketpy")
85 from flight_cases
import fly, header_curve, shipped
89 vehicle = layer2_flight_vehicle(cfg)
90 t, F, mO, mF = header_curve()
91 h = vertical_apogee_agl(t, F, mO + mF, res[
"flight_report"][
"wet_mass_kg"], **vehicle[
"flight"])
92 assert h == pytest.approx(res[
"apogee"], rel=0.01)
93 assert vehicle[
"gas_on_board_kg"] == pytest.approx(cfg.press_tank.initial_gas_mass)