zeeshan4801 commited on
Commit
e956a7f
·
verified ·
1 Parent(s): 6dc61a2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -1
app.py CHANGED
@@ -1,5 +1,7 @@
1
  import streamlit as st
2
  import math
 
 
3
 
4
  def calculate_pipe_diameter(flow_rate, velocity):
5
  """Calculate the pipe diameter using the formula:
@@ -44,6 +46,26 @@ def main():
44
  else:
45
  st.error("Velocity must be greater than zero.")
46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  # Sidebar for additional information
48
  st.sidebar.header("About the App")
49
  st.sidebar.markdown("This application helps you calculate the recommended pipe diameter for a given flow rate and velocity.")
@@ -55,4 +77,4 @@ def main():
55
  st.markdown("**Developed by [Your Name]**")
56
 
57
  if __name__ == "__main__":
58
- main()
 
1
  import streamlit as st
2
  import math
3
+ import matplotlib.pyplot as plt
4
+ import numpy as np
5
 
6
  def calculate_pipe_diameter(flow_rate, velocity):
7
  """Calculate the pipe diameter using the formula:
 
46
  else:
47
  st.error("Velocity must be greater than zero.")
48
 
49
+ # Graphical visualization
50
+ st.markdown("### Pipe Diameter Visualization")
51
+ st.write("This graph shows the relationship between pipe diameter and velocity for the specified flow rate.")
52
+
53
+ min_velocity = st.sidebar.number_input("Minimum Velocity (m/s):", min_value=0.01, value=0.5, step=0.1, format="%.2f")
54
+ max_velocity = st.sidebar.number_input("Maximum Velocity (m/s):", min_value=min_velocity + 0.1, value=5.0, step=0.1, format="%.2f")
55
+
56
+ velocities = np.linspace(min_velocity, max_velocity, 100)
57
+ diameters = [calculate_pipe_diameter(flow_rate, v) for v in velocities]
58
+
59
+ fig, ax = plt.subplots()
60
+ ax.plot(velocities, diameters, label="Pipe Diameter vs Velocity", color="blue")
61
+ ax.set_xlabel("Velocity (m/s)")
62
+ ax.set_ylabel("Pipe Diameter (m)")
63
+ ax.set_title("Recommended Pipe Diameter Across Velocity Range")
64
+ ax.grid(True)
65
+ ax.legend()
66
+
67
+ st.pyplot(fig)
68
+
69
  # Sidebar for additional information
70
  st.sidebar.header("About the App")
71
  st.sidebar.markdown("This application helps you calculate the recommended pipe diameter for a given flow rate and velocity.")
 
77
  st.markdown("**Developed by [Your Name]**")
78
 
79
  if __name__ == "__main__":
80
+ main()