rockmoc 0.6.0__py3-none-any.whl

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 (71) hide show
  1. rockmoc/__init__.py +132 -0
  2. rockmoc/_version.py +3 -0
  3. rockmoc/aerospike/__init__.py +29 -0
  4. rockmoc/aerospike/base_cowl.py +260 -0
  5. rockmoc/aerospike/lee_spike.py +395 -0
  6. rockmoc/analysis/__init__.py +22 -0
  7. rockmoc/analysis/atmosphere.py +48 -0
  8. rockmoc/analysis/boundary_layer.py +174 -0
  9. rockmoc/analysis/compare.py +123 -0
  10. rockmoc/analysis/throat.py +197 -0
  11. rockmoc/analysis/uq.py +206 -0
  12. rockmoc/cli.py +183 -0
  13. rockmoc/designers/__init__.py +31 -0
  14. rockmoc/designers/axisym_hf.py +115 -0
  15. rockmoc/designers/base.py +311 -0
  16. rockmoc/designers/conical.py +106 -0
  17. rockmoc/designers/ideal.py +11 -0
  18. rockmoc/designers/mln.py +19 -0
  19. rockmoc/designers/production.py +252 -0
  20. rockmoc/designers/rao.py +192 -0
  21. rockmoc/designers/rao_control.py +210 -0
  22. rockmoc/designers/rao_toc.py +87 -0
  23. rockmoc/designers/tic.py +11 -0
  24. rockmoc/exceptions.py +50 -0
  25. rockmoc/geometry/__init__.py +6 -0
  26. rockmoc/geometry/contour.py +145 -0
  27. rockmoc/geometry/export.py +74 -0
  28. rockmoc/moc/__init__.py +30 -0
  29. rockmoc/moc/axisym_hf.py +689 -0
  30. rockmoc/moc/equations.py +151 -0
  31. rockmoc/moc/kernel.py +570 -0
  32. rockmoc/moc/mesh.py +436 -0
  33. rockmoc/moc/planar_nasa.py +394 -0
  34. rockmoc/moc/strict_wall.py +121 -0
  35. rockmoc/moc/types.py +128 -0
  36. rockmoc/performance/__init__.py +21 -0
  37. rockmoc/performance/field_cf.py +240 -0
  38. rockmoc/performance/integrated.py +183 -0
  39. rockmoc/performance/metrics.py +83 -0
  40. rockmoc/plot/__init__.py +47 -0
  41. rockmoc/plot/contours.py +40 -0
  42. rockmoc/plot/dashboard.py +127 -0
  43. rockmoc/plot/moc_field.py +295 -0
  44. rockmoc/plot/performance_plots.py +403 -0
  45. rockmoc/plot/sweeps.py +207 -0
  46. rockmoc/plot/theme.py +227 -0
  47. rockmoc/py.typed +0 -0
  48. rockmoc/student/__init__.py +61 -0
  49. rockmoc/student/explainers.py +158 -0
  50. rockmoc/student/gases.py +103 -0
  51. rockmoc/student/limits.py +33 -0
  52. rockmoc/student/report.py +241 -0
  53. rockmoc/student/tables.py +159 -0
  54. rockmoc/thermo/__init__.py +37 -0
  55. rockmoc/thermo/cantera_backend.py +120 -0
  56. rockmoc/thermo/coolprop_backend.py +112 -0
  57. rockmoc/thermo/expansion_table.py +278 -0
  58. rockmoc/thermo/gas_protocol.py +47 -0
  59. rockmoc/thermo/perfect_gas.py +301 -0
  60. rockmoc/thermo/protocol.py +63 -0
  61. rockmoc/thermo/rocketcea_backend.py +158 -0
  62. rockmoc/thermo/solve.py +70 -0
  63. rockmoc/thermo/variable_gamma.py +148 -0
  64. rockmoc/validate/__init__.py +19 -0
  65. rockmoc/validate/benchmark.py +1217 -0
  66. rockmoc/validate/cases.py +689 -0
  67. rockmoc-0.6.0.dist-info/METADATA +581 -0
  68. rockmoc-0.6.0.dist-info/RECORD +71 -0
  69. rockmoc-0.6.0.dist-info/WHEEL +4 -0
  70. rockmoc-0.6.0.dist-info/entry_points.txt +2 -0
  71. rockmoc-0.6.0.dist-info/licenses/LICENSE +21 -0
rockmoc/__init__.py ADDED
@@ -0,0 +1,132 @@
1
+ """
2
+ rockmoc — Industry-oriented MOC rocket nozzle design library.
3
+
4
+ Production pipeline::
5
+
6
+ from rockmoc import DesignSpec, PerfectGas, design_production
7
+ r = design_production(DesignSpec(PerfectGas(1.25), throat_radius=0.05, exit_mach=3.0))
8
+ print(r.summary())
9
+ """
10
+
11
+ from rockmoc._version import __version__
12
+ from rockmoc.aerospike import (
13
+ SpikeResult,
14
+ design_primary_cowl,
15
+ design_spike,
16
+ design_spike_truncated,
17
+ design_spike_with_cowl,
18
+ truncated_spike_with_base,
19
+ )
20
+ from rockmoc.analysis import (
21
+ compare_nozzle_designs,
22
+ correct_wall_bl,
23
+ mesh_certificate,
24
+ monte_carlo_mln,
25
+ pressure_at_altitude,
26
+ sauer_throat_ivl,
27
+ sensitivity_one_at_a_time,
28
+ )
29
+ from rockmoc.designers import (
30
+ DesignResult,
31
+ DesignSpec,
32
+ ProductionResult,
33
+ design_conical,
34
+ design_ideal,
35
+ design_mln,
36
+ design_production,
37
+ design_rao,
38
+ design_rao_control,
39
+ design_rao_toc,
40
+ design_tic,
41
+ )
42
+ from rockmoc.student import (
43
+ KNOWN_LIMITS,
44
+ comparison_to_csv,
45
+ comparison_to_latex,
46
+ comparison_to_markdown,
47
+ describe_example_gases,
48
+ example_gas,
49
+ explainer,
50
+ format_design_report,
51
+ generate_lab_report,
52
+ list_example_gases,
53
+ )
54
+ from rockmoc.exceptions import (
55
+ ConvergenceError,
56
+ DesignError,
57
+ MeshError,
58
+ RockmocError,
59
+ ThermoError,
60
+ )
61
+ from rockmoc.geometry import Contour
62
+ from rockmoc.moc.axisym_hf import mesh_convergence_axisym
63
+ from rockmoc.moc.planar_nasa import PlanarNasaResult, design_planar_mln_nasa, mesh_convergence_planar
64
+ from rockmoc.performance import (
65
+ field_integrated_cf,
66
+ integrated_performance,
67
+ off_design_altitude_sweep,
68
+ )
69
+ from rockmoc.thermo import (
70
+ PerfectGas,
71
+ VariableGammaGas,
72
+ build_multi_gamma_table,
73
+ build_perfect_gas_table,
74
+ )
75
+ from rockmoc.validate import run_all_validation, validation_report_markdown
76
+
77
+ __all__ = [
78
+ "__version__",
79
+ "Contour",
80
+ "DesignResult",
81
+ "DesignSpec",
82
+ "PerfectGas",
83
+ "PlanarNasaResult",
84
+ "ProductionResult",
85
+ "SpikeResult",
86
+ "VariableGammaGas",
87
+ "RockmocError",
88
+ "DesignError",
89
+ "ThermoError",
90
+ "MeshError",
91
+ "ConvergenceError",
92
+ "design_mln",
93
+ "design_ideal",
94
+ "design_tic",
95
+ "design_rao",
96
+ "design_rao_control",
97
+ "design_rao_toc",
98
+ "design_conical",
99
+ "design_production",
100
+ "design_planar_mln_nasa",
101
+ "mesh_convergence_planar",
102
+ "mesh_convergence_axisym",
103
+ "design_spike",
104
+ "design_spike_truncated",
105
+ "design_spike_with_cowl",
106
+ "design_primary_cowl",
107
+ "truncated_spike_with_base",
108
+ "correct_wall_bl",
109
+ "sauer_throat_ivl",
110
+ "compare_nozzle_designs",
111
+ "comparison_to_markdown",
112
+ "comparison_to_latex",
113
+ "comparison_to_csv",
114
+ "example_gas",
115
+ "list_example_gases",
116
+ "describe_example_gases",
117
+ "explainer",
118
+ "format_design_report",
119
+ "generate_lab_report",
120
+ "KNOWN_LIMITS",
121
+ "integrated_performance",
122
+ "field_integrated_cf",
123
+ "off_design_altitude_sweep",
124
+ "pressure_at_altitude",
125
+ "monte_carlo_mln",
126
+ "mesh_certificate",
127
+ "sensitivity_one_at_a_time",
128
+ "build_perfect_gas_table",
129
+ "build_multi_gamma_table",
130
+ "run_all_validation",
131
+ "validation_report_markdown",
132
+ ]
rockmoc/_version.py ADDED
@@ -0,0 +1,3 @@
1
+ """Package version."""
2
+
3
+ __version__ = "0.6.0"
@@ -0,0 +1,29 @@
1
+ """Aerospike (plug) nozzle design — Lee / Vernacchia + base/cowl."""
2
+
3
+ from rockmoc.aerospike.base_cowl import (
4
+ BasePressureModel,
5
+ CowlDesign,
6
+ design_primary_cowl,
7
+ design_spike_with_cowl,
8
+ estimate_base_pressure,
9
+ truncated_spike_with_base,
10
+ )
11
+ from rockmoc.aerospike.lee_spike import (
12
+ SpikeResult,
13
+ design_spike,
14
+ design_spike_truncated,
15
+ majdalani_mach_from_er,
16
+ )
17
+
18
+ __all__ = [
19
+ "BasePressureModel",
20
+ "CowlDesign",
21
+ "SpikeResult",
22
+ "design_primary_cowl",
23
+ "design_spike",
24
+ "design_spike_truncated",
25
+ "design_spike_with_cowl",
26
+ "estimate_base_pressure",
27
+ "majdalani_mach_from_er",
28
+ "truncated_spike_with_base",
29
+ ]
@@ -0,0 +1,260 @@
1
+ """Aerospike truncation base pressure + primary cowl (internal nozzle) helpers.
2
+
3
+ Base pressure on a truncated spike is a major real-world Isp correction.
4
+ Models here are engineering correlations, not full CFD.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ import math
10
+ from dataclasses import dataclass
11
+
12
+ import numpy as np
13
+
14
+ from rockmoc.aerospike.lee_spike import SpikeResult, design_spike, design_spike_truncated
15
+ from rockmoc.exceptions import DesignError
16
+ from rockmoc.geometry.contour import Contour
17
+ from rockmoc.thermo.perfect_gas import PerfectGas
18
+
19
+
20
+ @dataclass(slots=True)
21
+ class BasePressureModel:
22
+ """Simple truncated-spike base pressure estimate."""
23
+
24
+ p_base: float
25
+ p_base_over_pc: float
26
+ model: str
27
+ meta: dict
28
+
29
+ def summary(self) -> dict:
30
+ return {
31
+ "p_base_Pa": self.p_base,
32
+ "p_base_over_pc": self.p_base_over_pc,
33
+ "model": self.model,
34
+ **self.meta,
35
+ }
36
+
37
+
38
+ def estimate_base_pressure(
39
+ *,
40
+ pc: float,
41
+ pa: float,
42
+ pe: float,
43
+ truncation_fraction: float,
44
+ gamma: float = 1.25,
45
+ ) -> BasePressureModel:
46
+ """Estimate base pressure on truncated aerospike tip.
47
+
48
+ Correlation (engineering):
49
+ p_b / p_a ≈ k1 + k2 * (1 - L/L_full) * (pe/pa)^n
50
+ clamped between a fraction of pe and a multiple of pa.
51
+
52
+ For full spike (truncation_fraction=1), base area → 0, p_b unused.
53
+ """
54
+ if pc <= 0:
55
+ raise DesignError("pc must be positive")
56
+ f = float(np.clip(truncation_fraction, 0.05, 1.0))
57
+ if f >= 0.999:
58
+ return BasePressureModel(
59
+ p_base=pa,
60
+ p_base_over_pc=pa / pc,
61
+ model="full_spike_no_base",
62
+ meta={"truncation_fraction": f},
63
+ )
64
+
65
+ # Open literature: base pressure often O(pa) with recovery toward pe
66
+ # for highly truncated plugs.
67
+ trunc = 1.0 - f
68
+ # Simple blend: more truncation → p_b closer to pe (recirculation)
69
+ # less truncation → p_b closer to pa
70
+ pe_use = max(pe, 1e-6)
71
+ pa_use = max(pa, 0.0)
72
+ p_b = pa_use * (1.0 - 0.6 * trunc) + pe_use * (0.35 * trunc)
73
+ # Ambient dominance at high altitude
74
+ if pa_use < 0.01 * pe_use:
75
+ p_b = 0.3 * pe_use * trunc + pa_use
76
+ p_b = max(p_b, 0.0)
77
+
78
+ return BasePressureModel(
79
+ p_base=float(p_b),
80
+ p_base_over_pc=float(p_b / pc),
81
+ model="blend_pa_pe_truncation",
82
+ meta={
83
+ "truncation_fraction": f,
84
+ "pa_Pa": pa,
85
+ "pe_Pa": pe,
86
+ "gamma": gamma,
87
+ },
88
+ )
89
+
90
+
91
+ def truncated_spike_with_base(
92
+ full: SpikeResult,
93
+ *,
94
+ length_fraction: float = 0.2,
95
+ ) -> tuple[SpikeResult, BasePressureModel, dict]:
96
+ """Truncate spike and correct thrust/Isp with base pressure force.
97
+
98
+ ΔF_base ≈ (p_b - p_a) * A_base
99
+ A_base ≈ π R_tip² (projected base of truncated spike).
100
+ """
101
+ trunc = design_spike_truncated(full, length_fraction=length_fraction)
102
+ R_tip = float(trunc.R[-1])
103
+ A_base = math.pi * max(R_tip, 0.0) ** 2
104
+ bp = estimate_base_pressure(
105
+ pc=full.Pc,
106
+ pa=full.Pa,
107
+ pe=full.Pe,
108
+ truncation_fraction=length_fraction,
109
+ gamma=full.gamma,
110
+ )
111
+ dF = (bp.p_base - full.Pa) * A_base
112
+ F_corr = trunc.F + dF
113
+ Isp_corr = F_corr / (trunc.m_dot * 9.80665) if trunc.m_dot > 0 else trunc.Isp
114
+ Cf_corr = F_corr / (full.Pc * full.At) if full.At > 0 else trunc.Cf
115
+
116
+ perf = {
117
+ "F_uncorrected_N": trunc.F,
118
+ "F_base_N": dF,
119
+ "F_corrected_N": F_corr,
120
+ "Isp_uncorrected_s": trunc.Isp,
121
+ "Isp_corrected_s": Isp_corr,
122
+ "Cf_corrected": Cf_corr,
123
+ "A_base_m2": A_base,
124
+ "R_tip_m": R_tip,
125
+ "base": bp.summary(),
126
+ }
127
+ # Update truncated result fields
128
+ trunc.F = F_corr
129
+ trunc.Isp = Isp_corr
130
+ trunc.Cf = Cf_corr
131
+ trunc.meta = {**trunc.meta, "base_pressure_correction": perf}
132
+ return trunc, bp, perf
133
+
134
+
135
+ @dataclass(slots=True)
136
+ class CowlDesign:
137
+ """Simple primary (internal) cowl nozzle feeding the aerospike lip."""
138
+
139
+ contour: Contour
140
+ throat_radius: float # annular gap scale proxy
141
+ exit_radius: float
142
+ length: float
143
+ area_ratio_primary: float
144
+ meta: dict
145
+
146
+ def summary(self) -> dict:
147
+ return {
148
+ "length_m": self.length,
149
+ "area_ratio_primary": self.area_ratio_primary,
150
+ "throat_radius_m": self.throat_radius,
151
+ "exit_radius_m": self.exit_radius,
152
+ **self.meta,
153
+ }
154
+
155
+
156
+ def design_primary_cowl(
157
+ *,
158
+ Re_lip: float,
159
+ ht: float,
160
+ delta_rad: float,
161
+ gamma: float = 1.25,
162
+ primary_eps: float = 2.0,
163
+ n_points: int = 80,
164
+ ) -> CowlDesign:
165
+ """Design a short conical/primary internal nozzle to the shroud lip.
166
+
167
+ Geometry (engineering):
168
+ - Throat annulus height ht at angle delta to the axis (Lee/Vernacchia).
169
+ - Short expansion to primary_eps along the shroud side before the lip.
170
+ - Contour returned in (x, r) with lip at r ≈ Re_lip.
171
+ """
172
+ if Re_lip <= 0 or ht <= 0:
173
+ raise DesignError("Re_lip and ht must be positive")
174
+ if primary_eps < 1.0:
175
+ raise DesignError("primary_eps must be ≥ 1")
176
+
177
+ gas = PerfectGas(gamma=gamma)
178
+ # Throat at lip-inner side: r_t_outer ≈ Re_lip, gap ht along shroud normal
179
+ # Approximate centerline of annulus
180
+ r_throat_mid = Re_lip - 0.5 * ht * math.sin(delta_rad)
181
+ # Primary exit at lip
182
+ r_exit = Re_lip
183
+ # Length of primary nozzle along axis
184
+ # Area ratio for annular: rough (r_e^2 - r_i^2)/(r_t^2 - r_i_t^2)
185
+ # Use simple axial length from 15° wall
186
+ L = 1.5 * ht / max(math.tan(abs(delta_rad) + 0.15), 0.1)
187
+ L = max(L, 0.5 * ht)
188
+
189
+ x = np.linspace(-L, 0.0, n_points) # lip at x=0
190
+ # Outer shroud wall: straight from throat station to lip
191
+ r_outer = np.linspace(r_throat_mid + 0.5 * ht, r_exit, n_points)
192
+ # Inner wall (spike side at primary): gap grows with primary_eps
193
+ gap = ht * np.sqrt(np.linspace(1.0, primary_eps, n_points))
194
+ r_inner = r_outer - gap * math.sin(max(delta_rad, 0.2))
195
+
196
+ # Export outer cowl contour as the primary wall
197
+ th = np.arctan2(np.gradient(r_outer), np.gradient(x))
198
+ M = np.linspace(1.05, float(gas.mach_from_area_ratio(primary_eps, branch="supersonic")), n_points)
199
+ contour = Contour(x=x, r=r_outer, theta=th, M=M)
200
+
201
+ return CowlDesign(
202
+ contour=contour,
203
+ throat_radius=ht, # gap as characteristic scale
204
+ exit_radius=r_exit,
205
+ length=L,
206
+ area_ratio_primary=primary_eps,
207
+ meta={
208
+ "delta_deg": math.degrees(delta_rad),
209
+ "Re_lip_m": Re_lip,
210
+ "ht_m": ht,
211
+ "r_inner_throat": float(r_inner[0]),
212
+ "r_inner_exit": float(r_inner[-1]),
213
+ "model": "short_primary_cowl_engineering",
214
+ },
215
+ )
216
+
217
+
218
+ def design_spike_with_cowl(
219
+ *,
220
+ Pc: float,
221
+ Tc: float,
222
+ gamma: float,
223
+ molar_mass: float,
224
+ Re: float,
225
+ expansion_ratio: float,
226
+ Pa: float = 101325.0,
227
+ n_points: int = 10000,
228
+ primary_eps: float = 2.0,
229
+ truncate: float | None = None,
230
+ ) -> dict:
231
+ """Full annular stack: primary cowl + spike (+ optional truncation/base)."""
232
+ spike = design_spike(
233
+ Pc=Pc,
234
+ Tc=Tc,
235
+ gamma=gamma,
236
+ molar_mass=molar_mass,
237
+ Re=Re,
238
+ expansion_ratio=expansion_ratio,
239
+ Pa=Pa,
240
+ n_points=n_points,
241
+ )
242
+ cowl = design_primary_cowl(
243
+ Re_lip=Re,
244
+ ht=spike.ht,
245
+ delta_rad=spike.delta_rad,
246
+ gamma=gamma,
247
+ primary_eps=primary_eps,
248
+ )
249
+ out: dict = {
250
+ "spike": spike,
251
+ "cowl": cowl,
252
+ "spike_summary": spike.summary(),
253
+ "cowl_summary": cowl.summary(),
254
+ }
255
+ if truncate is not None:
256
+ trunc, bp, perf = truncated_spike_with_base(spike, length_fraction=truncate)
257
+ out["truncated_spike"] = trunc
258
+ out["base_pressure"] = bp
259
+ out["base_performance"] = perf
260
+ return out