STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
patch.py
Go to the documentation of this file.
1"""An injector what-if on a private copy of the design: hole size, jet angle, passage L/d.
2
3Shared by the router (a what-if run, a YAML export) and the trade study, which burns one per point.
4"""
5
6from __future__ import annotations
7
8from typing import Any, Dict, Optional
9
10
11def apply_design_patch(config: Any, patch: Optional[Dict[str, Dict[str, float]]]) -> Any:
12 """A validated copy of ``config`` with the injector what-if written in. ``config`` is untouched."""
13 if not patch:
14 return config
15 from engine.pipeline.config_schemas import PintleEngineConfig
16
17 raw = config.model_dump()
18 for side, fields in patch.items():
19 geo = raw["injector"]["geometry"][side]
20 for key in ("d_jet", "impingement_angle"):
21 if key in fields:
22 geo[key] = float(fields[key])
23 if "orifice_l_over_d" in fields:
24 raw["discharge"][side]["orifice_l_over_d"] = float(fields["orifice_l_over_d"])
25 return PintleEngineConfig(**raw)
Any apply_design_patch(Any config, Optional[Dict[str, Dict[str, float]]] patch)
Definition patch.py:11