Created
June 10, 2019 13:21
-
-
Save sourceperl/e4382a23e62c94250e1db180b9da57c6 to your computer and use it in GitHub Desktop.
3d graph of control valve dynamic (flow vs pressure/valve travel)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# play with cv ( coefficient of flow) of control valve | |
from mpl_toolkits.mplot3d import Axes3D | |
import matplotlib.pyplot as plt | |
from matplotlib import cm | |
import numpy as np | |
# some const (see http://www.idealvalve.com/pdf/Flow-Calculation-for-Gases.pdf) | |
SG = 0.554 | |
T_DEG_C = 21.0 | |
P_DOWNSTREAM = 44.0 | |
VALVE_CV = 0.1 | |
# convert °C to Rankine | |
deg_r = T_DEG_C * 1.8 + 32 + 459.67 | |
# build data | |
x_ouv = np.linspace(0.0, 100.0, 1000) | |
y_p_upstream = np.linspace(50.0, 60.0, 1000) | |
x_ouv, y_p_upstream = np.meshgrid(x_ouv, y_p_upstream) | |
# sub critical flow (when: P up < 2 x P down) | |
z_qi = (962 * VALVE_CV * x_ouv) / np.sqrt((SG * deg_r) / (y_p_upstream ** 2 - P_DOWNSTREAM ** 2)) | |
# plot surface | |
fig = plt.figure() | |
ax = fig.gca(projection='3d') | |
surf = ax.plot_surface(x_ouv, y_p_upstream, z_qi, cmap=cm.coolwarm, linewidth=0, antialiased=False) | |
# custom label for axis | |
ax.set_xlabel("Valve position (%)") | |
ax.set_ylabel("P upstream (barA)") | |
ax.set_zlabel("Q (Nm3/h)") | |
# add color bar | |
fig.colorbar(surf, shrink=0.5, aspect=5) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment