STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
test_timeseries_injector_dp.py
Go to the documentation of this file.
1"""The Time-Series run reports each point's injector pressure drop, as forward mode does.
2
3The per-point diagnostics a run collects are the injector closure's, keyed
4``delta_p_injector_O`` / ``_F`` (engine/core/injectors/impinging.py, pintle.py). The Time-Series
5router read ``delta_P_injector_*`` (capital P), found nothing at any point, and left
6``delta_P_injector_O_psi`` out of every response -- so PressureCurveChart's "Injector Pressure Drops
7vs Time" never rendered and the plotter offered a series that was never there.
8"""
9
10from __future__ import annotations
11
12import types
13
14import numpy as np
15import pytest
16
17from backend.routers import timeseries as ts
18
19PSI = 6894.76
20
21
22class _Runner:
23 """Stands in for PintleEngineRunner.evaluate_arrays, closure diagnostics and all."""
24
25 def __init__(self, dp_O_pa, dp_F_pa):
26 self.config = types.SimpleNamespace(ablative_cooling=None, press_tank=None)
27 self._dp = (dp_O_pa, dp_F_pa)
28
29 def evaluate_arrays(self, P_O, P_F):
30 n = len(P_O)
31 one = np.ones(n)
32 return {
33 "Pc": 2.7374e6 * one, "F": 6870.0 * one, "Isp": 230.0 * one, "MR": 1.6 * one,
34 "mdot_O": 1.8755 * one, "mdot_F": 1.17 * one, "mdot_total": 3.0455 * one,
35 "cstar_actual": 1568.0 * one, "gamma": 1.2 * one,
36 "diagnostics": [
37 {"delta_p_injector_O": self._dp[0], "delta_p_injector_F": self._dp[1]} for _ in range(n)
38 ],
39 }
40
41
43 # Forward mode on the LE4 (3) stand's engine at 578/578 psia: 139.1 / 132.0 psi.
44 runner = _Runner(139.1 * PSI, 132.0 * PSI)
45 times = np.linspace(0.0, 1.0, 3)
46 data, _ = ts.compute_timeseries_results(runner, times, 578.0 * np.ones(3), 578.0 * np.ones(3), run_copv=False)
47 assert "delta_P_injector_O_psi" in data and "delta_P_injector_F_psi" in data, (
48 "the Time-Series response has no injector pressure drops: the chart cannot show"
49 )
50 assert data["delta_P_injector_O_psi"] == pytest.approx([139.1] * 3)
51 assert data["delta_P_injector_F_psi"] == pytest.approx([132.0] * 3)
52
53
55 runner = _Runner(139.1 * PSI, 132.0 * PSI)
56 times = np.linspace(0.0, 1.0, 3)
57 real = runner.evaluate_arrays
58
59 def gappy(P_O, P_F):
60 out = real(P_O, P_F)
61 out["diagnostics"][1] = {"error": "solver failed"}
62 return out
63
64 runner.evaluate_arrays = gappy
65 data, _ = ts.compute_timeseries_results(runner, times, 578.0 * np.ones(3), 578.0 * np.ones(3), run_copv=False)
66 v = data["delta_P_injector_O_psi"]
67 assert v[0] == pytest.approx(139.1) and np.isnan(v[1]) and v[2] == pytest.approx(139.1)