Spaces:
Sleeping
Sleeping
import streamlit as st | |
import pandas as pd | |
# Fixed latent heat values for given pressures (in kcal/kg) | |
LATENT_HEAT_VALUES = { | |
5: 486, | |
6: 480, | |
7: 475 | |
} | |
def main(): | |
st.title("Dyeing Machine Temperature Overshoot Calculator") | |
# Step 1: User Inputs | |
num_machines = st.number_input("Enter the number of machines:", min_value=1, step=1) | |
machine_type = st.selectbox("Select Dyeing Machine Type:", ["SoftFlow", "Yarn Dyeing", "Jet Dyeing"]) # Modify as needed | |
# Step 2: Single input for control system (applies to all machines) | |
control_system = st.selectbox( | |
"Select Current Control System:", | |
["ON/OFF Valve", "PID Control Valve", "Manual"] | |
) | |
# Assign fixed latent heat based on machine type | |
steam = 0 | |
if machine_type == "SoftFlow": | |
enthalpy = LATENT_HEAT_VALUES[6] # 6 Kg/cm²g pressure | |
mlr = 6 | |
elif machine_type == "Yarn Dyeing": | |
enthalpy = LATENT_HEAT_VALUES[7] # 7 Kg/cm²g pressure | |
mlr = 4 | |
elif machine_type == "Jet Dyeing": | |
enthalpy = LATENT_HEAT_VALUES[5] # 5 Kg/cm²g pressure | |
mlr = 10 | |
# Specific heat values | |
specific_heat_water = 1.0 # kcal/kg°C | |
specific_heat_cloth = 0.4 # kcal/kg°C | |
# Step 3: Creating input table dynamically | |
machines_data = [] | |
for i in range(1, num_machines + 1): | |
st.subheader(f"Machine {i}") | |
machine_name = f"{machine_type}_Machine_{i}" | |
quantity = st.number_input(f"{machine_name} - Quantity (kg)", min_value=0.0, step=0.1, key=f"qty_{i}") | |
set_temp = st.number_input(f"{machine_name} - Set Temperature (°C)", min_value=0.0, step=0.1, key=f"set_temp_{i}") | |
actual_temp = st.number_input(f"{machine_name} - Actual Temperature (°C)", min_value=0.0, step=0.1, key=f"act_temp_{i}") | |
overshoot = actual_temp - set_temp | |
q_water = mlr * quantity * specific_heat_water * overshoot | |
q_cloth = quantity * specific_heat_cloth * overshoot | |
steam_consumption = (q_water + q_cloth) / enthalpy | |
steam += steam_consumption | |
machines_data.append({ | |
"Machine Name": machine_name, | |
"Selected Machine Quantity (kg)": quantity, | |
"Set Temperature (°C)": set_temp, | |
"Actual Temperature (°C)": actual_temp, | |
"Overshoot (°C)": overshoot | |
}) | |
# Step 4: Display Data & Calculate Range | |
if machines_data: | |
df = pd.DataFrame(machines_data) | |
st.write("### Machines Data") | |
st.dataframe(df) | |
overshoot_values = df["Overshoot (°C)"].tolist() | |
min_overshoot = min(overshoot_values) if overshoot_values else 0 | |
max_overshoot = max(overshoot_values) if overshoot_values else 0 | |
# Step 5: Recommendation Logic | |
if control_system != "PID Control Valve": | |
recommendation_text = f"- **Recommended:** Use PID Control Valve instead of {control_system} for better control and reduced steam consumption." | |
else: | |
recommendation_text = "**No additional recommendations.**" | |
# Step 6: Editable Text Output | |
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. " | |
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" | |
f"{recommendation_text}" | |
) | |
user_text = st.text_area("Editable Report:", value=default_text, height=200) | |
st.write("### Final Report") | |
st.write(user_text) | |
if __name__ == "__main__": | |
main() | |