Shivraj8615's picture
Upload app.py
925a3c8 verified
import streamlit as st
def find_nearest_pipe_size(flow, pipe_sizes, commercial_pipes):
for size, max_flow in pipe_sizes.items():
if flow <= max_flow and size in commercial_pipes:
return size
return min(commercial_pipes, key=lambda x: abs(x - max(pipe_sizes.keys())))
def main():
st.set_page_config(page_title="Condensate Pipe Sizing", layout="centered")
st.title("๐Ÿ’ง Condensate Pipe Sizing Tool")
pipe_sizes = {
15: 160,
20: 370,
25: 695,
32: 1510,
40: 2300,
50: 4427,
65: 8972,
80: 13925,
100: 28350
}
commercial_pipes = [15, 20, 25, 40, 50, 65, 80, 100, 125, 150]
option = st.selectbox("Select Pipe Location:", ["Before Trap", "After Trap", "Header", "After Pump"])
num_connections = st.number_input("Enter number of connections:", min_value=1, step=1)
total_flow = 0
results = []
for i in range(num_connections):
flow = st.number_input(f"Enter flow for connection {i+1} (kg/h):", min_value=1.0, step=1.0, format="%.2f")
total_flow += flow
if option == "Before Trap":
final_flow = flow
pipe_size = find_nearest_pipe_size(final_flow, pipe_sizes, commercial_pipes)
results.append((flow, final_flow, pipe_size))
elif option == "After Trap":
final_flow = flow * 2
pipe_size = find_nearest_pipe_size(final_flow, pipe_sizes, commercial_pipes)
results.append((flow, final_flow, pipe_size))
elif option == "After Pump":
final_flow = flow * 3
pipe_size = find_nearest_pipe_size(final_flow, pipe_sizes, commercial_pipes)
results.append((flow, final_flow, pipe_size))
if option == "Header":
final_flow = total_flow * 2
pipe_size = find_nearest_pipe_size(final_flow, pipe_sizes, commercial_pipes)
if st.button("Calculate Pipe Sizes"):
st.write("### Recommended Pipe Sizes")
if option == "Header":
st.success(f"๐Ÿ”น Header: Total Flow: {total_flow} kg/h, Final Flow: {final_flow} kg/h, Recommended Pipe: {pipe_size} mm")
else:
for i, (flow, final_flow, pipe_size) in enumerate(results, start=1):
st.success(f"๐Ÿ”น Connection {i}: Input Flow: {flow} kg/h, Final Flow: {final_flow} kg/h, Recommended Pipe: {pipe_size} mm")
if __name__ == "__main__":
main()