Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
|
4 |
+
def calculate_metrics(data):
|
5 |
+
data["CRF"] = round((data["Condensate Return Quantity"] / data["Steam Consumption Quantity"]) * 100, 2)
|
6 |
+
data["SSC"] = round(data["Steam Consumption Quantity"] / data["Production Quantity"], 2)
|
7 |
+
data["SWC"] = round(data["Steam Consumption Quantity"] / data["Production Quantity"], 2)
|
8 |
+
return data
|
9 |
+
|
10 |
+
def calculate_feed_water_temp(cond_temp, cond_qty, tank_size):
|
11 |
+
ambient_temp = 30
|
12 |
+
make_up = tank_size - cond_qty
|
13 |
+
feed_water_temp = round(((cond_qty * cond_temp) + (make_up * ambient_temp)) / tank_size, 2)
|
14 |
+
return feed_water_temp
|
15 |
+
|
16 |
+
def main():
|
17 |
+
st.title("Industrial Utility Dashboard")
|
18 |
+
|
19 |
+
if "report_data" not in st.session_state:
|
20 |
+
st.session_state.report_data = None
|
21 |
+
|
22 |
+
num_sections = st.number_input("Enter number of sections:", min_value=1, step=1)
|
23 |
+
|
24 |
+
section_data = []
|
25 |
+
for i in range(1, num_sections + 1):
|
26 |
+
st.subheader(f"Section {i}")
|
27 |
+
steam_consumption = round(st.number_input(f"Steam Consumption Quantity (Section {i})", min_value=0.0, step=0.1), 2)
|
28 |
+
condensate_return = round(st.number_input(f"Condensate Return Quantity (Section {i})", min_value=0.0, step=0.1), 2)
|
29 |
+
production_quantity = round(st.number_input(f"Production Quantity (Section {i})", min_value=0.0, step=0.1), 2)
|
30 |
+
water_consumption = round(st.number_input(f"Water Consumption Quantity (Section {i})", min_value=0.0, step=0.1), 2)
|
31 |
+
|
32 |
+
section_data.append([f"Section {i}", production_quantity, water_consumption, condensate_return, steam_consumption])
|
33 |
+
|
34 |
+
if st.button("Generate Report"):
|
35 |
+
columns = ["Section", "Production Quantity", "Water Consumption Quantity", "Condensate Return Quantity", "Steam Consumption Quantity"]
|
36 |
+
df = pd.DataFrame(section_data, columns=columns)
|
37 |
+
df = calculate_metrics(df)
|
38 |
+
|
39 |
+
total_row = df.sum(numeric_only=True).round(2)
|
40 |
+
total_row["Section"] = "Total"
|
41 |
+
total_df = pd.DataFrame([total_row])
|
42 |
+
|
43 |
+
total_df["CRF"] = round((total_df["Condensate Return Quantity"] / total_df["Steam Consumption Quantity"]) * 100, 2)
|
44 |
+
total_df["SSC"] = round(total_df["Steam Consumption Quantity"] / total_df["Production Quantity"], 2)
|
45 |
+
total_df["SWC"] = round(total_df["Steam Consumption Quantity"] / total_df["Production Quantity"], 2)
|
46 |
+
|
47 |
+
df = pd.concat([df, total_df], ignore_index=True)
|
48 |
+
st.session_state.report_data = df
|
49 |
+
|
50 |
+
if st.session_state.report_data is not None:
|
51 |
+
st.dataframe(st.session_state.report_data)
|
52 |
+
|
53 |
+
st.subheader("Calculate Feed Water Temperature")
|
54 |
+
cond_temp = st.number_input("Enter Condensate Returning Temperature:", min_value=0.0, step=0.1)
|
55 |
+
cond_qty = st.number_input("Enter Condensate Returning Quantity:", min_value=0.0, step=0.1)
|
56 |
+
tank_size = st.number_input("Enter Feed Water Tank Size:", min_value=0.0, step=0.1)
|
57 |
+
|
58 |
+
if st.button("Calculate Feed Water Temperature"):
|
59 |
+
result = calculate_feed_water_temp(cond_temp, cond_qty, tank_size)
|
60 |
+
st.success(f"Feed Water Temperature: {result:.2f} °C")
|
61 |
+
|
62 |
+
if __name__ == "__main__":
|
63 |
+
main()
|