# Path: proptools/nozzle.py
# def thrust_coef(p_c, p_e, gamma, p_a=None, er=None):
# def c_star(gamma, m_molar, T_c):
# def er_from_p(p_c, p_e, gamma):
# def pressure_from_er(er, gamma):
# def throat_area(m_dot, p_c, T_c, gamma, m_molar):
# def mass_flow(A_t, p_c, T_c, gamma, m_molar):
# def thrust(A_t, p_c, p_e, gamma, p_a=None, er=None):
# def mach_from_er(er, gamma):
# def mach_from_pr(p_c, p_e, gamma):
# def is_choked(p_c, p_e, gamma):
# def mach_from_area_subsonic(area_ratio, gamma):
# def area_from_mach(M, gamma):
#     C_F = (2 * gamma**2 / (gamma - 1) \
#         * (2 / (gamma + 1))**((gamma + 1) / (gamma - 1)) \
#         * (1 - (p_e / p_c)**((gamma - 1) / gamma))
#           )**0.5
#     R = R_univ / m_molar
#     X = np.zeros((n,))
#     M = np.zeros((n,))
#     B = (y+1)/(y-1)
#     X[0] = (u*k)**(B/(1-B))
#     M[0] = X[0]
#     P = 2 / (gamma + 1)
#     Q = 1 - P
#     E = 1 / Q
#     R = area_ratio**2
#     X = fsolve(
#         lambda X: (P + Q * X)**E - R * X,
#         X_init
#         )


from scipy.integrate import cumtrapz
from proptools import nozzle
    Arguments:
        A_b (list): Burn area at each step [units: meter**-2].
        x (list): flame front progress distance at each step [units: meter].
        A_t (scalar): Nozzle throat area [units: meter**2].
        A_e (scalar): Nozzle exit area [units: meter**2].
        p_a (scalar): Ambient pressure during motor firing [units: pascal].
        a (scalar): Propellant burn rate coefficient [units: meter second**-1 pascal**-n].
        n (scalar): Propellant burn rate exponent [units: none].
        rho_solid (scalar): Solid propellant density [units: kilogram meter**-3].
        c_star (scalar): Propellant combustion characteristic velocity [units: meter second**-1].
        gamma (scalar): Exhaust gas ratio of specific heats [units: dimensionless].

    Returns:
        tuple: tuple containing:

            t (list): time at each step [units: second].

            p_c (list): Chamber pressure at each step [units: pascal].

            F (list): Thrust at each step [units: newton].
    """
    # Compute chamber pressure and exit pressure each flame progress distance x
    # [units: pascal].
    p_c = chamber_pressure(A_b / A_t, a, n, rho_solid, c_star)
    p_e = p_c * nozzle.pressure_from_er(A_e / A_t, gamma)

    # Compute the burn rate for each flame progress distance x [units: meter second**-1]
    r = a * p_c**n

    # Compute the thrust for each flame progress distance x [units: newton]

# Path: proptools/nozzle.py
# def thrust_coef(p_c, p_e, gamma, p_a=None, er=None):
# def c_star(gamma, m_molar, T_c):
# def er_from_p(p_c, p_e, gamma):
# def pressure_from_er(er, gamma):
# def throat_area(m_dot, p_c, T_c, gamma, m_molar):
# def mass_flow(A_t, p_c, T_c, gamma, m_molar):
# def thrust(A_t, p_c, p_e, gamma, p_a=None, er=None):
# def mach_from_er(er, gamma):
# def mach_from_pr(p_c, p_e, gamma):
# def is_choked(p_c, p_e, gamma):
# def mach_from_area_subsonic(area_ratio, gamma):
# def area_from_mach(M, gamma):
#     C_F = (2 * gamma**2 / (gamma - 1) \
#         * (2 / (gamma + 1))**((gamma + 1) / (gamma - 1)) \
#         * (1 - (p_e / p_c)**((gamma - 1) / gamma))
#           )**0.5
#     R = R_univ / m_molar
#     X = np.zeros((n,))
#     M = np.zeros((n,))
#     B = (y+1)/(y-1)
#     X[0] = (u*k)**(B/(1-B))
#     M[0] = X[0]
#     P = 2 / (gamma + 1)
#     Q = 1 - P
#     E = 1 / Q
#     R = area_ratio**2
#     X = fsolve(
#         lambda X: (P + Q * X)**E - R * X,
#         X_init
#         )


# Path: proptools/solid.py
from scipy.integrate import cumtrapz
from proptools import nozzle

    Arguments:
        A_b (list): Burn area at each step [units: meter**-2].
        x (list): flame front progress distance at each step [units: meter].
        A_t (scalar): Nozzle throat area [units: meter**2].
        A_e (scalar): Nozzle exit area [units: meter**2].
        p_a (scalar): Ambient pressure during motor firing [units: pascal].
        a (scalar): Propellant burn rate coefficient [units: meter second**-1 pascal**-n].
        n (scalar): Propellant burn rate exponent [units: none].
        rho_solid (scalar): Solid propellant density [units: kilogram meter**-3].
        c_star (scalar): Propellant combustion characteristic velocity [units: meter second**-1].
        gamma (scalar): Exhaust gas ratio of specific heats [units: dimensionless].

    Returns:
        tuple: tuple containing:

            t (list): time at each step [units: second].

            p_c (list): Chamber pressure at each step [units: pascal].

            F (list): Thrust at each step [units: newton].
    """
    # Compute chamber pressure and exit pressure each flame progress distance x
    # [units: pascal].
    p_c = chamber_pressure(A_b / A_t, a, n, rho_solid, c_star)
    p_e = p_c * nozzle.pressure_from_er(A_e / A_t, gamma)

    # Compute the burn rate for each flame progress distance x [units: meter second**-1]
    r = a * p_c**n

    # Compute the thrust for each flame progress distance x [units: newton]

    F = nozzle.thrust(A_t, p_c, p_e, gamma, p_a, A_e / A_t)