Repository navigation
Expand file tree
/
Copy pathrocket_engine.py
More file actions
2487 lines (2230 loc) · 110 KB
/
Copy pathrocket_engine.py
File metadata and controls
2487 lines (2230 loc) · 110 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Engineering notebook: a 1.5-million-pound-thrust LOX/RP-1 gas-generator engine, F-1 class
#
# Goal: an engine in the image of the Rocketdyne F-1, at the fidelity of every coolant tube, every
# injector orifice ring and baffle, every major duct and valve, and no small lines, harnesses,
# brackets or fasteners. Its test is the three-quarter view and the half-section on the
# turbopump plane: the tube-wall bell with its corrugated outside, the turbopump standing beside
# the chamber, the exhaust duct running down to the manifold that rings the nozzle. It takes the
# F-1 as a point of departure, not a replica: the bell is a Rao parabola from the published
# throat and exit, the turbomachinery is external shape only. The script measures the engine
# against the scope's checks, as the chief engineer's review 1 amended them, and prints each
# result.
#
# Structure: each part is built once in its own frame, as an assembly `Part`, and placed by
# `Component` frames in the scope's product tree; a part placed many times (178 primary tubes,
# 356 secondary tubes, 12 radial baffles, 3 struts, the main valves) is one product in STEP.
# F1_engine
# thrust_chamber: injector (body, 32 orifice rings, circumferential baffle, 12 radial
# baffles), lox_dome, fuel_inlet_manifold, 178 tube_primary, 356 tube_secondary,
# 10 hatbands, throat_band, return_manifold, nozzle_extension
# turbopump: lox_pump, fuel_pump, turbine, 3 struts
# gas_generator: combustor, gg_valve
# turbine_exhaust: heat_exchanger, exhaust_duct, exhaust_manifold
# propellant_feed: lox_duct +/-Y, main_lox_valve x2, fuel_duct +/-Y, main_fuel_valve x2
# gimbal_block
# The -Y ducts are the +Y ducts' mirror images, parts of their own, since a placement can't
# mirror.
#
# Outputs, in output/: rocket_engine.step (the product tree, named and colored by material), and
# renders: rocket_engine_iso.png (three-quarter view), rocket_engine_feed.png (the chamber head:
# feed, volute and mount), rocket_engine_side.png (elevation with a ruler) and
# rocket_engine_section.png (half-section on the turbopump plane). This run checks everything
# that takes seconds; checks/check_rocket_engine.py runs the checks that take minutes
# (interference, what each part touches, the exhaust duct's clearance sweep) and renders the
# detail views: the tubes at the throat and at eps 3, the chamber head and the eps 10 joint in
# section, and the injector face. This run takes about 10 minutes: the build 1 to 3 minutes,
# most of it the 6,300 injector holes; the STEP file, 64 MB, 20 s; the checks 2.5 minutes; the
# views 5 minutes. The checks script takes about 15.
#
# Units are millimetres. Z is the engine axis, positive up toward the vehicle; the origin is the
# injector face's center; +X points to the turbopump's axis. The chamber contour is written as
# radius r against x, the axial distance downstream of the throat, so z = -900 - x.
#
# Readings of the scope and the review, and why:
# - Tube corners are 0.45 of the section's smaller side at every profile (review 1), so the wide
# tubes at eps 3 read round. The scope's w = 2 pi r / N - 0.3 leaves 0.3 mm between neighbours
# only for sharp corners; with them rounded the nearest approach opens to 0.3 + corner x
# 2 pi / N. The braze gap is the nearest approach, so tubes are that much wider than the
# formula (0.25 to 0.35 mm on primaries, 0.11 to 0.14 mm on secondaries); the check reports
# both widths.
# - Tube sweeps take their profiles evenly spaced along the path (32 a tube), not at the scope's
# stations: profiles close together then far apart make the sweep's width law overshoot.
# Between stations the width stays within 0.02 mm of the design.
# - Secondary tube ends are cut square to the axis at the end of the tube wall, to sit on the
# return manifold's flat top, rather than square to the tube.
# - The eps 10 joint: the hot-gas wall runs on the contour through the tube crowns, the return
# manifold's bore and the extension's inner wall; the extension's top flange closes its
# passage and bolts to the return manifold's flat underside; the exhaust manifold rings the
# extension just below the flange (to r = 1,790), with two lips bearing on the extension's
# outside and 24 windows in its outer wall between them. The passage is open at the exit,
# where the exhaust leaves as a film; the shingles are not modeled.
# - The exhaust duct leaves the heat exchanger's neck straight down, on its axis (review 2: a
# stub tilted outward left a crease and a wedge where it met the duct), swings outward in one
# smooth curve beside the bell, and over its last 500 mm flattens, at the bore's area, into a
# curved fishtail mouth on the manifold's top outboard of the joint flanges (a round 562 mm
# duct can't land on a manifold 300 mm wide).
# - The propellant feed follows review 1: the LOX dome's inlets at +/-45 degrees and the fuel
# manifold's at +/-60 degrees from +X, each nozzle turned 45 degrees toward +X, so the valves
# point back at the pump. Their nozzles are 170 and 120 mm long, the least that keeps the
# valves' flanges clear of the dome and the manifold. The turbopump moves out from the
# scope's 1,200 to 1,250 mm, which leaves room for the ducts and keeps them within |y| 1,000.
# The LOX ducts are straight spools on the valves' axes: between discharge and valve there is
# no room for a bend of 1.5 diameters. Each fuel duct takes one bend of 91 degrees; it reaches
# 1.4 m from the engine axis at its bend beside the pump, past the review's 1.3 m. A search of
# every discharge position and direction on the fuel pump found no one-bend duct that stays
# within 1.3 m, since the fuel valve's outer flange is already at 1.05 m and points outward.
# - The LOX pump's double volute: two scrolls whose passage grows from 120 to 260 mm across as
# it wraps 90 degrees from the far side of the pump to a discharge on the +Y or -Y side, the
# discharges 180 degrees apart about the axis and both turned toward the engine. A true double
# volute is symmetric under a half turn, which points one discharge away from the engine; that
# duct would need a reversal of at least two bend radii (830 mm), past the review's limits. So
# the scrolls are mirror images, which also keeps the +/-Y ducts mirror pairs. The fuel pump
# stays a turned volute with stubs (optional in the review).
# - The turbopump mount: three struts, one part, each between flat-faced bosses on its two
# parts: two from the fuel manifold to the fuel pump either side of the X axis, one from a
# band at the throat (100 mm wide, so its bracket stands on it) to the turbine.
# - Injector passages: a groove behind each drilled ring; LOX down from the dome in 18 mm
# passages to the LOX grooves; fuel from a ring over the tube tops along 14 mm radial drillings
# above the grooves, dropping into the fuel grooves. The drillings and passages alternate every
# 15 degrees and swap over on the -X half, so the half-section shows a fuel path at 0 degrees
# and a LOX path at 180.
# - The fuel inlet manifold's bore is 0.05 mm larger than the tube crowns' 532 mm: the tubes'
# outer faces are flat, and their corners stand proud of a 532 mm circle. The injector's outer
# flange hangs 40 mm below the face, outside the tubes, onto its top.
# - Injector face: the radial baffles start on the +X axis, so the half-section cuts one
# lengthwise. Holes are like-on-like pairs; the two rings either side of the circumferential
# baffle lie within 12 mm of it and carry none. Holes per ring follow the ring's radius,
# scaled so the rings total 3,702 LOX and 2,602 fuel holes.
# - LOX dome: a 2:1 head on a 50 mm straight flange, rising 280 mm, its crown a solid boss for
# the gimbal.
# - Turbine inlet manifold: a drum with rounded edges, 950 x 300, rather than a torus, which
# would touch the casing's bottom face tangentially.
# - Colors: Inconel, aluminum and steel each have a color of their own, since the library's
# material greys for them are too close to tell apart (review 1).
# - Optional items taken: ten hatbands from eps 2 to eps 10, bearing on the tube crowns.
# - Densities only where a check needs a mass (the tube bundle, Inconel X-750).
# - Checks: interference is measured among all 534 tubes, and among every other part (the
# orifice rings as their undrilled envelopes) with a tube of each kind, which stands for all
# of them against a turned chamber. Contact is each part's list of neighbours within 0.01 mm
# against the list it should have. Tube gaps are measured to the plane of symmetry between
# neighbours, and the exhaust duct's clearance on sections through the axis every 2 degrees
# across it, where whole-solid distances between these swept parts take minutes.
"""F-1-class LOX/RP-1 gas-generator engine: build it, write it to STEP, check it, render it."""
from __future__ import annotations
import bisect
import math
import time
from itertools import pairwise
from pathlib import Path
from pyocctlite import (
Assembly,
Axis,
Box,
Camera,
CircleCurve,
ClearanceShapes,
Color,
Component,
Containment,
Continuity,
Cylinder,
CylindricalSurface,
DistanceShapes,
Edge,
EllipseCurve,
Face,
Frame,
InterferenceShapes,
Keep,
LoftShape,
MaterialColor,
MeasureShape,
MeshShape,
Part,
Plane,
Point,
ReadStep,
Rectangle,
RenderShapes,
RenderStyle,
SectionPlane,
Shape,
Solid,
SweepShape,
TrimmedCurve,
Vector,
View,
Wire,
WriteStep,
)
OUTPUTS = Path(__file__).parent / "output"
OUTPUTS.mkdir(parents=True, exist_ok=True)
def pt(x: float, y: float, z: float) -> Point:
"""A point by its coordinates."""
return Point.by_xyz(x, y, z)
def vec(x: float, y: float, z: float) -> Vector:
"""A vector by its components."""
return Vector.by_xyz(x, y, z)
# --- Key parameters -----------------------------------------------------------------------------
# Chamber and nozzle contour (Rao thrust-optimized bell; scope "Chamber and nozzle contour")
R_THROAT = 450.0
R_CHAMBER = 510.0
EPS_EXIT, EPS_TUBES, EPS_SPLIT = 16.0, 10.0, 3.0 # exit, end of tube wall, bifurcation
FACE_TO_THROAT = 900.0
CONV_ANGLE = math.radians(20.0)
R_UPSTREAM = 1.5 * R_THROAT # throat arc, upstream
R_CHAMBER_ARC = 250.0
R_DOWNSTREAM = 0.382 * R_THROAT # throat arc, downstream
BELL_START, BELL_EXIT = math.radians(31.0), math.radians(8.0) # Rao's theta_n, theta_e at eps 16
RAO_LENGTH = 0.8 # fraction of a 15 degree cone's length
# Coolant tubes
N_PRIMARY, N_SECONDARY = 178, 356
DEPTH_PRIMARY, DEPTH_SECONDARY = 22.0, 18.0
CORNER_FRACTION = (
0.45 # corner radius as a fraction of the section's smaller side, at every profile
)
TUBE_WALL = 0.5
BRAZE_GAP = 0.3 # nearest approach of neighbours, standing in for the braze joint
TUBE_PROFILES = 32 # profiles per sweep, evenly spaced along the path
# Injector
INJ_R, INJ_H = 560.0, 200.0
SKIRT_R, SKIRT_DROP = 535.0, 40.0 # outer flange hanging below the face onto the fuel manifold
N_RINGS, RING_R0, RING_PITCH, RING_W, RING_DEPTH = 32, 70.0, 13.6, 13.0, 25.0
N_LOX_HOLES, N_FUEL_HOLES = 3700, 2600
D_LOX_HOLE, D_FUEL_HOLE = 3.7, 3.2
HOLE_PAIR = 6.0 # spacing of the two holes of a like-on-like pair, along the ring
BAFFLE_CLEAR = 12.0 # no hole within this of a baffle's centerline
BAFFLE_R, N_RADIAL_BAFFLES = 250.0, 12
BAFFLE_H, BAFFLE_T = 76.0, 20.0
# LOX dome and gimbal
DOME_Z0, DOME_STRAIGHT, DOME_RISE = INJ_H, 50.0, 280.0 # 2:1 head on a 50 mm straight flange
DOME_WALL, DOME_TOP, BOSS_R = 15.0, 600.0, 200.0
LOX_INLET_Z, LOX_INLET_BORE = 350.0, 260.0
LOX_FLANGE_D, FLANGE_T = 360.0, 25.0
GIMBAL_TOP, GIMBAL_PIVOT = 850.0, 760.0
# Fuel inlet manifold
FUEL_MANIFOLD_TOP, FUEL_MANIFOLD_H, FUEL_MANIFOLD_DEPTH = -40.0, 200.0, 160.0
FUEL_MANIFOLD_WALL = 10.0
FUEL_INLET_Z, FUEL_INLET_BORE, FUEL_FLANGE_D = -140.0, 200.0, 300.0
# Return manifold, nozzle extension, exhaust manifold
RETURN_H, RETURN_DEPTH, RETURN_WALL = 120.0, 120.0, 8.0
EXT_WALL, EXT_GAP = 3.0, 25.0 # inner and outer wall thickness, exhaust passage between
EXT_FLANGE_T = 25.0
STIFFENER_H, STIFFENER_R = 50.0, 1860.0
EXH_MANIFOLD_H, EXH_MANIFOLD_R, EXH_WALL = 400.0, 1790.0, 6.0
EXH_LIP = 30.0 # lips bearing on the extension above and below the inlet windows
N_WINDOWS = 24
# Turbine exhaust
DUCT_BORE, DUCT_WALL = 550.0, 6.0
HX_R, HX_TOP, HX_BASE = 350.0, -850.0, -1350.0
HX_OUTLET_Z = -1450.0 # the outlet neck's face, on the heat exchanger's axis
# Materials (scope "Units ... Colors by material"); densities in kg/mm^3. The material colors
# of STEEL, STAINLESS_STEEL and ALUMINUM are greys too close to tell apart under shading (review
# 1, finding 7), so each material here has its own: Inconel a warm dark grey, aluminum castings a
# light grey, steel ducts a mid grey with a blue cast, copper as it is.
INCONEL = Color.by_rgb(0.44, 0.41, 0.38)
ALUMINUM = Color.by_rgb(0.83, 0.84, 0.86)
STEEL = Color.by_rgb(0.45, 0.52, 0.62)
COPPER = Color.by_material(MaterialColor.COPPER)
RHO_INCONEL = 8.28e-6
# --- Contour ------------------------------------------------------------------------------------
# The hot-gas wall in the XZ half-plane as radius r against x, the axial distance downstream of
# the throat, so z = -FACE_TO_THROAT - x. Every segment is its true curve: a line, three arcs and a
# quadratic Bezier bell, joined tangent. Values derived here match the scope's contour.py.
Z_THROAT = -FACE_TO_THROAT
X_FACE = -FACE_TO_THROAT
X_ARC_END = -R_UPSTREAM * math.sin(CONV_ANGLE) # start of the upstream throat arc
R_ARC_END = R_THROAT + R_UPSTREAM * (1 - math.cos(CONV_ANGLE))
R_CONE_TOP = R_CHAMBER - R_CHAMBER_ARC * (1 - math.cos(CONV_ANGLE))
X_CONE_TOP = X_ARC_END - (R_CONE_TOP - R_ARC_END) / math.tan(CONV_ANGLE)
X_CYL_END = X_CONE_TOP - R_CHAMBER_ARC * math.sin(CONV_ANGLE)
X_BELL = R_DOWNSTREAM * math.sin(BELL_START)
R_BELL = R_THROAT + R_DOWNSTREAM * (1 - math.cos(BELL_START))
R_EXIT = R_THROAT * math.sqrt(EPS_EXIT)
X_EXIT = (
RAO_LENGTH
* (R_THROAT * (math.sqrt(EPS_EXIT) - 1) + R_DOWNSTREAM * (1 / math.cos(math.radians(15)) - 1))
/ math.tan(math.radians(15))
)
_m1, _m2 = math.tan(BELL_START), math.tan(BELL_EXIT)
_c1, _c2 = R_BELL - _m1 * X_BELL, R_EXIT - _m2 * X_EXIT
X_Q = (_c2 - _c1) / (_m1 - _m2) # Bezier control point, where the end tangents meet
R_Q = _m1 * X_Q + _c1
def bell(t: float) -> tuple[float, float]:
"""Point (x, r) of the bell's quadratic Bezier at parameter t."""
u = 1 - t
return (
u * u * X_BELL + 2 * t * u * X_Q + t * t * X_EXIT,
u * u * R_BELL + 2 * t * u * R_Q + t * t * R_EXIT,
)
def bell_t(x: float = math.nan, r: float = math.nan) -> float:
"""Bezier parameter of the bell point at an x, or at a radius r; both rise along the bell."""
lo, hi = 0.0, 1.0
for _ in range(60):
m = (lo + hi) / 2
xm, rm = bell(m)
if (xm < x) if not math.isnan(x) else (rm < r):
lo = m
else:
hi = m
return (lo + hi) / 2
def contour(x: float) -> tuple[float, float]:
"""Hot-wall radius and slope dr/dx at x; the cylinder runs on above the injector face."""
if x <= X_CYL_END:
return R_CHAMBER, 0.0
if x <= X_CONE_TOP:
s = math.sqrt(R_CHAMBER_ARC**2 - (x - X_CYL_END) ** 2)
return R_CHAMBER - R_CHAMBER_ARC + s, -(x - X_CYL_END) / s
if x <= X_ARC_END:
return R_ARC_END + (X_ARC_END - x) * math.tan(CONV_ANGLE), -math.tan(CONV_ANGLE)
if x <= X_BELL:
rad = R_UPSTREAM if x <= 0 else R_DOWNSTREAM
s = math.sqrt(rad**2 - x**2)
return R_THROAT + rad - s, x / s
t = bell_t(x)
u = 1 - t
dx = 2 * u * (X_Q - X_BELL) + 2 * t * (X_EXIT - X_Q)
dr = 2 * u * (R_Q - R_BELL) + 2 * t * (R_EXIT - R_Q)
return bell(t)[1], dr / dx
def x_at_eps(eps: float) -> float:
"""x of the station on the bell with area ratio eps."""
return bell(bell_t(r=R_THROAT * math.sqrt(eps)))[0]
def offset(x: float, off: float) -> tuple[float, float]:
"""(x, r) of the point a distance off outward along the contour's normal at x."""
_, s = contour(x)
n = math.hypot(1.0, s)
return x - off * s / n, contour(x)[0] + off / n
def at(x: float, r: float, y: float = 0.0) -> Point:
"""The 3D point of contour coordinates (x, r), in the XZ plane."""
return pt(r, y, Z_THROAT - x)
def tangent(x: float) -> Vector:
"""Unit tangent of the contour at x, pointing downstream."""
_, s = contour(x)
n = math.hypot(1.0, s)
return vec(s / n, 0.0, -1.0 / n)
def x_at_z(z: float, off: float = 0.0) -> float:
"""Contour x whose offset point lies at height z."""
lo, hi = X_FACE - 200.0, X_EXIT + 200.0
for _ in range(80):
m = (lo + hi) / 2
if Z_THROAT - offset(m, off)[0] > z:
lo = m
else:
hi = m
return (lo + hi) / 2
def r_at_z(z: float, off: float = 0.0) -> float:
"""Radius of the contour offset by off, at height z."""
return offset(x_at_z(z, off), off)[1]
SEGMENTS = [
("line", -math.inf, X_CYL_END),
("arc", X_CYL_END, X_CONE_TOP),
("line", X_CONE_TOP, X_ARC_END),
("arc", X_ARC_END, 0.0),
("arc", 0.0, X_BELL),
("bell", X_BELL, X_EXIT + 400.0),
]
def contour_edges(xa: float, xb: float, off: float = 0.0) -> list[Edge]:
"""The contour from xa to xb, offset outward by off, as its true curves: lines and arcs
offset exactly; the bell's offset is a spline through 40 offset points with the bell's end
tangents, since an offset Bezier is not a Bezier."""
edges = []
for kind, s0, s1 in SEGMENTS:
a, b = max(xa, s0), min(xb, s1)
if b - a < 1e-6:
continue
if kind == "line":
edges.append(Edge.by_points(at(*offset(a, off)), at(*offset(b, off))))
elif kind == "arc":
mid = at(*offset((a + b) / 2, off))
edges.append(Edge.by_circular_arc(at(*offset(a, off)), mid, at(*offset(b, off))))
else:
ta, tb = bell_t(a), bell_t(b)
pts = [at(*offset(bell(ta + (tb - ta) * i / 40)[0], off)) for i in range(41)]
edges.append(
Edge.by_interpolation(pts, start_tangent=tangent(a), end_tangent=tangent(b))
)
return edges
def contour_path(xa: float, xb: float, off: float = 0.0) -> Edge:
"""The offset contour from xa to xb as one B-spline edge to sweep along, so that each edge of
a profile sweeps one face the length of the tube rather than one per segment of the path."""
return Edge.by_joining(Wire.by_edges(contour_edges(xa, xb, off)))
# --- Coolant tubes ------------------------------------------------------------------------------
def tube_section(x: float, n_tubes: int, depth: float) -> tuple[float, float]:
"""Outer width and corner radius of a tube at contour station x. The corner is
CORNER_FRACTION of the smaller side, so a wide tube reads round rather than as a plank. The
width brings neighbours, each a rounded rectangle with its sides parallel to its own meridian
plane, within BRAZE_GAP of each other at their nearest, the inner corner arcs at the hot wall.
The scope's 2 pi r / N - 0.3 gives that gap only for sharp corners; with them rounded it opens
to 0.3 + corner x 2 pi / N, so the width here is that much wider. Width and corner depend on
each other, so they are found together."""
r, s = contour(x)
h = math.pi / n_tubes
w = 2 * math.pi * r / n_tubes
for _ in range(20):
corner = CORNER_FRACTION * min(w, depth)
rho = r + corner / math.hypot(1.0, s) # radius of the inner corner arcs' centers
w = 2 * ((rho * math.sin(h) - corner - BRAZE_GAP / 2) / math.cos(h) + corner)
return w, CORNER_FRACTION * min(w, depth)
def tube_solid(xa: float, xb: float, depth: float, n_tubes: int) -> Solid:
"""One coolant tube at angle 0: a rounded-rectangle section, depth across the wall and width
around it, swept along the contour offset by half the depth, so its inner face is the hot
wall. Hollow with a TUBE_WALL wall: the outer and inner sections are swept as shells along
the same path and closed by the two flat end rings, which is exact and takes under a second
(cutting an inner sweep from an outer one took 14 s a tube). Profiles are spaced evenly along
the path: profiles close together then far apart made the sweep's width law overshoot by
metres between them."""
path = contour_path(xa, xb, depth / 2)
# x of each profile, evenly spaced in arc length along the offset contour
xs = [xa + (xb - xa) * i / 2000 for i in range(2001)]
pts = [offset(x, depth / 2) for x in xs]
arc = [0.0]
for p, q in pairwise(pts):
arc.append(arc[-1] + math.dist(p, q))
def x_at_arc(s: float) -> float:
i = min(max(bisect.bisect_left(arc, s), 1), len(arc) - 1)
f = (s - arc[i - 1]) / (arc[i] - arc[i - 1])
return xs[i - 1] + f * (xs[i] - xs[i - 1])
shells = []
for shrink in (0.0, TUBE_WALL):
sweep = None
for i in range(TUBE_PROFILES + 1):
x = x_at_arc(arc[-1] * i / TUBE_PROFILES)
frame = path.frame_at(path.length * i / TUBE_PROFILES, up=Vector.Y)
w, corner = tube_section(x, n_tubes, depth)
wire = Rectangle.by_size(
depth - 2 * shrink,
w - 2 * shrink,
frame=frame,
centered=True,
corner_radius=corner - shrink,
).outer_wire
if sweep is None:
sweep = SweepShape(wire, path, up=Vector.Y)
else:
sweep.add_profile(wire)
shells.append(sweep)
(outer, inner) = shells
ends = [
Face.by_wire(outer.first_shape(), holes=inner.first_shape()),
Face.by_wire(outer.last_shape(), holes=inner.last_shape()),
]
return Solid.by_faces([*outer.shape().faces(), *inner.shape().faces(), *ends])
# --- Sketch helpers -----------------------------------------------------------------------------
def rz(r: float, z: float) -> Point:
"""The point at radius r and height z in the XZ half-plane, where turned parts are drawn."""
return pt(r, 0.0, z)
def loop(*items: Point | list[Edge]) -> Wire:
"""A closed wire through points and chains of edges in order, joining each to the next with a
line from where the last one stopped; a chain is followed from whichever end is nearer."""
edges: list[Edge] = []
start: Point | None = None
cur: Point | None = None
def go(p: Point) -> None:
nonlocal start, cur
if cur is None:
start = p
elif cur.distance(p) > 1e-7:
edges.append(Edge.by_points(cur, p))
cur = p
for item in items:
if isinstance(item, Point):
go(item)
continue
a, b = item[0].first_vertex.point, item[-1].last_vertex.point
if cur is not None and cur.distance(b) < cur.distance(a):
a, b = item[-1].last_vertex.point, item[0].first_vertex.point
go(a)
edges.extend(item)
cur = b
assert start is not None and cur is not None
if cur.distance(start) > 1e-7:
edges.append(Edge.by_points(cur, start))
return Wire.by_edges(edges)
def rounded(face: Face, corners: list[tuple[float, float, float]]) -> Face:
"""The face with its corners at (r, z) rounded, each with its radius."""
for r, z, radius in corners:
corner = min(face.vertices(), key=lambda v: v.point.distance(rz(r, z)))
face = face.fillet_corners(corner, radius)
return face
def turned(
outline: Wire, corners: list[tuple[float, float, float]] | None = None, hole: Wire | None = None
) -> Solid:
"""A part turned about Z from an outline in the XZ half-plane, with its corners rounded, and
an optional hole in the section, which makes a closed hollow ring. The outline is rounded
before the hole goes in: rounding a corner of a face with a hole drops the hole."""
face = rounded(Face.by_wire(outline), corners or [])
if hole is not None:
face = Face.by_wire(face.wires()[0], holes=[hole])
# A crossed outline still makes a face, and the face a solid that checks valid, so check
# the section itself.
assert face.is_valid, "the section of a turned part crosses itself"
return face.revolve(Axis.Z)
def contour_between(z_top: float, z_bottom: float, off: float = 0.0) -> list[Edge]:
"""The contour offset by off, between two heights."""
return contour_edges(x_at_z(z_top, off), x_at_z(z_bottom, off), off)
def on_contour(z: float, off: float = 0.0) -> Point:
"""The point of the contour offset by off, at height z."""
return rz(r_at_z(z, off), z)
def disc(radius: float, length: float, origin: Point, axis: Vector) -> Solid:
"""A cylinder from a point along an axis, the x-direction of its frame chosen for it."""
side = Vector.Z if abs(axis.z) < 0.9 else Vector.X
return Cylinder.by_size(radius, length, frame=Frame.by_directions(origin, side, axis))
# --- Hatbands -----------------------------------------------------------------------------------
# Reinforcing bands round the bundle from eps 2 to eps 10 (optional in the scope), clear of the
# bifurcation's step in tube depth. Each bears on the tube crowns: its bore follows the contour
# offset by the tube depth plus 0.05 mm, since the crowns are flat and their corners stand
# 0.03 mm proud of the crown line.
HATBAND_EPS = [2.0, 2.6, 3.6, 4.4, 5.2, 6.0, 6.8, 7.6, 8.4, 9.2]
HATBAND_W, HATBAND_T, CROWN_CLEAR = 40.0, 6.0, 0.05
def hatband(x: float, width: float = HATBAND_W) -> Solid:
"""A band of a width along the wall, centered on contour station x."""
half = width / 2 / math.hypot(1.0, contour(x)[1])
depth = DEPTH_PRIMARY if x < x_at_eps(EPS_SPLIT) else DEPTH_SECONDARY
bore_off = depth + CROWN_CLEAR
return turned(
loop(
contour_edges(x - half, x + half, bore_off),
contour_edges(x - half, x + half, bore_off + HATBAND_T),
)
)
# --- Injector -----------------------------------------------------------------------------------
def ring_radii(k: int) -> tuple[float, float]:
"""Inner and outer radius of orifice ring k, numbered from the center out."""
r0 = RING_R0 + RING_PITCH * k
return r0, r0 + RING_W
def is_fuel_ring(k: int) -> bool:
"""Rings alternate fuel and LOX, the outermost fuel for a fuel film on the wall."""
return (N_RINGS - 1 - k) % 2 == 0
# One radial baffle lies on +X, in the turbopump plane, so the half-section cuts it lengthwise.
BAFFLE_ANGLES = [2 * math.pi * j / N_RADIAL_BAFFLES for j in range(N_RADIAL_BAFFLES)]
def clear_of_baffles(r: float, a: float, d: float) -> bool:
"""Whether a hole of diameter d at radius r and angle a keeps BAFFLE_CLEAR from every
baffle's centerline, measured to the hole's edge."""
keep = BAFFLE_CLEAR + d / 2
if abs(r - BAFFLE_R) < keep:
return False
if r < BAFFLE_R:
return True
return all(abs(r * math.sin(a - b)) >= keep or math.cos(a - b) < 0 for b in BAFFLE_ANGLES)
def ring_holes(k: int, pairs_per_mm: float) -> list[tuple[float, float]]:
"""Hole centers (x, y) of ring k: like-on-like pairs evenly around the ring's mid radius,
as many pairs as pairs_per_mm times the radius, less those too near a baffle."""
r = sum(ring_radii(k)) / 2
n_pairs = round(pairs_per_mm * r)
d = D_FUEL_HOLE if is_fuel_ring(k) else D_LOX_HOLE
holes = []
for i in range(n_pairs):
a = 2 * math.pi * (i + 0.5) / n_pairs
pair = [a - HOLE_PAIR / 2 / r, a + HOLE_PAIR / 2 / r]
if all(clear_of_baffles(r, b, d) for b in pair):
holes += [(r * math.cos(b), r * math.sin(b)) for b in pair]
return holes
def hole_layout() -> dict[int, list[tuple[float, float]]]:
"""Holes of every ring, the pairs per mm of radius of each propellant chosen so that the
holes clear of the baffles total N_LOX_HOLES and N_FUEL_HOLES."""
layout = {}
for fuel, total in ((False, N_LOX_HOLES), (True, N_FUEL_HOLES)):
rings = [k for k in range(N_RINGS) if is_fuel_ring(k) == fuel]
lo, hi = 0.0, 1.0
for _ in range(40):
m = (lo + hi) / 2
if sum(len(ring_holes(k, m)) for k in rings) < total:
lo = m
else:
hi = m
layout.update({k: ring_holes(k, hi) for k in rings})
return layout
# Propellant passages in the body (review 1, finding 4), enough for the half-section to show
# where the 6,304 holes are fed from. Each drilled ring has a feed groove behind it. LOX comes
# down from the dome through axial passages into the LOX grooves. Fuel comes up the tubes into a
# fuel ring over their tops, runs inward along radial drillings above the grooves, and drops into
# the fuel grooves; LOX and fuel each drop into their grooves through short holes narrower than
# the grooves (holes that met the groove walls left faces that could not be meshed). The radial
# drillings and the LOX passages lie at
# azimuths 15 degrees apart, so the two propellants never meet.
GROOVE_W, GROOVE_DEPTH = 8.0, 30.0
LOX_PASSAGE_D, N_PASSAGES = 18.0, 12 # per LOX groove
FUEL_RING = (512.0, 530.0, 90.0) # inner and outer radius, height above the face
FUEL_DRILL_D, FUEL_DRILL_Z = 14.0, 75.0
DROP_D = 6.0 # into each groove, narrower than it so no hole grazes a groove's wall
Z_GROOVE_TOP = RING_DEPTH + GROOVE_DEPTH
def passage_angles(fuel: bool) -> list[float]:
"""Azimuths of the fuel drillings, or of the LOX passages 15 degrees from them: every 30
degrees, the families swapping over on the -X half, so that the half-section on the
turbopump plane cuts a fuel drilling at 0 degrees and a LOX passage at 180."""
step, half = 2 * math.pi / N_PASSAGES, N_PASSAGES // 2
first = [step * j for j in range(half)]
second = [math.pi + step / 2 + step * j for j in range(half)]
if not fuel:
first = [a + step / 2 for a in first]
second = [a - step / 2 for a in second]
return first + second
def injector_blank() -> Solid:
"""The injector body before its passages: from the face up INJ_H, its face recessed
RING_DEPTH between the central plug and the wall for the orifice rings, with an outer flange
hanging SKIRT_DROP below the face onto the fuel manifold, clear of the tube tops that bear
on the face."""
r_rings = ring_radii(N_RINGS - 1)[1]
return turned(
loop(
rz(0, 0),
rz(RING_R0, 0),
rz(RING_R0, RING_DEPTH),
rz(r_rings, RING_DEPTH),
rz(r_rings, 0),
rz(SKIRT_R, 0),
rz(SKIRT_R, -SKIRT_DROP),
rz(INJ_R, -SKIRT_DROP),
rz(INJ_R, INJ_H),
rz(0, INJ_H),
)
)
def injector_body(layout: dict[int, list[tuple[float, float]]]) -> Shape:
"""The injector body: its blank with the propellant passages cut."""
body = injector_blank()
fed = [k for k in range(N_RINGS) if layout[k]]
grooves, lox, fuel = [], [], []
for k in fed:
r = sum(ring_radii(k)) / 2
g = GROOVE_W / 2
# from 1 mm below the ring's top, in the empty recess, so the faces don't coincide
grooves.append(
turned(
loop(
rz(r - g, RING_DEPTH - 1),
rz(r + g, RING_DEPTH - 1),
rz(r + g, Z_GROOVE_TOP),
rz(r - g, Z_GROOVE_TOP),
)
)
)
for a in passage_angles(is_fuel_ring(k)):
p = pt(r * math.cos(a), r * math.sin(a), 0)
top = FUEL_DRILL_Z if is_fuel_ring(k) else Z_GROOVE_TOP + 6
drop = p.translate(vec(0, 0, Z_GROOVE_TOP - 1))
(fuel if is_fuel_ring(k) else lox).append(
disc(DROP_D / 2, top - Z_GROOVE_TOP + 2, drop, Vector.Z)
)
if not is_fuel_ring(k): # down from the dome to 5 mm above the groove
above = p.translate(vec(0, 0, Z_GROOVE_TOP + 5))
lox.append(disc(LOX_PASSAGE_D / 2, INJ_H - Z_GROOVE_TOP - 4, above, Vector.Z))
r0, r1, h = FUEL_RING
fuel.append(turned(loop(rz(r0, -1), rz(r1, -1), rz(r1, h), rz(r0, h))))
for a in passage_angles(True):
u = vec(math.cos(a), math.sin(a), 0)
fuel.append(
disc(
FUEL_DRILL_D / 2,
r1 - RING_R0 + 10,
pt(0, 0, FUEL_DRILL_Z).translate(u.scale(RING_R0 - 10)),
u,
)
)
return body.cut(grooves).cut(lox).cut(fuel)
def orifice_ring(k: int, holes: list[tuple[float, float]]) -> Shape:
"""Copper ring k in the face recess, its holes drilled through in one operation."""
r0, r1 = ring_radii(k)
ring = turned(loop(rz(r0, 0), rz(r1, 0), rz(r1, RING_DEPTH), rz(r0, RING_DEPTH)))
if not holes:
return ring
d = D_FUEL_HOLE if is_fuel_ring(k) else D_LOX_HOLE
frames = [Frame.by_directions(pt(x, y, RING_DEPTH), Vector.X, Vector.Z) for x, y in holes]
return ring.holes(frames, d)
def baffle_outline(origin: Point, across: Vector) -> Wire:
"""Section of a baffle centered on a point of the face: BAFFLE_T thick across, BAFFLE_H tall
below the face, with a round tip."""
h = BAFFLE_T / 2
def p(a: float, z: float) -> Point:
return origin.translate(across.scale(a)).translate(vec(0, 0, z))
tip = Edge.by_circular_arc(p(-h, -BAFFLE_H + h), p(0, -BAFFLE_H), p(h, -BAFFLE_H + h))
return loop(p(-h, 0), [tip], p(h, 0))
def circumferential_baffle() -> Solid:
"""The ring baffle at BAFFLE_R that, with the radial baffles, makes 13 compartments."""
return turned(baffle_outline(rz(BAFFLE_R, 0), Vector.X))
def radial_baffle() -> Shape:
"""A radial baffle along +X from the circumferential baffle to 0.5 mm short of the hot wall,
its inner end hollowed to bear on the circumferential baffle's outer face."""
r_in = BAFFLE_R + BAFFLE_T / 2
bar = Face.by_wire(baffle_outline(pt(r_in - 5, 0, 0), Vector.Y)).extrude(
vec(R_CHAMBER - 0.5 - (r_in - 5), 0, 0)
)
return bar.cut(disc(r_in, 200, pt(0, 0, -150), Vector.Z))
# --- Propellant feed layout ---------------------------------------------------------------------
# The inlets on the LOX dome and on the fuel manifold face the turbopump (review 1, finding 1):
# each inlet nozzle leaves its part at an azimuth from +X, its axis level and turned from radial
# toward +X by INLET_TURN, so the main valve on it points back at the pump. Each duct runs from a
# pump discharge to its valve's outer flange. The LOX valves lie on the line of the LOX
# discharges, so the LOX ducts are straight spools: with the pump 1.2 m out there is no room
# between discharge and valve for a bend of 1.5 diameters. The fuel ducts take one bend.
LOX_INLET_AZ, FUEL_INLET_AZ, INLET_TURN = math.radians(45), math.radians(60), math.radians(45)
LOX_NOZZLE, FUEL_NOZZLE = 170.0, 120.0 # inlet nozzle, from its part's outside to its flange face
FEED_WALL = 8.0
BEND = 1.5 # bend radius, in duct outside diameters
SPOOL = 30.0 # straight run at least at each end of a duct, for its flange
PUMP_X = 1250.0 # turbopump axis on +X
LOX_DIFFUSER = 150.0 # LOX scroll's end to its discharge flange face
FUEL_STUB_AZ, FUEL_STUB = math.radians(94), 20.0 # fuel discharge: azimuth on the pump, length
FUEL_CORNER = 360.0 # the fuel duct's bend, from the valve's outer flange along its axis
def dome_radius(z: float) -> float:
"""Outside radius of the LOX dome at height z."""
z0 = DOME_Z0 + DOME_STRAIGHT
return INJ_R * math.sqrt(1 - ((z - z0) / DOME_RISE) ** 2) if z > z0 else INJ_R
def inlet(s: int, az: float, r: float, z: float, nozzle: float, valve: float) -> dict:
"""An inlet on the +Y (s = 1) or -Y (s = -1) side: the nozzle's base on its part's outside
at the azimuth, its axis, its flange face, and the outer flange of the valve on it."""
base = pt(r * math.cos(az), s * r * math.sin(az), z)
axis = vec(math.cos(az - INLET_TURN), s * math.sin(az - INLET_TURN), 0)
face = base.translate(axis.scale(nozzle))
return {"base": base, "axis": axis, "face": face, "end": face.translate(axis.scale(valve))}
def lox_inlet(s: int) -> dict:
"""The LOX dome's inlet on side s."""
return inlet(s, LOX_INLET_AZ, dome_radius(LOX_INLET_Z), LOX_INLET_Z, LOX_NOZZLE, 400.0)
def fuel_inlet(s: int) -> dict:
"""The fuel manifold's inlet on side s, on the round outside of its D-section."""
r = FUEL_MANIFOLD_R + FUEL_MANIFOLD_DEPTH
return inlet(s, FUEL_INLET_AZ, r, FUEL_INLET_Z, FUEL_NOZZLE, 320.0)
def lox_duct_points(s: int) -> list[Point]:
"""The LOX duct's centerline: from the scroll's discharge flange straight along -X into the
valve, on the valve's axis."""
end = lox_inlet(s)["end"]
return [pt(PUMP_X - LOX_DIFFUSER, end.y, LOX_INLET_Z), end]
def fuel_discharge(s: int) -> tuple[Point, Vector, Point]:
"""The fuel discharge on side s, pump-local: where it leaves the volute's outside at
FUEL_STUB_AZ, its direction, pointed at the fuel duct's bend, and its flange face."""
a = s * FUEL_STUB_AZ
v = fuel_inlet(s)
corner = v["end"].translate(v["axis"].scale(FUEL_CORNER)).translate(vec(-PUMP_X, 0, 0))
root = pt(FUEL_VOLUTE_R * math.cos(a), FUEL_VOLUTE_R * math.sin(a), FUEL_INLET_Z)
u = Vector.by_points(root, corner).normalize()
return root, u, root.translate(u.scale(FUEL_STUB))
def fuel_duct_points(s: int) -> list[Point]:
"""The fuel duct's centerline as a polyline: from the fuel discharge's flange, to the bend on
the valve's axis, to the valve's outer flange. The search for this layout found no one-bend
duct from the fuel pump to this valve within 1.3 m of the engine axis: the valve's outer
flange is already at 1.05 m, pointing outward."""
v = fuel_inlet(s)
to_engine = vec(PUMP_X, 0, 0)
start = fuel_discharge(s)[2].translate(to_engine)
return [start, v["end"].translate(v["axis"].scale(FUEL_CORNER)), v["end"]]
def bent_path(points: list[Point], radius: float) -> tuple[Edge, list[float]]:
"""A centerline through a polyline's ends with each corner rounded to a radius, as one edge,
and the angle of each bend in degrees; every corner leaves at least SPOOL straight at the
ends."""
edges, angles, cur = [], [], points[0]
for p0, p1, p2 in zip(points, points[1:], points[2:], strict=False):
d1 = Vector.by_points(p0, p1).normalize()
d2 = Vector.by_points(p1, p2).normalize()
theta = math.radians(d1.angle(d2))
t = radius * math.tan(theta / 2)
a, b = p1.translate(d1.scale(-t)), p1.translate(d2.scale(t))
bisector = d2.subtract(d1).normalize()
mid = p1.translate(bisector.scale(radius / math.cos(theta / 2) - radius))
assert cur.distance(a) >= SPOOL - 1e-6, "a bend runs into the end of its duct"
edges += [Edge.by_points(cur, a), Edge.by_circular_arc(a, mid, b)]
angles.append(math.degrees(theta))
cur = b
assert cur.distance(points[-1]) >= SPOOL - 1e-6, "a bend runs into the end of its duct"
edges.append(Edge.by_points(cur, points[-1]))
if len(edges) == 1:
return edges[0], angles
return Edge.by_joining(Wire.by_edges(edges)), angles
# --- LOX dome and gimbal block ------------------------------------------------------------------
def lox_dome() -> Shape:
"""A 2:1 elliptical head on a straight flange, its crown a solid boss for the gimbal, with the
two LOX inlets facing the pump: nozzles from the dome to flanges, bored through to the
inside."""
z0 = DOME_Z0 + DOME_STRAIGHT
frame = Frame.by_directions(pt(0, 0, z0), Vector.X, vec(0, -1, 0)) # sketch x = r, y = z
def head(a: float, b: float, r_end: float) -> Edge:
"""The quarter ellipse of the head from the flange in to radius r_end."""
curve = EllipseCurve.by_radii(a, b, frame=frame)
return Edge.by_curve(TrimmedCurve.by_curve(curve, 0.0, math.acos(r_end / a)))
r_in = INJ_R - DOME_WALL
outer = head(INJ_R, DOME_RISE, BOSS_R)
inner = head(r_in, DOME_RISE - DOME_WALL, 1e-3)
z_in = inner.last_vertex.point.z
dome = turned(
loop(
rz(r_in, DOME_Z0),
rz(INJ_R, DOME_Z0),
[outer],
rz(BOSS_R, DOME_TOP),
rz(0, DOME_TOP),
rz(0, z_in),
[inner],
)
)
cavity = turned(loop(rz(0, DOME_Z0 - 1), rz(r_in, DOME_Z0 - 1), [inner], rz(0, z_in)))
od = LOX_INLET_BORE + 2 * DOME_WALL
adds, bores = [], []
for side in (1, -1):
v = lox_inlet(side)
c = v["base"].translate(v["axis"].scale(-400)) # from inside the dome
length = 400 + LOX_NOZZLE
flange_at = v["face"].translate(v["axis"].scale(-FLANGE_T))
adds.append(disc(od / 2, length - FLANGE_T, c, v["axis"]).cut(cavity))
adds.append(disc(LOX_FLANGE_D / 2, FLANGE_T, flange_at, v["axis"]))
bores.append(disc(LOX_INLET_BORE / 2, length + 1, c, v["axis"]))
return dome.unite(adds).cut(bores)
def gimbal_block() -> Shape:
"""Block on the dome's boss, a spherical-bearing housing on it whose top is the vehicle
interface, and clevis ears on +/-X carrying a pin along Y through the pivot."""
z_block = GIMBAL_PIVOT - 40
block = Box.by_size(
400, 400, z_block - DOME_TOP, frame=Frame.by_origin(pt(-200, -200, DOME_TOP))
)
parts: list[Shape] = [disc(125, GIMBAL_TOP - z_block, pt(0, 0, z_block), Vector.Z)]
for s in (1, -1):
parts.append(
Box.by_size(40, 160, 110, frame=Frame.by_origin(pt(s * 170 - 20, -80, z_block)))
)
parts.append(disc(30, 220, pt(s * 170, -110, GIMBAL_PIVOT), Vector.Y))
return block.unite(parts)
# --- Fuel inlet manifold ------------------------------------------------------------------------
# Its bore clears the tubes' flat outer faces, whose corners stand 0.015 mm proud of the radius
# of their centers.
FUEL_MANIFOLD_R = R_CHAMBER + DEPTH_PRIMARY + 0.05
def fuel_inlet_manifold() -> Shape:
"""D-section ring, flat on the bore and round outside, hollow, with the two fuel inlets
facing the pump: nozzles to flanges, bored through into the ring."""
r0, r1 = FUEL_MANIFOLD_R, FUEL_MANIFOLD_R + FUEL_MANIFOLD_DEPTH
zt, zb = FUEL_MANIFOLD_TOP, FUEL_MANIFOLD_TOP - FUEL_MANIFOLD_H
zm, rd = (zt + zb) / 2, FUEL_MANIFOLD_H / 2 # the round outside
def d_section(inset: float) -> Wire:
arc = Edge.by_circular_arc(
rz(r1 - rd, zt - inset), rz(r1 - inset, zm), rz(r1 - rd, zb + inset)
)
return loop(rz(r0 + inset, zt - inset), [arc], rz(r0 + inset, zb + inset))
ring = turned(d_section(0), hole=d_section(FUEL_MANIFOLD_WALL))
cavity = turned(d_section(FUEL_MANIFOLD_WALL))
od = FUEL_INLET_BORE + 30
adds, bores = [], []
for side in (1, -1):
v = fuel_inlet(side)
c = v["base"].translate(v["axis"].scale(-60)) # from inside the ring
length = 60 + FUEL_NOZZLE
flange_at = v["face"].translate(v["axis"].scale(-FLANGE_T))
adds.append(disc(od / 2, length - FLANGE_T, c, v["axis"]).cut(cavity))
adds.append(disc(FUEL_FLANGE_D / 2, FLANGE_T, flange_at, v["axis"]))
bores.append(disc(FUEL_INLET_BORE / 2, length + 1, c, v["axis"]))
# brackets for the turbopump's two side struts
for (a, _, u), (seed, _) in zip(strut_ends()[:2], strut_seeds()[:2], strict=True):
adds.append(strut_boss(a, u.reverse(), a.distance(seed)))
return ring.unite(adds).cut(bores)
# --- The eps = 10 joint: return manifold, nozzle extension, exhaust manifold --------------------
# The hot-gas wall runs on the contour through all three: the tubes' crowns to Z_TUBES, the
# return manifold's bore to its underside, the extension's inner wall to the exit. The scope put
# the exhaust manifold at the joint itself (z = -3,020 to -3,420), where it would clash with the
# return manifold and the extension's walls, and fed the extension's passage through its top,
# which the return manifold covers. Here the extension's top flange closes the passage, the
# manifold rings the extension just below the flange, with its 300 mm radial section kept, and
# feeds the passage through windows in the outer wall between its two lips.
Z_TUBES = Z_THROAT - x_at_eps(EPS_TUBES) # end of the tube wall, top of the return manifold
Z_JOINT = Z_TUBES - RETURN_H # return manifold to nozzle extension
R_JOINT_OUT = r_at_z(Z_TUBES) + RETURN_DEPTH # outside of the return manifold and the flange
Z_EXIT = Z_THROAT - X_EXIT
OFF_PASSAGE, OFF_OUTER = EXT_WALL, EXT_WALL + EXT_GAP # the passage, between the walls
OFF_SKIN = OFF_OUTER + EXT_WALL # outside of the outer wall, where the exhaust manifold bears
Z_EXH_TOP = Z_JOINT - EXT_FLANGE_T
Z_EXH_BOTTOM = Z_EXH_TOP - EXH_MANIFOLD_H
# Heights where the extension's outside is split, so that the manifold's lips bear on the same
# surfaces: top lip, bottom lip.
Z_LIPS = [Z_EXH_TOP, Z_EXH_TOP - EXH_LIP, Z_EXH_BOTTOM + EXH_LIP, Z_EXH_BOTTOM]
def return_manifold() -> Solid:
"""Box-section ring from the tube ends to the joint, its bore the contour, hollow with a
RETURN_WALL wall; its flat underside is the bolting flange to the extension."""
w = RETURN_WALL
outline = loop(
on_contour(Z_TUBES),
rz(R_JOINT_OUT, Z_TUBES),
rz(R_JOINT_OUT, Z_JOINT),
on_contour(Z_JOINT),
contour_between(Z_TUBES, Z_JOINT),
)
cavity = loop(
on_contour(Z_TUBES - w, w),
rz(R_JOINT_OUT - w, Z_TUBES - w),
rz(R_JOINT_OUT - w, Z_JOINT + w),
on_contour(Z_JOINT + w, w),
contour_between(Z_TUBES - w, Z_JOINT + w, w),
)
return turned(outline, hole=cavity)
def skin_edges() -> list[Edge]:
"""The outside of the extension's outer wall, from the top flange to the stiffener, split
at the exhaust manifold's lips."""
zs = [*Z_LIPS, Z_EXIT + STIFFENER_H]
return [e for a, b in pairwise(zs) for e in contour_between(a, b, OFF_SKIN)]
def nozzle_extension() -> Shape:
"""Inner wall on the contour from the joint to the exit, an outer wall EXT_GAP outside it
for the turbine exhaust, both EXT_WALL thick; a top flange that joins them, closes the
passage and bolts to the return manifold; an exit stiffener; and N_WINDOWS windows in the
outer wall under the exhaust manifold. The passage is open at the exit, where the exhaust
leaves as a film along the nozzle lip."""
z_stiff = Z_EXIT + STIFFENER_H
outline = loop(