STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
feedtwin.solve.network.Network Class Reference

Public Member Functions

Node add_node (self, str id, str fluid, float temperature, *, float|None pressure=None, float demand=0.0)
Branch add_branch (self, str id, HydraulicComponent component, str upstream, str downstream)
list[str] free_nodes (self)
list[str] fixed_nodes (self)
list[tuple[Branch, int]] branches_at (self, str node_id)
set[str] isolated (self, Mapping[str, float]|None signals=None)
list[DeadEnd] dead_ends (self, Iterable[str]|None exclude=None)
Fluid fluid (self, str name)
FlowConditions conditions (self, str node_id, float pressure, dict[str, float]|None signals=None)
None validate (self)
list[Violation] check (self)
str __str__ (self)

Public Attributes

 fixed_nodes

Static Public Attributes

dict nodes = field(default_factory=dict)
dict branches = field(default_factory=dict)
bool multiphase = False
float gravity = 9.80665

Protected Member Functions

list[DeadEnd] _peel (self, set[str] removed)
DeadEnd|None _island_exit (self, str node_id, list[DeadEnd] found, set[str] removed)

Static Protected Attributes

dict _fluids = field(default_factory=dict, repr=False)
dict _stubs

Detailed Description

A feed system: nodes, branches, and the fluids in them.

Definition at line 111 of file network.py.

Member Function Documentation

◆ __str__()

str feedtwin.solve.network.Network.__str__ ( self)

Definition at line 448 of file network.py.

◆ _island_exit()

DeadEnd | None feedtwin.solve.network.Network._island_exit ( self,
str node_id,
list[DeadEnd] found,
set[str] removed )
protected
A stub entry for the last node of an island, or ``None``.

Walks the branches already peeled, starting at ``node_id``, to the first
node a removed branch (a shut valve) touches, and takes the live end
across that branch -- the pressure the island would see if the valve
opened, which is what a stub hung off a shut valve already reads. An
island with no shut valve on it at all has no pressure to inherit; it
is given its own peeled neighbour, and the back-fill reports it as
undefined rather than the solve failing.

Definition at line 322 of file network.py.

References feedtwin.session.model.AssemblyReport.branches, feedtwin.session.network_trace.NetworkTrace.branches, and branches.

Referenced by _peel().

◆ _peel()

list[DeadEnd] feedtwin.solve.network.Network._peel ( self,
set[str] removed )
protected

◆ add_branch()

◆ add_node()

Node feedtwin.solve.network.Network.add_node ( self,
str id,
str fluid,
float temperature,
* ,
float | None pressure = None,
float demand = 0.0 )

◆ branches_at()

list[tuple[Branch, int]] feedtwin.solve.network.Network.branches_at ( self,
str node_id )
Branches touching a node, with +1 for inflow and -1 for outflow.

Definition at line 186 of file network.py.

References feedtwin.session.model.AssemblyReport.branches, feedtwin.session.network_trace.NetworkTrace.branches, and branches.

◆ check()

list[Violation] feedtwin.solve.network.Network.check ( self)
Design limits broken by any component in the network.

Configuration only, so it runs before a solve. A bend inside its
minimum radius does not stop the network solving; it stops the hardware
being right, which is a different and equally worth-knowing thing.

Definition at line 439 of file network.py.

References feedtwin.session.model.AssemblyReport.branches, feedtwin.session.network_trace.NetworkTrace.branches, and branches.

◆ conditions()

FlowConditions feedtwin.solve.network.Network.conditions ( self,
str node_id,
float pressure,
dict[str, float] | None signals = None )

◆ dead_ends()

list[DeadEnd] feedtwin.solve.network.Network.dead_ends ( self,
Iterable[str] | None exclude = None )
Stubs that can carry no flow, peeled outermost-first.

Args:
    exclude: Branches already removed from the solve -- shut valves.
        A node left with one live branch once those are gone is a stub
        exactly as if nothing had ever been drawn on its other side,
        which is why this takes them rather than being told twice.

Found iteratively, because stubs chain: a plenum port feeding a short
line into a capped quick-disconnect is two branches deep, and removing
the outer one is what makes the inner one a stub in turn.

The returned order is safe to back-fill in reverse -- each entry's live
end is either solved or an earlier entry.

Remembered per shut set, wiring and which nodes are boundaries: a live
session asks the same question every solve, and peeling a two-page
stand costs a millisecond each time.

Definition at line 209 of file network.py.

References _peel(), _stubs, feedtwin.session.model.AssemblyReport.branches, feedtwin.session.network_trace.NetworkTrace.branches, branches, feedtwin.pid.document.Diagram.nodes, feedtwin.session.model.AssemblyReport.nodes, feedtwin.session.network_trace.NetworkTrace.nodes, and nodes.

◆ fixed_nodes()

list[str] feedtwin.solve.network.Network.fixed_nodes ( self)

◆ fluid()

Fluid feedtwin.solve.network.Network.fluid ( self,
str name )
A cached :class:`~feedtwin.props.Fluid`, one per species.

Definition at line 366 of file network.py.

References _fluids.

Referenced by conditions().

◆ free_nodes()

list[str] feedtwin.solve.network.Network.free_nodes ( self)
Nodes whose pressure is solved, in a stable order.

Definition at line 178 of file network.py.

References feedtwin.pid.document.Diagram.nodes, feedtwin.session.model.AssemblyReport.nodes, feedtwin.session.network_trace.NetworkTrace.nodes, and nodes.

◆ isolated()

set[str] feedtwin.solve.network.Network.isolated ( self,
Mapping[str, float] | None signals = None )
Branches commanded shut, which carry no flow and are not solved for.

See :meth:`feedtwin.comps.base.HydraulicComponent.isolates`. Removing
them is what turns "a shut valve" from a near-singular row into what it
physically is -- no connection.

Definition at line 196 of file network.py.

References feedtwin.session.model.AssemblyReport.branches, feedtwin.session.network_trace.NetworkTrace.branches, and branches.

◆ validate()

None feedtwin.solve.network.Network.validate ( self)
Every structural problem that can be found without solving.

Raises:
    NetworkError: with all problems listed together, because fixing a
        network six errors at a time beats six solve attempts.

Definition at line 393 of file network.py.

References feedtwin.session.model.AssemblyReport.branches, feedtwin.session.network_trace.NetworkTrace.branches, and branches.

Member Data Documentation

◆ _fluids

dict feedtwin.solve.network.Network._fluids = field(default_factory=dict, repr=False)
staticprotected

Definition at line 136 of file network.py.

Referenced by fluid().

◆ _stubs

feedtwin.solve.network.Network._stubs
staticprotected
Initial value:
= field(
default_factory=dict, repr=False, compare=False
)

Definition at line 137 of file network.py.

Referenced by dead_ends().

◆ branches

dict feedtwin.solve.network.Network.branches = field(default_factory=dict)
static

Definition at line 115 of file network.py.

Referenced by _island_exit(), _peel(), add_branch(), branches_at(), check(), dead_ends(), isolated(), and validate().

◆ fixed_nodes

feedtwin.solve.network.Network.fixed_nodes

Definition at line 405 of file network.py.

◆ gravity

float feedtwin.solve.network.Network.gravity = 9.80665
static

Definition at line 130 of file network.py.

Referenced by conditions().

◆ multiphase

bool feedtwin.solve.network.Network.multiphase = False
static

Definition at line 117 of file network.py.

Referenced by conditions().

◆ nodes


The documentation for this class was generated from the following file: