29 data = np.load(path, allow_pickle=
True)
30 if "meta" not in data:
31 raise ValueError(f
"LUT {path} missing 'meta' entry")
32 meta = json.loads(data[
"meta"].tolist())
34 for ax
in meta.get(
"axes", []):
38 raise ValueError(f
"LUT missing axis '{name}'")
39 self.
_axes.append({
"name": name,
"values": np.asarray(data[key], dtype=float)})
41 for out_name
in meta.get(
"outputs", []):
42 key = f
"data/{out_name}"
44 self.
_outputs[out_name] = np.asarray(data[key], dtype=float)
52 use_cache: bool =
True,
55 Estimate engine performance from tank/ullage pressures via LUT lookup.
57 Parameters P_d_F, P_d_O are tank pressures (P_u_fuel, P_u_ox).
59 point = {
"P_u_fuel": P_d_F,
"P_u_ox": P_d_O}
62 stability_metrics: Optional[Dict[str, Any]] =
None
63 if "stability_score" in out
or "injector_stiffness_ok" in out:
64 stability_metrics = {}
65 if "stability_score" in out
and np.isfinite(out[
"stability_score"]):
66 stability_metrics[
"stability_score"] = out[
"stability_score"]
67 if "injector_stiffness_ok" in out:
68 ok = out[
"injector_stiffness_ok"]
69 stability_metrics[
"injector_stiffness_ok"] = bool(ok > 0.5)
if np.isfinite(ok)
else False
72 P_ch=float(out.get(
"P_ch", np.nan)),
73 F=float(out.get(
"F", np.nan)),
74 mdot_F=float(out.get(
"mdot_F", np.nan)),
75 mdot_O=float(out.get(
"mdot_O", np.nan)),
76 MR=float(out.get(
"MR", np.nan)),
77 injector_dp_F=float(out.get(
"injector_dp_F", np.nan)),
78 injector_dp_O=float(out.get(
"injector_dp_O", np.nan)),
79 stability_metrics=stability_metrics,
83 def _evaluate(self, point: Dict[str, float]) -> Dict[str, float]:
84 """Multilinear interpolation at point."""
90 x = point.get(name, np.nan)
92 hi = int(np.searchsorted(grid, x))
98 x0, x1 = grid[lo], grid[hi]
99 t = 0.0
if x1 == x0
else float(np.clip((x - x0) / (x1 - x0), 0.0, 1.0))
100 indices.append((lo, hi))
101 weights.append((1.0 - t, t))
103 result = {k: 0.0
for k
in self.
_outputs}
105 for corner
in range(n_corners):
111 if (corner >> i) & 1:
119 for name, arr
in self.
_outputs.items():
120 val = arr[tuple(idx)]
122 result[name] += w * float(val)