@interstellar-tools/equations 0.64.2 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/dist/categories/helpers/misc.d.ts +18 -0
  2. package/dist/categories/helpers/misc.d.ts.map +1 -1
  3. package/dist/categories/helpers/misc.js +24 -0
  4. package/dist/categories/helpers/misc.js.map +1 -1
  5. package/dist/categories/manoeuvres/burn-time.d.ts +63 -0
  6. package/dist/categories/manoeuvres/burn-time.d.ts.map +1 -0
  7. package/dist/categories/manoeuvres/burn-time.js +87 -0
  8. package/dist/categories/manoeuvres/burn-time.js.map +1 -0
  9. package/dist/categories/manoeuvres/gravity-loss.d.ts +48 -0
  10. package/dist/categories/manoeuvres/gravity-loss.d.ts.map +1 -0
  11. package/dist/categories/manoeuvres/gravity-loss.js +74 -0
  12. package/dist/categories/manoeuvres/gravity-loss.js.map +1 -0
  13. package/dist/categories/manoeuvres/initial-mass-for-delta-v.d.ts +60 -0
  14. package/dist/categories/manoeuvres/initial-mass-for-delta-v.d.ts.map +1 -0
  15. package/dist/categories/manoeuvres/initial-mass-for-delta-v.js +79 -0
  16. package/dist/categories/manoeuvres/initial-mass-for-delta-v.js.map +1 -0
  17. package/dist/categories/manoeuvres/mass-flow-rate.d.ts +57 -0
  18. package/dist/categories/manoeuvres/mass-flow-rate.d.ts.map +1 -0
  19. package/dist/categories/manoeuvres/mass-flow-rate.js +73 -0
  20. package/dist/categories/manoeuvres/mass-flow-rate.js.map +1 -0
  21. package/dist/categories/manoeuvres/rocket-thrust.d.ts +48 -0
  22. package/dist/categories/manoeuvres/rocket-thrust.d.ts.map +1 -0
  23. package/dist/categories/manoeuvres/rocket-thrust.js +62 -0
  24. package/dist/categories/manoeuvres/rocket-thrust.js.map +1 -0
  25. package/dist/categories/manoeuvres/thrust-to-weight.d.ts +57 -0
  26. package/dist/categories/manoeuvres/thrust-to-weight.d.ts.map +1 -0
  27. package/dist/categories/manoeuvres/thrust-to-weight.js +73 -0
  28. package/dist/categories/manoeuvres/thrust-to-weight.js.map +1 -0
  29. package/dist/categories/orbits/elements-to-state.d.ts +61 -0
  30. package/dist/categories/orbits/elements-to-state.d.ts.map +1 -0
  31. package/dist/categories/orbits/elements-to-state.js +107 -0
  32. package/dist/categories/orbits/elements-to-state.js.map +1 -0
  33. package/dist/categories/orbits/inclination-from-launch-azimuth.d.ts +64 -0
  34. package/dist/categories/orbits/inclination-from-launch-azimuth.d.ts.map +1 -0
  35. package/dist/categories/orbits/inclination-from-launch-azimuth.js +76 -0
  36. package/dist/categories/orbits/inclination-from-launch-azimuth.js.map +1 -0
  37. package/dist/categories/orbits/launch-azimuth-for-inclination.d.ts +71 -0
  38. package/dist/categories/orbits/launch-azimuth-for-inclination.d.ts.map +1 -0
  39. package/dist/categories/orbits/launch-azimuth-for-inclination.js +87 -0
  40. package/dist/categories/orbits/launch-azimuth-for-inclination.js.map +1 -0
  41. package/dist/categories/orbits/rotating-launch-azimuth.d.ts +49 -0
  42. package/dist/categories/orbits/rotating-launch-azimuth.d.ts.map +1 -0
  43. package/dist/categories/orbits/rotating-launch-azimuth.js +65 -0
  44. package/dist/categories/orbits/rotating-launch-azimuth.js.map +1 -0
  45. package/dist/categories/orbits/state-to-elements.d.ts +82 -0
  46. package/dist/categories/orbits/state-to-elements.d.ts.map +1 -0
  47. package/dist/categories/orbits/state-to-elements.js +131 -0
  48. package/dist/categories/orbits/state-to-elements.js.map +1 -0
  49. package/dist/categories/orbits/surface-rotation-speed.d.ts +61 -0
  50. package/dist/categories/orbits/surface-rotation-speed.d.ts.map +1 -0
  51. package/dist/categories/orbits/surface-rotation-speed.js +74 -0
  52. package/dist/categories/orbits/surface-rotation-speed.js.map +1 -0
  53. package/dist/index.d.ts +12 -0
  54. package/dist/index.d.ts.map +1 -1
  55. package/dist/index.js +12 -0
  56. package/dist/index.js.map +1 -1
  57. package/package.json +4 -4
@@ -69,6 +69,24 @@ export declare const sub: (a: Vector3DTupleType, b: Vector3DTupleType) => Vector
69
69
  * ```
70
70
  */
71
71
  export declare const dot: (a: Vector3DTupleType, b: Vector3DTupleType) => number;
72
+ /**
73
+ * Compute the **cross product** of two 3D vectors.
74
+ *
75
+ * $$
76
+ * \mathbf{a}\times\mathbf{b} = \begin{pmatrix} a_y b_z - a_z b_y \\ a_z b_x - a_x b_z \\ a_x b_y - a_y b_x \end{pmatrix}
77
+ * $$
78
+ *
79
+ * @param a - First vector.
80
+ * @param b - Second vector.
81
+ * @returns Cross product, perpendicular to both (units: product of the input component units).
82
+ * @group Helpers
83
+ *
84
+ * @example
85
+ * ```ts
86
+ * cross([1, 0, 0], [0, 1, 0]); // [0, 0, 1]
87
+ * ```
88
+ */
89
+ export declare const cross: (a: Vector3DTupleType, b: Vector3DTupleType) => Vector3DTupleType;
72
90
  /**
73
91
  * Normalize an angle to the range **[0, 2π)**.
74
92
  *
@@ -1 +1 @@
1
- {"version":3,"file":"misc.d.ts","sourceRoot":"","sources":["../../../src/categories/helpers/misc.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAEnE;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,IAAI,GAAI,GAAG,iBAAiB,WAExC,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,KAAK,GAAI,GAAG,iBAAiB,EAAE,GAAG,MAAM,KAAG,iBAEvD,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,GAAG,GACd,GAAG,iBAAiB,EACpB,GAAG,iBAAiB,KACnB,iBAEF,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,GAAG,GAAI,GAAG,iBAAiB,EAAE,GAAG,iBAAiB,WAE7D,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,OAAO,GAAI,GAAG,MAAM,KAAG,MAEnC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,QAAQ,GAAI,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,MAAM,WAIvD,CAAC"}
1
+ {"version":3,"file":"misc.d.ts","sourceRoot":"","sources":["../../../src/categories/helpers/misc.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAEnE;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,IAAI,GAAI,GAAG,iBAAiB,WAExC,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,KAAK,GAAI,GAAG,iBAAiB,EAAE,GAAG,MAAM,KAAG,iBAEvD,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,GAAG,GACd,GAAG,iBAAiB,EACpB,GAAG,iBAAiB,KACnB,iBAEF,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,GAAG,GAAI,GAAG,iBAAiB,EAAE,GAAG,iBAAiB,WAE7D,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,KAAK,GAChB,GAAG,iBAAiB,EACpB,GAAG,iBAAiB,KACnB,iBAMF,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,OAAO,GAAI,GAAG,MAAM,KAAG,MAEnC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,QAAQ,GAAI,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,MAAM,WAIvD,CAAC"}
@@ -77,6 +77,30 @@ export const sub = (a, b) => {
77
77
  export const dot = (a, b) => {
78
78
  return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
79
79
  };
80
+ /**
81
+ * Compute the **cross product** of two 3D vectors.
82
+ *
83
+ * $$
84
+ * \mathbf{a}\times\mathbf{b} = \begin{pmatrix} a_y b_z - a_z b_y \\ a_z b_x - a_x b_z \\ a_x b_y - a_y b_x \end{pmatrix}
85
+ * $$
86
+ *
87
+ * @param a - First vector.
88
+ * @param b - Second vector.
89
+ * @returns Cross product, perpendicular to both (units: product of the input component units).
90
+ * @group Helpers
91
+ *
92
+ * @example
93
+ * ```ts
94
+ * cross([1, 0, 0], [0, 1, 0]); // [0, 0, 1]
95
+ * ```
96
+ */
97
+ export const cross = (a, b) => {
98
+ return [
99
+ a[1] * b[2] - a[2] * b[1],
100
+ a[2] * b[0] - a[0] * b[2],
101
+ a[0] * b[1] - a[1] * b[0]
102
+ ];
103
+ };
80
104
  /**
81
105
  * Normalize an angle to the range **[0, 2π)**.
82
106
  *
@@ -1 +1 @@
1
- {"version":3,"file":"misc.js","sourceRoot":"","sources":["../../../src/categories/helpers/misc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAGvD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,CAAoB,EAAE,EAAE;IAC3C,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACtC,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,CAAoB,EAAE,CAAS,EAAqB,EAAE;IAC1E,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AACxC,CAAC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,CACjB,CAAoB,EACpB,CAAoB,EACD,EAAE;IACrB,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,GAA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C,GAAG,CAAC,CAAC,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;KAC1B,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,CAAS,EAAU,EAAE;IAC3C,OAAO,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,MAAM,CAAC;AAC1C,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,EAAE;IAC1D,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAEtB,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;AAClC,CAAC,CAAC"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Compute the **burn time** needed for a given delta-v, at constant thrust and mass flow.
3
+ *
4
+ * $$
5
+ * t_b = \frac{m_0 - m_f}{\dot m} = \frac{m_0\, I_{sp}\, g_0}{F}\left(1 - e^{-\Delta v/(I_{sp} g_0)}\right)
6
+ * $$
7
+ *
8
+ * Where:
9
+ * - $ m_0 $ is the mass at ignition (kg)
10
+ * - $ \Delta v $ is the delta-v of the burn (m/s)
11
+ * - $ F $ is the thrust (N)
12
+ * - $ I_{sp} $ is the specific impulse (s)
13
+ * - $ g_0 $ is standard gravity (m/s²)
14
+ *
15
+ * **Units**
16
+ * - Inputs: `m0` in **kg**, `dv` in **m/s**, `F` in **N**, `Isp` in **s**, `g0` in **m/s²**.
17
+ * - Output: $ t_b $ in **s**.
18
+ *
19
+ * ::: info Notes
20
+ *
21
+ * - The propellant used, $ m_0 - m_f $, comes from the rocket equation; the burn time is that mass divided by the {@link massFlowRate}.
22
+ * - Assumes constant thrust and specific impulse. A throttled engine, like Apollo's descent engine, needs the burn split into steps.
23
+ * - `dv = 0` gives a burn time of 0.
24
+ *
25
+ * :::
26
+ *
27
+ * ::: practice Apollo 11's lunar module, leaving the Moon
28
+ *
29
+ * **439 s**
30
+ *
31
+ * _Ascent stage, 4 888 kg, for 1 850.2 m/s_
32
+ *
33
+ * The flown burn took 434.9 s, 1% less: the thrust and specific impulse used here are the pre-flight predictions.
34
+ *
35
+ * ```ts
36
+ * burnTime(4888, 1850.2, 15_409, 309); // ≈ 439.3 s
37
+ * ```
38
+ *
39
+ * :::
40
+ *
41
+ * @param m0 - Mass at ignition $ m_0 $ in **kg** (finite, > 0).
42
+ * @param dv - Delta-v of the burn $ \Delta v $ in **m/s** (finite, >= 0).
43
+ * @param F - Thrust $ F $ in **N** (finite, > 0).
44
+ * @param Isp - Specific impulse $ I_{sp} $ in **seconds** (finite, > 0).
45
+ * @param g0 - Standard gravity $ g_0 $ in **m/s²** (finite, > 0). Defaults to `9.80665`.
46
+ * @returns Burn time $ t_b $ in **s**.
47
+ * @throws {TypeError} If any input is not a finite number.
48
+ * @throws {RangeError} If `m0 <= 0`, `dv < 0`, `F <= 0`, `Isp <= 0` or `g0 <= 0`.
49
+ * @group Manoeuvres
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * // A 1200 kg spacecraft, 500 m/s with a 400 N engine at Isp = 320 s
54
+ * const t = burnTime(1200, 500, 400, 320);
55
+ * // t ≈ 1200 * 3138.1 / 400 * (1 - e^(-500/3138.1)) ≈ 1387 s
56
+ * ```
57
+ *
58
+ * @see {@link massFlowRate}
59
+ * @see {@link rocketDeltaVFromIsp}
60
+ * @see https://en.wikipedia.org/wiki/Tsiolkovsky_rocket_equation Tsiolkovsky rocket equation
61
+ */
62
+ export declare const burnTime: (m0: number, dv: number, F: number, Isp: number, g0?: number) => number;
63
+ //# sourceMappingURL=burn-time.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"burn-time.d.ts","sourceRoot":"","sources":["../../../src/categories/manoeuvres/burn-time.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AACH,eAAO,MAAM,QAAQ,GACnB,IAAI,MAAM,EACV,IAAI,MAAM,EACV,GAAG,MAAM,EACT,KAAK,MAAM,EACX,WAAY,KACX,MA0BF,CAAC"}
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Compute the **burn time** needed for a given delta-v, at constant thrust and mass flow.
3
+ *
4
+ * $$
5
+ * t_b = \frac{m_0 - m_f}{\dot m} = \frac{m_0\, I_{sp}\, g_0}{F}\left(1 - e^{-\Delta v/(I_{sp} g_0)}\right)
6
+ * $$
7
+ *
8
+ * Where:
9
+ * - $ m_0 $ is the mass at ignition (kg)
10
+ * - $ \Delta v $ is the delta-v of the burn (m/s)
11
+ * - $ F $ is the thrust (N)
12
+ * - $ I_{sp} $ is the specific impulse (s)
13
+ * - $ g_0 $ is standard gravity (m/s²)
14
+ *
15
+ * **Units**
16
+ * - Inputs: `m0` in **kg**, `dv` in **m/s**, `F` in **N**, `Isp` in **s**, `g0` in **m/s²**.
17
+ * - Output: $ t_b $ in **s**.
18
+ *
19
+ * ::: info Notes
20
+ *
21
+ * - The propellant used, $ m_0 - m_f $, comes from the rocket equation; the burn time is that mass divided by the {@link massFlowRate}.
22
+ * - Assumes constant thrust and specific impulse. A throttled engine, like Apollo's descent engine, needs the burn split into steps.
23
+ * - `dv = 0` gives a burn time of 0.
24
+ *
25
+ * :::
26
+ *
27
+ * ::: practice Apollo 11's lunar module, leaving the Moon
28
+ *
29
+ * **439 s**
30
+ *
31
+ * _Ascent stage, 4 888 kg, for 1 850.2 m/s_
32
+ *
33
+ * The flown burn took 434.9 s, 1% less: the thrust and specific impulse used here are the pre-flight predictions.
34
+ *
35
+ * ```ts
36
+ * burnTime(4888, 1850.2, 15_409, 309); // ≈ 439.3 s
37
+ * ```
38
+ *
39
+ * :::
40
+ *
41
+ * @param m0 - Mass at ignition $ m_0 $ in **kg** (finite, > 0).
42
+ * @param dv - Delta-v of the burn $ \Delta v $ in **m/s** (finite, >= 0).
43
+ * @param F - Thrust $ F $ in **N** (finite, > 0).
44
+ * @param Isp - Specific impulse $ I_{sp} $ in **seconds** (finite, > 0).
45
+ * @param g0 - Standard gravity $ g_0 $ in **m/s²** (finite, > 0). Defaults to `9.80665`.
46
+ * @returns Burn time $ t_b $ in **s**.
47
+ * @throws {TypeError} If any input is not a finite number.
48
+ * @throws {RangeError} If `m0 <= 0`, `dv < 0`, `F <= 0`, `Isp <= 0` or `g0 <= 0`.
49
+ * @group Manoeuvres
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * // A 1200 kg spacecraft, 500 m/s with a 400 N engine at Isp = 320 s
54
+ * const t = burnTime(1200, 500, 400, 320);
55
+ * // t ≈ 1200 * 3138.1 / 400 * (1 - e^(-500/3138.1)) ≈ 1387 s
56
+ * ```
57
+ *
58
+ * @see {@link massFlowRate}
59
+ * @see {@link rocketDeltaVFromIsp}
60
+ * @see https://en.wikipedia.org/wiki/Tsiolkovsky_rocket_equation Tsiolkovsky rocket equation
61
+ */
62
+ export const burnTime = (m0, dv, F, Isp, g0 = 9.80665) => {
63
+ for (const [name, v] of [
64
+ ['m0', m0],
65
+ ['dv', dv],
66
+ ['F', F],
67
+ ['Isp', Isp],
68
+ ['g0', g0]
69
+ ]) {
70
+ if (!Number.isFinite(v))
71
+ throw new TypeError(`${name} must be a finite number. Received: ${v}`);
72
+ }
73
+ if (m0 <= 0)
74
+ throw new RangeError(`m0 must be > 0. Received: ${m0}`);
75
+ if (dv < 0)
76
+ throw new RangeError(`dv must be >= 0. Received: ${dv}`);
77
+ if (F <= 0)
78
+ throw new RangeError(`F must be > 0. Received: ${F}`);
79
+ if (Isp <= 0)
80
+ throw new RangeError(`Isp must be > 0. Received: ${Isp}`);
81
+ if (g0 <= 0)
82
+ throw new RangeError(`g0 must be > 0. Received: ${g0}`);
83
+ const ve = Isp * g0;
84
+ // -expm1(-x) = 1 - e^(-x), accurate for small burns
85
+ return ((m0 * ve) / F) * -Math.expm1(-dv / ve);
86
+ };
87
+ //# sourceMappingURL=burn-time.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"burn-time.js","sourceRoot":"","sources":["../../../src/categories/manoeuvres/burn-time.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CACtB,EAAU,EACV,EAAU,EACV,CAAS,EACT,GAAW,EACX,EAAE,GAAG,OAAO,EACJ,EAAE;IACV,KAAK,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI;QACtB,CAAC,IAAI,EAAE,EAAE,CAAC;QACV,CAAC,IAAI,EAAE,EAAE,CAAC;QACV,CAAC,GAAG,EAAE,CAAC,CAAC;QACR,CAAC,KAAK,EAAE,GAAG,CAAC;QACZ,CAAC,IAAI,EAAE,EAAE,CAAC;KACF,EAAE,CAAC;QACX,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;YACrB,MAAM,IAAI,SAAS,CAAC,GAAG,IAAI,uCAAuC,CAAC,EAAE,CAAC,CAAC;IAC3E,CAAC;IAED,IAAI,EAAE,IAAI,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,6BAA6B,EAAE,EAAE,CAAC,CAAC;IAErE,IAAI,EAAE,GAAG,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,8BAA8B,EAAE,EAAE,CAAC,CAAC;IAErE,IAAI,CAAC,IAAI,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,4BAA4B,CAAC,EAAE,CAAC,CAAC;IAElE,IAAI,GAAG,IAAI,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,8BAA8B,GAAG,EAAE,CAAC,CAAC;IAExE,IAAI,EAAE,IAAI,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,6BAA6B,EAAE,EAAE,CAAC,CAAC;IAErE,MAAM,EAAE,GAAG,GAAG,GAAG,EAAE,CAAC;IAEpB,oDAAoD;IACpD,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;AACjD,CAAC,CAAC"}
@@ -0,0 +1,48 @@
1
+ import type { Radians } from '@interstellar-tools/types';
2
+ /**
3
+ * Compute the **gravity loss** of a burn from samples of gravity and flight-path angle.
4
+ *
5
+ * $$
6
+ * \Delta v_g = \int_0^{t_b} g \sin\gamma \, dt
7
+ * $$
8
+ *
9
+ * integrated with the trapezoidal rule over equally spaced samples.
10
+ *
11
+ * Where:
12
+ * - $ g $ is the local gravitational acceleration (m/s²)
13
+ * - $ \gamma $ is the flight-path angle above the local horizontal (rad)
14
+ * - $ t_b $ is the burn time (s)
15
+ *
16
+ * **Units**
17
+ * - Inputs: `g` in **m/s²**, `gamma` in **radians**, `dt` in **s**.
18
+ * - Output: $ \Delta v_g $ in **m/s**.
19
+ *
20
+ * ::: info Notes
21
+ *
22
+ * - Thrust spent holding a rocket up against gravity doesn't speed it up. The loss is largest for a vertical climb ($ \gamma = 90° $) and zero for a horizontal burn ($ \gamma = 0 $).
23
+ * - The delta-v a rocket must carry is its orbital delta-v plus its gravity, drag and steering losses.
24
+ * - Pass `g` as one number when it's constant over the burn, or as samples matching `gamma`.
25
+ *
26
+ * :::
27
+ *
28
+ * @param g - Gravitational acceleration in **m/s²**: one value, or one sample per entry of `gamma` (finite, >= 0).
29
+ * @param gamma - Flight-path angles $ \gamma $ in **radians**, sampled every `dt` seconds (at least 2 samples, each finite).
30
+ * @param dt - Time between samples in **s** (finite, > 0).
31
+ * @returns Gravity loss $ \Delta v_g $ in **m/s**. Negative when the vehicle is mostly descending.
32
+ * @throws {TypeError} If any input is not a finite number, or `g` and `gamma` have different lengths.
33
+ * @throws {RangeError} If `gamma` has fewer than 2 samples, `dt <= 0` or any `g < 0`.
34
+ * @group Manoeuvres
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * import type { Radians } from '@interstellar-tools/types';
39
+ *
40
+ * // A 10 s vertical climb in constant Earth gravity
41
+ * const vertical = Array.from({ length: 11 }, () => (Math.PI / 2) as Radians);
42
+ * gravityLoss(9.80665, vertical, 1); // ≈ 98.07 m/s
43
+ * ```
44
+ *
45
+ * @see https://en.wikipedia.org/wiki/Gravity_drag Gravity drag
46
+ */
47
+ export declare const gravityLoss: (g: number | readonly number[], gamma: readonly Radians[], dt: number) => number;
48
+ //# sourceMappingURL=gravity-loss.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gravity-loss.d.ts","sourceRoot":"","sources":["../../../src/categories/manoeuvres/gravity-loss.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAEzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,eAAO,MAAM,WAAW,GACtB,GAAG,MAAM,GAAG,SAAS,MAAM,EAAE,EAC7B,OAAO,SAAS,OAAO,EAAE,EACzB,IAAI,MAAM,KACT,MA2CF,CAAC"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Compute the **gravity loss** of a burn from samples of gravity and flight-path angle.
3
+ *
4
+ * $$
5
+ * \Delta v_g = \int_0^{t_b} g \sin\gamma \, dt
6
+ * $$
7
+ *
8
+ * integrated with the trapezoidal rule over equally spaced samples.
9
+ *
10
+ * Where:
11
+ * - $ g $ is the local gravitational acceleration (m/s²)
12
+ * - $ \gamma $ is the flight-path angle above the local horizontal (rad)
13
+ * - $ t_b $ is the burn time (s)
14
+ *
15
+ * **Units**
16
+ * - Inputs: `g` in **m/s²**, `gamma` in **radians**, `dt` in **s**.
17
+ * - Output: $ \Delta v_g $ in **m/s**.
18
+ *
19
+ * ::: info Notes
20
+ *
21
+ * - Thrust spent holding a rocket up against gravity doesn't speed it up. The loss is largest for a vertical climb ($ \gamma = 90° $) and zero for a horizontal burn ($ \gamma = 0 $).
22
+ * - The delta-v a rocket must carry is its orbital delta-v plus its gravity, drag and steering losses.
23
+ * - Pass `g` as one number when it's constant over the burn, or as samples matching `gamma`.
24
+ *
25
+ * :::
26
+ *
27
+ * @param g - Gravitational acceleration in **m/s²**: one value, or one sample per entry of `gamma` (finite, >= 0).
28
+ * @param gamma - Flight-path angles $ \gamma $ in **radians**, sampled every `dt` seconds (at least 2 samples, each finite).
29
+ * @param dt - Time between samples in **s** (finite, > 0).
30
+ * @returns Gravity loss $ \Delta v_g $ in **m/s**. Negative when the vehicle is mostly descending.
31
+ * @throws {TypeError} If any input is not a finite number, or `g` and `gamma` have different lengths.
32
+ * @throws {RangeError} If `gamma` has fewer than 2 samples, `dt <= 0` or any `g < 0`.
33
+ * @group Manoeuvres
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * import type { Radians } from '@interstellar-tools/types';
38
+ *
39
+ * // A 10 s vertical climb in constant Earth gravity
40
+ * const vertical = Array.from({ length: 11 }, () => (Math.PI / 2) as Radians);
41
+ * gravityLoss(9.80665, vertical, 1); // ≈ 98.07 m/s
42
+ * ```
43
+ *
44
+ * @see https://en.wikipedia.org/wiki/Gravity_drag Gravity drag
45
+ */
46
+ export const gravityLoss = (g, gamma, dt) => {
47
+ if (!Number.isFinite(dt))
48
+ throw new TypeError(`dt must be a finite number. Received: ${dt}`);
49
+ if (dt <= 0)
50
+ throw new RangeError(`dt must be > 0. Received: ${dt}`);
51
+ if (gamma.length < 2)
52
+ throw new RangeError(`gamma must have at least 2 samples. Received: ${gamma.length}`);
53
+ if (typeof g !== 'number' && g.length !== gamma.length)
54
+ throw new TypeError(`g must be a number or have one sample per gamma. Received: ${g.length} for ${gamma.length}`);
55
+ const at = (i) => {
56
+ const gi = typeof g === 'number' ? g : g[i];
57
+ if (!Number.isFinite(gi))
58
+ throw new TypeError(`g must be finite. Received: ${gi} at ${i}`);
59
+ if (gi < 0)
60
+ throw new RangeError(`g must be >= 0. Received: ${gi} at ${i}`);
61
+ if (!Number.isFinite(gamma[i]))
62
+ throw new TypeError(`gamma must be finite. Received: ${gamma[i]} at ${i}`);
63
+ return gi * Math.sin(gamma[i]);
64
+ };
65
+ let loss = 0;
66
+ let previous = at(0);
67
+ for (let i = 1; i < gamma.length; i++) {
68
+ const current = at(i);
69
+ loss += ((previous + current) / 2) * dt;
70
+ previous = current;
71
+ }
72
+ return loss;
73
+ };
74
+ //# sourceMappingURL=gravity-loss.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gravity-loss.js","sourceRoot":"","sources":["../../../src/categories/manoeuvres/gravity-loss.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,CAA6B,EAC7B,KAAyB,EACzB,EAAU,EACF,EAAE;IACV,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,SAAS,CAAC,yCAAyC,EAAE,EAAE,CAAC,CAAC;IAErE,IAAI,EAAE,IAAI,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,6BAA6B,EAAE,EAAE,CAAC,CAAC;IAErE,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;QAClB,MAAM,IAAI,UAAU,CAClB,iDAAiD,KAAK,CAAC,MAAM,EAAE,CAChE,CAAC;IAEJ,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM;QACpD,MAAM,IAAI,SAA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ition** to give a final mass a delta-v: the rocket equation solved for $ m_0 $.
3
+ *
4
+ * $$
5
+ * m_0 = m_f\, e^{\Delta v/(I_{sp}\, g_0)}
6
+ * $$
7
+ *
8
+ * Where:
9
+ * - $ m_f $ is the mass left after the burn (kg)
10
+ * - $ \Delta v $ is the delta-v of the burn (m/s)
11
+ * - $ I_{sp} $ is the specific impulse (s)
12
+ * - $ g_0 $ is standard gravity (m/s²)
13
+ *
14
+ * **Units**
15
+ * - Inputs: `mf` in **kg**, `dv` in **m/s**, `Isp` in **s**, `g0` in **m/s²**.
16
+ * - Output: $ m_0 $ in **kg**.
17
+ *
18
+ * ::: info Notes
19
+ *
20
+ * - The factor $ e^{\Delta v/(I_{sp} g_0)} $ is the price of the burn: every kilogram left after it costs that many kilograms before it.
21
+ * - For a sequence of burns, work backwards from the last one: each burn's $ m_0 $ is the previous burn's $ m_f $.
22
+ * - This is the ideal rocket equation: the result counts propellant, not the tanks and engines that hold and burn it.
23
+ *
24
+ * :::
25
+ *
26
+ * ::: practice Apollo 11's lunar module, before landing
27
+ *
28
+ * **9 905 kg**
29
+ *
30
+ * _To land with a 4 888 kg ascent stage, for 2 112.3 m/s at 305 s_
31
+ *
32
+ * The real lunar module weighed 15 279 kg at undocking: the rest is the descent stage's own structure, engine and legs.
33
+ *
34
+ * ```ts
35
+ * initialMassForDeltaV(4888, 2112.3, 305); // ≈ 9905 kg
36
+ * ```
37
+ *
38
+ * :::
39
+ *
40
+ * @param mf - Mass after the burn $ m_f $ in **kg** (finite, > 0).
41
+ * @param dv - Delta-v of the burn $ \Delta v $ in **m/s** (finite, >= 0).
42
+ * @param Isp - Specific impulse $ I_{sp} $ in **seconds** (finite, > 0).
43
+ * @param g0 - Standard gravity $ g_0 $ in **m/s²** (finite, > 0). Defaults to `9.80665`.
44
+ * @returns Mass at ignition $ m_0 $ in **kg**.
45
+ * @throws {TypeError} If any input is not a finite number.
46
+ * @throws {RangeError} If `mf <= 0`, `dv < 0`, `Isp <= 0` or `g0 <= 0`.
47
+ * @group Manoeuvres
48
+ *
49
+ * @example
50
+ * ```ts
51
+ * // 800 kg left after a 1270 m/s burn at Isp = 320 s
52
+ * const m0 = initialMassForDeltaV(800, 1270, 320);
53
+ * // m0 ≈ 800 * e^(1270 / 3138.1) ≈ 1200 kg
54
+ * ```
55
+ *
56
+ * @see {@link rocketDeltaVFromIsp}
57
+ * @see https://en.wikipedia.org/wiki/Tsiolkovsky_rocket_equation Tsiolkovsky rocket equation
58
+ */
59
+ export declare const initialMassForDeltaV: (mf: number, dv: number, Isp: number, g0?: number) => number;
60
+ //# sourceMappingURL=initial-mass-for-delta-v.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initial-mass-for-delta-v.d.ts","sourceRoot":"","sources":["../../../src/categories/manoeuvres/initial-mass-for-delta-v.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AACH,eAAO,MAAM,oBAAoB,GAC/B,IAAI,MAAM,EACV,IAAI,MAAM,EACV,KAAK,MAAM,EACX,WAAY,KACX,MAoBF,CAAC"}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Compute the **mass needed at ignition** to give a final mass a delta-v: the rocket equation solved for $ m_0 $.
3
+ *
4
+ * $$
5
+ * m_0 = m_f\, e^{\Delta v/(I_{sp}\, g_0)}
6
+ * $$
7
+ *
8
+ * Where:
9
+ * - $ m_f $ is the mass left after the burn (kg)
10
+ * - $ \Delta v $ is the delta-v of the burn (m/s)
11
+ * - $ I_{sp} $ is the specific impulse (s)
12
+ * - $ g_0 $ is standard gravity (m/s²)
13
+ *
14
+ * **Units**
15
+ * - Inputs: `mf` in **kg**, `dv` in **m/s**, `Isp` in **s**, `g0` in **m/s²**.
16
+ * - Output: $ m_0 $ in **kg**.
17
+ *
18
+ * ::: info Notes
19
+ *
20
+ * - The factor $ e^{\Delta v/(I_{sp} g_0)} $ is the price of the burn: every kilogram left after it costs that many kilograms before it.
21
+ * - For a sequence of burns, work backwards from the last one: each burn's $ m_0 $ is the previous burn's $ m_f $.
22
+ * - This is the ideal rocket equation: the result counts propellant, not the tanks and engines that hold and burn it.
23
+ *
24
+ * :::
25
+ *
26
+ * ::: practice Apollo 11's lunar module, before landing
27
+ *
28
+ * **9 905 kg**
29
+ *
30
+ * _To land with a 4 888 kg ascent stage, for 2 112.3 m/s at 305 s_
31
+ *
32
+ * The real lunar module weighed 15 279 kg at undocking: the rest is the descent stage's own structure, engine and legs.
33
+ *
34
+ * ```ts
35
+ * initialMassForDeltaV(4888, 2112.3, 305); // ≈ 9905 kg
36
+ * ```
37
+ *
38
+ * :::
39
+ *
40
+ * @param mf - Mass after the burn $ m_f $ in **kg** (finite, > 0).
41
+ * @param dv - Delta-v of the burn $ \Delta v $ in **m/s** (finite, >= 0).
42
+ * @param Isp - Specific impulse $ I_{sp} $ in **seconds** (finite, > 0).
43
+ * @param g0 - Standard gravity $ g_0 $ in **m/s²** (finite, > 0). Defaults to `9.80665`.
44
+ * @returns Mass at ignition $ m_0 $ in **kg**.
45
+ * @throws {TypeError} If any input is not a finite number.
46
+ * @throws {RangeError} If `mf <= 0`, `dv < 0`, `Isp <= 0` or `g0 <= 0`.
47
+ * @group Manoeuvres
48
+ *
49
+ * @example
50
+ * ```ts
51
+ * // 800 kg left after a 1270 m/s burn at Isp = 320 s
52
+ * const m0 = initialMassForDeltaV(800, 1270, 320);
53
+ * // m0 ≈ 800 * e^(1270 / 3138.1) ≈ 1200 kg
54
+ * ```
55
+ *
56
+ * @see {@link rocketDeltaVFromIsp}
57
+ * @see https://en.wikipedia.org/wiki/Tsiolkovsky_rocket_equation Tsiolkovsky rocket equation
58
+ */
59
+ export const initialMassForDeltaV = (mf, dv, Isp, g0 = 9.80665) => {
60
+ for (const [name, v] of [
61
+ ['mf', mf],
62
+ ['dv', dv],
63
+ ['Isp', Isp],
64
+ ['g0', g0]
65
+ ]) {
66
+ if (!Number.isFinite(v))
67
+ throw new TypeError(`${name} must be a finite number. Received: ${v}`);
68
+ }
69
+ if (mf <= 0)
70
+ throw new RangeError(`mf must be > 0. Received: ${mf}`);
71
+ if (dv < 0)
72
+ throw new RangeError(`dv must be >= 0. Received: ${dv}`);
73
+ if (Isp <= 0)
74
+ throw new RangeError(`Isp must be > 0. Received: ${Isp}`);
75
+ if (g0 <= 0)
76
+ throw new RangeError(`g0 must be > 0. Received: ${g0}`);
77
+ return mf * Math.exp(dv / (Isp * g0));
78
+ };
79
+ //# sourceMappingURL=initial-mass-for-delta-v.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initial-mass-for-delta-v.js","sourceRoot":"","sources":["../../../src/categories/manoeuvres/initial-mass-for-delta-v.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,EAAU,EACV,EAAU,EACV,GAAW,EACX,EAAE,GAAG,OAAO,EACJ,EAAE;IACV,KAAK,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI;QACtB,CAAC,IAAI,EAAE,EAAE,CAAC;QACV,CAAC,IAAI,EAAE,EAAE,CAAC;QACV,CAAC,KAAK,EAAE,GAAG,CAAC;QACZ,CAAC,IAAI,EAAE,EAAE,CAAC;KACF,EAAE,CAAC;QACX,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;YACrB,MAAM,IAAI,SAAS,CAAC,GAAG,IAAI,uCAAuC,CAAC,EAAE,CAAC,CAAC;IAC3E,CAAC;IAED,IAAI,EAAE,IAAI,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,6BAA6B,EAAE,EAAE,CAAC,CAAC;IAErE,IAAI,EAAE,GAAG,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,8BAA8B,EAAE,EAAE,CAAC,CAAC;IAErE,IAAI,GAAG,IAAI,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,8BAA8B,GAAG,EAAE,CAAC,CAAC;IAExE,IAAI,EAAE,IAAI,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,6BAA6B,EAAE,EAAE,CAAC,CAAC;IAErE,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC;AACxC,CAAC,CAAC"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Compute the **mass flow rate** of a rocket engine from its thrust and specific impulse.
3
+ *
4
+ * $$
5
+ * \dot m = \frac{F}{I_{sp}\, g_0}
6
+ * $$
7
+ *
8
+ * Where:
9
+ * - $ F $ is the thrust (N)
10
+ * - $ I_{sp} $ is the specific impulse (s)
11
+ * - $ g_0 $ is standard gravity (m/s²)
12
+ *
13
+ * **Units**
14
+ * - Inputs: `F` in **N**, `Isp` in **s**, `g0` in **m/s²**.
15
+ * - Output: $ \dot m $ in **kg/s**.
16
+ *
17
+ * ::: info Notes
18
+ *
19
+ * - $ I_{sp}\, g_0 $ is the effective exhaust velocity $ v_e $, so this is $ F = \dot m\, v_e $ solved for $ \dot m $.
20
+ * - `g0` defaults to **9.80665 m/s²** (standard gravity). It converts the units of $ I_{sp} $; it is not the local gravity.
21
+ *
22
+ * :::
23
+ *
24
+ * ::: practice Apollo 11's lunar module, leaving the Moon
25
+ *
26
+ * **5.09 kg/s**
27
+ *
28
+ * _Ascent engine, 15 409 N at 309 s_
29
+ *
30
+ * The ascent stage burned about 5 kg of propellant a second for its 7-minute climb to lunar orbit.
31
+ *
32
+ * ```ts
33
+ * massFlowRate(15_409, 309); // ≈ 5.085 kg/s
34
+ * ```
35
+ *
36
+ * :::
37
+ *
38
+ * @param F - Thrust $ F $ in **N** (finite, > 0).
39
+ * @param Isp - Specific impulse $ I_{sp} $ in **seconds** (finite, > 0).
40
+ * @param g0 - Standard gravity $ g_0 $ in **m/s²** (finite, > 0). Defaults to `9.80665`.
41
+ * @returns Mass flow rate $ \dot m $ in **kg/s**.
42
+ * @throws {TypeError} If any input is not a finite number.
43
+ * @throws {RangeError} If `F <= 0`, `Isp <= 0` or `g0 <= 0`.
44
+ * @group Manoeuvres
45
+ *
46
+ * @example
47
+ * ```ts
48
+ * // A 1 kN thruster with Isp = 300 s
49
+ * const mDot = massFlowRate(1000, 300);
50
+ * // mDot ≈ 1000 / (300 * 9.80665) ≈ 0.340 kg/s
51
+ * ```
52
+ *
53
+ * @see {@link burnTime}
54
+ * @see {@link rocketThrust}
55
+ */
56
+ export declare const massFlowRate: (F: number, Isp: number, g0?: number) => number;
57
+ //# sourceMappingURL=mass-flow-rate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mass-flow-rate.d.ts","sourceRoot":"","sources":["../../../src/categories/manoeuvres/mass-flow-rate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,eAAO,MAAM,YAAY,GAAI,GAAG,MAAM,EAAE,KAAK,MAAM,EAAE,WAAY,KAAG,MAiBnE,CAAC"}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Compute the **mass flow rate** of a rocket engine from its thrust and specific impulse.
3
+ *
4
+ * $$
5
+ * \dot m = \frac{F}{I_{sp}\, g_0}
6
+ * $$
7
+ *
8
+ * Where:
9
+ * - $ F $ is the thrust (N)
10
+ * - $ I_{sp} $ is the specific impulse (s)
11
+ * - $ g_0 $ is standard gravity (m/s²)
12
+ *
13
+ * **Units**
14
+ * - Inputs: `F` in **N**, `Isp` in **s**, `g0` in **m/s²**.
15
+ * - Output: $ \dot m $ in **kg/s**.
16
+ *
17
+ * ::: info Notes
18
+ *
19
+ * - $ I_{sp}\, g_0 $ is the effective exhaust velocity $ v_e $, so this is $ F = \dot m\, v_e $ solved for $ \dot m $.
20
+ * - `g0` defaults to **9.80665 m/s²** (standard gravity). It converts the units of $ I_{sp} $; it is not the local gravity.
21
+ *
22
+ * :::
23
+ *
24
+ * ::: practice Apollo 11's lunar module, leaving the Moon
25
+ *
26
+ * **5.09 kg/s**
27
+ *
28
+ * _Ascent engine, 15 409 N at 309 s_
29
+ *
30
+ * The ascent stage burned about 5 kg of propellant a second for its 7-minute climb to lunar orbit.
31
+ *
32
+ * ```ts
33
+ * massFlowRate(15_409, 309); // ≈ 5.085 kg/s
34
+ * ```
35
+ *
36
+ * :::
37
+ *
38
+ * @param F - Thrust $ F $ in **N** (finite, > 0).
39
+ * @param Isp - Specific impulse $ I_{sp} $ in **seconds** (finite, > 0).
40
+ * @param g0 - Standard gravity $ g_0 $ in **m/s²** (finite, > 0). Defaults to `9.80665`.
41
+ * @returns Mass flow rate $ \dot m $ in **kg/s**.
42
+ * @throws {TypeError} If any input is not a finite number.
43
+ * @throws {RangeError} If `F <= 0`, `Isp <= 0` or `g0 <= 0`.
44
+ * @group Manoeuvres
45
+ *
46
+ * @example
47
+ * ```ts
48
+ * // A 1 kN thruster with Isp = 300 s
49
+ * const mDot = massFlowRate(1000, 300);
50
+ * // mDot ≈ 1000 / (300 * 9.80665) ≈ 0.340 kg/s
51
+ * ```
52
+ *
53
+ * @see {@link burnTime}
54
+ * @see {@link rocketThrust}
55
+ */
56
+ export const massFlowRate = (F, Isp, g0 = 9.80665) => {
57
+ for (const [name, v] of [
58
+ ['F', F],
59
+ ['Isp', Isp],
60
+ ['g0', g0]
61
+ ]) {
62
+ if (!Number.isFinite(v))
63
+ throw new TypeError(`${name} must be a finite number. Received: ${v}`);
64
+ }
65
+ if (F <= 0)
66
+ throw new RangeError(`F must be > 0. Received: ${F}`);
67
+ if (Isp <= 0)
68
+ throw new RangeError(`Isp must be > 0. Received: ${Isp}`);
69
+ if (g0 <= 0)
70
+ throw new RangeError(`g0 must be > 0. Received: ${g0}`);
71
+ return F / (Isp * g0);
72
+ };
73
+ //# sourceMappingURL=mass-flow-rate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mass-flow-rate.js","sourceRoot":"","sources":["../../../src/categories/manoeuvres/mass-flow-rate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAS,EAAE,GAAW,EAAE,EAAE,GAAG,OAAO,EAAU,EAAE;IAC3E,KAAK,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI;QACtB,CAAC,GAAG,EAAE,CAAC,CAAC;QACR,CAAC,KAAK,EAAE,GAAG,CAAC;QACZ,CAAC,IAAI,EAAE,EAAE,CAAC;KACF,EAAE,CAAC;QACX,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;YACrB,MAAM,IAAI,SAAS,CAAC,GAAG,IAAI,uCAAuC,CAAC,EAAE,CAAC,CAAC;IAC3E,CAAC;IAED,IAAI,CAAC,IAAI,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,4BAA4B,CAAC,EAAE,CAAC,CAAC;IAElE,IAAI,GAAG,IAAI,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,8BAA8B,GAAG,EAAE,CAAC,CAAC;IAExE,IAAI,EAAE,IAAI,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,6BAA6B,EAAE,EAAE,CAAC,CAAC;IAErE,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC;AACxB,CAAC,CAAC"}