Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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")
|
22 |
+
|
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 |
+
if machine_type == "SoftFlow":
|
30 |
+
enthalpy = get_enthalpy(6)['Saturation_Vapour(KCal/kg)']
|
31 |
+
mlr = 6
|
32 |
+
if machine_type == "Yarn Dyeing":
|
33 |
+
enthalpy = get_enthalpy(7)['Saturation_Vapour(KCal/kg)']
|
34 |
+
mlr = 4
|
35 |
+
if machine_type == "Jet Dyeing":
|
36 |
+
enthalpy = get_enthalpy(5)['Saturation_Vapour(KCal/kg)']
|
37 |
+
mlr = 10
|
38 |
+
for i in range(1, num_machines + 1):
|
39 |
+
st.subheader(f"Machine {i}")
|
40 |
+
machine_name = f"{machine_type}_Machine_{i}"
|
41 |
+
quantity = st.number_input(f"{machine_name} - Quantity (kg)", min_value=0.0, step=0.1, key=f"qty_{i}")
|
42 |
+
set_temp = st.number_input(f"{machine_name} - Set Temperature (°C)", min_value=0.0, step=0.1, key=f"set_temp_{i}")
|
43 |
+
actual_temp = st.number_input(f"{machine_name} - Actual Temperature (°C)", min_value=0.0, step=0.1, key=f"act_temp_{i}")
|
44 |
+
|
45 |
+
overshoot = actual_temp - set_temp
|
46 |
+
water_steam_consumption = mlr*quantity*1*overshoot
|
47 |
+
cloth_steam_consumption = quantity*1*overshoot
|
48 |
+
steam_consumption = (water_steam_consumption + cloth_steam_consumption)// enthalpy
|
49 |
+
|
50 |
+
machines_data.append({
|
51 |
+
"Machine Name": machine_name,
|
52 |
+
"Selected Machine Quantity (kg)": quantity,
|
53 |
+
"Set Temperature (°C)": set_temp,
|
54 |
+
"Actual Temperature (°C)": actual_temp,
|
55 |
+
"Overshoot (°C)": overshoot
|
56 |
+
})
|
57 |
+
|
58 |
+
# Step 3: Display Data & Calculate Range
|
59 |
+
if machines_data:
|
60 |
+
df = pd.DataFrame(machines_data)
|
61 |
+
st.write("### Machines Data")
|
62 |
+
st.dataframe(df)
|
63 |
+
|
64 |
+
overshoot_values = df["Overshoot (°C)"].tolist()
|
65 |
+
min_overshoot = min(overshoot_values) if overshoot_values else 0
|
66 |
+
max_overshoot = max(overshoot_values) if overshoot_values else 0
|
67 |
+
|
68 |
+
# Step 4: Editable Text Output
|
69 |
+
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_consumption} Kg/day."
|
70 |
+
user_text = st.text_area("Editable Report:", value=default_text, height=150)
|
71 |
+
|
72 |
+
st.write("### Final Report")
|
73 |
+
st.write(f"{user_text}")
|
74 |
+
|
75 |
+
if __name__ == "__main__":
|
76 |
+
main()
|