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

Functions

LineLoss read_segments (Any raw, str where)
list[str] _check (LineSegment segment, str basis, str place, float run_bore=0.0)
Curve|None _curve (Any raw, str where, list[str] warnings)
Param|None _param (Any entry, str name, str where)
tuple[tuple[Fitting,...], list[str]] _fittings (Any raw, str where, frozenset[str] known)
int _count (Any value)
float _mm (Any value)
float _plain (Any value)
list[float] _floats (Any raw)
frozenset[str] _known_fittings ()

Variables

dict _PROVENANCE = {p.value: p for p in Provenance}
 _BASES = frozenset({"tube", "overall"})

Detailed Description

Read a line's segment list off a P&ID edge.

`pid-designer` writes ``data.segments`` on an edge: the run broken into
segments, each with a tube size, a bore, a developed length and a counted list
of fittings. Until this module existed the reader stopped at ``data.params``, so
an itemised line arrived at the solver as an *unstated* one and got a default
with a shrug -- while the drawing's own editor was greying out the line-level
``Length`` and ``Bore`` fields and saying "superseded by the segments below".
The field marked superseded was the only one being read.

The shapes are :mod:`feedtwin.model.segments`, which is also where the physics
of the thing is written down. This module is only the boundary: JSON in,
provenance checked, dataclasses out.

Function Documentation

◆ _check()

list[str] feedtwin.pid.segments._check ( LineSegment segment,
str basis,
str place,
float run_bore = 0.0 )
protected
What the drawing said that will not survive contact with the solver.

Every one of these is a case where the segment still produces a number --
the point is that the number is not the one the drawing appears to promise,
so it is said out loud rather than absorbed. ``run_bore`` is the narrowest
bore stated anywhere on the run [m], zero for none: what the solver sizes a
segment with no bore of its own at.

Definition at line 108 of file segments.py.

Referenced by read_segments().

◆ _count()

int feedtwin.pid.segments._count ( Any value)
protected

Definition at line 276 of file segments.py.

References max.

Referenced by _fittings().

◆ _curve()

Curve | None feedtwin.pid.segments._curve ( Any raw,
str where,
list[str] warnings )
protected
A ``{mdot, mdotUnit, dp, dpUnit}`` table, or None.

A curve is the top of the ladder, so a malformed one is *not* silently
dropped to a lower rung -- it is reported, and then dropped, because a run
somebody flowed and recorded badly is a thing to go and fix rather than to
quietly replace with a correlation.

Definition at line 184 of file segments.py.

References _floats().

Referenced by read_segments().

◆ _fittings()

tuple[tuple[Fitting, ...], list[str]] feedtwin.pid.segments._fittings ( Any raw,
str where,
frozenset[str] known )
protected

Definition at line 234 of file segments.py.

References _count(), _mm(), and _plain().

Referenced by read_segments().

◆ _floats()

list[float] feedtwin.pid.segments._floats ( Any raw)
protected
A list of numbers, or nothing. One bad entry voids the list.

Half a curve is not a curve -- interpolating across a hole in it would put
a straight line through whatever the drawing failed to record.

Definition at line 299 of file segments.py.

Referenced by _curve().

◆ _known_fittings()

frozenset[str] feedtwin.pid.segments._known_fittings ( )
protected

Definition at line 316 of file segments.py.

Referenced by read_segments().

◆ _mm()

float feedtwin.pid.segments._mm ( Any value)
protected

Definition at line 283 of file segments.py.

Referenced by _fittings().

◆ _param()

Param | None feedtwin.pid.segments._param ( Any entry,
str name,
str where )
protected
One ``{value, unit, source, reference}`` block, or None if unstated.

Definition at line 213 of file segments.py.

Referenced by read_segments().

◆ _plain()

float feedtwin.pid.segments._plain ( Any value)
protected

Definition at line 290 of file segments.py.

Referenced by _fittings().

◆ read_segments()

LineLoss feedtwin.pid.segments.read_segments ( Any raw,
str where )
Read ``data.segments`` off an edge.

Absent, empty or malformed gives an empty :class:`LineLoss`, which the
caller reads as "this line says nothing" and falls back to the line-level
parameters -- the behaviour every existing drawing already gets.

Raises:
    DiagramError: a segment states a value with no recognised provenance.
        Same contract as the reader's own parameters, and for the same
        reason: a number whose source is unrecognised means the document
        came from something other than this drawing tool, and quietly
        defaulting it turns a format mismatch into a figure nobody checked.

Definition at line 39 of file segments.py.

References _check(), _curve(), _fittings(), _known_fittings(), _param(), and min.

Variable Documentation

◆ _BASES

feedtwin.pid.segments._BASES = frozenset({"tube", "overall"})
protected

Definition at line 36 of file segments.py.

◆ _PROVENANCE

dict feedtwin.pid.segments._PROVENANCE = {p.value: p for p in Provenance}
protected

Definition at line 31 of file segments.py.