File size: 2,550 Bytes
925a3c8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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()