sheikhzain185 commited on
Commit
da53511
·
verified ·
1 Parent(s): c24de06

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +67 -0
app.py ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import math
3
+
4
+ def design_heat_exchanger(duty, t_hot_in, t_hot_out, t_cold_in, t_cold_out, overall_heat_transfer_coeff, fouling_factor):
5
+ """
6
+ Calculate heat transfer area and LMTD for shell-and-tube heat exchanger.
7
+
8
+ Parameters:
9
+ - duty: Heat duty (kW)
10
+ - t_hot_in: Hot fluid inlet temperature (°C)
11
+ - t_hot_out: Hot fluid outlet temperature (°C)
12
+ - t_cold_in: Cold fluid inlet temperature (°C)
13
+ - t_cold_out: Cold fluid outlet temperature (°C)
14
+ - overall_heat_transfer_coeff: Overall heat transfer coefficient (W/m²°C)
15
+ - fouling_factor: Fouling resistance (m²°C/W)
16
+
17
+ Returns:
18
+ - Heat transfer area (m²)
19
+ - Log Mean Temperature Difference (°C)
20
+ """
21
+ try:
22
+ # Convert duty from kW to W
23
+ duty_w = duty * 1000
24
+
25
+ # Calculate Log Mean Temperature Difference (LMTD)
26
+ delta_t1 = t_hot_in - t_cold_out
27
+ delta_t2 = t_hot_out - t_cold_in
28
+
29
+ if delta_t1 <= 0 or delta_t2 <= 0:
30
+ return "Invalid temperature inputs!", "N/A"
31
+
32
+ lmtd = (delta_t1 - delta_t2) / math.log(delta_t1 / delta_t2)
33
+
34
+ # Calculate heat transfer area
35
+ effective_u = overall_heat_transfer_coeff * (1 - fouling_factor)
36
+ if effective_u <= 0:
37
+ return "Invalid fouling factor or heat transfer coefficient!", "N/A"
38
+
39
+ area = duty_w / (effective_u * lmtd)
40
+ return round(area, 2), round(lmtd, 2)
41
+
42
+ except Exception as e:
43
+ return str(e), "N/A"
44
+
45
+ # Streamlit App
46
+ st.title("Shell-and-Tube Heat Exchanger Design")
47
+ st.write("Enter the design parameters to calculate the heat transfer area and LMTD.")
48
+
49
+ # Input fields
50
+ duty = st.number_input("Heat Duty (kW)", min_value=0.1, step=0.1)
51
+ t_hot_in = st.number_input("Hot Fluid Inlet Temperature (°C)", step=0.1)
52
+ t_hot_out = st.number_input("Hot Fluid Outlet Temperature (°C)", step=0.1)
53
+ t_cold_in = st.number_input("Cold Fluid Inlet Temperature (°C)", step=0.1)
54
+ t_cold_out = st.number_input("Cold Fluid Outlet Temperature (°C)", step=0.1)
55
+ overall_heat_transfer_coeff = st.number_input("Overall Heat Transfer Coefficient (W/m²°C)", min_value=1.0, step=0.1)
56
+ fouling_factor = st.number_input("Fouling Factor (m²°C/W)", min_value=0.0, max_value=1.0, step=0.01)
57
+
58
+ # Perform calculation on button click
59
+ if st.button("Calculate"):
60
+ area, lmtd = design_heat_exchanger(
61
+ duty, t_hot_in, t_hot_out, t_cold_in, t_cold_out,
62
+ overall_heat_transfer_coeff, fouling_factor
63
+ )
64
+
65
+ st.write("### Results")
66
+ st.write(f"**Heat Transfer Area:** {area} m²")
67
+ st.write(f"**Log Mean Temperature Difference:** {lmtd} °C")