STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
test_chamber_lengths_profiles.py
Go to the documentation of this file.
1"""Chamber lengths and the reported pressure profile (CN-1, CN-12).
2
3CN-1: the chamber "length" is barrel + cone and leaves out the 1.5 Rt entrance arc; the solved
4 contour was rebuilt from a stored length that went stale (it drew L* 1.0035 for 1.0000),
5 and the cone/arc junction carried a duplicate vertex.
6CN-12: the pressure profile was invented -- 1.10 Pc at the injector "for pintle injectors" and
7 a throat at Pc -- where the throat static pressure is Pc (2/(g+1))^(g/(g-1)).
8Geometry references are hand geometry on the drawn contour (1.5 Rt arc, 45 deg cone).
9"""
10import math
11import os
12import sys
13import warnings
14
15import numpy as np
16import pytest
17
18sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
19
20from engine.pipeline.io import load_config # noqa: E402
21
22ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
23CG = load_config(os.path.join(ROOT, "configs", "ethalox_6500N.yaml")).chamber_geometry
24
25
26def _solved(length):
27 from engine.core.chamber_geometry_solver import solved_chamber_plot
28 with warnings.catch_warnings():
29 warnings.simplefilter("ignore")
30 return solved_chamber_plot(CG.A_throat, CG.A_exit, CG.volume, CG.Lstar, CG.chamber_diameter,
31 length, steps=2000)
32
33
35 pts, _, lengths = _solved(CG.length)
36 Rt = math.sqrt(CG.A_throat / math.pi)
37 assert lengths["entrance_arc"] == pytest.approx(1.5 * Rt * math.sin(math.pi / 4), rel=1e-12)
38 x_face, x_throat = pts[:, 0].min(), pts[np.argmin(pts[:, 1]), 0]
39 assert lengths["face_to_throat"] == pytest.approx(x_throat - x_face, abs=1e-6)
40 assert lengths["face_to_throat"] == pytest.approx(0.15399, abs=5e-5)
41
42
44 for stored in (CG.length, CG.length + 0.01, None):
45 pts, _, _ = _solved(stored)
46 x, y = pts[:, 0], pts[:, 1]
47 ch = x <= 1e-12
48 V = float(np.sum(np.pi * 0.5 * (y[ch][1:] ** 2 + y[ch][:-1] ** 2) * np.diff(x[ch])))
49 assert V / CG.A_throat == pytest.approx(CG.volume / CG.A_throat, abs=1e-4)
50
51
53 pts, _, _ = _solved(CG.length)
54 seg = np.hypot(np.diff(pts[:, 0]), np.diff(pts[:, 1]))
55 assert np.all(seg > 1e-12)
56
57
59 from engine.core.chamber_profiles import calculate_chamber_pressure_profile
60 Pc, g = 2.99e6, 1.1375
61 p = calculate_chamber_pressure_profile(Pc, CG.Lstar, 2.8, g, 373.6, 3226.0, CG.A_throat,
62 chamber_diameter=CG.chamber_diameter, volume=CG.volume)
63 crit = (2 / (g + 1)) ** (g / (g - 1))
64 assert p["P_injection"] == Pc
65 assert p["P_throat"] == pytest.approx(Pc * crit, rel=0.01)
66 # CEA finite-area combustor at CR 8.26 puts the nozzle stagnation 0.30 % below the face
67 assert p["P0_nozzle"] == pytest.approx(Pc / 1.002971, rel=2e-4)
68 assert all(b <= a for a, b in zip(p["pressures"], p["pressures"][1:]))
#define min(a, b)
Definition Arduino.h:42