Shivraj8615 commited on
Commit
5fc6466
·
verified ·
1 Parent(s): 42898f0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +51 -34
app.py CHANGED
@@ -1,21 +1,12 @@
1
  import streamlit as st
2
  import pandas as pd
3
- import requests
4
-
5
-
6
- def get_enthalpy(pressure):
7
- api_url = f"https://steam-properties.onrender.com/get_properties"
8
- params = {"pressure":pressure}
9
- response = requests.get(api_url,params)
10
-
11
- if response.status_code == 200:
12
- data = response.json()
13
- else:
14
- data = 500
15
- return data
16
-
17
-
18
 
 
 
 
 
 
 
19
 
20
  def main():
21
  st.title("Dyeing Machine Temperature Overshoot Calculator")
@@ -23,31 +14,46 @@ def main():
23
  # Step 1: User Inputs
24
  num_machines = st.number_input("Enter the number of machines:", min_value=1, step=1)
25
  machine_type = st.selectbox("Select Dyeing Machine Type:", ["SoftFlow", "Yarn Dyeing", "Jet Dyeing"]) # Modify as needed
26
-
27
- # Step 2: Creating input table dynamically
28
- machines_data = []
 
 
 
 
 
29
  steam = 0
30
  if machine_type == "SoftFlow":
31
- enthalpy = get_enthalpy(6)['Saturation_Vapour(KCal/kg)']
32
- mlr = 6
33
- if machine_type == "Yarn Dyeing":
34
- enthalpy = get_enthalpy(7)['Saturation_Vapour(KCal/kg)']
35
  mlr = 4
36
- if machine_type == "Jet Dyeing":
37
- enthalpy = get_enthalpy(5)['Saturation_Vapour(KCal/kg)']
38
  mlr = 10
 
 
 
 
 
 
 
 
39
  for i in range(1, num_machines + 1):
40
  st.subheader(f"Machine {i}")
41
  machine_name = f"{machine_type}_Machine_{i}"
 
42
  quantity = st.number_input(f"{machine_name} - Quantity (kg)", min_value=0.0, step=0.1, key=f"qty_{i}")
43
  set_temp = st.number_input(f"{machine_name} - Set Temperature (°C)", min_value=0.0, step=0.1, key=f"set_temp_{i}")
44
  actual_temp = st.number_input(f"{machine_name} - Actual Temperature (°C)", min_value=0.0, step=0.1, key=f"act_temp_{i}")
45
 
46
  overshoot = actual_temp - set_temp
47
- water_steam_consumption = mlr*quantity*1*overshoot
48
- cloth_steam_consumption = quantity*1*overshoot
49
- steam_consumption = (water_steam_consumption + cloth_steam_consumption)// enthalpy
50
- steam = steam + steam_consumption
 
51
  machines_data.append({
52
  "Machine Name": machine_name,
53
  "Selected Machine Quantity (kg)": quantity,
@@ -56,7 +62,7 @@ def main():
56
  "Overshoot (°C)": overshoot
57
  })
58
 
59
- # Step 3: Display Data & Calculate Range
60
  if machines_data:
61
  df = pd.DataFrame(machines_data)
62
  st.write("### Machines Data")
@@ -66,12 +72,23 @@ def main():
66
  min_overshoot = min(overshoot_values) if overshoot_values else 0
67
  max_overshoot = max(overshoot_values) if overshoot_values else 0
68
 
69
- # Step 4: Editable Text Output
70
- default_text = f"Currently there is temperature overshoot observed (from {min_overshoot}°C to {max_overshoot}°C) in heating, holding cycle in {machine_type} machine. Due to overshoot there is unnecessary heating. This leads to an increase in steam consumption. Estimated Steam Saving is {steam} Kg/day."
71
- user_text = st.text_area("Editable Report:", value=default_text, height=150)
 
 
 
 
 
 
 
 
 
 
 
72
 
73
  st.write("### Final Report")
74
- st.write(f"{user_text}")
75
 
76
  if __name__ == "__main__":
77
- main()
 
1
  import streamlit as st
2
  import pandas as pd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
+ # Fixed latent heat values for given pressures (in kcal/kg)
5
+ LATENT_HEAT_VALUES = {
6
+ 5: 486,
7
+ 6: 480,
8
+ 7: 475
9
+ }
10
 
11
  def main():
12
  st.title("Dyeing Machine Temperature Overshoot Calculator")
 
14
  # Step 1: User Inputs
15
  num_machines = st.number_input("Enter the number of machines:", min_value=1, step=1)
16
  machine_type = st.selectbox("Select Dyeing Machine Type:", ["SoftFlow", "Yarn Dyeing", "Jet Dyeing"]) # Modify as needed
17
+
18
+ # Step 2: Single input for control system (applies to all machines)
19
+ control_system = st.selectbox(
20
+ "Select Current Control System:",
21
+ ["ON/OFF Valve", "PID Control Valve", "Manual"]
22
+ )
23
+
24
+ # Assign fixed latent heat based on machine type
25
  steam = 0
26
  if machine_type == "SoftFlow":
27
+ enthalpy = LATENT_HEAT_VALUES[6] # 6 Kg/cm²g pressure
28
+ mlr = 6
29
+ elif machine_type == "Yarn Dyeing":
30
+ enthalpy = LATENT_HEAT_VALUES[7] # 7 Kg/cm²g pressure
31
  mlr = 4
32
+ elif machine_type == "Jet Dyeing":
33
+ enthalpy = LATENT_HEAT_VALUES[5] # 5 Kg/cm²g pressure
34
  mlr = 10
35
+
36
+ # Specific heat values
37
+ specific_heat_water = 1.0 # kcal/kg°C
38
+ specific_heat_cloth = 0.4 # kcal/kg°C
39
+
40
+ # Step 3: Creating input table dynamically
41
+ machines_data = []
42
+
43
  for i in range(1, num_machines + 1):
44
  st.subheader(f"Machine {i}")
45
  machine_name = f"{machine_type}_Machine_{i}"
46
+
47
  quantity = st.number_input(f"{machine_name} - Quantity (kg)", min_value=0.0, step=0.1, key=f"qty_{i}")
48
  set_temp = st.number_input(f"{machine_name} - Set Temperature (°C)", min_value=0.0, step=0.1, key=f"set_temp_{i}")
49
  actual_temp = st.number_input(f"{machine_name} - Actual Temperature (°C)", min_value=0.0, step=0.1, key=f"act_temp_{i}")
50
 
51
  overshoot = actual_temp - set_temp
52
+ q_water = mlr * quantity * specific_heat_water * overshoot
53
+ q_cloth = quantity * specific_heat_cloth * overshoot
54
+ steam_consumption = (q_water + q_cloth) / enthalpy
55
+ steam += steam_consumption
56
+
57
  machines_data.append({
58
  "Machine Name": machine_name,
59
  "Selected Machine Quantity (kg)": quantity,
 
62
  "Overshoot (°C)": overshoot
63
  })
64
 
65
+ # Step 4: Display Data & Calculate Range
66
  if machines_data:
67
  df = pd.DataFrame(machines_data)
68
  st.write("### Machines Data")
 
72
  min_overshoot = min(overshoot_values) if overshoot_values else 0
73
  max_overshoot = max(overshoot_values) if overshoot_values else 0
74
 
75
+ # Step 5: Recommendation Logic
76
+ if control_system != "PID Control Valve":
77
+ recommendation_text = f"- **Recommended:** Use PID Control Valve instead of {control_system} for better control and reduced steam consumption."
78
+ else:
79
+ recommendation_text = "**No additional recommendations.**"
80
+
81
+ # Step 6: Editable Text Output
82
+ default_text = (
83
+ f"Currently, there is temperature overshoot observed (from {min_overshoot}°C to {max_overshoot}°C) in heating, holding cycle in {machine_type} machine. "
84
+ f"Due to overshoot, there is unnecessary heating. This leads to an increase in steam consumption. Estimated Steam Saving is {steam:.2f} Kg/day.\n\n"
85
+ f"{recommendation_text}"
86
+ )
87
+
88
+ user_text = st.text_area("Editable Report:", value=default_text, height=200)
89
 
90
  st.write("### Final Report")
91
+ st.write(user_text)
92
 
93
  if __name__ == "__main__":
94
+ main()