File size: 3,755 Bytes
7fd359f
 
 
5fc6466
 
 
 
 
 
7fd359f
 
 
 
 
 
 
5fc6466
 
 
 
 
 
 
 
42898f0
7fd359f
5fc6466
 
 
 
7fd359f
5fc6466
 
7fd359f
5fc6466
 
 
 
 
 
 
 
7fd359f
 
 
5fc6466
7fd359f
 
 
 
 
5fc6466
 
 
 
 
7fd359f
 
 
 
 
 
 
 
5fc6466
7fd359f
 
 
 
 
 
 
 
 
5fc6466
 
 
 
 
 
 
 
 
 
 
 
 
 
7fd359f
 
5fc6466
7fd359f
 
5fc6466
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
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()