export g₀, rocket_thrust, mass_flow
# These are equations related to rocketry from Tsiolkovsky rocket equation
#  https://en.wikipedia.org/wiki/Tsiolkovsky_rocket_equation

const global g₀ = 9.80665 # Acceleration of gravity on earth in m/s²

"""
    rocket_thrust(Isp, mass_flow)

Calculate the thrust generated by a rocket engine with specific impulse of `Isp` and
mass flow of `mass_flow`. Specific impulse says something about efficiency of engine:
how much force you get out of one unit of propellant.
"""
rocket_thrust(Isp::Number, mass_flow::Number) = g₀ * Isp * mass_flow

"""
    mass_flow(thrust, Isp)
Get mass flow in Kg/s of propellant for an engine with given `thrust` and specific impulse `Isp`.

## Example

```@example    
# Calculating mass flow for a Falcon 9 rocket.

engine_thrust = 0.845e6            # Newton
Isp           = 282                # Specific impulse in seconds
thrust  = engine_thrust * 9        # There are 9 merlin engines on Falcon 9
mflow1  = mass_flow(thrust, Isp)   # Total mass flow in rocket. Kg/s

# Should get similar result from using burn time and total propellant
burn_time = 162          # Number of seconds first stage engines will burn
propellant_mass = 395700 # About 400 tons
mflow2 = propellant_mass / burn_time 
```
"""
mass_flow(thrust::Number, Isp::Number) = thrust / (Isp * g₀)