STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
test_pressure_curve_segments.py
Go to the documentation of this file.
1
"""Tank-pressure curves from segments (layer2_pressure.generate_pressure_curve_from_segments).
2
3
The Time-Series tab asks for what it draws: a segment may rise or fall as the user's feed system
4
does, and a blowdown segment ends at its end pressure. Layer 2's
5
search keeps the old behaviour: rises forced into a 5 % fall, blowdown stopping short.
6
"""
7
import
numpy
as
np
8
import
pytest
9
10
from
engine.optimizer.layers.layer2_pressure
import
generate_pressure_curve_from_segments
as
gen
11
12
PSI = 6894.757
13
14
15
def
test_a_rising_segment_rises_when_asked
():
16
seg = [{
"length_ratio"
: 1.0,
"type"
:
"linear"
,
"start_pressure"
: 500 * PSI,
"end_pressure"
: 540 * PSI}]
17
c = gen(seg, n_points=50, allow_rise=
True
, exact_ends=
True
)
18
assert
c[0] == pytest.approx(500 * PSI)
and
c[-1] == pytest.approx(540 * PSI)
19
assert
np.all(np.diff(c) > 0)
20
21
22
def
test_layer2_default_is_unchanged
():
23
seg = [{
"length_ratio"
: 1.0,
"type"
:
"linear"
,
"start_pressure"
: 500 * PSI,
"end_pressure"
: 540 * PSI}]
24
assert
gen(seg, n_points=50)[-1] == pytest.approx(475 * PSI)
# forced 5 % fall
25
bd = [{
"length_ratio"
: 1.0,
"type"
:
"blowdown"
,
"start_pressure"
: 600 * PSI,
"end_pressure"
: 400 * PSI,
"k"
: 0.5}]
26
assert
gen(bd, n_points=50)[-1] == pytest.approx((400 + 200 * np.exp(-0.5)) * PSI)
27
28
29
def
test_exact_ends_blowdown_reaches_its_end
():
30
bd = [{
"length_ratio"
: 1.0,
"type"
:
"blowdown"
,
"start_pressure"
: 600 * PSI,
"end_pressure"
: 400 * PSI,
"k"
: 0.5}]
31
c = gen(bd, n_points=50, exact_ends=
True
)
32
assert
c[0] == pytest.approx(600 * PSI)
and
c[-1] == pytest.approx(400 * PSI)
engine.optimizer.layers.layer2_pressure
Definition
layer2_pressure.py:1
test_pressure_curve_segments.test_a_rising_segment_rises_when_asked
test_a_rising_segment_rises_when_asked()
Definition
test_pressure_curve_segments.py:15
test_pressure_curve_segments.test_layer2_default_is_unchanged
test_layer2_default_is_unchanged()
Definition
test_pressure_curve_segments.py:22
test_pressure_curve_segments.test_exact_ends_blowdown_reaches_its_end
test_exact_ends_blowdown_reaches_its_end()
Definition
test_pressure_curve_segments.py:29
EngineDesign
tests
test_pressure_curve_segments.py
Generated by
1.15.0