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

Functions

dict[str, object] measured (float value, str unit)
object pipe (segments, **params)
None test_a_segment_list_is_read_at_all ()
None test_a_line_with_no_segments_is_empty_not_defaulted ()
None test_a_value_with_no_provenance_is_refused ()
None test_the_ladder_reports_the_best_and_the_worst ()
None test_a_curve_keeps_its_units ()
None test_a_malformed_curve_is_reported_not_swallowed ()
None test_an_unknown_fitting_is_carried_and_reported ()
None test_one_segment_is_the_darcy_pipe_exactly ()
None test_friction_matches_darcy_weisbach_worked_by_hand ()
None test_a_fitting_body_is_not_also_tube ()
None test_an_unmeasurable_body_length_refuses_to_guess ()
None test_a_bore_change_is_a_reducer_nobody_drew ()
None test_the_bore_is_inside_the_sum_not_averaged ()
None test_velocity_is_reported_at_the_tightest_bore ()
None test_a_measured_segment_beats_the_correlation ()
None test_a_curve_is_continued_quadratically_not_clamped ()
None test_a_segmented_line_needs_a_segment_list ()
dict[str, object] _drawing (list[dict[str, object]] segments)
None test_the_line_level_length_is_superseded_not_added ()
None test_a_drawing_without_segments_still_builds_a_darcy_pipe ()
None test_a_superseded_line_level_length_is_said_out_loud ()
None test_nothing_is_said_when_there_was_nothing_to_supersede ()
None test_a_sketched_bend_is_priced_at_its_own_radius_and_angle ()
None test_an_itemised_run_at_zero_flow_drops_nothing_and_does_not_raise ()
None test_a_trickle_through_an_itemised_run_is_priced_not_raised ()

Variables

 RHO
 MU
 FLOW = FlowConditions(rho=RHO, mu=MU, p_upstream=4.0e6, temperature=293.15)

Detailed Description

Phase 11b: a line's loss as the drawing itemises it.

The bug these guard against is not a wrong correlation. It is a *silently
discarded* one: ``data.segments`` was written by the drawing editor and never
read, so a line somebody had itemised down to the elbow arrived at the solver as
an unstated line and got a default. The drawing was greying out the line-level
Length and Bore and saying "superseded by the segments below", and the
superseded field was the only one being read.

So these tests are mostly about *which* number won.

Function Documentation

◆ _drawing()

dict[str, object] test_segments._drawing ( list[dict[str, object]] segments)
protected

◆ measured()

◆ pipe()

◆ test_a_bore_change_is_a_reducer_nobody_drew()

None test_segments.test_a_bore_change_is_a_reducer_nobody_drew ( )
Two adjacent segments of different bore *are* the transition.

Making somebody add a row for it is a step they can forget, and then the run
is quietly cheap.

Definition at line 250 of file test_segments.py.

References measured(), and pipe().

◆ test_a_curve_is_continued_quadratically_not_clamped()

None test_segments.test_a_curve_is_continued_quadratically_not_clamped ( )
A clamped curve takes the flow dependence out of the branch equation.

That is a singular Jacobian, not a conservative answer -- so past the last
measured point the turbulent law the curve is a measurement *of* carries it.

Definition at line 347 of file test_segments.py.

References pipe().

◆ test_a_curve_keeps_its_units()

None test_segments.test_a_curve_keeps_its_units ( )
psi on the wire, Pa in the solver. Reading it as Pa would be 6895x wrong.

Definition at line 103 of file test_segments.py.

◆ test_a_drawing_without_segments_still_builds_a_darcy_pipe()

None test_segments.test_a_drawing_without_segments_still_builds_a_darcy_pipe ( )

Definition at line 440 of file test_segments.py.

References _drawing().

◆ test_a_fitting_body_is_not_also_tube()

None test_segments.test_a_fitting_body_is_not_also_tube ( )
A fitting's K already contains its own friction.

Counting the elbow's own arc as tube *and* pricing the elbow pays for it
twice. Three long-radius elbows in a 1.6 m run are about 72 mm, which is
the several percent of dp this asserts is actually removed.

Definition at line 203 of file test_segments.py.

References measured(), and pipe().

◆ test_a_line_with_no_segments_is_empty_not_defaulted()

None test_segments.test_a_line_with_no_segments_is_empty_not_defaulted ( )
Every drawing that shipped before this has no segments and must not move.

Definition at line 60 of file test_segments.py.

◆ test_a_malformed_curve_is_reported_not_swallowed()

None test_segments.test_a_malformed_curve_is_reported_not_swallowed ( )
A run somebody flowed and recorded badly is a thing to go and fix.

Definition at line 125 of file test_segments.py.

◆ test_a_measured_segment_beats_the_correlation()

None test_segments.test_a_measured_segment_beats_the_correlation ( )
Top of the ladder. The curve's number is used, not a friction factor.

Definition at line 322 of file test_segments.py.

References measured(), and pipe().

◆ test_a_segment_list_is_read_at_all()

None test_segments.test_a_segment_list_is_read_at_all ( )
The whole point. `PidEdge.segments` used not to exist.

Definition at line 49 of file test_segments.py.

References measured().

◆ test_a_segmented_line_needs_a_segment_list()

None test_segments.test_a_segmented_line_needs_a_segment_list ( )

Definition at line 374 of file test_segments.py.

References pipe().

◆ test_a_sketched_bend_is_priced_at_its_own_radius_and_angle()

None test_segments.test_a_sketched_bend_is_priced_at_its_own_radius_and_angle ( )
A bend from the centerline sketch carries r/D and the angle it turns.
The reader keeps both, and the run prices the bend on them rather than
on the correlation's defaults -- a tight bend and a sweep are not the
same fitting.

Definition at line 477 of file test_segments.py.

◆ test_a_superseded_line_level_length_is_said_out_loud()

None test_segments.test_a_superseded_line_level_length_is_said_out_loud ( )
The spec would drop it anyway -- but silently, and 9.9 m is a lot to lose.

If the segments turn out to be wrong, the stale line-level value is the
first place anybody would look, so the run report has to mention it.

Definition at line 449 of file test_segments.py.

References _drawing(), and measured().

◆ test_a_trickle_through_an_itemised_run_is_priced_not_raised()

None test_segments.test_a_trickle_through_an_itemised_run_is_priced_not_raised ( )
Below Re ~ 5 fluids' Rennels bend computes its own friction factor with
Clamond's turbulent formula, which takes a log of a negative number and
raises. A solve reporting its result at a near-zero flow (a press line
settling, a tank topping up) hit that and the error escaped the solve. The
adapter now hands Rennels the friction factor the run already has --
laminar-correct -- whenever its own refuses, and only then.

Definition at line 531 of file test_segments.py.

References pipe().

◆ test_a_value_with_no_provenance_is_refused()

None test_segments.test_a_value_with_no_provenance_is_refused ( )
Same contract as every other parameter: no source, no number.

A silent default here would turn a format mismatch -- a document written by
something that is not this drawing tool -- into a figure nobody checked.

Definition at line 66 of file test_segments.py.

◆ test_an_itemised_run_at_zero_flow_drops_nothing_and_does_not_raise()

None test_segments.test_an_itemised_run_at_zero_flow_drops_nothing_and_does_not_raise ( )
A capped run -- a fill line behind a shut QD, a vent leg -- is back-filled
by the solver at exactly zero flow, and opening a stand prices every run at
rest. Bends and bore changes are K times a dynamic head that is zero there,
but the bend correlation (Rennels, via fluids) refuses a Reynolds number of
zero, and the ValueError escaped: a drawing with an itemised run on a capped
branch could not open as a stand at all (a 500 on POST /api/session).

Definition at line 503 of file test_segments.py.

References pipe().

◆ test_an_unknown_fitting_is_carried_and_reported()

None test_segments.test_an_unknown_fitting_is_carried_and_reported ( )
The drawing is allowed to be ahead of the solver. A dropped elbow is not.

Definition at line 141 of file test_segments.py.

References measured().

◆ test_an_unmeasurable_body_length_refuses_to_guess()

None test_segments.test_an_unmeasurable_body_length_refuses_to_guess ( )
A partial subtraction is a wrong number that looks careful.

Definition at line 229 of file test_segments.py.

References measured().

◆ test_friction_matches_darcy_weisbach_worked_by_hand()

None test_segments.test_friction_matches_darcy_weisbach_worked_by_hand ( )
Against the equation, not against the other code path.

Definition at line 187 of file test_segments.py.

References measured(), and pipe().

◆ test_nothing_is_said_when_there_was_nothing_to_supersede()

None test_segments.test_nothing_is_said_when_there_was_nothing_to_supersede ( )

Definition at line 466 of file test_segments.py.

References _drawing(), and measured().

◆ test_one_segment_is_the_darcy_pipe_exactly()

None test_segments.test_one_segment_is_the_darcy_pipe_exactly ( )
The new path must not move an answer the old path already got right.

Bit-identical, not approximately: a segmented run of one segment is the same
equation with the same friction factor at the same Reynolds number.

Definition at line 161 of file test_segments.py.

References measured(), and pipe().

◆ test_the_bore_is_inside_the_sum_not_averaged()

None test_segments.test_the_bore_is_inside_the_sum_not_averaged ( )
Why this class exists.

Velocity head goes as D^-4 and L/D adds a fifth power, so the loss of a run
that steps bore is nowhere near the loss of the same run at its mean bore.
Lumping under-predicts by tens of percent, always in the unsafe direction.

Definition at line 275 of file test_segments.py.

References measured(), and pipe().

◆ test_the_ladder_reports_the_best_and_the_worst()

None test_segments.test_the_ladder_reports_the_best_and_the_worst ( )

Definition at line 76 of file test_segments.py.

References measured().

◆ test_the_line_level_length_is_superseded_not_added()

None test_segments.test_the_line_level_length_is_superseded_not_added ( )
The drawing greys those fields out. Summing both is the double-count.

Definition at line 421 of file test_segments.py.

References _drawing(), and measured().

◆ test_velocity_is_reported_at_the_tightest_bore()

None test_segments.test_velocity_is_reported_at_the_tightest_bore ( )
Where a velocity limit bites and where cavitation starts.

Definition at line 305 of file test_segments.py.

References measured(), and pipe().

Variable Documentation

◆ FLOW

test_segments.FLOW = FlowConditions(rho=RHO, mu=MU, p_upstream=4.0e6, temperature=293.15)

Definition at line 31 of file test_segments.py.

◆ MU

test_segments.MU

Definition at line 27 of file test_segments.py.

◆ RHO

test_segments.RHO

Definition at line 27 of file test_segments.py.