-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHeatBalance.py
1799 lines (1414 loc) · 111 KB
/
HeatBalance.py
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#Lines 2-18 import the necessary LIBRARIES.
import json
import math
import requests
import numpy as np
import array as arr
import pandas as pd
import seaborn as sns
import scipy.constants
import streamlit as st
from scipy import linalg
from st_aggrid import AgGrid #Library used for creating interactive tables.
import matplotlib.pyplot as plt
from pandas import DataFrame, Series
from streamlit_lottie import st_lottie
from annotated_text import annotated_text, annotation
from streamlit_option_menu import option_menu
import base64
#The base64 libarary helps with the data download for the csv file because it is going to encode the ASCII to byte conversion.
#Declaring the required GLOBAL CONSTANT(s). Line 22.
REFERENCE_TEMPERATURE_NTP = 20
#Lines 26-32 hide the HAMBURGER MENU and the "MADE WITH STREAMLIT FOOTER" footer.
hide_streamlit_style = """
<style>
#MainMenu {visibility: hidden;}
footer {visibility: hidden;}
</style>
"""
st.markdown(hide_streamlit_style, unsafe_allow_html=True)
#FUNCTION for LOTTIE GIF's to be used in the web application. Lines 36-41.
@st.cache(allow_output_mutation=True)
def load_lottieurl(url:str):
r = requests.get(url)
if r.status_code != 200:
return None
return r.json()
#FUNCTION used for generating DOWNLOAD LINKS. Lines 44-51.
def df_to_link(df, title='Download csv', filename='download.csv'):
"""Generates a link allowing the data in a given pandas dataframe to be downloaded.
input: dataframe
output: href string
"""
csv = df.to_csv(index=False)
b64 = base64.b64encode(csv.encode()).decode() # some strings <-> bytes conversions necessary here
return f'<a href="data:file/csv;base64,{b64}" download="{filename}">{title}</a>'
#CLASS containing all the function definitions required for calculating Kiln Surface Radiation. Lines 57-93.
class Kiln():
def __init__(self, diameter, ambient_velocity, ambient_temp, temp_unit, emissivity, interval, df):
self.diameter = diameter # meter
self.ambient_velocity = ambient_velocity # m/s
self.ambient_temp = ambient_air_temperature + 273
self.emissivity = emissivity
self.interval = interval # meter
self.section_area = math.pi * diameter * interval
columns_count = len(df.columns)
rows_count = len(df.index)
self.length = interval * rows_count
#To AUTO-GENERATE names for the columns in input excel (dfKilnRadTemps in this case).
df.columns = [f'Input {i}' for i in range(1, columns_count+1)]
#Compute average of temperatures in input columns.
average = df[list(df.columns)].sum(axis=1)/columns_count
df['Temp'] = average if temp_unit=='Kelvin' else average + 273
#AUTO-GENERATE lengths at which readings were taken based on the interval and the number of readings.
length = [i for i in range(interval, self.length+1, interval)]
df.insert(0, 'Length', length)
self.df = df # Pandas DF with temp readings in Kelvin.
def radiation(self, tempcol='Temp'):
"""Calculate radiation heat loss (kcal/hr) from each section of kiln"""
return self.emissivity * self.section_area * scipy.constants.Stefan_Boltzmann * (self.df[tempcol]**4 - self.ambient_temp**4)
def convection(self, tempcol='Temp'):
""" Calculate convection heat loss (kcal/hr) from each section of kiln """
if self.ambient_velocity < 3:
#Natural Convection.
return 80.33 * (((self.df[tempcol] + self.ambient_temp)/2)**-0.724 * (self.df[tempcol] - self.ambient_temp)**1.333) * self.section_area
else:
#Forced Convection.
return 28.03 * (self.df[tempcol] * self.ambient_temp)**-0.351 * self.ambient_velocity**0.805 * self.diameter**-0.195 * (self.df[tempcol] - self.ambient_temp) * self.section_area
#SIDEBAR. Lines 99-126.
with st.sidebar:
url1 = "https://assets7.lottiefiles.com/packages/lf20_b2lc5tdx.json"
res1_json = load_lottieurl(url1) #Bootstrap icons used for navigation bar.
st_lottie(res1_json)
options = option_menu("Navigation", ["Introduction", "User Notes", "Average Values", "Split DataFrames", "Fan Flows", "Cooler Fans", "Blowers/PA Fans", "Cooler Heat Balance", "Kiln Radiation", "Kiln Heat Balance", "Dashboard Reset"],
icons=["info-circle-fill", "journal-check", "calculator-fill", "bar-chart-fill", "fan", "wind", "layout-three-columns", "cloud-snow", "radioactive", "bricks", "yin-yang"],
menu_icon="cast", default_index=0,
styles={
"container": {"padding": "5!important", "background-color": "#000000"},
"icon": {"color": "cornflowerblue", "font-size": "25px"},
"nav-link": {"font-size": "16px", "text-align": "left", "margin":"0px", "--hover-color": "#0FDECE"},
"nav-link-selected": {"background-color": "#1B9B91"},
}
)
#orientation = "horizontal")
st.sidebar.write("***")
st.sidebar.title('Excel Uploads')
input_excel = st.sidebar.file_uploader('Upload the Dynamic Pressures and Velocities Sheet.', type=['xls','xlsx','xlsm','xlsb','odf'])
input_excel_kilnsurftemps = st.sidebar.file_uploader('Upload the Kiln Surface Temperatures.', type=['xls', 'xlsx', 'xlsm', 'xlsb', 'odf'])
with st.sidebar:
url2 = "https://assets9.lottiefiles.com/packages/lf20_jkdsmf9r.json"
res2_json = load_lottieurl(url2)
st_lottie(res2_json)
st.sidebar.write("***")
st.sidebar.title('Video')
st.sidebar.info("For a demo of the Web Application, you may refer to the following video:")
st.sidebar.markdown("[Web Application Demo](https://youtu.be/eM6Qcjr2sUs)")
st.sidebar.write("***")
#Code for the "INTRODUCTION" section. Lines 132-167.
if(options == 'Introduction'):
col1i, col2i = st.columns( [0.8, 0.2])
with col1i: # To display the header text using css style
st.markdown(""" <style> .font {
font-size:35px ; font-family: 'Cooper Black'; color: #1BA6C4;}
</style> """, unsafe_allow_html=True)
st.markdown('<p class="font">PYRO HEAT BALANCE WEB APPLICATION</p>', unsafe_allow_html=True)
st.markdown("""
Well, Hello there! This software is all you need for establishing the Heat Balance of Pyro systems in cement plants.
""")
#To display the animation via LOTTIE Library.
url3 = "https://assets8.lottiefiles.com/packages/lf20_DVSwGQ.json"
res3_json = load_lottieurl(url3)
st_lottie(res3_json)
col3i, col4i = st.columns( [0.8, 0.2])
with col3i:
st.markdown(""" <style> .font {
font-size:35px ; font-family: 'Cooper Black'; color: #1BA6C4;}
</style> """, unsafe_allow_html=True)
st.markdown('<p class="font">LETS GET STARTED</p>', unsafe_allow_html=True)
with col4i:
url4 = "https://assets5.lottiefiles.com/packages/lf20_cm4iroai.json"
res4_json = load_lottieurl(url4)
st_lottie(res4_json)
annotated_text(
"Click on the ",
(" 'USER NOTES' ", "", "#14BF9A"),
"checkbox under",
(" 'NAVIGATION' ", "", "#14BF9A"),
"to see how to use this app and what features are available."
)
#Code for the "USER NOTES" section. Lines 170-238.
elif(options == 'User Notes'):
st.title("NOTES")
url5 = "https://assets2.lottiefiles.com/packages/lf20_kzfwp1ef.json" #Code to display the NOTES GIF from Lottie Library.
res5_json = load_lottieurl(url5)
st_lottie(res5_json)
st.write("""
Let's walk you through the web application!
1. The first thing you need to get familiar with is the **'NAVIGATION'** section in the sidebar to your left. You have already seen the **'INTRODUCTION'** of the web app and right now you are in the **'USER NOTES'** section. By clicking on the respective checkboxes the relevant results will be displayed. For eg: the next option is that of **'AVERAGE VALUES'**. Here you can download the excel sheet with the average values (columnwise) of your data.
2. Now, of course you might be wondering where to upload your file. Go to the **'EXCEL UPLOADS'** section in the sidebar. There you can see two boxes. One is for the **'Dynamic Pressures and Velocities Sheet'** and the other for the **'Kiln Surface Temperatures'**. Click on respective **'BROWSE FILES'** button and upload your excel. You are now all set to go (or maybe not...),
3. In the excel file that you are going to upload (for the 'Dynamic Pressures and Velocities'), make sure that the data is in the order as given below (columnwise).
**Dynamic Pressure** Values of:
* Preheater Downcomer Ducts
* Tertiary Air Ducts
* Cooler Mid Air Ducts
* Cooler Vent Air Ducts
* ESP Stack Duct
then the **Velocities** of:
* Cooler Fans
and finally the **Dynamic Pressure** Values of,
* Kiln Blowers
* Calciner Blowers
* PA Fans
""")
st.write("If you have any doubt, you may click on the **'EXCEL FILE EXAMPLE'** link to see how your input excel should look like.")
st.markdown("[EXCEL FILE EXAMPLE](https://drive.google.com/file/d/1CNGLBLcFnylBkYjmMGMORRFZBh01sH5i/view?usp=sharing)") #Pic showing a sample "INPUT EXCEL SHEET".
st.write("If you want, then you can fill in the information in the **'GENERAL INFORMATION ABOUT YOUR DATA'** section. A template excel will be automatically generated. You can fill up the generated excel sheet and upload it here for further use.")
st.write("""
4. Whereas, for the other excel file (containing the 'Kiln Surface Temperatures') you are going to upload, keep in mind the following details:
* The first meter starts from the kiln outlet side.
* "Interval" is the distance between consecutive temperature readings. For example, when surface temperature was measured every 3 meters, the interval would be 3.
* Multiple temperature readings can be provided at each point by putting them in separate excel columns. In such a case, the **average** of the readings will be automatically computed.
* Fill the columns in the Input Excel starting from column A and use columns B,C,D,... as required. Columns should contain only the temperature readings in numbers and nothing else, not even column headers!
""")
st.write("***")
st.write("""
5. The reference temperature (NTP) considered for the calculations is **20 degree celsius**.
6. You can always use the **'DASHBOARD RESET'** button to unclutter the dashboard and work only with the input columns. It will not reset your data to the default values in the input columns though. Go ahead... give it a shot! If you want to come back here, then you know what to do. A few more tips and you are good to go.
7. Next, what are the input columns? Scroll down below where you can see the **'GENERAL INFORMATION ABOUT YOUR DATA'** section. Before you download any of the excel sheets or view any of the dataframes, make sure to fill in the right information. Below that you will be able to see the **'FAN FLOWS'**, **'COOLER FANS'**, **'COOLER HB'**, **'BLOWERS/PA FANS'** and **'KILN HB'** columns. You can enter data in these expanders by clicking on them.
Finally if you want to see the Python Libraries used for creating this web app, then select 'YES' below (in the dropdown).
""")
libraries = st.selectbox(
'Would you like to see the Python Libraries used to make this app?',
('No', 'Yes'))
if (libraries == 'Yes'):
st.write("1. streamlit")
st.write("2. base64")
st.write("3. json")
st.write("4. requests")
st.write("5. numpy")
st.write("6. array")
st.write("7. pandas")
st.write("8. math")
st.write("9. scipy")
st.write("10. streamlit-aggrid")
st.write("11. streamlit-lottie")
st.write("12. annotated_text")
st.write("13. streamlit-option-menu")
st.write("14. matplotlib")
st.write("You are all set to use this app now. If you have any doubt regarding the functionalities of the web application, then you may watch the demo. The link for it has been provided at the bottom of the sidebar.")
st.write("Now go ahead and upload your excel files!!!")
url6 = "https://assets2.lottiefiles.com/packages/lf20_4m0f2coq.json" #"BLUE LINE" animation from Lottie. To separate the 2 sections.
res6_json = load_lottieurl(url6)
st_lottie(res6_json)
#EXPANDER to input the GENERAL INFORMATION required for further computation. Lines 230-257.
st.header("GENERAL INFORMATION ABOUT YOUR DATA")
with st.expander("GENERAL INFO"):
number_of_preheater_downcomer_ducts = st.number_input('How many Preheater Downcomer Ducts are to be considered?', 1, 3, 3, 1)
number_of_tertiaryair_ducts = st.number_input('How many Tertiary Air Ducts are to be considered?', 0, 2, 2, 1)
number_of_coolermidair = st.number_input('How many Cooler Mid Air Ducts are to be considered?', 0, 2, 2, 1)
number_of_cooler_ventair_ducts = st.number_input('How many Cooler Vent Air Ducts are to be considered?', 0, 1, 1, 1)
st.write('<style>div.row-widget.stRadio > div{flex-direction:row;}</style>', unsafe_allow_html = True)
backcalcordirectorindirect = st.radio(
"How do you want to calculate the CVA flow?",
('Direct', 'Back Calculate', 'Indirect (ESP Stack Flow - MidAir Flow)'))
number_of_cooler_fans = st.number_input('How many Cooler Fans are to be considered?', 0, 15, 7, 1)
number_of_kiln_blowers = st.number_input('How many Kiln Blowers are to be considered?', 1, 2, 1, 1)
number_of_calciner_blowers = st.number_input('How many Calciner Blowers are to be considered?', 0, 2, 1, 1)
number_of_PA_fans = st.number_input('How many PA Fans are to be considered?', 1, 2, 1, 1)
mean_sea_level = st.number_input('Mean Sea Level (in Meters):', 0.000, 1000.000, 432.000, 10.000, format = "%.3f")
datum_pressure = 10336*(math.e)**(-0.0001255*mean_sea_level)
st.write('The datum pressure is:')
st.write(datum_pressure)
ambient_air_temperature = st.number_input('Ambient Air Temperature (in Celsius):', 0.00, 2000.00, 30.00, 10.00)
cooler_air_density = st.number_input('Enter the Cooler Air Density:', 0.000, 5.000, 1.293, 0.001, format="%.3f")
kilnfeed_factor = st.number_input('Enter the Kiln Feed Factor:', 0.000, 5.000, 1.615, 0.001, format="%.3f")
kilnfeed = st.number_input('Enter the Kiln Feed (tph):', 0.00, 2000.00, 689.00, 10.00)
clinker_capacity = kilnfeed/kilnfeed_factor
st.write("The Clinker Capacity is (tph):")
st.write(clinker_capacity)
st.write("The Clinker Capacity is (tpd):")
st.write(clinker_capacity*24)
st.write("***")
#Code for the template excel that will be generated via link. Lines 262-295.
dftemplatePH = pd.DataFrame(columns = range(1, int(number_of_preheater_downcomer_ducts)+1))
dftemplatePH.columns = ['PH' + str(i+1) for i in range (int(number_of_preheater_downcomer_ducts))]
dftemplateTAD = pd.DataFrame(columns = range(1, int(number_of_tertiaryair_ducts)+1))
dftemplateTAD.columns = ['TAD' + str(i+1) for i in range (int(number_of_tertiaryair_ducts))]
dftemplateCMA = pd.DataFrame(columns = range(1, int(number_of_coolermidair)+1))
dftemplateCMA.columns = ['CMA' + str(i+1) for i in range (int(number_of_coolermidair))]
if ( (number_of_cooler_ventair_ducts > 0 and backcalcordirectorindirect == 'Direct') ):
dftemplateCVA = pd.DataFrame(columns = range(1, int(number_of_cooler_ventair_ducts)+1))
dftemplateCVA.columns = ['CVA' + str(i+1) for i in range (int(number_of_cooler_ventair_ducts))]
elif ( (number_of_cooler_ventair_ducts > 0 and backcalcordirectorindirect == 'Back Calculate') or (number_of_cooler_ventair_ducts == 0) or (number_of_cooler_ventair_ducts > 0 and backcalcordirectorindirect == 'Indirect (ESP Stack Flow - MidAir Flow)') ):
dftemplateCVA = pd.DataFrame(columns = range(1,1))
dftemplateESP = pd.DataFrame(columns = range(1, 2))
dftemplateESP.columns = ['ESP Stack']
dftemplateCF = pd.DataFrame(columns = range(1, int(number_of_cooler_fans)+1))
dftemplateCF.columns = ['Cooler Fan' + str(i+1) for i in range (int(number_of_cooler_fans))]
dftemplateKB = pd.DataFrame(columns = range(1, int(number_of_kiln_blowers)+1))
dftemplateKB.columns = ['Kiln Blower' + str(i+1) for i in range (int(number_of_kiln_blowers))]
dftemplateCB = pd.DataFrame(columns = range(1, int(number_of_calciner_blowers)+1))
dftemplateCB.columns = ['Calciner Blower' + str(i+1) for i in range (int(number_of_calciner_blowers))]
dftemplatePA = pd.DataFrame(columns = range(1, int(number_of_PA_fans)+1))
dftemplatePA.columns = ['PA Fan' + str(i+1) for i in range (int(number_of_PA_fans))]
dftemplate = pd.concat([dftemplatePH, dftemplateTAD, dftemplateCMA, dftemplateCVA, dftemplateESP, dftemplateCF, dftemplateKB, dftemplateCB, dftemplatePA] , axis = 1)
download_link = df_to_link(dftemplate, title='Template for Dp Values and Velocities', filename='Template.csv')
st.markdown(download_link, unsafe_allow_html=True)
st.write("***")
#Lines 300-303 take care of the first output of the program, that is the appended excel with average values (columnwise).
if input_excel is not None:
dfinputexcel = pd.read_excel(input_excel)
dfmeanexcel = dfinputexcel.mean(axis = 0) #dfmeanexcel variable stores the average values of the input excel columns in a dataframe.
dfappendedoriginalandaverages = dfinputexcel.append(dfmeanexcel, ignore_index=True) #Original+Average Values Sheet (appended).
#Splitting the original dataframe for further usage. Did the splitting using .T feature for transpose and the iloc function for accessing specific rows. Lines 308-356.
dfinputexceltranspose = dfinputexcel.T
#Variable holding the transposed data of preheater downcomer ducts columns.
dfpreheater_downcomerducts_rowsintransposedframe = dfinputexceltranspose.iloc[0:int(number_of_preheater_downcomer_ducts)]
dfpreheatercolumns = dfpreheater_downcomerducts_rowsintransposedframe.T
df_tertiary_airducts_rowsintransposedframe = dfinputexceltranspose.iloc[int(number_of_preheater_downcomer_ducts):int(number_of_tertiaryair_ducts+number_of_preheater_downcomer_ducts)]
dfTADcolumns = df_tertiary_airducts_rowsintransposedframe.T
df_cooler_midairs_rowsintransposedframe = dfinputexceltranspose.iloc[int(number_of_preheater_downcomer_ducts+number_of_tertiaryair_ducts):int(number_of_tertiaryair_ducts+number_of_preheater_downcomer_ducts+number_of_coolermidair)]
dfCMAcolumns = df_cooler_midairs_rowsintransposedframe.T
if (backcalcordirectorindirect == 'Direct'):
df_cooler_ventair_rowsintransposedframe = dfinputexceltranspose.iloc[int(number_of_tertiaryair_ducts+number_of_preheater_downcomer_ducts+number_of_coolermidair):int(number_of_tertiaryair_ducts+number_of_preheater_downcomer_ducts+number_of_coolermidair+number_of_cooler_ventair_ducts)]
dfCVAcolumns = df_cooler_ventair_rowsintransposedframe.T
df_cooler_ESPstack_rowsintransposedframe = dfinputexceltranspose.iloc[int(number_of_tertiaryair_ducts+number_of_preheater_downcomer_ducts+number_of_coolermidair+number_of_cooler_ventair_ducts):int(number_of_tertiaryair_ducts+number_of_preheater_downcomer_ducts+number_of_coolermidair+number_of_cooler_ventair_ducts+1)]
dfESPcolumns = df_cooler_ESPstack_rowsintransposedframe.T
df_cooler_coolerfans_rowsintransposedframe = dfinputexceltranspose.iloc[int(number_of_tertiaryair_ducts+number_of_preheater_downcomer_ducts+number_of_coolermidair+number_of_cooler_ventair_ducts+1):int(number_of_tertiaryair_ducts+number_of_preheater_downcomer_ducts+number_of_coolermidair+number_of_cooler_ventair_ducts+number_of_cooler_fans+1)]
dfcoolerfancolumns = df_cooler_coolerfans_rowsintransposedframe.T
df_cooler_kilnblowersintransposedframe = dfinputexceltranspose.iloc[int(number_of_tertiaryair_ducts+number_of_preheater_downcomer_ducts+number_of_coolermidair+number_of_cooler_ventair_ducts+number_of_cooler_fans+1):int(number_of_tertiaryair_ducts+number_of_preheater_downcomer_ducts+number_of_coolermidair+number_of_cooler_ventair_ducts+number_of_cooler_fans+1+number_of_kiln_blowers)]
dfkilnblowerscolumns = df_cooler_kilnblowersintransposedframe.T
df_cooler_calcinerblowersintransposedframe = dfinputexceltranspose.iloc[int(number_of_tertiaryair_ducts+number_of_preheater_downcomer_ducts+number_of_coolermidair+number_of_cooler_ventair_ducts+number_of_cooler_fans+1+number_of_kiln_blowers):int(number_of_tertiaryair_ducts+number_of_preheater_downcomer_ducts+number_of_coolermidair+number_of_cooler_ventair_ducts+number_of_cooler_fans+1+number_of_kiln_blowers+number_of_calciner_blowers)]
dfcalcinerblowerscolumns = df_cooler_calcinerblowersintransposedframe.T
df_cooler_PAfansintransposedframe = dfinputexceltranspose.iloc[int(number_of_tertiaryair_ducts+number_of_preheater_downcomer_ducts+number_of_coolermidair+number_of_cooler_ventair_ducts+number_of_cooler_fans+1+number_of_kiln_blowers+number_of_calciner_blowers):int(number_of_tertiaryair_ducts+number_of_preheater_downcomer_ducts+number_of_coolermidair+number_of_cooler_ventair_ducts+number_of_cooler_fans+1+number_of_kiln_blowers+number_of_calciner_blowers+number_of_PA_fans)]
dfPAfanscolumns = df_cooler_PAfansintransposedframe.T
elif (backcalcordirectorindirect == 'Back Calculate' or backcalcordirectorindirect == 'Indirect (ESP Stack Flow - MidAir Flow)'):
df_cooler_ventair_rowsintransposedframe = dfinputexceltranspose.iloc[int(number_of_tertiaryair_ducts+number_of_preheater_downcomer_ducts+number_of_coolermidair):int(number_of_tertiaryair_ducts+number_of_preheater_downcomer_ducts+number_of_coolermidair)]
dfCVAcolumns = df_cooler_ventair_rowsintransposedframe.T
df_cooler_ESPstack_rowsintransposedframe = dfinputexceltranspose.iloc[int(number_of_tertiaryair_ducts+number_of_preheater_downcomer_ducts+number_of_coolermidair):int(number_of_tertiaryair_ducts+number_of_preheater_downcomer_ducts+number_of_coolermidair+1)]
dfESPcolumns = df_cooler_ESPstack_rowsintransposedframe.T
df_cooler_coolerfans_rowsintransposedframe = dfinputexceltranspose.iloc[int(number_of_tertiaryair_ducts+number_of_preheater_downcomer_ducts+number_of_coolermidair+1):int(number_of_tertiaryair_ducts+number_of_preheater_downcomer_ducts+number_of_coolermidair+1+number_of_cooler_fans)]
dfcoolerfancolumns = df_cooler_coolerfans_rowsintransposedframe.T
df_cooler_kilnblowersintransposedframe = dfinputexceltranspose.iloc[int(number_of_tertiaryair_ducts+number_of_preheater_downcomer_ducts+number_of_coolermidair+number_of_cooler_fans+1):int(number_of_tertiaryair_ducts+number_of_preheater_downcomer_ducts+number_of_coolermidair+number_of_cooler_fans+1+number_of_kiln_blowers)]
dfkilnblowerscolumns = df_cooler_kilnblowersintransposedframe.T
df_cooler_calcinerblowersintransposedframe = dfinputexceltranspose.iloc[int(number_of_tertiaryair_ducts+number_of_preheater_downcomer_ducts+number_of_coolermidair+number_of_cooler_fans+1+number_of_kiln_blowers):int(number_of_tertiaryair_ducts+number_of_preheater_downcomer_ducts+number_of_coolermidair+number_of_cooler_fans+1+number_of_kiln_blowers+number_of_calciner_blowers)]
dfcalcinerblowerscolumns = df_cooler_calcinerblowersintransposedframe.T
df_cooler_PAfansintransposedframe = dfinputexceltranspose.iloc[int(number_of_tertiaryair_ducts+number_of_preheater_downcomer_ducts+number_of_coolermidair+number_of_cooler_fans+1+number_of_kiln_blowers+number_of_calciner_blowers):int(number_of_tertiaryair_ducts+number_of_preheater_downcomer_ducts+number_of_coolermidair+number_of_cooler_fans+1+number_of_kiln_blowers+number_of_calciner_blowers+number_of_PA_fans)]
dfPAfanscolumns = df_cooler_PAfansintransposedframe.T
#Code for the COLUMNS OF THE DASHBOARD (excluding the CONTAINER). Lines 362-984.
col1, col2, col3 = st.columns(3)
#Code for COLUMN 1, taking care of the FAN FLOWS. Lines 366-746 as of now.
with col1:
st.header("FAN FLOWS")
CountColumn1Expander1PH = 1
CountColumn1Expander1TAD = 1
CountColumn1Expander1CoolerMidair = 1
np.arraypreheaterdowncomerductstemperatures = [] #Array to store the temperatures of preheater downcomer ducts.
np.arrayTADtemperatures = [] #Array to store the temperatures of TAD's. (Tertiary Air Ducts).
np.arrayCoolerMidAirtemperatures = [] #Array to store the temperatures of Cooler Mid Air Ducts.
CountColumn1Expander2PH = 1
CountColumn1Expander2TAD = 1
CountColumn1Expander2CoolerMidair = 1
np.arraypreheaterdowncomerductsdiameters = [] #Array to store the diameters of preheater downcomer ducts.
np.arrayTADdiameters = [] #Array to store the diameters of TAD's. (Tertiary Air Ducts).
np.arrayCoolerMidAirdiameters = [] #Array to store the diameters of Cooler Mid Air Ducts.
#CMA: Cooler Mid Air, TAD: Tertiary Air Duct.
CountColumn1Expander3PH = 1
CountColumn1Expander3TAD = 1
CountColumn1Expander3CoolerMidair = 1
np.arraypreheaterdowncomerductsstaticpressures = [] #Array to store the static pressures of preheater downcomer ducts.
np.arrayTADstaticpressures = [] #Array to store the static pressures of TAD's. (Tertiary Air Ducts).
np.arrayCoolerMidAirstaticpressures = [] #Array to store the static pressures of Cooler Mid Air Ducts.
CountColumn1Expander4PH = 1
np.arraypreheaterdowncomerductsO2 = []
np.arraypreheaterdowncomerductsCO2 = []
np.arraypreheaterdowncomerductsCO = []
np.arraypreheaterdowncomerductsH2O = []
np.arraydensitiesPH = []
CountColumn1Expander5PH = 1
CountColumn1Expander5TAD = 1
CountColumn1Expander5CoolerMidair = 1
np.arraypreheaterdowncomerductspitotconstants = [] #Array to store the pitot constants of preheater downcomer ducts.
np.arrayTADpitotconstants = [] #Array to store the pitot constants of TAD's. (Tertiary Air Ducts).
np.arrayCoolerMidAirpitotconstants = [] #Array to store the pitot constants of Cooler Mid Air Ducts.
CountColumn1Expander6PH = 1
np.arraypreheaterdowncomerductspower = []
CountColumn1Expander7PH = 1
np.arraypreheaterdowncomerductsfanoutletpressure = []
with st.expander("TEMPERATURES"): #EXPANDER 1 for TEMPERATURES.
st.write("Enter the temperatures in **celsius**:")
cooler_ESPstack_temperature = st.number_input("Temperature of the Cooler ESP Stack:", 0.00, 1000.00, 151.00, 1.00)
while (CountColumn1Expander1PH <= number_of_preheater_downcomer_ducts):
temperaturePH = st.number_input('Temperature of Preheater Downcomer Duct %d:' %CountColumn1Expander1PH, 0.00, 1000.00, 264.00, 1.00, key = CountColumn1Expander1PH)
np.arraypreheaterdowncomerductstemperatures.append(temperaturePH)
CountColumn1Expander1PH += 1
while ( (CountColumn1Expander1TAD <= number_of_tertiaryair_ducts) and (number_of_tertiaryair_ducts > 0) ):
temperatureTAD = st.number_input('Temperature of Tertiary Air Duct %d:' %CountColumn1Expander1TAD, 0.00, 1000.00, 912.00, 1.00, key = CountColumn1Expander1TAD)
np.arrayTADtemperatures.append(temperatureTAD)
CountColumn1Expander1TAD += 1
while ( (CountColumn1Expander1CoolerMidair <= number_of_coolermidair) and (number_of_coolermidair > 0) ):
temperatureCMA = st.number_input('Temperature of Cooler Mid Air Duct %d:' %CountColumn1Expander1CoolerMidair, 0.00, 1000.00, 161.50, 1.00, key = CountColumn1Expander1CoolerMidair)
np.arrayCoolerMidAirtemperatures.append(temperatureCMA)
CountColumn1Expander1CoolerMidair += 1
if ( (backcalcordirectorindirect == 'Direct' and number_of_cooler_ventair_ducts > 0) or (backcalcordirectorindirect == 'Indirect (ESP Stack Flow - MidAir Flow)' and number_of_cooler_ventair_ducts > 0) ):
tempCVAdirect = st.number_input("Temperature of Cooler Vent Air:", 0.00, 1000.00, 320.0, 1.00)
with st.expander("DIAMETERS"): #EXPANDER 2 for DIAMETERS.
st.write("Enter the diameters in **meters (m)**:")
cooler_ESPstack_diameter = st.number_input("Diameter of the Cooler ESP Stack:", 0.00, 100.00, 6.00, 1.0)
while (CountColumn1Expander2PH <= number_of_preheater_downcomer_ducts):
diameterPH = st.number_input('Diameter of Preheater Downcomer Duct %d:' %CountColumn1Expander2PH, 0.00, 20.00, 3.55, 0.10, key = CountColumn1Expander2PH)
np.arraypreheaterdowncomerductsdiameters.append(diameterPH)
CountColumn1Expander2PH += 1
while ( (CountColumn1Expander2TAD <= number_of_tertiaryair_ducts) and (number_of_tertiaryair_ducts > 0) ):
diameterTAD = st.number_input('Diameter of Tertiary Air Duct %d:' %CountColumn1Expander2TAD, 0.00, 20.00, 2.50, 0.10, key = CountColumn1Expander2TAD)
np.arrayTADdiameters.append(diameterTAD)
CountColumn1Expander2TAD += 1
while ( (CountColumn1Expander2CoolerMidair <= number_of_coolermidair) and (number_of_coolermidair > 0) ):
diameterCMA = st.number_input('Diameter of Cooler Mid Air Duct %d:' %CountColumn1Expander2CoolerMidair, 0.00, 20.00, 3.20, 0.10, key = CountColumn1Expander2CoolerMidair)
np.arrayCoolerMidAirdiameters.append(diameterCMA)
CountColumn1Expander2CoolerMidair += 1
if ( (backcalcordirectorindirect == 'Direct' and number_of_cooler_ventair_ducts > 0) or (backcalcordirectorindirect == 'Indirect (ESP Stack Flow - MidAir Flow)' and number_of_cooler_ventair_ducts > 0) ):
diamCVAdirect = st.number_input("Diameter of Cooler Vent Air:", 0.00, 20.00, 1.50, 0.01)
with st.expander("STATIC PRESSURES"): #EXPANDER 3 for STATIC PRESSURES.
st.write("Just enter the **magnitude** of the static pressures in **Millimeters of Water Gauge (mmWg)**:")
cooler_ESPstack_staticpressure = st.number_input("Enter the Static Pressure of the Cooler ESP Stack:", 0.00, 1000.00, 146.00, 1.00)
while (CountColumn1Expander3PH <= number_of_preheater_downcomer_ducts):
staticpressurePH = st.number_input('Static Pressure of Preheater Downcomer Duct %d:' %CountColumn1Expander3PH, 0.00, 2000.00, 835.00, 10.00, key = CountColumn1Expander3PH)
np.arraypreheaterdowncomerductsstaticpressures.append(-staticpressurePH)
CountColumn1Expander3PH += 1
while ( (CountColumn1Expander3TAD <= number_of_tertiaryair_ducts) and (number_of_tertiaryair_ducts > 0) ):
staticpressureTAD = st.number_input('Static Pressure of Tertiary Air Duct %d:' %CountColumn1Expander3TAD, 0.00, 2000.00, 25.00, 10.00, key = CountColumn1Expander3TAD)
np.arrayTADstaticpressures.append(-staticpressureTAD)
CountColumn1Expander3TAD += 1
while ( (CountColumn1Expander3CoolerMidair <= number_of_coolermidair) and (number_of_coolermidair > 0) ):
staticpressureCMA = st.number_input('Static Pressure of Cooler Mid Air Duct %d:' %CountColumn1Expander3CoolerMidair, 0.00, 2000.00, 100.00, 10.00, key = CountColumn1Expander3CoolerMidair)
np.arrayCoolerMidAirstaticpressures.append(-staticpressureCMA)
CountColumn1Expander3CoolerMidair += 1
if ( (backcalcordirectorindirect == 'Direct' and number_of_cooler_ventair_ducts > 0) or (backcalcordirectorindirect == 'Indirect (ESP Stack Flow - MidAir Flow)' and number_of_cooler_ventair_ducts > 0) ):
staticpressureCVAdirect = st.number_input("Static Pressure of Cooler Vent Air:", 0.00, 2000.00, 100.00, 10.00)
with st.expander("DENSITY CALCULATIONS"): #EXPANDER 4 for DENSITY CALCULATIONS.
st.write("In order to calculate the density of the Pre-Heater Downcomer Ducts, answer the following questions: in (%)")
st.write("(**Enter 0** in the H20 Column if you are **not** considering water vapor).")
while( CountColumn1Expander4PH <= number_of_preheater_downcomer_ducts):
PHO2 = st.number_input('Oxygen (O2) measurement in Pre Heater Downcomer Duct %d:' %CountColumn1Expander4PH, 0.00, 100.00, 1.12, 0.10, key = CountColumn1Expander4PH)
np.arraypreheaterdowncomerductsO2.append(PHO2)
PHCO2 = st.number_input('Carbon dioxide (CO2) measurement in Pre Heater Downcomer Duct %d:' %CountColumn1Expander4PH, 0.00, 100.00, 28.5, 0.10, key = CountColumn1Expander4PH)
np.arraypreheaterdowncomerductsCO2.append(PHCO2)
PHCO = st.number_input('Carbon monoxide (CO) measurement in Pre Heater Downcomer Duct %d:' %CountColumn1Expander4PH, 0.000, 100.00, 0.134, 0.10, format="%.3f", key = CountColumn1Expander4PH)
np.arraypreheaterdowncomerductsCO.append(PHCO)
PHH2O = st.number_input('Water (H2O) measurement in Pre Heater Downcomer Duct %d:' %CountColumn1Expander4PH, 0.000, 100.00, 0.00, 0.10, key = CountColumn1Expander4PH)
np.arraypreheaterdowncomerductsH2O.append(PHH2O)
CountColumn1Expander4PH += 1
dfPHO2 = pd.DataFrame(np.arraypreheaterdowncomerductsO2, columns = ['O2'])
dfPHCO2 = pd.DataFrame(np.arraypreheaterdowncomerductsCO2, columns = ['CO2'])
dfPHCO = pd.DataFrame(np.arraypreheaterdowncomerductsCO, columns = ['CO'])
dfPHH2O = pd.DataFrame(np.arraypreheaterdowncomerductsH2O, columns = ['H2O'])
dfdensitydata = pd.concat([dfPHO2, dfPHCO2, dfPHCO, dfPHH2O], axis = 1)
dfdensitydata['Density'] = (32*dfdensitydata['O2']+44*dfdensitydata['CO2']+18*dfdensitydata['H2O']+28*(100-dfdensitydata['O2']-dfdensitydata['CO2']-dfdensitydata['CO']-dfdensitydata['H2O']))/(2240)
with st.expander("PITOT TUBE CONSTANTS"):
st.write("Answer the following questions:") #EXPANDER 5 for PITOT TUBE CONSTANTS.
cooler_ESPstack_pitottubeconstant = st.number_input('Pitot Tube Constant of Cooler ESP stack:', 0.00, 1.00, 0.81, 0.01)
while (CountColumn1Expander5PH <= number_of_preheater_downcomer_ducts):
pitotconstantPH = st.number_input('Pitot Constant of Preheater Downcomer Duct %d:' %CountColumn1Expander5PH, 0.0000, 1.0000, 0.8467, 0.0001, format="%.4f", key = CountColumn1Expander5PH)
np.arraypreheaterdowncomerductspitotconstants.append(pitotconstantPH)
CountColumn1Expander5PH += 1
while ( (CountColumn1Expander5TAD <= number_of_tertiaryair_ducts) and (number_of_tertiaryair_ducts > 0) ):
pitotconstantTAD = st.number_input('Pitot Constant of Tertiary Air Duct %d:' %CountColumn1Expander5TAD, 0.0000, 1.0000, 0.8100, 0.0001, format="%.4f", key = CountColumn1Expander5TAD)
np.arrayTADpitotconstants.append(pitotconstantTAD)
CountColumn1Expander5TAD += 1
while ( (CountColumn1Expander5CoolerMidair <= number_of_coolermidair) and (number_of_coolermidair > 0) ):
pitotconstantCMA = st.number_input('Pitot Constant of Cooler Mid Air Duct %d:' %CountColumn1Expander5CoolerMidair, 0.0000, 1.0000, 0.8100, 0.0001, format="%.4f", key = CountColumn1Expander5CoolerMidair)
np.arrayCoolerMidAirpitotconstants.append(pitotconstantCMA)
CountColumn1Expander5CoolerMidair += 1
if ( (backcalcordirectorindirect == 'Direct' and number_of_cooler_ventair_ducts > 0) or (backcalcordirectorindirect == 'Indirect (ESP Stack Flow - MidAir Flow)' and number_of_cooler_ventair_ducts > 0) ):
pitottubeconstantCVAdirect = st.number_input("Pitot Tube Constant of Cooler Vent Air:", 0.0000, 1.0000, 0.7950, 0.0001, format ="%.4f")
dfPHpitotconstants = pd.DataFrame(np.arraypreheaterdowncomerductspitotconstants, columns = ['PH Pitot Constants'])
dfTADpitotconstants = pd.DataFrame(np.arrayTADpitotconstants, columns = ['TAD Pitot Constants'])
dfCMApitotconstants = pd.DataFrame(np.arrayCoolerMidAirpitotconstants, columns = ['CMA Pitot Constants'])
dfpitotconstantsdata = pd.concat([dfPHpitotconstants, dfTADpitotconstants, dfCMApitotconstants], axis = 1)
with st.expander("POWER"): #EXPANDER 6 for POWER.
st.write("Enter the Power in **Kilowatts (kW)**:")
cooler_ESPstack_power = st.number_input("Power of the Cooler ESP Stack:", 0.00, 10000.00, 104.00, 10.00)
while (CountColumn1Expander6PH <= number_of_preheater_downcomer_ducts):
powerPH = st.number_input('Power of Preheater Downcomer Duct %d:' %CountColumn1Expander6PH, 0.00, 10000.00, 1906.00, 10.00, key = CountColumn1Expander6PH)
np.arraypreheaterdowncomerductspower.append(powerPH)
CountColumn1Expander6PH += 1
dfPHpower = pd.DataFrame(np.arraypreheaterdowncomerductspower, columns = ['PH Power'])
with st.expander("FAN OUTLET PRESSURES"): #EXPANDER 7 for FAN OUTLET PRESSURES.
st.write("Enter the Fan Outlet Pressures:")
cooler_ESPstack_fanoutletpressure = st.number_input("Outlet Pressure of the Cooler ESP Stack:", 0.00, 1000.00, 20.00, 10.00)
positiveornegativeESPoutletpr = st.radio(
"Is the Cooler ESP Outlet Pressure positive or negative?",
('+','-'))
if(positiveornegativeESPoutletpr == '+'):
a = cooler_ESPstack_fanoutletpressure
else:
a = -(cooler_ESPstack_fanoutletpressure)
while (CountColumn1Expander7PH <= number_of_preheater_downcomer_ducts):
fanoutletpressurePH = st.number_input('Outlet Pressure of Preheater Downcomer Duct %d:' %CountColumn1Expander7PH, 0.00, 1000.00, 90.00, 10.00, key = CountColumn1Expander7PH)
positiveornegativePHoutletpr = st.radio(
"Is the Pre Heater Downcomer Duct %d Outlet Pressure positive or negative?" %CountColumn1Expander7PH,
('+','-'), key = CountColumn1Expander7PH)
if(positiveornegativePHoutletpr == '+'):
np.arraypreheaterdowncomerductsfanoutletpressure.append(fanoutletpressurePH)
else:
np.arraypreheaterdowncomerductsfanoutletpressure.append(-fanoutletpressurePH)
CountColumn1Expander7PH += 1
dfPHfanoutletpressure = pd.DataFrame(np.arraypreheaterdowncomerductsfanoutletpressure, columns = ['PH Outlet Pressure'])
st.write('<style>div.row-widget.stRadio > div{flex-direction:row;}</style>', unsafe_allow_html = True)
#Lines 556-583 take care of the ESP sheet and it's required dataframe. And the link for downloading the excel as well.
if input_excel is not None:
i = 1
np.ESPnamesarray = []
while(i <= 1):
(np.ESPnamesarray).append("ESP Stack %d" %i)
i+=1
dfESPnames = pd.DataFrame(np.ESPnamesarray, columns = ['Name'])
dfESPmeansqrt = np.sqrt(dfESPcolumns.mean())
dfESPmean = pd.DataFrame(dfESPmeansqrt, columns = ['Sqrt DP'])
dfESPmean.reset_index(drop=True, inplace=True)
dfESP = pd.concat([dfESPnames, dfESPmean], axis = 1)
dfESP['Temp'] = cooler_ESPstack_temperature
dfESP['Temp K'] = dfESP['Temp']+273
dfESP['Static Pressure'] = -cooler_ESPstack_staticpressure
dfESP['Calculated Pressure'] = datum_pressure+dfESP['Static Pressure']
dfESP['Temp CF'] = (273/10336)*(dfESP['Calculated Pressure']/dfESP['Temp K'])
dfESP['Density'] = (cooler_air_density*273*dfESP['Calculated Pressure'])/(10336*(273+dfESP['Temp']))
dfESP['Diameter'] = cooler_ESPstack_diameter
dfESP['Area'] = ((np.pi)*cooler_ESPstack_diameter**2)/4
dfESP['V'] = cooler_ESPstack_pitottubeconstant*dfESP['Sqrt DP']*(((2*9.81)**0.5)/np.sqrt(dfESP['Density']))
dfESP['Flow m3/s'] = dfESP['V']*dfESP['Area']
dfESP['Flow m3/hr'] = dfESP['Flow m3/s']*3600
dfESP['Nm3/hr'] = (dfESP['Flow m3/hr']*273*(dfESP['Calculated Pressure']))/(10330*(273+dfESP['Temp']))
dfESP['Nm3/kgcl'] = dfESP['Nm3/hr']/(clinker_capacity*1000)
dfESP['Outlet Pressure'] = a
dfESP['kW'] = cooler_ESPstack_power
dfESP['% Efficiency'] = dfESP['Flow m3/s']*((a+cooler_ESPstack_staticpressure)/(102*0.95*dfESP['kW']))*100
#Lines 588-616 take care of the TAD sheet and it's required dataframe. And the link for downloading the excel as well.
if input_excel is not None and (number_of_tertiaryair_ducts > 0):
i = 1
np.TADnamesarray = []
while(i <= number_of_tertiaryair_ducts):
(np.TADnamesarray).append("Tertiary Air Duct %d" %i)
i+=1
dfTADnames = pd.DataFrame(np.TADnamesarray, columns = ['Name'])
dfTADmeansqrt = np.sqrt(dfTADcolumns.mean())
dfsqrt = pd.DataFrame(dfTADmeansqrt, columns = ['Sqrt DP'])
dfsqrt.reset_index(drop=True, inplace=True)
dfTADtemperatures = pd.DataFrame(np.arrayTADtemperatures, columns = ['Temp'])
dfTADdiameters = pd.DataFrame(np.arrayTADdiameters, columns = ['Diameter'])
dfTADstaticpressures = pd.DataFrame(np.arrayTADstaticpressures, columns = ['Static Pressure'])
dfTAD = pd.concat([dfTADnames, dfsqrt, dfTADtemperatures], axis = 1)
dfTAD['Temp K'] = dfTAD['Temp']+273
dfTAD = pd.concat([dfTAD, dfTADstaticpressures], axis = 1)
dfTAD['Calculated Pressure'] = datum_pressure+dfTAD['Static Pressure']
dfTAD['Temp CF'] = (273/10336)*(dfTAD['Calculated Pressure']/dfTAD['Temp K'])
dfTAD['Density'] = (cooler_air_density*273*dfTAD['Calculated Pressure'])/(10336*(273+dfTAD['Temp']))
dfTAD = pd.concat([dfTAD, dfTADdiameters], axis = 1)
dfTAD['Area'] = ((np.pi)*dfTAD['Diameter']**2)/4
dfTAD['V'] = dfpitotconstantsdata['TAD Pitot Constants']*dfTAD['Sqrt DP']*(((2*9.81)**0.5)/np.sqrt(dfTAD['Density']))
dfTAD['Flow m3/s'] = dfTAD['V']*dfTAD['Area']
dfTAD['Flow m3/hr'] = dfTAD['Flow m3/s']*3600
dfTAD['Nm3/hr'] = (dfTAD['Flow m3/hr']*273*(dfTAD['Calculated Pressure']))/(10330*(273+dfTAD['Temp']))
dfTAD['Nm3/kgcl'] = dfTAD['Nm3/hr']/(clinker_capacity*1000)
elif input_excel is not None and (number_of_tertiaryair_ducts == 0):
dfTAD = pd.DataFrame([[np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan]], columns = ['Name', 'Sqrt DP', 'Temp', 'Temp K', 'Static Pressure', 'Calculated Pressure', 'Temp CF', 'Density', 'Diameter', 'Area', 'V', 'Flow m3/s', 'Flow m3/hr', 'Nm3/hr', 'Nm3/kgcl'])
#Lines 622-650 take care of the CMA (or WHRS o/I) sheet and it's required dataframe. And the link for downloading the excel as well.
if input_excel is not None and (number_of_coolermidair > 0):
i = 1
np.CMAnamesarray = []
while(i <= number_of_coolermidair):
(np.CMAnamesarray).append("Cooler Mid Air %d" %i)
i+=1
dfCMAnames = pd.DataFrame(np.CMAnamesarray, columns = ['Name'])
dfCMAmeansqrt = np.sqrt(dfCMAcolumns.mean())
dfCMAsqrt = pd.DataFrame(dfCMAmeansqrt, columns = ['Sqrt DP'])
dfCMAsqrt.reset_index(drop=True, inplace=True)
dfCMAtemperatures = pd.DataFrame(np.arrayCoolerMidAirtemperatures, columns = ['Temp'])
dfCMAdiameters = pd.DataFrame(np.arrayCoolerMidAirdiameters, columns = ['Diameter'])
dfCMAstaticpressures = pd.DataFrame(np.arrayCoolerMidAirstaticpressures, columns = ['Static Pressure'])
dfCMA = pd.concat([dfCMAnames, dfCMAsqrt, dfCMAtemperatures], axis = 1)
dfCMA['Temp K'] = dfCMA['Temp']+273
dfCMA = pd.concat([dfCMA, dfCMAstaticpressures], axis = 1)
dfCMA['Calculated Pressure'] = datum_pressure+dfCMA['Static Pressure']
dfCMA['Temp CF'] = (273/10336)*(dfCMA['Calculated Pressure']/dfCMA['Temp K'])
dfCMA['Density'] = (cooler_air_density*273*dfCMA['Calculated Pressure'])/(10336*(273+dfCMA['Temp']))
dfCMA = pd.concat([dfCMA, dfCMAdiameters], axis = 1)
dfCMA['Area'] = ((np.pi)*dfCMA['Diameter']**2)/4
dfCMA['V'] = dfpitotconstantsdata['CMA Pitot Constants']*dfCMA['Sqrt DP']*(((2*9.81)**0.5)/np.sqrt(dfCMA['Density']))
dfCMA['Flow m3/s'] = dfCMA['V']*dfCMA['Area']
dfCMA['Flow m3/hr'] = dfCMA['Flow m3/s']*3600
dfCMA['Nm3/hr'] = (dfCMA['Flow m3/hr']*273*(dfCMA['Calculated Pressure']))/(10330*(273+dfCMA['Temp']))
dfCMA['Nm3/kgcl'] = dfCMA['Nm3/hr']/(clinker_capacity*1000)
elif input_excel is not None and (number_of_coolermidair == 0):
dfCMA = pd.DataFrame([[np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan]], columns = ['Name', 'Sqrt DP', 'Temp', 'Temp K', 'Static Pressure', 'Calculated Pressure', 'Temp CF', 'Density', 'Diameter', 'Area', 'V', 'Flow m3/s', 'Flow m3/hr', 'Nm3/hr', 'Nm3/kgcl'])
#Lines 656-685 take care of the PH Downcomer Ducts sheet and it's required dataframe. And the link for downloading the excel as well.
if input_excel is not None:
i = 1
np.PHnamesarray = []
while(i <= number_of_preheater_downcomer_ducts):
(np.PHnamesarray).append("Pre Heater Downcomer Duct %d" %i)
i+=1
dfPHnames = pd.DataFrame(np.PHnamesarray, columns = ['Name'])
dfPHmeansqrt = np.sqrt(dfpreheatercolumns.mean())
dfPHsqrt = pd.DataFrame(dfPHmeansqrt, columns = ['Sqrt DP'])
dfPHsqrt.reset_index(drop=True, inplace=True)
dfPHtemperatures = pd.DataFrame(np.arraypreheaterdowncomerductstemperatures, columns = ['Temp'])
dfPHdiameters = pd.DataFrame(np.arraypreheaterdowncomerductsdiameters, columns = ['Diameter'])
dfPHstaticpressures = pd.DataFrame(np.arraypreheaterdowncomerductsstaticpressures, columns = ['Static Pressure'])
dfPH = pd.concat([dfPHnames, dfPHsqrt, dfPHtemperatures], axis = 1)
dfPH['Temp K'] = dfPH['Temp']+273
dfPH = pd.concat([dfPH, dfPHstaticpressures], axis = 1)
dfPH['Calculated Pressure'] = datum_pressure+dfPH['Static Pressure']
dfPH['Temp CF'] = (273/10336)*(dfPH['Calculated Pressure']/dfPH['Temp K'])
dfPH['Density'] =(dfdensitydata['Density']*273*dfPH['Calculated Pressure'])/(10336*(273+dfPH['Temp']))
dfPH = pd.concat([dfPH, dfPHdiameters], axis = 1)
dfPH['Area'] = ((np.pi)*dfPH['Diameter']**2)/4
dfPH['V'] = dfpitotconstantsdata['PH Pitot Constants']*dfPH['Sqrt DP']*(((2*9.81)**0.5)/np.sqrt(dfPH['Density']))
dfPH['Flow m3/s'] = dfPH['V']*dfPH['Area']
dfPH['Flow m3/hr'] = dfPH['Flow m3/s']*3600
dfPH['Nm3/hr'] = (dfPH['Flow m3/hr']*273*(dfPH['Calculated Pressure']))/(10330*(273+dfPH['Temp']))
dfPH['Nm3/kgcl'] = dfPH['Nm3/hr']/(clinker_capacity*1000)
dfPH['Outlet Pressure'] = dfPHfanoutletpressure['PH Outlet Pressure']
dfPH['kW'] = dfPHpower['PH Power']
dfPH['% Efficiency'] = dfPH['Flow m3/s']*((-dfPH['Static Pressure']+dfPHfanoutletpressure['PH Outlet Pressure'])/(102*0.95*dfPH['kW']))*100
#DATAFRAME containing all FAN FLOWS except for Cooler Vent Air.
dfnew = pd.concat([dfESP, dfTAD, dfCMA, dfPH])
#Lines 694-743 take care of the CVA fans data (DIRECT CALCULATION, BACK CALCULATION and ZERO case as well).
if input_excel is not None and ( backcalcordirectorindirect == 'Direct' and number_of_cooler_ventair_ducts > 0 ): #Change
i = 1
np.CVAnamesarray = []
while(i <= 1):
(np.CVAnamesarray).append("Cooler Vent Air %d" %i)
i+=1
dfCVAnames = pd.DataFrame(np.CVAnamesarray, columns = ['Name'])
dfCVAmeansqrt = np.sqrt(dfCVAcolumns.mean())
dfCVAmean = pd.DataFrame(dfCVAmeansqrt, columns = ['Sqrt DP'])
dfCVAmean.reset_index(drop=True, inplace=True)
dfCVA = pd.concat([dfCVAnames, dfCVAmean], axis = 1)
dfCVA['Temp'] = tempCVAdirect
dfCVA['Temp K'] = tempCVAdirect+273
dfCVA['Static Pressure'] = -staticpressureCVAdirect
dfCVA['Calculated Pressure'] = datum_pressure+dfCVA['Static Pressure']
dfCVA['Temp CF'] = (273/10336)*(dfCVA['Calculated Pressure']/dfCVA['Temp K'])
dfCVA['Density'] = (cooler_air_density*273*dfCVA['Calculated Pressure'])/(10336*(273+dfCVA['Temp']))
dfCVA['Diameter'] = diamCVAdirect
dfCVA['Area'] = ((np.pi)*diamCVAdirect**2)/4
dfCVA['V'] = pitottubeconstantCVAdirect*dfCVA['Sqrt DP']*(((2*9.81)**0.5)/np.sqrt(dfCVA['Density']))
dfCVA['Flow m3/s'] = dfCVA['V']*dfCVA['Area']
dfCVA['Flow m3/hr'] = dfCVA['Flow m3/s']*3600
dfCVA['Nm3/hr'] = (dfCVA['Flow m3/hr']*273*(dfCVA['Calculated Pressure']))/(10330*(273+dfCVA['Temp']))
dfCVA['Nm3/kgcl'] = dfCVA['Nm3/hr']/(clinker_capacity*1000)
elif input_excel is not None and (backcalcordirectorindirect == 'Indirect (ESP Stack Flow - MidAir Flow)'):
dfCVA = pd.DataFrame([['Cooler Vent Air 1', np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, dfESP['Nm3/kgcl']-(dfCMA['Nm3/kgcl'].sum(axis = 0))*0.97]])
elif input_excel is not None and (number_of_cooler_ventair_ducts == 0):
dfCVA = pd.DataFrame([[np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan]], columns = ['Name', 'Sqrt DP', 'Temp', 'Temp K', 'Static Pressure', 'Calculated Pressure', 'Temp CF', 'Density', 'Diameter', 'Area', 'V', 'Flow m3/s', 'Flow m3/hr', 'Nm3/hr', 'Nm3/kgcl'])
elif input_excel is not None and (number_of_cooler_ventair_ducts > 0 and backcalcordirectorindirect == 'Back Calculate'):
i = 1
np.CVAnamesarray = []
while(i <= 1):
(np.CVAnamesarray).append("Cooler Vent Air %d" %i)
i+=1
dfCVAnames = pd.DataFrame(np.CVAnamesarray, columns = ['Name'])
with st.expander("COOLER VENT AIR BACK CALCULATION"):
st.write("Answer the following questions:")
CVAbackcaltemp = st.number_input('Temperature of Cooler Vent Air:', 0.00, 2000.00, 338.00, 5.00)
A = np.array( [ [1,1], [(CVAbackcaltemp-20)*(0.237+23*(CVAbackcaltemp*10**(-6))), (ambient_air_temperature-20)*(0.237+23*(ambient_air_temperature*10**(-6))) ] ] )
B = np.array( [ cooler_air_density*dfESP['Nm3/kgcl'], (cooler_air_density*dfESP['Nm3/kgcl']*(dfESP['Temp']-20))*(0.237+23*dfESP['Temp']*10**(-6)) ] )
Fbhai = linalg.solve(A,B)
st.write("Cooler Vent Air Flow is (**X**, kg/kg cl):")
st.write(float(Fbhai[0]))
st.write("False Air Flow is (**Y**, kg/kg cl):")
st.write(float(Fbhai[1]))
dfCVA = pd.DataFrame([['Cooler Vent Air 1', np.nan, CVAbackcaltemp, CVAbackcaltemp+273, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, float(Fbhai[0])/cooler_air_density]], columns = ['Name', 'Sqrt DP', 'Temp', 'Temp K', 'Static Pressure', 'Calculated Pressure', 'Temp CF', 'Density', 'Diameter', 'Area', 'V', 'Flow m3/s', 'Flow m3/hr', 'Nm3/hr', 'Nm3/kgcl'])
#st.write("***")
if input_excel is not None:
dfnewCVAaswell = pd.concat([dfESP, dfTAD, dfCMA, dfPH, dfCVA])
#Code for COLUMN 2, taking care of the COOLER FANS. Lines 752-854 as of now.
with col2:
st.header("COOLER FANS")
pitot_tube_constant_forcoolerfans = st.number_input('Enter the Pitot Tube Constant for Cooler Fans:', 0.0000, 1.0000, 0.8100, 0.0001, format = "%.4f")
with st.expander("ANEMOMETER OR NOT?"):
st.write("Answer the following questions: (Type 1 if yes, 0 otherwise)")
CountColumn2Expander1 = 1
np.arrayforanemometeryesorno = [] #Array to hold yes or no responses in the form of 1 or 0.
while ( (CountColumn2Expander1 <= number_of_cooler_fans) and (number_of_cooler_fans > 0) ):
yorn = st.number_input("Was the measurement of the cooler fan %d taken by an anemometer?" %CountColumn2Expander1, 0, 1, 0, 1, key = CountColumn2Expander1)
np.arrayforanemometeryesorno.append(yorn) #yorn means Yes or No.
CountColumn2Expander1 += 1 #Using an array to store all the values of anemometer. 1 if Yes, 0 otherwise.
with st.expander("DIAMETERS OR AREA?"):
CountColumn2Expander2 = 1
CountColumn2Expander2area = 1
CountColumn2Expander2dia = 1
np.arrayforcoolerfansarea = []
while( (CountColumn2Expander2 <= number_of_cooler_fans) ):
choiceofareaordiameter = st.number_input('Choose if you want to enter the Area of Cooler Fan %d or the Diameter? (Type 1 for area, 0 for diameter)' %CountColumn2Expander2, 0, 1, 1, 1, key = CountColumn2Expander2)
if(choiceofareaordiameter == 1):
areacoolerfan = st.number_input('Enter the Area of Cooler Fan %d:' %CountColumn2Expander2, 0.00, 100.00, 1.23, 1.00, format = "%.4f", key = CountColumn2Expander2area)
np.arrayforcoolerfansarea.append(areacoolerfan)
CountColumn2Expander2area += 1
elif(choiceofareaordiameter == 0):
diametercoolerfan = st.number_input('Enter the Diameter of Cooler Fan %d:' %CountColumn2Expander2, 0.00, 50.0, 2.00, 0.01, format = "%.4f", key = CountColumn2Expander2dia)
np.arrayforcoolerfansarea.append(((np.pi)*(diametercoolerfan)**2)/4)
CountColumn2Expander2dia += 1
CountColumn2Expander2 += 1
with st.expander("STATIC PRESSURES"):
st.write("Enter just the **magnitude** of static pressure of the fans:")
CountColumn2Expander3 = 1
np.arrayforcoolerfanstaticpressures = []
while ( (CountColumn2Expander3 <= number_of_cooler_fans) and (number_of_cooler_fans > 0) ):
staticpressureCF = st.number_input('Static pressure of cooler fan %d:' %CountColumn2Expander3, 0.00, 2000.00, 30.00, 10.00, key = CountColumn2Expander3)
np.arrayforcoolerfanstaticpressures.append(-staticpressureCF)
CountColumn2Expander3 += 1
with st.expander("POWER"):
st.write("Enter the Power in **KiloWatts(kW)**:")
CountColumn2Expander4 = 1
np.arrayforcoolerfanspower = []
while ( (CountColumn2Expander4 <= number_of_cooler_fans) and (number_of_cooler_fans > 0) ):
powerCF = st.number_input('Power of cooler fan %d:' %CountColumn2Expander4, 0.00, 2000.00, 200.00, 10.00, key = CountColumn2Expander4)
np.arrayforcoolerfanspower.append(powerCF)
CountColumn2Expander4 += 1
dfCFpower = pd.DataFrame(np.arrayforcoolerfanspower, columns = ['Power'])
with st.expander("FAN OUTLET PRESSURES"):
st.write("Enter the Fan Outlet Pressures:")
CountColumn2Expander5 = 1
np.arrayforcoolerfansoutletpressures = []
while ( (CountColumn2Expander5 <= number_of_cooler_fans) and (number_of_cooler_fans > 0) ):
outletpressuresCF = st.number_input('Outlet Pressure of Cooler Fan %d:' %CountColumn2Expander5, 0.00, 2000.00, 900.00, 10.00, key = CountColumn2Expander5)
positiveornegativeCFoutletpr = st.radio(
"Is the Cooler Fan %d Outlet Pressure positive or negative?" %CountColumn2Expander5,
('+','-'), key = CountColumn2Expander5)
if(positiveornegativeCFoutletpr == '+'):
np.arrayforcoolerfansoutletpressures.append(outletpressuresCF)
else:
np.arrayforcoolerfansoutletpressures.append(-outletpressuresCF)
CountColumn2Expander5 += 1
dfCFfanoutletpressure = pd.DataFrame(np.arrayforcoolerfansoutletpressures, columns = ['Outlet Pressure'])
st.write('<style>div.row-widget.stRadio > div{flex-direction:row;}</style>', unsafe_allow_html = True)
if input_excel is not None and (number_of_cooler_fans > 0):
i = 1
np.CFnamesarray = []
while(i <= number_of_cooler_fans):
(np.CFnamesarray).append("Cooler Fan %d" %i)
i+=1
dfCFnames = pd.DataFrame(np.CFnamesarray, columns = ['Name'])
dfcoolerfancolumnsmean = dfcoolerfancolumns.mean()
dfCFmean = pd.DataFrame(dfcoolerfancolumnsmean, columns = ['Average Velocities'])
dfCFmean.reset_index(drop=True, inplace=True)
dfcoolerfanareas = pd.DataFrame(np.arrayforcoolerfansarea, columns = ['Areas'])
dfcoolerfansstaticpressure = pd.DataFrame(np.arrayforcoolerfanstaticpressures, columns = ['Static Pressures'])
dfanemometeryesorno = pd.DataFrame(np.arrayforanemometeryesorno, columns = ['Anemometer Y/N'])
dfCF = pd.concat([dfCFnames, dfanemometeryesorno, dfCFmean, dfcoolerfanareas, dfcoolerfansstaticpressure], axis = 1)
dfCF['m3/sec'] = dfCF.apply(lambda row: row['Average Velocities']*row['Areas'] if row['Anemometer Y/N'] == 1 else pitot_tube_constant_forcoolerfans*(2*9.81)**0.5*row['Average Velocities']/(cooler_air_density)**0.5, axis = 1 )
#Verify the formula to be used in case anemometer is not used.
dfCF['m3/hr'] = dfCF['m3/sec']*3600
dfCF['TCF'] = (273/(273+ambient_air_temperature))*((datum_pressure+dfCF['Static Pressures'])/10330)
dfCF['Nm3/hr'] = dfCF['TCF']*dfCF['m3/hr']
dfCF['Nm3/s'] = dfCF['Nm3/hr']/3600
dfCF['Nm3/kgcl'] = dfCF['Nm3/hr']/(clinker_capacity*1000)
dfCF['Temp'] = ambient_air_temperature
dfCF['Outlet Pressure'] = dfCFfanoutletpressure['Outlet Pressure']
dfCF['Power'] = dfCFpower['Power']
dfCF['% Efficiency'] = dfCF['m3/sec']*((dfCF['Static Pressures']+dfCF['Outlet Pressure'])/(102*0.95*dfCF['Power']))*100
elif input_excel is not None and (number_of_cooler_fans == 0):
dfCF = pd.DataFrame()
dfCF = pd.DataFrame([[np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan]], columns = ['Name', 'Anemometer Y/N', 'Average Velocities', 'Areas', 'Static Pressures', 'm3/sec', 'm3/hr', 'TCF', 'Nm3/hr', 'Nm3/s', 'Nm3/kgcl', 'Temp', 'Outlet Pressure', 'Power', '% Efficiency'])
#Code for Column 3, taking care of the COOLER HEAT BALANCE. Lines 860-984 as of now.
with col3:
st.header("COOLER HB")
clinker_inlet_temperature = st.number_input('Clinker Inlet Temperature:', 0.00, 2000.00, 1450.00, 1.00)
clinker_outlet_temperature = st.number_input('Clinker Outlet Temperature:', 0.00, 2000.00, 260.00, 1.00)
cooler_radiation_losses = st.number_input('Enter the Cooler Radiation Losses (Heat):', 0.00, 100.00, 3.00, 0.01)
#Code for COOLER HEAT BALANCE INPUT SECTION. Lines 869-873.
if input_excel is not None:
HeatBalanceInputData = [ [ 'Hot Clinker', 1, clinker_inlet_temperature, 0.186+54*clinker_inlet_temperature*10**(-6), (0.186+54*clinker_inlet_temperature*10**(-6))*(clinker_inlet_temperature-REFERENCE_TEMPERATURE_NTP)],
[ 'Cooling Air', dfCF['Nm3/kgcl'].sum(axis = 0)*cooler_air_density, ambient_air_temperature, 0.237+23*ambient_air_temperature*10**(-6), (dfCF['Nm3/kgcl'].sum(axis = 0))*(cooler_air_density)*((0.237+23*ambient_air_temperature*10**(-6))*(ambient_air_temperature-REFERENCE_TEMPERATURE_NTP))],
]
dfInputHeatBalance = pd.DataFrame(HeatBalanceInputData, columns = ['Item', 'Flow (kg/kg clinker)', 'Temp (Celsius)', 'Cp (kcal/kg celsius)', 'Heat (kcal/kg clinker)'])
#Code for COOLER HEAT BALANCE OUTPUT SECTION. Lines 879-984 as of now.
if input_excel is not None:
HeatBalanceOutputDataSame = [ ['Clinker Leaving the Cooler', 1, clinker_outlet_temperature, 0.186+(54*clinker_outlet_temperature*10**(-6)), (0.186+(54*clinker_outlet_temperature*10**(-6)))*(clinker_outlet_temperature-REFERENCE_TEMPERATURE_NTP)],
['Cooler Radiation Losses', np.nan, np.nan, np.nan, cooler_radiation_losses],
]
dfHeatBalanceOutputSame = pd.DataFrame(HeatBalanceOutputDataSame, columns = ['Item', 'Flow (kg/kg clinker)', 'Temp (Celsius)', 'Cp (kcal/kg celsius)', 'Heat (kcal/kg clinker)'])
#TAD HEAT BALANCE OUTPUT. Lines 889-905.
if input_excel is not None and (number_of_tertiaryair_ducts > 0):
i = 1
np.TAtoILCnamesarray = []
while(i <= number_of_tertiaryair_ducts):
(np.TAtoILCnamesarray).append("Tertiary Air to ILC %d" %i)
i+=1
dfTAtoILCnames = pd.DataFrame(np.TAtoILCnamesarray, columns = ['Item'])
HeatBalanceOutputDataTAD = pd.DataFrame()
HeatBalanceOutputDataTAD = dfTAtoILCnames
HeatBalanceOutputDataTAD['Flow (kg/kg clinker)'] = dfTAD['Nm3/kgcl']*cooler_air_density
HeatBalanceOutputDataTAD['Temp (Celsius)'] = dfTAD['Temp']
HeatBalanceOutputDataTAD['Cp (kcal/kg celsius)'] = 0.237+(23*dfTAD['Temp']*10**(-6))
HeatBalanceOutputDataTAD['Heat (kcal/kg clinker)'] = (dfTAD['Nm3/kgcl']*cooler_air_density)*(0.237+(23*dfTAD['Temp']*10**(-6)))*(dfTAD['Temp']-REFERENCE_TEMPERATURE_NTP)
elif input_excel is not None and (number_of_tertiaryair_ducts == 0):
HeatBalanceOutputDataTAD = pd.DataFrame()
HeatBalanceOutputDataTAD = pd.DataFrame([[np.nan, np.nan, np.nan, np.nan, np.nan]], columns = ['Item', 'Flow (kg/kg clinker)', 'Temp (Celsius)', 'Cp (kcal/kg celsius)', 'Heat (kcal/kg clinker)'])
#CMA HEAT BALANCE OUTPUT. Lines 910-926.
if input_excel is not None and (number_of_coolermidair > 0):
i = 1
np.CoolerMidAirnamesarray = []
while(i <= number_of_coolermidair):
(np.CoolerMidAirnamesarray).append("Cooler Mid Air %d" %i)
i+=1
dfCoolerMidAirnames = pd.DataFrame(np.CoolerMidAirnamesarray, columns = ['Item'])
HeatBalanceOutputDataCMA = pd.DataFrame()
HeatBalanceOutputDataCMA = dfCoolerMidAirnames
HeatBalanceOutputDataCMA['Flow (kg/kg clinker)'] = dfCMA['Nm3/kgcl']*cooler_air_density
HeatBalanceOutputDataCMA['Temp (Celsius)'] = dfCMA['Temp']
HeatBalanceOutputDataCMA['Cp (kcal/kg celsius)'] = 0.237+(23*dfCMA['Temp']*10**(-6))
HeatBalanceOutputDataCMA['Heat (kcal/kg clinker)'] = (dfCMA['Nm3/kgcl']*cooler_air_density)*(0.237+(23*dfCMA['Temp']*10**(-6)))*(dfCMA['Temp']-REFERENCE_TEMPERATURE_NTP)
elif input_excel is not None and (number_of_coolermidair == 0):
HeatBalanceOutputDataCMA = pd.DataFrame()
HeatBalanceOutputDataCMA = pd.DataFrame([[np.nan, np.nan, np.nan, np.nan, np.nan]], columns = ['Item', 'Flow (kg/kg clinker)', 'Temp (Celsius)', 'Cp (kcal/kg celsius)', 'Heat (kcal/kg clinker)'])
#CVA HEAT BALANCE OUTPUT. Lines 931-958.
if input_excel is not None and (number_of_cooler_ventair_ducts > 0):
i = 1
np.CoolerVentAirnamesarray = []
while(i <= number_of_coolermidair):
(np.CoolerVentAirnamesarray).append("Cooler Vent Air %d" %i)
i+=1
dfCoolerVentAirnames = pd.DataFrame(np.CoolerVentAirnamesarray, columns = ['Item'])
HeatBalanceOutputDataCVA = pd.DataFrame()
HeatBalanceOutputDataCVA = dfCoolerVentAirnames
if (backcalcordirectorindirect == 'Direct'):
HeatBalanceOutputDataCVA['Flow (kg/kg clinker)'] = dfCVA['Nm3/kgcl']*cooler_air_density
HeatBalanceOutputDataCVA['Temp (Celsius)'] = dfCVA['Temp']
HeatBalanceOutputDataCVA['Cp (kcal/kg celsius)'] = 0.237+(23*dfCVA['Temp']*10**(-6))
elif (backcalcordirectorindirect == 'Back Calculate'):
HeatBalanceOutputDataCVA['Flow (kg/kg clinker)'] = Fbhai[0]
HeatBalanceOutputDataCVA['Temp (Celsius)'] = CVAbackcaltemp
HeatBalanceOutputDataCVA['Cp (kcal/kg celsius)'] = 0.237+(23*CVAbackcaltemp*10**(-6))
else:
HeatBalanceOutputDataCVA['Flow (kg/kg clinker)'] = (dfESP['Nm3/kgcl']-(dfCMA['Nm3/kgcl'].sum(axis = 0))*0.97)*cooler_air_density
HeatBalanceOutputDataCVA['Temp (Celsius)'] = dfESP['Temp']
HeatBalanceOutputDataCVA['Cp (kcal/kg celsius)'] = 0.237+(23*dfESP['Temp']*10**(-6))
HeatBalanceOutputDataCVA['Heat (kcal/kg clinker)'] = (HeatBalanceOutputDataCVA['Flow (kg/kg clinker)'])*HeatBalanceOutputDataCVA['Cp (kcal/kg celsius)']*(HeatBalanceOutputDataCVA['Temp (Celsius)']-REFERENCE_TEMPERATURE_NTP)
elif input_excel is not None and (number_of_cooler_ventair_ducts == 0):
HeatBalanceOutputDataCVA = pd.DataFrame()
HeatBalanceOutputDataCVA = pd.DataFrame([[np.nan, np.nan, np.nan, np.nan, np.nan]], columns = ['Item', 'Flow (kg/kg clinker)', 'Temp (Celsius)', 'Cp (kcal/kg celsius)', 'Heat (kcal/kg clinker)'])
#HEAT BALANCE OUTPUT (excluding Secondary Air). Lines 963-965.
if input_excel is not None:
HeatBalanceOutputDataCVA.reset_index(drop=True, inplace=True)
dfOutputHeatBalance = pd.concat([dfHeatBalanceOutputSame, HeatBalanceOutputDataTAD, HeatBalanceOutputDataCMA, HeatBalanceOutputDataCVA])
#SECONDARY AIR CALCULATIONS. Line 970-984.
SAflowkgkgclinker = dfInputHeatBalance['Flow (kg/kg clinker)'].sum(axis = 0) - dfOutputHeatBalance['Flow (kg/kg clinker)'].sum(axis = 0)
HeatSA = dfInputHeatBalance['Heat (kcal/kg clinker)'].sum(axis = 0)-dfOutputHeatBalance['Heat (kcal/kg clinker)'].sum(axis = 0)
acoeff = 23*10**(-6)
bcoeff = 0.237 - (REFERENCE_TEMPERATURE_NTP)*23*(10**(-6))
ccoeff = -(HeatSA)/SAflowkgkgclinker - ((REFERENCE_TEMPERATURE_NTP)*0.237)
discriminant = (bcoeff**2)-4*acoeff*ccoeff
sol2 = (-bcoeff+np.sqrt(discriminant))/(2*acoeff)
dfOutputHeatBalance.loc[len(dfOutputHeatBalance.index)] = ['Secondary Air to Kiln', float(SAflowkgkgclinker), sol2, 0.237+(23*sol2*10**(-6)), HeatSA]
st.write("Cooler Recuperation Efficiency:")
st.write( ((HeatSA+HeatBalanceOutputDataTAD['Heat (kcal/kg clinker)'].sum(axis = 0))/dfInputHeatBalance['Heat (kcal/kg clinker)'].sum(axis = 0))*100 )
st.write("Cooler Heat Losses:")
st.write( dfInputHeatBalance['Heat (kcal/kg clinker)'].sum(axis = 0)-(HeatSA+HeatBalanceOutputDataTAD['Heat (kcal/kg clinker)'].sum(axis = 0)) )