Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Include Gate Valve function #160

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 47 additions & 2 deletions indsl/equipment/valve_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
from indsl.type_check import check_types
from indsl.validations import UserValueError

from . import valve_parameters_ # noqa


@versioning.register(
version="3.0",
Expand Down Expand Up @@ -125,3 +123,50 @@ def flow_through_valve(
)

return scalar_to_pandas_series(Q)


@check_types
def flow_through_gate_valves(
p_A: Union[pd.Series, float], # Gauge Pressure at block terminal A
p_B: Union[pd.Series, float], # Gauge Pressure at block terminal B
C_D: Union[pd.Series, float], # Flow Discharge Coefficient
x_0: Union[pd.Series, float], # Initial opening
x: Union[pd.Series, float], # Gate displacement from initial position
D: Union[pd.Series, float], # Diameter of the orifice
rho: Union[pd.Series, float], # Density of the fluid
p_cr: Union[pd.Series, float], # Minimum pressure for turbulent flow
A_leak: Union[pd.Series, float] = 0, # Closed valve leakage area
) -> pd.Series:
r"""Flow through gate valves.

This function is used to calculate the flow rate through a gate valve. The calculation is based on the Bernoulli equation and the orifice equation.

Args:
p_A: Gauge Pressure at block terminal A
p_B: Gauge Pressure at block terminal B
C_D: Flow Discharge Coefficient
x_0: Initial opening
x: Gate displacement from initial position
D: Diameter of the orifice
rho: Density of the fluid
p_cr: Minimum pressure for turbulent flow
A_leak: Closed valve leakage area. Defaults to 0.

Returns:
pd.Series: Flow rate through gate valve

"""
p_delta = p_A - p_B # Pressure differential
h = x_0 + x # Valve opening

# Instantaneous orifice passage area
A_opening = A_leak
if (h > 0) and (h < 2 * D):
A_orifice = np.pi * D**2 / 4
A_overlap = ((D**2 / 2) * (np.arccos(h / D))) - (h * np.sqrt(D**2 - h**2) / 2)
A_opening = A_orifice - A_overlap

# Flow Rate
q = C_D * A_opening * np.sqrt(2 / rho) * (p_delta) / (p_delta**2 + p_cr**2) ** 0.25

return q # type: ignore
173 changes: 0 additions & 173 deletions indsl/equipment/valve_parameters_.py

This file was deleted.

Loading