rehanafzal commited on
Commit
4f856e9
·
verified ·
1 Parent(s): 6c72b5b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py CHANGED
@@ -1,5 +1,7 @@
1
  import streamlit as st
2
  import math
 
 
3
 
4
  # Set page config with an icon and title
5
  st.set_page_config(page_title="Pipe Sizing Helper", page_icon="🛠️")
@@ -57,3 +59,26 @@ if st.button("Generate Recommended Pipe Diameter"):
57
  st.success(f"Recommended Pipe Diameter: {diameter_mm:.2f} mm")
58
  else:
59
  st.error("Permissible velocity must be greater than zero.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
  import math
3
+ import numpy as np
4
+ import matplotlib.pyplot as plt
5
 
6
  # Set page config with an icon and title
7
  st.set_page_config(page_title="Pipe Sizing Helper", page_icon="🛠️")
 
59
  st.success(f"Recommended Pipe Diameter: {diameter_mm:.2f} mm")
60
  else:
61
  st.error("Permissible velocity must be greater than zero.")
62
+
63
+ # Graphical visualization section
64
+ st.header("Graphical Visualization")
65
+ st.write("Explore how pipe diameter changes with flow rate and velocity.")
66
+
67
+ # Generate ranges for flow rate and velocity
68
+ flow_rates = np.linspace(0.1, 10, 100) # Flow rates from 0.1 to 10 m³/s
69
+ velocities = np.linspace(0.1, 5, 50) # Velocities from 0.1 to 5 m/s
70
+
71
+ # Create a grid for flow rates and velocities
72
+ flow_rate_mesh, velocity_mesh = np.meshgrid(flow_rates, velocities)
73
+ pipe_diameters = np.sqrt(4 * flow_rate_mesh / (np.pi * velocity_mesh)) * 1000 # Diameter in mm
74
+
75
+ # Plotting
76
+ fig, ax = plt.subplots(figsize=(8, 6))
77
+ c = ax.contourf(flow_rate_mesh, velocity_mesh, pipe_diameters, cmap="viridis", levels=20)
78
+ plt.colorbar(c, label="Pipe Diameter (mm)")
79
+ ax.set_title("Pipe Diameter Heatmap")
80
+ ax.set_xlabel("Flow Rate (m³/s)")
81
+ ax.set_ylabel("Velocity (m/s)")
82
+
83
+ # Display plot in Streamlit
84
+ st.pyplot(fig)