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

Classes

class  FittingContext

Functions

float darcy_friction_factor (float Re, float roughness_ratio, str method)
float reynolds (float mdot, float bore, float rho, float mu)
float velocity (float mdot, float bore, float rho)
None register_fitting (str name, FittingK fn)
FittingK get_fitting (str name)
list[str] registered_fittings ()
float fitting_K (str name, FittingContext ctx)
float _bend (FittingContext ctx, float angle)
float _contraction (FittingContext ctx)
float _expansion (FittingContext ctx)
FittingK _crane (float constant)

Variables

tuple FRICTION_METHODS
str DEFAULT_FRICTION_METHOD = "Clamond"
float LAMINAR_LIMIT = 2040.0
 FittingK = Callable[[FittingContext], float]
dict _FITTINGS = {}

Detailed Description

Friction factors and fitting losses, as registries rather than choices.

Two registries, both extensible from outside this package, both wrapping
``fluids`` rather than reimplementing it.

**Friction factors.** Colebrook is implicit and has to be iterated; a dozen
explicit approximations to it exist, and they disagree in the third significant
figure. Which one a project uses is a modelling decision, not a fact, so it is
an *option* on the component -- ``pipe.options.friction`` -- and changing it is
a config edit.

**Fitting losses.** Crane TP-410's resistance coefficients, plus the Hooper 2K
and Darby 3K methods, all of which ``fluids`` implements and validates against
the source books. Every fitting here is a thin adapter that unpacks a uniform
context into the arguments one of those functions wants -- deliberately thin, so
that what this package contributes is the plumbing and never the physics.

Nothing in this module computes a loss coefficient from first principles. If a
number here disagrees with Crane, it is this module's adapter that is wrong.

Function Documentation

◆ _bend()

float feedtwin.comps.correlations._bend ( FittingContext ctx,
float angle )
protected

Definition at line 160 of file correlations.py.

Referenced by _crane().

◆ _contraction()

float feedtwin.comps.correlations._contraction ( FittingContext ctx)
protected

Definition at line 185 of file correlations.py.

◆ _crane()

FittingK feedtwin.comps.correlations._crane ( float constant)
protected
A Crane coefficient expressed as a multiple of the pipe friction factor.

Crane TP-410 gives many fittings as ``K = n . f_T``, where f_T is the
fully-turbulent friction factor *of the pipe size* -- ``fluids.fittings.
ft_Crane(D)``, a constant of the bore, not the line's friction factor at its
own Reynolds number. Scaling ``ctx.fd`` instead put a 30 f_T elbow anywhere
from 0.55 to 1.09 against Crane's 0.885 in 9.5 mm tube, and laminar flow
(64/Re) made it larger still.

Definition at line 201 of file correlations.py.

References _bend(), _crane(), and register_fitting().

Referenced by _crane().

◆ _expansion()

float feedtwin.comps.correlations._expansion ( FittingContext ctx)
protected

Definition at line 193 of file correlations.py.

◆ darcy_friction_factor()

float feedtwin.comps.correlations.darcy_friction_factor ( float Re,
float roughness_ratio,
str method )
Darcy friction factor from a named correlation.

Args:
    Re: Reynolds number.
    roughness_ratio: Absolute roughness over bore, e/D.
    method: One of :data:`FRICTION_METHODS`.

Zero and negative Reynolds numbers return zero rather than raising: a
solver's first iterate legitimately passes through zero flow, and a
component with no flow through it has no frictional loss.

Below the transition the answer is 64/Re regardless of which turbulent
correlation was named -- ``fluids`` applies that itself, and it matters
because a solve sweeping down toward zero flow passes through the laminar
regime whether or not the design point is anywhere near it.

Definition at line 55 of file correlations.py.

◆ fitting_K()

float feedtwin.comps.correlations.fitting_K ( str name,
FittingContext ctx )
Resistance coefficient of one fitting, referred to ``ctx.bore``.

Definition at line 150 of file correlations.py.

References get_fitting().

◆ get_fitting()

FittingK feedtwin.comps.correlations.get_fitting ( str name)

Definition at line 138 of file correlations.py.

Referenced by fitting_K().

◆ register_fitting()

None feedtwin.comps.correlations.register_fitting ( str name,
FittingK fn )
Register a fitting correlation. Replacing a name is allowed.

Definition at line 133 of file correlations.py.

Referenced by _crane().

◆ registered_fittings()

list[str] feedtwin.comps.correlations.registered_fittings ( )

Definition at line 146 of file correlations.py.

◆ reynolds()

float feedtwin.comps.correlations.reynolds ( float mdot,
float bore,
float rho,
float mu )
Reynolds number from mass flow. ``Re = 4 m / (pi D mu)``.

Written in terms of mass flow rather than velocity because that is what a
network solver carries, and going via velocity would divide by density and
then multiply by it again.

Definition at line 82 of file correlations.py.

◆ velocity()

float feedtwin.comps.correlations.velocity ( float mdot,
float bore,
float rho )
Bulk velocity [m/s] through a circular bore.

Definition at line 94 of file correlations.py.

Variable Documentation

◆ _FITTINGS

dict feedtwin.comps.correlations._FITTINGS = {}
protected

Definition at line 130 of file correlations.py.

◆ DEFAULT_FRICTION_METHOD

str feedtwin.comps.correlations.DEFAULT_FRICTION_METHOD = "Clamond"

Definition at line 45 of file correlations.py.

◆ FittingK

feedtwin.comps.correlations.FittingK = Callable[[FittingContext], float]

Definition at line 128 of file correlations.py.

◆ FRICTION_METHODS

tuple feedtwin.comps.correlations.FRICTION_METHODS
Initial value:
1= tuple(
2 sorted(friction_factor_methods(Re=1.0e5, eD=1.0e-4))
3)

Definition at line 41 of file correlations.py.

◆ LAMINAR_LIMIT

float feedtwin.comps.correlations.LAMINAR_LIMIT = 2040.0

Definition at line 51 of file correlations.py.