STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
test_layer1_tilt_preference.py
Go to the documentation of this file.
1
"""The spray fan should point straight down the chamber: tilt preference around 0 deg.
2
3
Positive tilt is OUTWARD (toward the liner). Inward lean is allowed at the plain quadratic cost;
4
outward costs ``outward_multiplier`` times as much. The hard wall guard is separate.
5
"""
6
import
pytest
7
8
from
engine.optimizer.layers.layer1_static_optimization
import
(
9
_impinging_resultant_tilt_preference
as
pref,
10
)
11
12
13
def
test_zero_tilt_is_free_and_the_cost_grows_quadratically
():
14
assert
pref(0.0) == 0.0
15
assert
pref(-2.0, scale_deg=2.0) == pytest.approx(1.0)
16
assert
pref(-4.0, scale_deg=2.0) == pytest.approx(4.0)
17
18
19
def
test_outward_costs_the_multiplier_more_than_the_same_lean_inward
():
20
assert
pref(1.0, scale_deg=2.0, outward_multiplier=25.0) == pytest.approx(25.0 * pref(-1.0, scale_deg=2.0))
21
assert
pref(0.5, outward_multiplier=25.0) > pref(-2.0, outward_multiplier=25.0)
22
23
24
def
test_unusable_tilt_costs_nothing
():
25
assert
pref(
None
) == 0.0
26
assert
pref(float(
"nan"
)) == 0.0
27
28
29
def
test_the_weight_reaches_the_objective_constants
():
30
import
inspect
31
from
engine.optimizer.layers
import
layer1_static_optimization
as
L
32
src = inspect.getsource(L.run_layer1_optimization)
33
assert
"'layer1_W_TILT': layer1_W_TILT"
in
src
34
assert
"resultant_tilt_penalty"
in
inspect.getsource(L._compute_objective_value)
engine.optimizer.layers.layer1_static_optimization
Definition
layer1_static_optimization.py:1
engine.optimizer.layers
Definition
__init__.py:1
test_layer1_tilt_preference.test_unusable_tilt_costs_nothing
test_unusable_tilt_costs_nothing()
Definition
test_layer1_tilt_preference.py:24
test_layer1_tilt_preference.test_zero_tilt_is_free_and_the_cost_grows_quadratically
test_zero_tilt_is_free_and_the_cost_grows_quadratically()
Definition
test_layer1_tilt_preference.py:13
test_layer1_tilt_preference.test_the_weight_reaches_the_objective_constants
test_the_weight_reaches_the_objective_constants()
Definition
test_layer1_tilt_preference.py:29
test_layer1_tilt_preference.test_outward_costs_the_multiplier_more_than_the_same_lean_inward
test_outward_costs_the_multiplier_more_than_the_same_lean_inward()
Definition
test_layer1_tilt_preference.py:19
EngineDesign
tests
test_layer1_tilt_preference.py
Generated by
1.15.0