The comp_valve submodule

Hydraulic valve component models.

This module provides valve-related resistance components used to model controllable pressure losses in hydraulic systems.

Main ideas:

  • valves are modeled as resistance components,

  • valve behavior is state-dependent (opening/position logic defined by each subclass),

  • loss is evaluated through valve-specific coefficients and converted to head.

Design conventions:

  • mounting direction is port 1 -> port 2,

  • runtime flow direction is represented by sense,

  • valve classes inherit from Comp_Valve and specialize calcK and/or related helper methods,

  • resulting head loss is returned through calcH in the same unit conventions as other components.

Typical extension pattern:

  1. Subclass Comp_Valve.

  2. Define how state maps to hydraulic behavior.

  3. Implement calcK (or equivalent) for that state.

  4. Reuse the base calcH conversion pipeline.

Example:

valve = Comp_Valve(D=50)
valve.state = 1.0
H = valve.calcH(2.0 * u.m**3 / u.h, sense=1)

Valve subclasses in this module are intended to be combined with pumps, pipes, and fittings inside paths or full network solves.

class fluidsolve.comp_valve.Comp_Valve(**kwargs: Any)[source]

Bases: Comp_Base

Generic valve base class.

State meaning is defined by subclasses.

Parameters:

D (int | float | Quantity, optional) – Valve bore diameter (default in mm).

_group: str = 'Resistance'
_part: str = 'Valve'
_prefix: str = 'V'
_conn: dict = {1: [[1, 2]]}
__init__(**kwargs: Any) Any[source]
property state: float

Valve state.

Returns:

State value.

Return type:

int | float

connections(state: Any | None = None) Any[source]

Return open port connections for the given valve state.

Parameters:

state (Any, optional) – Valve state override. Uses current state when omitted.

Returns:

List of open port-pair tuples.

Return type:

Any

calcK(Q: Quantity, sense: int, pin: int = 1, pout: int = 2) float[source]

Default valve behavior: open.

calcH(Q: Quantity, sense: int = 1, pin: int = 1, pout: int = 2) Quantity[source]

Calculate head change.

Parameters:
  • Q – Flow rate.

  • sense – +1 if flow is from pin to pout, -1 for reverse flow.

  • pin – Inlet port number.

  • pout – Outlet port number.

Returns:

Head change in meters.

Return type:

Quantity

toString(detail: int = 0) str[source]

Return string representation.

class fluidsolve.comp_valve.Comp_Valve_NR(**kwargs: Any)[source]

Bases: Comp_Valve

Non-return (check) valve.

Mounted flow direction:

port 1 -> port 2 = allowed flow

_part: str = 'Valve_NR'
calcK(Q: Quantity, sense: int = 1, pin: int = 1, pout: int = 2) float[source]

Default valve behavior: open.

class fluidsolve.comp_valve.Comp_Valve_01(**kwargs: Any)[source]

Bases: Comp_Valve

On/off valve.

state:

0.0 = closed 1.0 = fully open

_part: str = 'Valve_01'
calcK(Q: Quantity, sense: int = 1, pin: int = 1, pout: int = 2) float[source]

Default valve behavior: open.

class fluidsolve.comp_valve.Comp_Valve_Kv(**kwargs: Any)[source]

Bases: Comp_Valve

Throttling valve with equal percentage characteristic.

state: valve position (0.0 = closed, 1.0 = fully open) Kv at position s = Kvs * (R^s - 1) / (R - 1)

_part: str = 'Valve_KV'
__init__(**kwargs: Any) Any[source]
property Kvs: float

Fully-open flow coefficient Kvs.

Returns:

Kvs value (m³/h at 1 bar).

Return type:

float

property R: float

Valve rangeability (authority ratio).

Returns:

R value (Kvs / Kvmin), default 3.0.

Return type:

float

connections(state: Any | None = None) Any[source]

Return always-open hydraulic connectivity for throttling valves.

calcK(Q: Quantity, sense: int = 1, pin: int = 1, pout: int = 2) float[source]

Default valve behavior: open.

class fluidsolve.comp_valve.Comp_Valve_3W(**kwargs: Any)[source]

Bases: Comp_Valve

3-way valve.

Ports:

1 = common 2 = branch A 3 = branch B

state:

1 -> connect 1-2 2 -> connect 1-3

_part: str = 'Valve_3W'
_nports: int = 3
_ports: list = [[1, 2], [1, 3], [2, 3]]
_conn: dict = {1: [[1, 2]], 2: [[1, 3]]}
calcK(Q: Quantity, sense: int = 1, pin: int = 1, pout: int = 2) float[source]

Fixed valve loss, independent of direction.

class fluidsolve.comp_valve.Comp_Valve_DS(**kwargs: Any)[source]

Bases: Comp_Valve

Double seat valve.

Ports:

state 1: 1-2 and 3-4 open state 2: 1-2 and 3-4 remain open, plus 1-3 opens

_part: str = 'Valve_DS'
_nports: int = 4
_ports: list = [[1, 2], [1, 3], [3, 4]]
_conn: dict = {1: [[1, 2], [3, 4]], 2: [[1, 2], [1, 3], [3, 4]]}
calcK(Q: Quantity, sense: int = 1, pin: int = 1, pout: int = 2) float[source]

Fixed valve loss coefficient.