Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,7 @@
|
|
1 |
import streamlit as st
|
2 |
import math
|
|
|
|
|
3 |
|
4 |
# Set page configuration
|
5 |
st.set_page_config(
|
@@ -17,7 +19,7 @@ st.sidebar.markdown(
|
|
17 |
- Flow Rate (\( Q \)) in cubic meters per second.
|
18 |
- Velocity (\( V \)) in meters per second.
|
19 |
|
20 |
-
|
21 |
"""
|
22 |
)
|
23 |
|
@@ -64,6 +66,51 @@ with col2:
|
|
64 |
else:
|
65 |
st.info("Click the button to calculate the pipe diameter.")
|
66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
# Footer with additional info
|
68 |
st.sidebar.markdown("---")
|
69 |
st.sidebar.markdown(
|
@@ -73,3 +120,4 @@ st.sidebar.markdown(
|
|
73 |
"""
|
74 |
)
|
75 |
|
|
|
|
1 |
import streamlit as st
|
2 |
import math
|
3 |
+
import numpy as np
|
4 |
+
import matplotlib.pyplot as plt
|
5 |
|
6 |
# Set page configuration
|
7 |
st.set_page_config(
|
|
|
19 |
- Flow Rate (\( Q \)) in cubic meters per second.
|
20 |
- Velocity (\( V \)) in meters per second.
|
21 |
|
22 |
+
Also visualize pipe diameters over a range of flow rates and velocities. 🌊
|
23 |
"""
|
24 |
)
|
25 |
|
|
|
66 |
else:
|
67 |
st.info("Click the button to calculate the pipe diameter.")
|
68 |
|
69 |
+
# Graphical visualization
|
70 |
+
st.header("Graphical Visualization 📊")
|
71 |
+
st.markdown(
|
72 |
+
"""
|
73 |
+
Visualize how pipe diameter varies with different **flow rates** and **velocities**.
|
74 |
+
"""
|
75 |
+
)
|
76 |
+
|
77 |
+
# User input for visualization range
|
78 |
+
col3, col4 = st.columns(2)
|
79 |
+
with col3:
|
80 |
+
flow_rate_range = st.slider(
|
81 |
+
"Select Flow Rate Range (m³/s):",
|
82 |
+
min_value=0.1,
|
83 |
+
max_value=5.0,
|
84 |
+
value=(0.5, 2.5),
|
85 |
+
step=0.1
|
86 |
+
)
|
87 |
+
with col4:
|
88 |
+
velocity_range = st.slider(
|
89 |
+
"Select Velocity Range (m/s):",
|
90 |
+
min_value=0.1,
|
91 |
+
max_value=10.0,
|
92 |
+
value=(1.0, 5.0),
|
93 |
+
step=0.5
|
94 |
+
)
|
95 |
+
|
96 |
+
# Generate and plot graph
|
97 |
+
flow_rates = np.linspace(flow_rate_range[0], flow_rate_range[1], 50)
|
98 |
+
velocities = np.linspace(velocity_range[0], velocity_range[1], 50)
|
99 |
+
|
100 |
+
flow_grid, velocity_grid = np.meshgrid(flow_rates, velocities)
|
101 |
+
diameter_grid = np.sqrt((4 * flow_grid) / (np.pi * velocity_grid)) * 100 # Diameter in cm
|
102 |
+
|
103 |
+
fig, ax = plt.subplots(figsize=(8, 6))
|
104 |
+
contour = ax.contourf(flow_grid, velocity_grid, diameter_grid, cmap="coolwarm")
|
105 |
+
cbar = fig.colorbar(contour, ax=ax)
|
106 |
+
cbar.set_label("Pipe Diameter (cm)")
|
107 |
+
ax.set_title("Pipe Diameter vs. Flow Rate and Velocity")
|
108 |
+
ax.set_xlabel("Flow Rate (m³/s)")
|
109 |
+
ax.set_ylabel("Velocity (m/s)")
|
110 |
+
ax.grid(True)
|
111 |
+
|
112 |
+
st.pyplot(fig)
|
113 |
+
|
114 |
# Footer with additional info
|
115 |
st.sidebar.markdown("---")
|
116 |
st.sidebar.markdown(
|
|
|
120 |
"""
|
121 |
)
|
122 |
|
123 |
+
|