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

Functions

float _exit_pressure_from_eps (float eps, float Pc, float gamma)
 test_derived_eps_reproduces_target_exit_pressure (Pc_psi, gamma)
 test_derived_eps_rejects_unphysical_inputs ()
 test_solver_clamps_to_search_range_when_target_unreachable ()
 test_solver_is_a_noop_when_both_toggles_are_off ()
 test_toggles_are_real_schema_fields_so_the_frontend_reaches_the_optimizer ()
 test_requirement_bool_parses_the_forms_yaml_and_the_ui_produce (raw, expected)
 test_snap_outer_puts_the_tube_on_a_stock_size ()
 test_snap_bore_puts_the_gas_side_on_a_stock_size ()
 test_snapping_disabled_passes_the_value_through ()
 test_unknown_snap_target_falls_back_to_outer ()
 test_tank_deadband_is_free_inside_the_band_by_default ()
 test_integer_jet_angles_only_apply_to_impinging ()
 test_unit_granularity_dims_become_cma_integer_variables ()
 test_chamber_od_gets_a_std_floor_but_is_NOT_an_integer_variable ()
 test_no_od_floor_when_stock_snapping_is_off ()
 test_out_of_range_discrete_indices_are_dropped ()
 test_block_subproblems_remap_discrete_indices ()
 test_L_imp_reaches_the_reported_geometry ()
 test_standoff_uses_the_RADIAL_ring_offset_not_the_hole_pitch ()
 test_ring_penalty_charges_for_lox_outboard_of_fuel ()
 test_ring_geometry_is_enforced_by_default ()
 test_pitch_circles_are_reported_alongside_hole_pitch ()
 test_lstar_target_hits_the_anchor_band ()
 test_lstar_target_follows_the_d_squared_law ()
 test_lstar_target_clamps_to_the_allowed_envelope ()
 test_lstar_band_term_is_free_inside_and_two_sided_outside ()
 test_resolver_treats_explicit_None_as_unset ()
 test_resolver_falls_back_rather_than_silently_disabling ()
 test_effective_smd_is_the_mass_flux_weighted_blend ()
 test_impingement_target_defaults_to_four_jet_diameters ()
 test_fuel_spacing_is_solved_to_hit_the_target_exactly ()
 test_fuel_spacing_derivation_snaps_the_doublet_count_in_place ()
 test_fuel_spacing_derivation_respects_ring_order_and_opt_out ()
 test_clamped_fuel_ring_reports_the_miss_instead_of_hiding_it ()
 test_momentum_band_is_free_and_symmetric ()
 test_momentum_multiplier_is_clamped_against_legacy_ban_values ()
 test_superseded_R_wall_violation_still_behaves_for_back_compat ()
 test_outside_band_is_discouraged_not_banned ()
 test_momentum_penalty_ignores_garbage ()
 test_momentum_gate_is_symmetric_and_widened ()
 test_pinned_dimensions_get_no_cma_std_floor ()
 test_thrust_deadband_is_tight_when_throat_is_derived ()
 test_solve_restores_x_and_config_when_a_step_fails ()
 test_R_equal_one_is_not_a_balanced_doublet ()
 test_angle_asymmetry_is_the_lever_that_balances_the_fan ()
 test_tilt_sign_follows_the_ring_order ()
 test_tilt_violation_is_one_sided_and_ignores_garbage ()
 test_momentum_band_is_symmetric_now_that_tilt_owns_the_guard ()
 test_design_point_is_stamped_from_the_solved_engine ()
 test_design_point_stamp_warns_outside_the_cea_cache_range ()
 test_design_point_stamp_ignores_non_finite_performance ()
 test_stale_pressure_curves_are_flagged ()

Variables

float PSI = 6894.76
float IN = 0.0254

Detailed Description

Guards for the Layer-1 DOFs that are solved rather than searched.

``expansion_ratio`` and ``A_throat`` are determined by requirements the user
already stated (expand to ambient; hit the thrust target), so Layer 1 solves
them and collapses their CMA-ES bounds. These tests pin the parts that are easy
to break silently:

  * the closed-form expansion-ratio inversion actually reproduces the target
    exit pressure when pushed back through the isentropic relation;
  * the solver respects its clamps and degrades safely on nonsense input;
  * both toggles are real config fields, so the frontend checkboxes reach the
    optimizer instead of being dropped by the schema.

Function Documentation

◆ _exit_pressure_from_eps()

float test_layer1_derived_dofs._exit_pressure_from_eps ( float eps,
float Pc,
float gamma )
protected
Invert the area-ratio relation numerically: eps -> Pe.

Deliberately independent of the production formula so this is a real check
and not a restatement of the code under test.

Definition at line 29 of file test_layer1_derived_dofs.py.

Referenced by test_derived_eps_reproduces_target_exit_pressure().

◆ test_angle_asymmetry_is_the_lever_that_balances_the_fan()

test_layer1_derived_dofs.test_angle_asymmetry_is_the_lever_that_balances_the_fan ( )
sin(th_O)/sin(th_F) = p_F/p_O -> alpha = 0. This is what the optimizer found (29/62).

Definition at line 777 of file test_layer1_derived_dofs.py.

◆ test_block_subproblems_remap_discrete_indices()

test_layer1_derived_dofs.test_block_subproblems_remap_discrete_indices ( )
A block optimizes a SUBSET, so global indices do not address the sub-vector.

Guards the remap in run_hybrid_optimization: passing the global list would mark the
wrong coordinates as integers.

Definition at line 291 of file test_layer1_derived_dofs.py.

◆ test_chamber_od_gets_a_std_floor_but_is_NOT_an_integer_variable()

test_layer1_derived_dofs.test_chamber_od_gets_a_std_floor_but_is_NOT_an_integer_variable ( )
Its granularity is one stock increment in METRES, not 1.

Declaring it an integer variable would centre it on integer metres, which is
meaningless. It only needs a std floor so sigma cannot collapse inside one cell.

Definition at line 265 of file test_layer1_derived_dofs.py.

◆ test_clamped_fuel_ring_reports_the_miss_instead_of_hiding_it()

test_layer1_derived_dofs.test_clamped_fuel_ring_reports_the_miss_instead_of_hiding_it ( )
If the solved ring will not fit the bore it clamps -- and L/d then misses, which the
ring-geometry penalty is there to report. Silently producing an unbuildable ring, or
silently pretending the target was met, would both be worse.

Definition at line 578 of file test_layer1_derived_dofs.py.

◆ test_derived_eps_rejects_unphysical_inputs()

test_layer1_derived_dofs.test_derived_eps_rejects_unphysical_inputs ( )

Definition at line 67 of file test_layer1_derived_dofs.py.

◆ test_derived_eps_reproduces_target_exit_pressure()

test_layer1_derived_dofs.test_derived_eps_reproduces_target_exit_pressure ( Pc_psi,
gamma )

Definition at line 55 of file test_layer1_derived_dofs.py.

References _exit_pressure_from_eps().

◆ test_design_point_is_stamped_from_the_solved_engine()

test_layer1_derived_dofs.test_design_point_is_stamped_from_the_solved_engine ( )
chamber_geometry.design_* must describe THIS engine, not the template it came from.

Nothing ever wrote these: config_schemas builds them with
`getattr(chamber, 'design_MR', 2.55)`, so an optimised config carried the template's values
forward forever. A real emitted design was stamped MR 2.55 / 350 psi / 7000 N while actually
solving at O/F ~1.65 / 416 psi / 7200 N -- and backend/routers/geometry.py feeds design_MR
straight into solve_chamber_geometry_with_cea, so the geometry tab drew the contour at the
stale ratio.

Definition at line 812 of file test_layer1_derived_dofs.py.

◆ test_design_point_stamp_ignores_non_finite_performance()

test_layer1_derived_dofs.test_design_point_stamp_ignores_non_finite_performance ( )
A failed evaluate must not overwrite a good design point with NaN.

Definition at line 859 of file test_layer1_derived_dofs.py.

◆ test_design_point_stamp_warns_outside_the_cea_cache_range()

test_layer1_derived_dofs.test_design_point_stamp_warns_outside_the_cea_cache_range ( )
An MR outside combustion.cea.MR_range means anything reading it extrapolates.

Definition at line 839 of file test_layer1_derived_dofs.py.

◆ test_effective_smd_is_the_mass_flux_weighted_blend()

test_layer1_derived_dofs.test_effective_smd_is_the_mass_flux_weighted_blend ( )

Definition at line 498 of file test_layer1_derived_dofs.py.

◆ test_fuel_spacing_derivation_respects_ring_order_and_opt_out()

test_layer1_derived_dofs.test_fuel_spacing_derivation_respects_ring_order_and_opt_out ( )

Definition at line 553 of file test_layer1_derived_dofs.py.

◆ test_fuel_spacing_derivation_snaps_the_doublet_count_in_place()

test_layer1_derived_dofs.test_fuel_spacing_derivation_snaps_the_doublet_count_in_place ( )
The worker truncates int(x[4]) while apply_x_to_config rounds; the derivation divides
by n, so the two must be made to agree or the solved standoff misses.

Definition at line 538 of file test_layer1_derived_dofs.py.

◆ test_fuel_spacing_is_solved_to_hit_the_target_exactly()

test_layer1_derived_dofs.test_fuel_spacing_is_solved_to_hit_the_target_exactly ( )
One equation, one unknown -- the standoff must land ON the number, not near it.

Definition at line 520 of file test_layer1_derived_dofs.py.

◆ test_impingement_target_defaults_to_four_jet_diameters()

test_layer1_derived_dofs.test_impingement_target_defaults_to_four_jet_diameters ( )

Definition at line 507 of file test_layer1_derived_dofs.py.

◆ test_integer_jet_angles_only_apply_to_impinging()

test_layer1_derived_dofs.test_integer_jet_angles_only_apply_to_impinging ( )
Index 6 is the LOX angle for doublets but n_orifices for a pintle.

Snapping [6, 9] on a pintle vector would quantise an orifice diameter, so the
injector-type guard is load-bearing, not cosmetic.

Definition at line 233 of file test_layer1_derived_dofs.py.

References max.

◆ test_L_imp_reaches_the_reported_geometry()

test_layer1_derived_dofs.test_L_imp_reaches_the_reported_geometry ( )
It must be in optimized_parameters -- that dict IS the frontend's geometry table.

Also pins the canonical SEED: both rings used to sit on the same 38.2 mm pitch circle,
which is a zero radial offset, i.e. a doublet whose two jets never converge. The old
standoff formula reported a plausible number for that degenerate geometry; this one
returns NaN, so a finite value here is the guard.

Definition at line 316 of file test_layer1_derived_dofs.py.

◆ test_lstar_band_term_is_free_inside_and_two_sided_outside()

test_layer1_derived_dofs.test_lstar_band_term_is_free_inside_and_two_sided_outside ( )

Definition at line 457 of file test_layer1_derived_dofs.py.

◆ test_lstar_target_clamps_to_the_allowed_envelope()

test_layer1_derived_dofs.test_lstar_target_clamps_to_the_allowed_envelope ( )
A target pinned at the ceiling is information: the spray is too coarse to vaporise
inside the chamber the requirements allow.

Definition at line 449 of file test_layer1_derived_dofs.py.

◆ test_lstar_target_follows_the_d_squared_law()

test_layer1_derived_dofs.test_lstar_target_follows_the_d_squared_law ( )
tau_vap ~ D32^2 and tau_res ~ L*, so L*_target ~ SMD^2 -- not linear, not a fit.

Definition at line 440 of file test_layer1_derived_dofs.py.

◆ test_lstar_target_hits_the_anchor_band()

test_layer1_derived_dofs.test_lstar_target_hits_the_anchor_band ( )
SMD 99 um must give a 1.05-1.15 m window.

Definition at line 433 of file test_layer1_derived_dofs.py.

◆ test_momentum_band_is_free_and_symmetric()

test_layer1_derived_dofs.test_momentum_band_is_free_and_symmetric ( )
R's only job was the liner guard, and it did it wrong. It is now a mild symmetric
mixing preference; the resultant tilt owns the liner.

Definition at line 605 of file test_layer1_derived_dofs.py.

◆ test_momentum_band_is_symmetric_now_that_tilt_owns_the_guard()

test_layer1_derived_dofs.test_momentum_band_is_symmetric_now_that_tilt_owns_the_guard ( )
A one-sided R band taxed exactly the tilt-balanced designs (R ~ 1.05).

Definition at line 804 of file test_layer1_derived_dofs.py.

◆ test_momentum_gate_is_symmetric_and_widened()

test_layer1_derived_dofs.test_momentum_gate_is_symmetric_and_widened ( )
R is no longer the liner gate (the resultant tilt is), so its gate is symmetric.

A one-sided gate failed tilt-balanced designs, which sit at R ~ 1.05: every other check
green, pressure_candidate_valid False.

Definition at line 648 of file test_layer1_derived_dofs.py.

◆ test_momentum_multiplier_is_clamped_against_legacy_ban_values()

test_layer1_derived_dofs.test_momentum_multiplier_is_clamped_against_legacy_ban_values ( )
A config left over from the ban era can still carry 999999. Unclamped, that put a
quality term at 1e7..1e11 against BASE_INFEAS = 1e6 and stopped the run in ~1 s.

Definition at line 616 of file test_layer1_derived_dofs.py.

◆ test_momentum_penalty_ignores_garbage()

test_layer1_derived_dofs.test_momentum_penalty_ignores_garbage ( )

Definition at line 641 of file test_layer1_derived_dofs.py.

◆ test_no_od_floor_when_stock_snapping_is_off()

test_layer1_derived_dofs.test_no_od_floor_when_stock_snapping_is_off ( )
With snapping disabled the coordinate really is continuous.

Definition at line 278 of file test_layer1_derived_dofs.py.

◆ test_out_of_range_discrete_indices_are_dropped()

test_layer1_derived_dofs.test_out_of_range_discrete_indices_are_dropped ( )

Definition at line 285 of file test_layer1_derived_dofs.py.

◆ test_outside_band_is_discouraged_not_banned()

test_layer1_derived_dofs.test_outside_band_is_discouraged_not_banned ( )
A momentum miss is a mixing loss, not a hazard -- it must stay negotiable.

The liner hazard is the resultant tilt, which is a separate, one-sided constraint.

Definition at line 632 of file test_layer1_derived_dofs.py.

◆ test_pinned_dimensions_get_no_cma_std_floor()

test_layer1_derived_dofs.test_pinned_dimensions_get_no_cma_std_floor ( )
A frozen or derived-pinned coordinate must be left out of minstd/integer_variables.

Its domain is ~2e-12 wide. Handing cma a floor of 0.2 (or 0.00254 m for the chamber OD)
against that makes it inflate the sampling std by ~1e9 to satisfy the floor -- 'sigma0 x
stds is larger than the bounded domain size in variable 3' -- which wrecks the covariance
matrix on a coordinate that cannot move anyway. Freezing the chamber OD at 6.5 in took the
objective from ~40 to ~14700 before this guard.

Definition at line 667 of file test_layer1_derived_dofs.py.

◆ test_pitch_circles_are_reported_alongside_hole_pitch()

test_layer1_derived_dofs.test_pitch_circles_are_reported_alongside_hole_pitch ( )
Both numbers, so 'spacing' can't be misread as the ring diameter.

Definition at line 405 of file test_layer1_derived_dofs.py.

◆ test_R_equal_one_is_not_a_balanced_doublet()

test_layer1_derived_dofs.test_R_equal_one_is_not_a_balanced_doublet ( )
The whole reason the old guard was wrong: p_O/p_F = R^2 * (A_O/A_F).

Equal jets at equal angles balance; unequal AREAS do not, no matter what R is.

Definition at line 760 of file test_layer1_derived_dofs.py.

◆ test_requirement_bool_parses_the_forms_yaml_and_the_ui_produce()

test_layer1_derived_dofs.test_requirement_bool_parses_the_forms_yaml_and_the_ui_produce ( raw,
expected )

Definition at line 165 of file test_layer1_derived_dofs.py.

◆ test_resolver_falls_back_rather_than_silently_disabling()

test_layer1_derived_dofs.test_resolver_falls_back_rather_than_silently_disabling ( )

Definition at line 487 of file test_layer1_derived_dofs.py.

◆ test_resolver_treats_explicit_None_as_unset()

test_layer1_derived_dofs.test_resolver_treats_explicit_None_as_unset ( )
model_dump() emits None for every unset Optional -- .get(key, default) returns None,
not the default. This crashed every run until the resolver handled it.

Definition at line 470 of file test_layer1_derived_dofs.py.

◆ test_ring_geometry_is_enforced_by_default()

test_layer1_derived_dofs.test_ring_geometry_is_enforced_by_default ( )
It was opt-in while the infeasibility plateau made a hard constraint stall the
search. The gradient fixed that, so leaving it off silences a weight the user set.

Definition at line 396 of file test_layer1_derived_dofs.py.

◆ test_ring_penalty_charges_for_lox_outboard_of_fuel()

test_layer1_derived_dofs.test_ring_penalty_charges_for_lox_outboard_of_fuel ( )

Definition at line 368 of file test_layer1_derived_dofs.py.

◆ test_snap_bore_puts_the_gas_side_on_a_stock_size()

test_layer1_derived_dofs.test_snap_bore_puts_the_gas_side_on_a_stock_size ( )

Definition at line 187 of file test_layer1_derived_dofs.py.

◆ test_snap_outer_puts_the_tube_on_a_stock_size()

test_layer1_derived_dofs.test_snap_outer_puts_the_tube_on_a_stock_size ( )

Definition at line 181 of file test_layer1_derived_dofs.py.

◆ test_snapping_disabled_passes_the_value_through()

test_layer1_derived_dofs.test_snapping_disabled_passes_the_value_through ( )

Definition at line 196 of file test_layer1_derived_dofs.py.

◆ test_solve_restores_x_and_config_when_a_step_fails()

test_layer1_derived_dofs.test_solve_restores_x_and_config_when_a_step_fails ( )
x and the config must always describe the RETURNED result.

A failed last step used to leave x/config on the geometry that had just failed while
returning the result from the one before -- the finalised design then did not evaluate.

Definition at line 724 of file test_layer1_derived_dofs.py.

◆ test_solver_clamps_to_search_range_when_target_unreachable()

test_layer1_derived_dofs.test_solver_clamps_to_search_range_when_target_unreachable ( )
An unreachable thrust target must clamp to the bound, not run away.

The residual is then carried by the ordinary thrust penalty, which the
infeasibility gradient can still descend.

Definition at line 78 of file test_layer1_derived_dofs.py.

◆ test_solver_is_a_noop_when_both_toggles_are_off()

test_layer1_derived_dofs.test_solver_is_a_noop_when_both_toggles_are_off ( )

Definition at line 131 of file test_layer1_derived_dofs.py.

◆ test_stale_pressure_curves_are_flagged()

test_layer1_derived_dofs.test_stale_pressure_curves_are_flagged ( )
The initial tank pressure exists twice, owned by different layers, never reconciled.

Layer 1 writes lox_tank/fuel_tank.initial_pressure_psi; Layer 2 writes
pressure_curves.initial_lox/fuel_pressure_pa. Re-running Layer 1 silently leaves the curves
describing the previous design (observed 11.3 psi out on LOX, 24.9 psi on fuel). Tank
pressure is the upstream boundary condition for the feed-system twin (docs/adr/0001), so a
disagreement must not cross that boundary unannounced.

Definition at line 870 of file test_layer1_derived_dofs.py.

◆ test_standoff_uses_the_RADIAL_ring_offset_not_the_hole_pitch()

test_layer1_derived_dofs.test_standoff_uses_the_RADIAL_ring_offset_not_the_hole_pitch ( )
The offset a doublet closes is the gap between the two RINGS.

``spacing`` is the arc between adjacent holes on ONE ring -- it says how densely that
ring is populated and nothing about how far the O and F jets of a single doublet are
from each other. Using it as the offset (the old behaviour) under-reports the standoff.

Definition at line 341 of file test_layer1_derived_dofs.py.

◆ test_superseded_R_wall_violation_still_behaves_for_back_compat()

test_layer1_derived_dofs.test_superseded_R_wall_violation_still_behaves_for_back_compat ( )
Retained only so older configs/tests keep working; the live guard is the tilt.

Definition at line 623 of file test_layer1_derived_dofs.py.

◆ test_tank_deadband_is_free_inside_the_band_by_default()

test_layer1_derived_dofs.test_tank_deadband_is_free_inside_the_band_by_default ( )
The in-band pull is OFF by default.

It scales with W_TANK_EQUAL, so at W=30000 it charged 300 objective points for a delta
sitting INSIDE the tolerance -- most of the reported residual, for a design that met the
spec. It exists only to stop the optimizer parking just outside the band, and a large
W_TANK_EQUAL already does that.

Definition at line 207 of file test_layer1_derived_dofs.py.

◆ test_thrust_deadband_is_tight_when_throat_is_derived()

test_layer1_derived_dofs.test_thrust_deadband_is_tight_when_throat_is_derived ( )

Definition at line 714 of file test_layer1_derived_dofs.py.

◆ test_tilt_sign_follows_the_ring_order()

test_layer1_derived_dofs.test_tilt_sign_follows_the_ring_order ( )

Definition at line 785 of file test_layer1_derived_dofs.py.

◆ test_tilt_violation_is_one_sided_and_ignores_garbage()

test_layer1_derived_dofs.test_tilt_violation_is_one_sided_and_ignores_garbage ( )

Definition at line 792 of file test_layer1_derived_dofs.py.

◆ test_toggles_are_real_schema_fields_so_the_frontend_reaches_the_optimizer()

test_layer1_derived_dofs.test_toggles_are_real_schema_fields_so_the_frontend_reaches_the_optimizer ( )

Definition at line 146 of file test_layer1_derived_dofs.py.

◆ test_unit_granularity_dims_become_cma_integer_variables()

test_layer1_derived_dofs.test_unit_granularity_dims_become_cma_integer_variables ( )
Element counts and whole-degree angles have granularity 1 -> integer_variables.

Definition at line 257 of file test_layer1_derived_dofs.py.

◆ test_unknown_snap_target_falls_back_to_outer()

test_layer1_derived_dofs.test_unknown_snap_target_falls_back_to_outer ( )

Definition at line 201 of file test_layer1_derived_dofs.py.

Variable Documentation

◆ IN

float test_layer1_derived_dofs.IN = 0.0254

Definition at line 178 of file test_layer1_derived_dofs.py.

◆ PSI

float test_layer1_derived_dofs.PSI = 6894.76

Definition at line 26 of file test_layer1_derived_dofs.py.