Spaces:
Sleeping
Sleeping
import gradio as gr | |
def process_cal(production,f_t): | |
actual_inlet = 40 | |
intial_temp = 40 | |
final_temp = f_t | |
water = 2*production | |
step_time = (final_temp - intial_temp)//2 | |
steam = 6 | |
enthalpy = 494 | |
hot_drain = 0 | |
cold_drain = 0 | |
heat_water = water*1*(final_temp-intial_temp) | |
heat_fabric = production*0.4*(final_temp-intial_temp) | |
heat_radition = 10*10*(final_temp-30)*step_time/60 | |
total_heat = heat_water + heat_fabric + heat_radition | |
steam_consumption = total_heat/enthalpy | |
if final_temp > 60 : | |
hot_drain = water | |
else: | |
cold_drain = water | |
return steam_consumption , cold_drain , hot_drain , water | |
def dark_shade_jet(production): | |
total_water = 0 | |
steam_consumption = 0 | |
hot_drain = 0 | |
cold_drain = 0 | |
dark_shade = {"Desizing":98,"Bleaching":98,"Hot Wash":98,"Room Temp. Wash":60,"Dyeing":98,"Soaping":70,"Hot wash":70,"Cold wash":40} | |
for i in dark_shade : | |
steam,cold,hot,water = process_cal(production,dark_shade[i]) | |
steam_consumption += steam | |
hot_drain += hot | |
cold_drain += cold | |
total_water += water | |
#print(steam,cold,hot,water) | |
steam_consumption = int(steam_consumption) | |
cold_drain = int(cold_drain) | |
hot_drain = int(hot_drain) | |
total_water = cold_drain + hot_drain | |
if production != 0: | |
ssc1 = round(steam_consumption/production,2) | |
swc1 = round(total_water/production,2) | |
else: | |
ssc1 = 0 | |
swc1 = 0 | |
#print(steam,cold,hot,water) | |
return steam_consumption , cold_drain , hot_drain , total_water, ssc1,swc1 | |
def medium_shade_jet(production): | |
total_water = 0 | |
steam_consumption = 0 | |
hot_drain = 0 | |
cold_drain = 0 | |
medium_shade = {"Desizing":98,"Bleaching":98,"Hot Wash":98,"Room Temp. Wash":60,"Dyeing":98,"Hot wash":70,"Cold wash":40} | |
for i in medium_shade : | |
steam,cold,hot,water = process_cal(production,medium_shade[i]) | |
steam_consumption += steam | |
hot_drain += hot | |
cold_drain += cold | |
total_water += water | |
#print(steam,cold,hot,water) | |
steam_consumption = int(steam_consumption) | |
cold_drain = int(cold_drain) | |
hot_drain = int(hot_drain) | |
total_water = cold_drain + hot_drain | |
if production != 0: | |
ssc2 = round(steam_consumption/production,2) | |
swc2 = round(total_water/production,2) | |
else: | |
ssc2 = 0 | |
swc2 = 0 | |
#print(steam,cold,hot,water) | |
return steam_consumption , cold_drain , hot_drain , total_water , ssc2,swc2 | |
def white_shade_jet(production): | |
total_water = 0 | |
steam_consumption = 0 | |
hot_drain = 0 | |
cold_drain = 0 | |
white_shade = {"Desizing":98,"Bleaching":98,"Hot Wash":98,"Room Temp. Wash":60,"Dyeing":98,"Hot wash":70,"Cold wash":40} | |
for i in white_shade : | |
steam,cold,hot,water = process_cal(production,white_shade[i]) | |
steam_consumption += steam | |
hot_drain += hot | |
cold_drain += cold | |
total_water += water | |
#print(steam,cold,hot,water) | |
steam_consumption = int(steam_consumption) | |
cold_drain = int(cold_drain) | |
hot_drain = int(hot_drain) | |
total_water = cold_drain + hot_drain | |
if production != 0: | |
ssc3 = round(steam_consumption/production,2) | |
swc3 = round(total_water/production,2) | |
else: | |
ssc3 = 0 | |
swc3 = 0 | |
#print(steam,cold,hot,water) | |
return steam_consumption , cold_drain , hot_drain , total_water , ssc3,swc3 | |
def light_shade_jet(production): | |
total_water = 0 | |
steam_consumption = 0 | |
hot_drain = 0 | |
cold_drain = 0 | |
light_shade = {"Desizing":98,"Bleaching":98,"Hot Wash":98,"Room Temp. Wash":60,"Dyeing":98,"Hot wash":70,"Cold wash":40} | |
for i in light_shade : | |
steam,cold,hot,water = process_cal(production,light_shade[i]) | |
steam_consumption += steam | |
hot_drain += hot | |
cold_drain += cold | |
total_water += water | |
#print(steam,cold,hot,water) | |
steam_consumption = int(steam_consumption) | |
cold_drain = int(cold_drain) | |
hot_drain = int(hot_drain) | |
total_water = cold_drain + hot_drain | |
if production != 0: | |
ssc4 = round(steam_consumption/production,2) | |
swc4 = round(total_water/production,2) | |
else: | |
ssc4 = 0 | |
swc4 = 0 | |
#print(steam,cold,hot,water) | |
return steam_consumption , cold_drain , hot_drain , total_water,ssc4,swc4 | |
def jigger(value1, value2, value3, value4): | |
s1,c1,h1,t1,ssc1,swc1 = dark_shade_jet(value1) | |
s2,c2,h2,t2,ssc2,swc2 = medium_shade_jet(value2) | |
s3,c3,h3,t3,ssc3,swc3 = white_shade_jet(value3) | |
s4,c4,h4,t4,ssc4,swc4 = light_shade_jet(value4) | |
final_steam = s1+s2+s3+s4 | |
final_cold_drain = c1+c2+c3+c4 | |
final_hot_drain = h1+h2+h3+h4 | |
final_total_drain = t1+t2+t3+t4 | |
total_production = value1 + value2 + value3 + value4 | |
ssc_final = round(final_steam/total_production,2) | |
swc_final = round(final_total_drain/total_production,2) | |
table_html = f""" | |
<table> | |
<tr><th>Shade</th><th>Steam Consumption</th><th>Cold Drain</th><th>Hot Drain</th><th>Total Water</th><th>SSC</th><th>SWC</th></tr> | |
<tr><th>Dark</th><td>{s1}</td><td>{c1}</td><td>{h1}</td><td>{t1}</td><td>{ssc1}</td><td>{swc1}</td></tr> | |
<tr><th>Medium</th><td>{s2}</td><td>{c2}</td><td>{h2}</td><td>{t2}</td><td>{ssc2}</td><td>{swc2}</td></tr> | |
<tr><th>Light</th><td>{s3}</td><td>{c3}</td><td>{h3}</td><td>{t3}</td><td>{ssc3}</td><td>{swc3}</td></tr> | |
<tr><th>White</th><td>{s4}</td><td>{c4}</td><td>{h4}</td><td>{t4}</td><td>{ssc4}</td><td>{swc4}</td></tr> | |
<tr><th>Total</th><td>{final_steam}</td><td>{final_cold_drain}</td><td>{final_hot_drain}</td><td>{final_total_drain}</td><td>{ssc_final}</td><td>{swc_final}</td></tr> | |
</table> | |
""" | |
return table_html | |
iface = gr.Interface( | |
fn=jigger, | |
inputs= [ | |
gr.Number(value=0, label="Dark"), | |
gr.Number(value=0, label="Medium"), | |
gr.Number(value=0, label="Light"), | |
gr.Number(value=0, label="White"), | |
], | |
outputs= gr.components.HTML(label="Final Table"), | |
title ="Steam Consumption, Water, Hot_Drain, Cold_Drain Calculation Dashboard for Jigger", | |
description="Enter values and click 'Calculate' to see the results.<br/><br/>" , | |
css=".gr-box {padding: 20px;}" ) | |
iface.launch() |