STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
engine.core.chamber_geometry_solver Namespace Reference

Functions

Tuple[np.ndarray, list, float, Dict[str, Any]] solve_chamber_geometry_with_cea (float pc_design, float thrust_design, CEACache cea_cache, float MR, float diameter_inner=chamber_diameter_default, float diameter_exit=diameter_exit_default, float l_star=l_star_default, float Pa=101325.0, float nozzle_efficiency=1.0, float tolerance=1e-6, int max_iterations=100, bool do_plot=False, bool color_segments=False, int steps=200, Optional[str] export_dxf=None, bool verbose=False, float theta=theta_default)
CEAConfig _get_default_cea_config ()
Tuple[np.ndarray, list, float, Dict[str, Any]] solve_chamber_geometry (float pc_design, float thrust_design, float MR, Optional[CEAConfig] cea_config=None, float diameter_inner=chamber_diameter_default, float diameter_exit=diameter_exit_default, float l_star=l_star_default, **kwargs)
Tuple[np.ndarray, list, float, Dict[str, Any]] solve_chamber_geometry_from_config (float pc_design, float thrust_design, CEAConfig cea_config, float MR, float diameter_inner=chamber_diameter_default, float diameter_exit=diameter_exit_default, float l_star=l_star_default, **kwargs)
Tuple[np.ndarray, list, Dict[str, float]] solved_chamber_plot (float area_throat, float area_exit, float volume_chamber, float lstar, float chamber_diameter, Optional[float] length, bool do_plot=False, bool color_segments=False, int steps=200, Optional[str] export_dxf=None, float theta=theta_default)

Variables

str DEFAULT_CEA_CACHE_FILE = "output/cache/cea_cache_LOX_RP1.npz"
 logger = logging.getLogger("evaluate")
float pc_design = 2.068e6
float thrust_design = 6000.0
float MR = 2.5
 chamber_pts
 table_data
 total_length
 solver_info
 do_plot
 color_segments
 export_dxf
 verbose

Detailed Description

Chamber geometry solver that uses CEA lookup table to find real Cf.

This solver iteratively converges on the correct throat area and thrust coefficient
given chamber pressure and thrust, using thermochemistry from the CEA cache.

Function Documentation

◆ _get_default_cea_config()

CEAConfig engine.core.chamber_geometry_solver._get_default_cea_config ( )
protected
Create a default CEA config using the standard cache file.

Returns:
--------
CEAConfig with default cache file path

Definition at line 426 of file chamber_geometry_solver.py.

Referenced by solve_chamber_geometry().

◆ solve_chamber_geometry()

Tuple[np.ndarray, list, float, Dict[str, Any]] engine.core.chamber_geometry_solver.solve_chamber_geometry ( float pc_design,
float thrust_design,
float MR,
Optional[CEAConfig] cea_config = None,
float diameter_inner = chamber_diameter_default,
float diameter_exit = diameter_exit_default,
float l_star = l_star_default,
** kwargs )
Solve chamber geometry using CEA lookup table (convenience function).

This is the main entry point. If no CEA config is provided, uses the default
cache file at output/cache/cea_cache_LOX_RP1.npz.

Parameters:
-----------
pc_design : float
    Design chamber pressure [Pa]
thrust_design : float
    Design thrust [N]
MR : float
    Mixture ratio (O/F)
cea_config : CEAConfig, optional
    CEA configuration object. If None, uses default cache file.
diameter_inner : float, optional
    Inner chamber diameter [m]
diameter_exit : float, optional
    Exit diameter [m]
l_star : float, optional
    Characteristic length [m]
**kwargs
    Additional arguments passed to solve_chamber_geometry_with_cea
    (do_plot, color_segments, steps, export_dxf, verbose, etc.)

Returns:
--------
Same as solve_chamber_geometry_with_cea

Definition at line 460 of file chamber_geometry_solver.py.

References _get_default_cea_config(), and solve_chamber_geometry_with_cea().

◆ solve_chamber_geometry_from_config()

Tuple[np.ndarray, list, float, Dict[str, Any]] engine.core.chamber_geometry_solver.solve_chamber_geometry_from_config ( float pc_design,
float thrust_design,
CEAConfig cea_config,
float MR,
float diameter_inner = chamber_diameter_default,
float diameter_exit = diameter_exit_default,
float l_star = l_star_default,
** kwargs )
Convenience function that creates a CEA cache from config and solves.

Note: For most use cases, use solve_chamber_geometry() instead, which
automatically uses the default cache file.

Parameters:
-----------
pc_design : float
    Design chamber pressure [Pa]
thrust_design : float
    Design thrust [N]
cea_config : CEAConfig
    CEA configuration object
MR : float
    Mixture ratio (O/F)
diameter_inner : float, optional
    Inner chamber diameter [m]
diameter_exit : float, optional
    Exit diameter [m]
l_star : float, optional
    Characteristic length [m]
**kwargs
    Additional arguments passed to solve_chamber_geometry_with_cea

Returns:
--------
Same as solve_chamber_geometry_with_cea

Definition at line 516 of file chamber_geometry_solver.py.

References solve_chamber_geometry_with_cea().

◆ solve_chamber_geometry_with_cea()

Tuple[np.ndarray, list, float, Dict[str, Any]] engine.core.chamber_geometry_solver.solve_chamber_geometry_with_cea ( float pc_design,
float thrust_design,
CEACache cea_cache,
float MR,
float diameter_inner = chamber_diameter_default,
float diameter_exit = diameter_exit_default,
float l_star = l_star_default,
float Pa = 101325.0,
float nozzle_efficiency = 1.0,
float tolerance = 1e-6,
int max_iterations = 100,
bool do_plot = False,
bool color_segments = False,
int steps = 200,
Optional[str] export_dxf = None,
bool verbose = False,
float theta = theta_default )
Solve for chamber geometry using CEA lookup table to find corrected Cf.

This function iteratively solves for the throat area that achieves the desired
thrust using the corrected thrust coefficient (Cf) that accounts for nozzle
efficiency losses, matching what the pipeline uses for thrust calculations.

The solver finds the optimal throat area by:
1. Guessing an initial throat area
2. Calculating expansion ratio eps = A_exit / A_throat
3. Looking up ideal Cf from CEA cache using (Pc, MR, eps, Pa)
   - For 3D cache: Cf is optimized for the current expansion ratio
4. Applying nozzle efficiency correction: Cf_corrected = nozzle_efficiency * Cf_ideal
   - This matches the corrected Cf used in the pipeline (pintle_models/nozzle.py)
5. Calculating new throat area: A_throat = F / (Cf_corrected * Pc)
6. Iterating until convergence (throat area stabilizes)

The final Cf is the corrected thrust coefficient that accounts for:
- Ideal Cf from CEA (isentropic flow, real gas properties)
- Nozzle efficiency losses (boundary layer, divergence, etc.)
- This matches the Cf used in the actual thrust calculations

Parameters:
-----------
pc_design : float
    Design chamber pressure [Pa]
thrust_design : float
    Design thrust [N]
cea_cache : CEACache
    CEA cache instance for thermochemistry lookup
MR : float
    Mixture ratio (O/F) for CEA lookup
diameter_inner : float, optional
    Inner chamber diameter [m] (default: 3.4")
diameter_exit : float, optional
    Exit diameter [m] (default: 4")
l_star : float, optional
    Characteristic length [m] (default: 1.27 m)
Pa : float, optional
    Ambient pressure [Pa] (default: sea level)
nozzle_efficiency : float, optional
    Nozzle efficiency factor (0-1) to apply to ideal Cf (default: 1.0).
    Typical values: 0.96-0.99. This accounts for boundary layer losses,
    divergence losses, and other nozzle inefficiencies.
tolerance : float, optional
    Convergence tolerance for throat area (default: 1e-6)
max_iterations : int, optional
    Maximum number of iterations (default: 100)
do_plot : bool, optional
    Whether to generate plot (default: False)
color_segments : bool, optional
    Whether to color-code segments in plot (default: False)
steps : int, optional
    Number of points for geometry generation (default: 200)
export_dxf : str or None, optional
    Path to export DXF file (default: None)
verbose : bool, optional
    Whether to print convergence information (default: False)

Returns:
--------
chamber_pts : numpy array
    Array of (x, y) points representing the full chamber contour
table_data : list of lists
    Table data with metric and imperial units
total_chamber_length : float
    Total chamber length [m]
solver_info : dict
    Dictionary containing:
    - converged: bool
    - iterations: int
    - final_Cf: float (corrected Cf with efficiency applied)
    - final_Cf_ideal: float (ideal Cf from CEA before efficiency correction)
    - final_A_throat: float
    - final_eps: float
    - convergence_history: list of (iteration, A_throat, Cf, eps, residual)

Definition at line 48 of file chamber_geometry_solver.py.

References max.

Referenced by solve_chamber_geometry(), and solve_chamber_geometry_from_config().

◆ solved_chamber_plot()

Tuple[np.ndarray, list, Dict[str, float]] engine.core.chamber_geometry_solver.solved_chamber_plot ( float area_throat,
float area_exit,
float volume_chamber,
float lstar,
float chamber_diameter,
Optional[float] length,
bool do_plot = False,
bool color_segments = False,
int steps = 200,
Optional[str] export_dxf = None,
float theta = theta_default )
Generate chamber geometry plot from fully-constrained parameters.

This function is used when all geometry parameters are already known (e.g., from
optimizer output) and no CEA iteration is needed. It directly generates the chamber
contour from the given parameters.

Parameters:
-----------
area_throat : float
    Throat area [m²]
area_exit : float
    Exit area [m²]
volume_chamber : float
    Chamber volume [m³]
lstar : float
    Characteristic length [m]
chamber_diameter : float
    Chamber inner diameter [m]
length : float or None
    Stored barrel + cone length [m], checked against the volume only: the barrel is
    drawn from ``volume_chamber``. Face to throat adds the 1.5 Rt entrance arc
    (lengths['face_to_throat']).
do_plot : bool, optional
    Whether to generate plot (default: False)
color_segments : bool, optional
    Whether to color-code segments in plot (default: False)
steps : int, optional
    Number of points for geometry generation (default: 200)
export_dxf : str or None, optional
    Path to export DXF file (default: None)

Returns:
--------
chamber_pts : numpy array
    Array of (x, y) points representing the full chamber contour
table_data : list of lists
    Table data with metric and imperial units
lengths : dict
    Dictionary containing:
    - cylindrical: Cylindrical section length [m]
    - contraction: Contraction section length [m]
    - total: Total chamber length [m]

Definition at line 568 of file chamber_geometry_solver.py.

Variable Documentation

◆ chamber_pts

engine.core.chamber_geometry_solver.chamber_pts

Definition at line 851 of file chamber_geometry_solver.py.

◆ color_segments

engine.core.chamber_geometry_solver.color_segments

Definition at line 856 of file chamber_geometry_solver.py.

◆ DEFAULT_CEA_CACHE_FILE

str engine.core.chamber_geometry_solver.DEFAULT_CEA_CACHE_FILE = "output/cache/cea_cache_LOX_RP1.npz"

Definition at line 42 of file chamber_geometry_solver.py.

◆ do_plot

engine.core.chamber_geometry_solver.do_plot

Definition at line 855 of file chamber_geometry_solver.py.

◆ export_dxf

engine.core.chamber_geometry_solver.export_dxf

Definition at line 857 of file chamber_geometry_solver.py.

◆ logger

engine.core.chamber_geometry_solver.logger = logging.getLogger("evaluate")

Definition at line 45 of file chamber_geometry_solver.py.

◆ MR

engine.core.chamber_geometry_solver.MR = 2.5

Definition at line 842 of file chamber_geometry_solver.py.

◆ pc_design

engine.core.chamber_geometry_solver.pc_design = 2.068e6

Definition at line 840 of file chamber_geometry_solver.py.

◆ solver_info

engine.core.chamber_geometry_solver.solver_info

Definition at line 851 of file chamber_geometry_solver.py.

◆ table_data

engine.core.chamber_geometry_solver.table_data

Definition at line 851 of file chamber_geometry_solver.py.

◆ thrust_design

engine.core.chamber_geometry_solver.thrust_design = 6000.0

Definition at line 841 of file chamber_geometry_solver.py.

◆ total_length

engine.core.chamber_geometry_solver.total_length

Definition at line 851 of file chamber_geometry_solver.py.

◆ verbose

engine.core.chamber_geometry_solver.verbose

Definition at line 858 of file chamber_geometry_solver.py.