# Path: proptools/solid.py
# def chamber_pressure(K, a, n, rho_solid, c_star):
# def burn_area_ratio(p_c, a, n, rho_solid, c_star):
# def burn_and_throat_area(F, p_c, p_e, a, n, rho_solid, c_star, gamma):
# def thrust_curve(A_b, x, A_t, A_e, p_a, a, n, rho_solid, c_star, gamma):
#     C_F = nozzle.thrust_coef(p_c, p_e, gamma)
#     F = nozzle.thrust(A_t, p_c, p_e, gamma, p_a, A_e / A_t)


from matplotlib import pyplot as plt
from proptools import solid
import numpy as np
"""Plot the thrust curve of a solid rocket motor with a cylindrical propellant grain."""



# Grain geometry (Clinder with circular port)
r_in = 0.15    # Grain inner radius [units: meter].
r_out = 0.20    # Grain outer radius [units: meter].
length = 1.0    # Grain length [units: meter].

# Propellant properties
gamma = 1.26    # Exhaust gas ratio of specific heats [units: dimensionless].
rho_solid = 1510.    # Solid propellant density [units: kilogram meter**-3].
n = 0.5    # Propellant burn rate exponent [units: dimensionless].
a = 2.54e-3 * (6.9e6)**(-n)    # Burn rate coefficient, such that the propellant
# burns at 2.54 mm s**-1 at 6.9 MPa [units: meter second**-1 pascal**-n].
c_star = 1209.    # Characteristic velocity [units: meter second**-1].

# Nozzle geometry
A_t = 839e-6    # Throat area [units: meter**2].
A_e = 8 * A_t    # Exit area [units: meter**2].
p_a = 101e3    # Ambeint pressure during motor firing [units: pascal].

# Burning surface evolution
x = np.linspace(0, r_out - r_in)    # Flame front progress steps [units: meter].
A_b = 2 * np.pi * (r_in + x) * length    # Burn area at each flame progress step [units: meter**2].

# Compute thrust curve.

# Path: proptools/solid.py
# def chamber_pressure(K, a, n, rho_solid, c_star):
# def burn_area_ratio(p_c, a, n, rho_solid, c_star):
# def burn_and_throat_area(F, p_c, p_e, a, n, rho_solid, c_star, gamma):
# def thrust_curve(A_b, x, A_t, A_e, p_a, a, n, rho_solid, c_star, gamma):
#     C_F = nozzle.thrust_coef(p_c, p_e, gamma)
#     F = nozzle.thrust(A_t, p_c, p_e, gamma, p_a, A_e / A_t)


# Path: docs/source/examples/solid/plots/thrust_curve.py
from matplotlib import pyplot as plt
from proptools import solid
import numpy as np

"""Plot the thrust curve of a solid rocket motor with a cylindrical propellant grain."""



# Grain geometry (Clinder with circular port)
r_in = 0.15    # Grain inner radius [units: meter].
r_out = 0.20    # Grain outer radius [units: meter].
length = 1.0    # Grain length [units: meter].

# Propellant properties
gamma = 1.26    # Exhaust gas ratio of specific heats [units: dimensionless].
rho_solid = 1510.    # Solid propellant density [units: kilogram meter**-3].
n = 0.5    # Propellant burn rate exponent [units: dimensionless].
a = 2.54e-3 * (6.9e6)**(-n)    # Burn rate coefficient, such that the propellant
# burns at 2.54 mm s**-1 at 6.9 MPa [units: meter second**-1 pascal**-n].
c_star = 1209.    # Characteristic velocity [units: meter second**-1].

# Nozzle geometry
A_t = 839e-6    # Throat area [units: meter**2].
A_e = 8 * A_t    # Exit area [units: meter**2].
p_a = 101e3    # Ambeint pressure during motor firing [units: pascal].

# Burning surface evolution
x = np.linspace(0, r_out - r_in)    # Flame front progress steps [units: meter].
A_b = 2 * np.pi * (r_in + x) * length    # Burn area at each flame progress step [units: meter**2].

# Compute thrust curve.

t, p_c, F = solid.thrust_curve(A_b, x, A_t, A_e, p_a, a, n, rho_solid, c_star, gamma)