-
Notifications
You must be signed in to change notification settings - Fork 0
/
main
979 lines (780 loc) · 43.6 KB
/
main
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
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
#
# generated by wxGlade 1.0.4 on Sat Feb 25 20:47:05 2023
#
import sys
import os
import matplotlib.pyplot as plt
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
import wx.lib.masked as masked
import wx
import wx.adv
from math import floor
import CoolProp
import CoolProp.CoolProp as CP,json
from CoolProp.Plots import StateContainer
from CoolProp.Plots import PropertyPlot
from numpy import log, log10
def resource_path(relative_path):
""" Get absolute path to resource, works for dev and for PyInstaller """
if getattr(sys, 'frozen', False):
# If the application is frozen (e.g., PyInstaller)
base_path = sys._MEIPASS
else:
# If the application is run from the source files
base_path = os.path.abspath(os.path.dirname(__file__))
return os.path.join(base_path, relative_path)
# with open('R1336mzz(E).json', 'r') as file:
# # JSON verilerini okuyun ve bir Python sözlüğüne dönüştürün
# R1336mzze = json.load(file)
#
# CP.add_fluids_as_JSON("HEOS", json.dumps(R1336mzze))
#
# # Overwrite fluids ayarını etkinleştirin
# CP.set_config_bool(CP.OVERWRITE_FLUIDS, True)
# JSON dosyasının yolunu alın
json_path = resource_path('R1336mzz(E).json')
# JSON dosyasını okuyun
with open(json_path, 'r') as file:
R1336mzze = json.load(file)
# JSON verilerini ekleyin
CP.add_fluids_as_JSON("HEOS", json.dumps(R1336mzze))
class MyFrame(wx.Frame):
DEFAULT_STYLE = wx.DEFAULT_FRAME_STYLE
def __init__(self):
style = MyFrame.DEFAULT_STYLE
wx.Frame.__init__(self, None, style=style, title="NeuORC v1.1")
self.SetSize((1500, 900))
self.Maximize(True)
self.fluid = 'Water'
self.efluid = 'Water'
self.cfluid = 'Water'
self.Tunit1 = 0
self.Tunit2 = 0.0002777778
self.Tunit3 = 0
self.evaptype = 0
self.condtype = 0
self.Tsource = 0
self.msource = 0
font = wx.Font(7, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)
self.SetFont(font)
# Menu Bar
self.frame_menubar = wx.MenuBar()
self.File_menu = wx.Menu()
self.frame_menubar.New_menu = self.File_menu.Append(wx.ID_NEW, "New", "")
self.Bind(wx.EVT_MENU, self.OnNew, id=wx.ID_NEW)
self.File_menu.Append(wx.ID_OPEN, "Open", "Open file")
self.Bind(wx.EVT_MENU, self.OnOpen, id=wx.ID_OPEN)
self.File_menu.Append(wx.ID_SAVE, "Save", "Save project")
self.File_menu.AppendSeparator()
self.File_menu.Append(wx.ID_EXIT, "Exit", "Exit")
self.frame_menubar.Append(self.File_menu, "File")
wxglade_tmp_menu = wx.Menu()
wxglade_tmp_menu.Append(wx.ID_ABOUT, "About", "")
wxglade_tmp_menu.Bind(wx.EVT_MENU, self.OnAboutBox)
self.frame_menubar.Append(wxglade_tmp_menu, "Help")
self.SetMenuBar(self.frame_menubar)
# Menu Bar end
self.frame_statusbar = self.CreateStatusBar(1)
self.frame_statusbar.SetStatusWidths([-1])
# statusbar fields
frame_statusbar_fields = ["Ready"]
for i in range(len(frame_statusbar_fields)):
self.frame_statusbar.SetStatusText(frame_statusbar_fields[i], i)
self.notebook_1 = wx.Notebook(self, wx.ID_ANY)
self.Design = wx.Panel(self.notebook_1, wx.ID_ANY)
self.notebook_1.AddPage(self.Design, "System design")
sizer_6 = wx.BoxSizer(wx.VERTICAL)
sizer_7 = wx.BoxSizer(wx.HORIZONTAL)
sizer_6.Add(sizer_7, 0, wx.LEFT, 10)
self.sizer_3 = wx.BoxSizer(wx.VERTICAL)
sizer_7.Add(self.sizer_3, 2, wx.EXPAND | wx.TOP, 12)
self.yellow_panel = wx.Panel(self.Design)
self.sizer_3.Add(self.yellow_panel, 1, wx.EXPAND)
# ORC resmini yükle (resmi "ORC.jpg" dosyasından yüklemek için dosya yolu belirtmelisiniz)
self.image_1 = wx.Image(resource_path('ORC6.png'), wx.BITMAP_TYPE_ANY)
self.original_width = self.GetSize()[0] # Orijinal pencere genişliği
self.bitmap_1 = self._resize_image(self.original_width)
wx.StaticBitmap(self.yellow_panel, -1, self.bitmap_1, style=wx.BORDER_SIMPLE | wx.FULL_REPAINT_ON_RESIZE)
self.Bind(wx.EVT_SIZE, self.on_resize) # Boyut değişikliklerini dinle
sizer_8 = wx.StaticBoxSizer(wx.StaticBox(self.Design, wx.ID_ANY, "Inputs"), wx.VERTICAL)
sizer_7.Add(sizer_8, 0, wx.ALL, 0)
sizer_9 = wx.BoxSizer(wx.VERTICAL)
sizer_8.Add(sizer_9, 0, wx.EXPAND, 0)
sizer_12 = wx.BoxSizer(wx.HORIZONTAL)
sizer_9.Add(sizer_12, 0, wx.EXPAND | wx.RIGHT, 0)
sizer_2 = wx.BoxSizer(wx.HORIZONTAL)
sizer_12.Add(sizer_2, 0, wx.EXPAND | wx.TOP, 0)
sel_fld_lbl = wx.StaticText(self.Design, wx.ID_ANY, "Selected fluid:")
sizer_2.Add(sel_fld_lbl, 1, wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5)
self.combo_box_1 = wx.ComboBox(self.Design, wx.ID_ANY, choices=["1-Butene", "Acetone", "Air", "Ammonia", "Argon", "Benzene", "CarbonDioxide", "CarbonMonoxide", "CarbonylSulfide", "CycloHexane", "CycloPropane", "Cyclopentane", "D4", "D5", "D6", "Deuterium", "Dichloroethane", "DiethylEther", "DimethylCarbonate", "DimethylEther", "Ethane", "Ethanol", "EthylBenzene", "Ethylene", "EthyleneOxide", "Fluorine", "HFE143m", "HeavyWater", "Helium", "Hydrogen", "HydrogenChloride", "HydrogenSulfide", "IsoButane", "IsoButene", "Isohexane", "Isopentane", "Krypton", "MD2M", "MD3M", "MD4M", "MDM", "MM", "Methane", "Methanol", "MethylLinoleate", "MethylLinolenate", "MethylOleate", "MethylPalmitate", "MethylStearate", "Neon", "Neopentane", "Nitrogen", "NitrousOxide", "Novec649", "OrthoDeuterium", "OrthoHydrogen", "Oxygen", "ParaDeuterium", "ParaHydrogen", "Propylene", "Propyne", "R11", "R113", "R114", "R115", "R116", "R12", "R123", "R1233zd(E)", "R1234yf", "R1234ze(E)", "R1234ze(Z)","R1336mzz(E)" ,"R124", "R1243zf", "R125", "R13", "R134a", "R13I1", "R14", "R141b", "R142b", "R143a", "R152A", "R161", "R21", "R218", "R22", "R227EA", "R23", "R236EA", "R236FA", "R245ca", "R245fa", "R32", "R365MFC", "R40", "R404A", "R407C", "R41", "R410A", "R507A", "RC318", "SES36", "SulfurDioxide", "SulfurHexafluoride", "Toluene", "Water", "Xenon", "cis-2-Butene", "m-Xylene", "n-Butane", "n-Decane", "n-Dodecane", "n-Heptane", "n-Hexane", "n-Nonane", "n-Octane", "n-Pentane", "n-Propane", "n-Undecane", "o-Xylene", "p-Xylene", "trans-2-Butene"], style=wx.CB_DROPDOWN | wx.CB_READONLY)
self.combo_box_1.SetSelection(0)
sizer_2.Add(self.combo_box_1, 1, wx.ALIGN_CENTER_VERTICAL, 8)
self.Bind(wx.EVT_COMBOBOX, self.onComboSelect1, self.combo_box_1)
sizer_1 = wx.StaticBoxSizer(wx.StaticBox(self.Design, wx.ID_ANY, "Unit"), wx.HORIZONTAL)
sizer_12.Add(sizer_1, 1, wx.LEFT, 5)
self.radio_btn_2 = wx.RadioButton(self.Design, wx.ID_ANY, "SI")
self.radio_btn_2.SetValue(1)
sizer_1.Add(self.radio_btn_2, 1, 0, 0)
self.radio_btn_3 = wx.RadioButton(self.Design, wx.ID_ANY, "British")
sizer_1.Add(self.radio_btn_3, 1, 0, 0)
sizer_10 = wx.StaticBoxSizer(wx.StaticBox(self.Design, wx.ID_ANY, "Evaporator"), wx.VERTICAL)
sizer_9.Add(sizer_10, 0, wx.ALL | wx.EXPAND, 0)
sizer_4 = wx.BoxSizer(wx.VERTICAL)
sizer_10.Add(sizer_4, 0, wx.EXPAND, 0)
sizer_23 = wx.BoxSizer(wx.HORIZONTAL)
sizer_4.Add(sizer_23, 0, wx.EXPAND, 0)
self.evap_ht_src_lbl = wx.StaticText(self.Design, wx.ID_ANY, "Heat source temperature:")
sizer_23.Add(self.evap_ht_src_lbl, 1, wx.ALL, 5)
self.evap_ht_src = masked.NumCtrl(self.Design,value='',fractionWidth=2,integerWidth=9,allowNone=True,allowNegative=False)
sizer_23.Add(self.evap_ht_src, 1, wx.LEFT, 0)
self.evap_ht_src_unit = wx.ComboBox(self.Design, wx.ID_ANY, choices=["K", "°C"], style=wx.CB_DROPDOWN | wx.CB_READONLY)
self.evap_ht_src_unit.SetMinSize((70, 23))
self.evap_ht_src_unit.SetSelection(0)
sizer_23.Add(self.evap_ht_src_unit, 0, wx.LEFT, 5)
self.Bind(wx.EVT_COMBOBOX, self.onComboSelect2, self.evap_ht_src_unit)
sizer_24 = wx.BoxSizer(wx.HORIZONTAL)
sizer_4.Add(sizer_24, 0, wx.EXPAND, 0)
evap_flw_rate_lbl = wx.StaticText(self.Design, wx.ID_ANY, "Heat source mass flow:")
sizer_24.Add(evap_flw_rate_lbl, 1, wx.ALL, 5)
self.evap_flw_rate = masked.NumCtrl(self.Design,value='',fractionWidth=2,integerWidth=9,allowNone=True,allowNegative=False)
sizer_24.Add(self.evap_flw_rate, 1, wx.LEFT, 0)
self.evap_flw_rate_unit = wx.ComboBox(self.Design, wx.ID_ANY, choices=["kg/h", "kg/s"], style=wx.CB_DROPDOWN | wx.CB_READONLY)
self.evap_flw_rate_unit.SetMinSize((70, 23))
self.evap_flw_rate_unit.SetSelection(0)
sizer_24.Add(self.evap_flw_rate_unit, 0, wx.LEFT, 5)
self.Bind(wx.EVT_COMBOBOX, self.onComboSelect3, self.evap_flw_rate_unit)
sizer_15 = wx.BoxSizer(wx.HORIZONTAL)
sizer_4.Add(sizer_15, 0, wx.EXPAND, 0)
evap_tp_lbl = wx.StaticText(self.Design, wx.ID_ANY, "Pinch temp. difference:")
sizer_15.Add(evap_tp_lbl, 1, wx.ALL, 5)
self.evap_tp = masked.NumCtrl(self.Design,value='',fractionWidth=3,integerWidth=9,allowNone=True,allowNegative=False)
sizer_15.Add(self.evap_tp, 1, wx.LEFT, 0)
self.panel_4 = wx.Panel(self.Design, wx.ID_ANY)
self.panel_4.SetMinSize((70, 23))
sizer_15.Add(self.panel_4, 0, wx.BOTTOM | wx.LEFT, 5)
sizer_29 = wx.BoxSizer(wx.HORIZONTAL)
sizer_4.Add(sizer_29, 0, wx.EXPAND, 0)
sizer_5 = wx.BoxSizer(wx.HORIZONTAL)
sizer_4.Add(sizer_5, 0, wx.EXPAND, 0)
evap_eff_lbl = wx.StaticText(self.Design, wx.ID_ANY, "Evaporator effectiveness[%]:")
sizer_5.Add(evap_eff_lbl, 1, wx.ALL, 5)
self.evap_eff = masked.NumCtrl(self.Design,value='',fractionWidth=2,integerWidth=9,allowNone=True,allowNegative=False)
sizer_5.Add(self.evap_eff, 1, wx.LEFT, 0)
self.panel_1 = wx.Panel(self.Design, wx.ID_ANY)
self.panel_1.SetMinSize((70, 23))
sizer_5.Add(self.panel_1, 0, wx.BOTTOM | wx.LEFT, 5)
sizer_18 = wx.StaticBoxSizer(wx.StaticBox(self.Design, wx.ID_ANY, "Condenser"), wx.VERTICAL)
sizer_9.Add(sizer_18, 0, wx.ALL | wx.EXPAND, 0)
sizer_20 = wx.BoxSizer(wx.VERTICAL)
sizer_18.Add(sizer_20, 0, wx.EXPAND, 0)
sizer_21 = wx.BoxSizer(wx.HORIZONTAL)
sizer_20.Add(sizer_21, 0, wx.EXPAND, 0)
cond_cool_temp_lbl = wx.StaticText(self.Design, wx.ID_ANY, "Cooling flow temperature:")
sizer_21.Add(cond_cool_temp_lbl, 0, wx.ALL, 5)
self.cond_cool_temp = masked.NumCtrl(self.Design,value='',fractionWidth=2,integerWidth=9,allowNone=True,allowNegative=False)
sizer_21.Add(self.cond_cool_temp, 1, wx.LEFT, 22)
self.cond_cool_temp_unit = wx.ComboBox(self.Design, wx.ID_ANY, choices=["K", "°C"], style=wx.CB_DROPDOWN | wx.CB_READONLY)
self.cond_cool_temp_unit.SetMinSize((70, 23))
self.cond_cool_temp_unit.SetSelection(0)
sizer_21.Add(self.cond_cool_temp_unit, 0, wx.LEFT, 5)
self.Bind(wx.EVT_COMBOBOX, self.onComboSelect9, self.cond_cool_temp_unit)
sizer_35 = wx.BoxSizer(wx.HORIZONTAL)
sizer_20.Add(sizer_35, 0, wx.EXPAND, 0)
sizer_22 = wx.BoxSizer(wx.HORIZONTAL)
sizer_20.Add(sizer_22, 0, wx.EXPAND, 0)
cond_tp_lbl = wx.StaticText(self.Design, wx.ID_ANY, "Pinch temp. difference:")
sizer_22.Add(cond_tp_lbl, 1, wx.ALL, 5)
self.cond_tp = masked.NumCtrl(self.Design,value='',fractionWidth=3,integerWidth=9,allowNone=True,allowNegative=False)
sizer_22.Add(self.cond_tp, 1, wx.LEFT, 5)
sizer_34 = wx.BoxSizer(wx.HORIZONTAL)
sizer_20.Add(sizer_34, 0, wx.EXPAND, 0)
sizer_33 = wx.BoxSizer(wx.HORIZONTAL)
sizer_20.Add(sizer_33, 0, wx.EXPAND, 0)
self.panel_5 = wx.Panel(self.Design, wx.ID_ANY)
self.panel_5.SetMinSize((70, 23))
sizer_22.Add(self.panel_5, 0, wx.BOTTOM | wx.LEFT, 5)
sizer_25 = wx.StaticBoxSizer(wx.StaticBox(self.Design, wx.ID_ANY, "Turbine"), wx.VERTICAL)
sizer_9.Add(sizer_25, 0, wx.ALL | wx.EXPAND, 0)
sizer_26 = wx.BoxSizer(wx.VERTICAL)
sizer_25.Add(sizer_26, 0, wx.EXPAND, 0)
sizer_27 = wx.BoxSizer(wx.HORIZONTAL)
sizer_26.Add(sizer_27, 0, wx.EXPAND, 0)
sizer_28 = wx.BoxSizer(wx.HORIZONTAL)
sizer_26.Add(sizer_28, 0, wx.EXPAND, 0)
tur_eff_lbl = wx.StaticText(self.Design, wx.ID_ANY, "Isentropic efficiency[%]:")
sizer_28.Add(tur_eff_lbl, 0, wx.ALL, 5)
self.tur_eff = masked.NumCtrl(self.Design,value='',fractionWidth=2,integerWidth=9,allowNone=True,allowNegative=False)
sizer_28.Add(self.tur_eff, 1, wx.LEFT, 34)
self.panel_2 = wx.Panel(self.Design, wx.ID_ANY)
self.panel_2.SetMinSize((70, 23))
sizer_28.Add(self.panel_2, 0, wx.BOTTOM | wx.LEFT, 5)
sizer_30 = wx.StaticBoxSizer(wx.StaticBox(self.Design, wx.ID_ANY, "Pump"), wx.VERTICAL)
sizer_9.Add(sizer_30, 0, wx.ALL | wx.EXPAND, 0)
sizer_31 = wx.BoxSizer(wx.VERTICAL)
sizer_30.Add(sizer_31, 0, wx.EXPAND, 0)
sizer_32 = wx.BoxSizer(wx.HORIZONTAL)
sizer_31.Add(sizer_32, 0, wx.EXPAND, 0)
pump_eff_lbl = wx.StaticText(self.Design, wx.ID_ANY, "Isentropic efficiency[%]:")
sizer_32.Add(pump_eff_lbl, 0, wx.ALL, 5)
self.pump_eff = masked.NumCtrl(self.Design,value='',fractionWidth=2,integerWidth=9,allowNone=True,allowNegative=False)
sizer_32.Add(self.pump_eff, 1, wx.LEFT, 35)
self.panel_3 = wx.Panel(self.Design, wx.ID_ANY)
self.panel_3.SetMinSize((70, 23))
sizer_32.Add(self.panel_3, 0, wx.BOTTOM | wx.LEFT, 5)
#############
sizer_53 = wx.StaticBoxSizer(wx.StaticBox(self.Design, wx.ID_ANY, "Economy"), wx.VERTICAL)
sizer_9.Add(sizer_53, 0, wx.ALL | wx.EXPAND, 0)
sizer_54 = wx.BoxSizer(wx.HORIZONTAL)
sizer_53.Add(sizer_54, 0, wx.EXPAND, 0)
U_evap_lbl = wx.StaticText(self.Design, wx.ID_ANY, "Uevap.[kW/m2K]:")
sizer_54.Add(U_evap_lbl, 0, wx.ALL, 5)
self.U_evap = masked.NumCtrl(self.Design,value='',fractionWidth=2,integerWidth=9,allowNone=True,allowNegative=False)
sizer_54.Add(self.U_evap, 1, wx.LEFT, 2)
############
interest_lbl = wx.StaticText(self.Design, wx.ID_ANY, "Interest rate[%-yr]:")
sizer_54.Add(interest_lbl, 0, wx.ALL, 5)
self.interest = masked.NumCtrl(self.Design,value='',fractionWidth=2,integerWidth=9,allowNone=True,allowNegative=False)
sizer_54.Add(self.interest, 1, wx.LEFT, 0)
############
# self.panel_7 = wx.Panel(self.Design, wx.ID_ANY)
# self.panel_7.SetMinSize((70, 23))
# sizer_54.Add(self.panel_7, 0, wx.BOTTOM | wx.LEFT, 5)
sizer_55 = wx.BoxSizer(wx.HORIZONTAL)
sizer_53.Add(sizer_55, 0, wx.EXPAND, 0)
U_cond_lbl = wx.StaticText(self.Design, wx.ID_ANY, "Ucond.[kW/m2K]:")
sizer_55.Add(U_cond_lbl, 0, wx.ALL, 5)
self.U_cond = masked.NumCtrl(self.Design,value='',fractionWidth=2,integerWidth=9,allowNone=True,allowNegative=False)
sizer_55.Add(self.U_cond,1, wx.RIGHT, 17)
############
lifetime_lbl = wx.StaticText(self.Design, wx.ID_ANY, "Lifetime[yr]:")
sizer_55.Add(lifetime_lbl, 0, wx.ALL, 5)
self.lifetime = masked.NumCtrl(self.Design,value='',fractionWidth=2,integerWidth=9,allowNone=True,allowNegative=False)
sizer_55.Add(self.lifetime, 1, wx.LEFT, 8)
sizer_56 = wx.BoxSizer(wx.HORIZONTAL)
sizer_53.Add(sizer_56, 0, wx.EXPAND, 0)
optime_lbl = wx.StaticText(self.Design, wx.ID_ANY, "Annual op. time[hr]:")
sizer_56.Add(optime_lbl, 0, wx.ALL, 5)
self.optime = masked.NumCtrl(self.Design,value='',fractionWidth=2,integerWidth=9,allowNone=True,allowNegative=False)
sizer_56.Add(self.optime, 1, wx.LEFT, 0)
###########
price_lbl = wx.StaticText(self.Design, wx.ID_ANY, "Electric cost[$/kWh]:")
sizer_56.Add(price_lbl, 0, wx.ALL, 5)
self.price = masked.NumCtrl(self.Design,value='',fractionWidth=2,integerWidth=9,allowNone=True,allowNegative=False)
sizer_56.Add(self.price, 1, wx.LEFT, 0)
############
# self.panel_8 = wx.Panel(self.Design, wx.ID_ANY)
# self.panel_8.SetMinSize((70, 23))
# sizer_55.Add(self.panel_8, 0, wx.BOTTOM | wx.LEFT, 5)
#############
sizer_46 = wx.StaticBoxSizer(wx.StaticBox(self.Design, wx.ID_ANY, "Useful outputs:"), wx.VERTICAL)
sizer_9.Add(sizer_46, 0, wx.ALL | wx.EXPAND, 0)
self.text_1 = wx.TextCtrl(self.Design,wx.ID_ANY,value=" ",size=(70,50),style=wx.TE_READONLY | wx.TE_MULTILINE)
sizer_46.Add(self.text_1,0,wx.ALL | wx.EXPAND,5)
############
# self.panel_5 = wx.Panel(self.Design, wx.ID_ANY)
# self.panel_5.SetMinSize((70, 20))
# sizer_9.Add(self.panel_5, 0, wx.BOTTOM | wx.LEFT, 5)
############
self.button_1 = wx.Button(self.Design, wx.ID_ANY, "Calculate")
self.button_1.SetMinSize((130, 23))
self.button_1.Bind(wx.EVT_BUTTON, self.Calculate)
sizer_9.Add(self.button_1, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.TOP, 10)
sizer_13 = wx.StaticBoxSizer(wx.StaticBox(self.Design, wx.ID_ANY, "Outputs"), wx.HORIZONTAL)
sizer_6.Add(sizer_13, 1, wx.EXPAND | wx.LEFT, 10)
sizer_11 = wx.BoxSizer(wx.HORIZONTAL)
sizer_13.Add(sizer_11, 1, wx.EXPAND, 0)
self.list_ctrl_1 = wx.ListCtrl(self.Design, wx.ID_ANY, style=wx.BORDER_DEFAULT | wx.LC_REPORT | wx.LC_SINGLE_SEL)
self.list_ctrl_1.InsertColumn(1, "State", width=40)
self.list_ctrl_1.InsertColumn(2, "Temperature", width=80)
self.list_ctrl_1.InsertColumn(3, "Pressure", width=60)
self.list_ctrl_1.InsertColumn(4, "Specific volume", width=100)
self.list_ctrl_1.InsertColumn(5, "Enthalpy", width=60)
self.list_ctrl_1.InsertColumn(6, "Enthropy", width=60)
self.list_ctrl_1.InsertColumn(7, "Phase", width=50)
self.list_ctrl_1.InsertColumn(8, "Vapor quality", width=125)
self.list_ctrl_1.InsertItem(1, " ")
self.list_ctrl_1.InsertItem(2, " ")
self.list_ctrl_1.InsertItem(3, " ")
self.list_ctrl_1.InsertItem(4, " ")
sizer_11.Add(self.list_ctrl_1, 1, wx.ALL | wx.EXPAND, 5)
sizer_14 = wx.BoxSizer(wx.HORIZONTAL)
sizer_13.Add(sizer_14, 1, wx.EXPAND, 0)
self.list_ctrl_2 = wx.ListCtrl(self.Design, wx.ID_ANY, style=wx.BORDER_DEFAULT | wx.LC_REPORT)
self.list_ctrl_2.InsertColumn(1,"Cycle mass flow", width=100)
self.list_ctrl_2.InsertColumn(2,"Cooling mass flow", width=100)
self.list_ctrl_2.InsertColumn(3,"Pre-heating power",width=120)
self.list_ctrl_2.InsertColumn(4,"Vaporization power",width=120)
self.list_ctrl_2.InsertColumn(5,"Evaporator capacity",width=120)
self.list_ctrl_2.InsertColumn(6,"Condenser capacity",width=120)
self.list_ctrl_2.InsertColumn(7,"Heat source outlet temperature",width=185)
self.list_ctrl_2.InsertColumn(8,"Cooling outlet temperature",width=185)
self.list_ctrl_2.InsertColumn(9,"Wpump",width=60)
self.list_ctrl_2.InsertColumn(10,"Wturbine",width=70)
self.list_ctrl_2.InsertColumn(11,"Turbine pressure ratio",width=50)
self.list_ctrl_2.InsertColumn(12,"Wnet",width=50)
self.list_ctrl_2.InsertColumn(13,"ηthermal",width=120)
self.list_ctrl_2.InsertItem(1, " ")
self.list_ctrl_2.InsertItem(2, " ")
self.list_ctrl_2.InsertItem(3, " ")
self.list_ctrl_2.SetItem(1,0,"ηIIevap")
self.list_ctrl_2.SetItem(1,1,"ηIIcond")
self.list_ctrl_2.SetItem(1,2,"ηIItur")
self.list_ctrl_2.SetItem(1,3,"ηIIpump")
self.list_ctrl_2.SetItem(1,4,"Ievap")
self.list_ctrl_2.SetItem(1,5,"Icond")
self.list_ctrl_2.SetItem(1,6,"Iturb")
self.list_ctrl_2.SetItem(1,7,"Ipump")
self.list_ctrl_2.SetItem(1,8,"Exin")
self.list_ctrl_2.SetItem(1,9,"ηII")
sizer_14.Add(self.list_ctrl_2, 1, wx.ALL | wx.EXPAND, 5)
self.Design.SetSizer(sizer_6)
# Panel oluşturma
self.plot_panel = wx.Panel(self.Design, wx.ID_ANY,size=(500,350))
self.plot_sizer = wx.BoxSizer(wx.HORIZONTAL)
sizer_7.Add(self.plot_sizer, 1, wx.EXPAND | wx.TOP, 12)
self.plot_sizer.Add(self.plot_panel, 1, wx.EXPAND | wx.BOTTOM, 6)
# Create a FigureCanvas object and add it to plot_panel
pp = PropertyPlot(self.fluid, 'TS', unit_system='EUR', tp_limits='ORC')
pp.calc_isolines(CoolProp.iQ, num=11)
pp.figure.set_size_inches(4.5, 4.5) #ORC şeması ayarlandıktan sonra T-s diyagramı buradan küçültülecek
FigureCanvas(self.plot_panel, wx.ID_ANY, pp.figure)
plt.close()
def CopyItems(self, event):
selectedItems = []
for i in range(self.list_ctrl_2.GetColumnCount()):
item = self.list_ctrl_2.GetItem(0, i)
selectedItems.append(item.GetText())
for i in range(self.list_ctrl_2.GetColumnCount()):
item = self.list_ctrl_2.GetItem(1, i)
selectedItems.append(item.GetText())
for i in range(self.list_ctrl_2.GetColumnCount()):
item = self.list_ctrl_2.GetItem(2, i)
selectedItems.append(item.GetText())
clipdata = wx.TextDataObject()
clipdata.SetText("\n".join(selectedItems))
wx.TheClipboard.Open()
wx.TheClipboard.SetData(clipdata)
wx.TheClipboard.Close()
def OnNew(self, event): # wxGlade: MyFrame.<event_handler>
print("Event handler 'OnNew' not implemented!")
event.Skip()
def OnOpen(self, event): # wxGlade: MyFrame.<event_handler>
print("Event handler 'OnOpen' not implemented!")
event.Skip()
def Calculate(self, event): # wxGlade: MyFrame.<event_handler>
try:
self.Tsource = self.evap_ht_src.GetValue() + self.Tunit1
self.msource = self.evap_flw_rate.GetValue() * self.Tunit2
self.evappinch = self.evap_tp.GetValue()
self.evapeff = self.evap_eff.GetValue()
self.Tsink = self.cond_cool_temp.GetValue() + self.Tunit3
self.condpinch = self.cond_tp.GetValue()
self.turbeff = self.tur_eff.GetValue()
self.pumpeff = self.pump_eff.GetValue()
self.fluid = self.combo_box_1.GetValue()
self.Uevap = self.U_evap.GetValue()
self.Ucond = self.U_cond.GetValue()
self.i = self.interest.GetValue()
self.N = self.lifetime.GetValue()
self.n = self.optime.GetValue()
self.Cel = self.price.GetValue()
self.Cp = 4180
a = 10 #dTCooling
self.T1 = self.Tsink + a
self.T3f = self.Tsource - (self.evappinch/(1-(self.evapeff/100)))
self.Tpe = self.evappinch + self.T3f
self.H3f = CP.PropsSI('H','T',self.T3f,'Q',0,self.fluid)
self.S3f = CP.PropsSI('S','T',self.T3f,'Q',0,self.fluid)
self.T3 = self.T3f
self.P3 = CP.PropsSI('P','T',(self.T3),'Q',1,self.fluid)
self.H3 = CP.PropsSI('H','T',self.T3,'Q',1,self.fluid)
self.S3 = CP.PropsSI('S','T',self.T3,'Q',1,self.fluid)
#Pompa
self.P1 = CP.PropsSI('P','T',self.T1,'Q',0,self.fluid)
self.H1 = CP.PropsSI('H','T',self.T1,'Q',0,self.fluid)
self.V1 = 1/CP.PropsSI('D','T',self.T1,'Q',0,self.fluid)
self.S1 = CP.PropsSI('S','T',self.T1,'Q',0,self.fluid)
self.dp = 0 #Pressure drop
self.P2 = self.P3/(1-self.dp)
self.P4 = self.P1/(1-self.dp)
self.wpompa = self.V1*(self.P2-self.P1)
self.wpompag = (self.V1*(self.P2-self.P1))/(self.pumpeff/100)
self.H2 = self.wpompag + self.H1
self.T2 = CP.PropsSI('T','H',self.H2,'P',self.P2,self.fluid)
self.S2 = CP.PropsSI('S','H',self.H2,'P',self.P2,self.fluid)
self.S4s = self.S3
self.H4s = CP.PropsSI('H','S',self.S4s,'P',self.P4,self.fluid)
self.X4s = CP.PropsSI('Q','H',self.H4s,'P',self.P4,self.fluid)
self.H4 = self.H3 - (self.turbeff/100) * (self.H3 - self.H4s)
self.S4 = CP.PropsSI('S','H',self.H4,'P',self.P4,self.fluid)
self.T4 = CP.PropsSI('T','H',self.H4,'P',self.P4,self.fluid)
self.X4 = CP.PropsSI('Q','H',self.H4,'P',self.P4,self.fluid)
self.Qb = self.msource*self.Cp*(self.Tsource-self.Tpe)
self.morc = self.Qb/(self.H3-self.H3f)
self.Wt = self.morc*(self.H3- self.H4)
self.Qc = self.morc*(self.H4 - self.H1)
self.Qö = self.morc*(self.H3f - self.H2)
self.Qevap = self.Qö+self.Qb
self.Teout = self.Tsource - self.Qevap/(self.msource*self.Cp)
self.Wp = self.morc*(self.H2 - self.H1)
self.Wnet = self.Wt-self.Wp
self.Eff = (self.Wnet/self.Qevap)*100
######### Türbin çıkışının çift fazlı olup olmadığının kontrolü
if CP.PhaseSI('S',self.S4,'T',self.T4,self.fluid) == 'gas':
self.T1g = self.T1
self.S1g = CP.PropsSI('S','Q',1,'T',self.T1g,self.fluid)
self.H1g = CP.PropsSI('H','Q',1,'T',self.T1g,self.fluid)
else:
if self.fluid in {"R404A", "R407C"}:
raise Exception()
return
self.T1g = self.T4
self.H1g = self.H4
self.S1g = CP.PropsSI('S','P',self.P3,'H',self.H1g,self.fluid)
self.Tpc = self.T1g -self.condpinch
self.msink = (self.morc*(self.H1g-self.H1))/(self.Cp*(self.Tpc-self.Tsink))
self.Qcond = self.morc*(self.H4-self.H1)
self.Tcout = self.Tsink + self.Qcond/(self.msink*self.Cp)
self.Pratio = self.P3/self.P4
print(f"Satır: {self.list_ctrl_1.GetItemCount()}")
print(f"Sütun: {self.list_ctrl_1.GetColumnCount()}")
#Özgül Hacmiler
self.V2 = 1/CP.PropsSI('D','P',self.P2,'H',self.H2,self.fluid)
self.V3 = 1/CP.PropsSI('D','T',self.T3,'Q',1,self.fluid)
self.V4 = 1/CP.PropsSI('D','P',self.P4,'H',self.H4,self.fluid)
#Çevre durumları
self.T0 = 298.15 #[K]
self.P0 = 100000 #[Pa]
#Çevre durumunda organik akışkan için
self.S0 = CP.PropsSI('S','T',self.T0,'P',self.P0,self.fluid)
self.H0 = CP.PropsSI('H','T',self.T0,'P',self.P0,self.fluid)
#Çevre durumunda su için
self.S01 = CP.PropsSI('S','T',self.T0,'P',self.P0,"Water")
self.H01 = CP.PropsSI('H','T',self.T0,'P',self.P0,"Water")
#Evaporatörde sıcak akışkanın sıvı formda olduğu kabulü ile
self.x5 = 0
self.x6 = 0
self.H5 = CP.PropsSI('H','T',self.Tsource,'Q',self.x5,"Water")
self.H6 = CP.PropsSI('H','T',self.Teout,'Q',self.x6,"Water")
self.S5 = CP.PropsSI('S','T',self.Tsource,'Q',self.x5,"Water")
self.S6 = CP.PropsSI('S','T',self.Teout,'Q',self.x6,"Water")
#Kondenserde soğuk akışkanın sıvı formda olduğu kabulü ile
self.x7 = 0
self.x8 = 0
self.H7 = CP.PropsSI('H','T',self.Tsink,'Q',self.x7,"Water")
self.H8 = CP.PropsSI('H','T',self.Tcout,'Q',self.x8,"Water")
self.S7 = CP.PropsSI('S','T',self.Tsink,'Q',self.x7,"Water")
self.S8 = CP.PropsSI('S','T',self.Tcout,'Q',self.x8,"Water")
#Özgül exerji hesaplamaları
self.E1 = (self.H1-self.H0)-((self.T0)*(self.S1-self.S0))
self.E2 = (self.H2-self.H0)-((self.T0)*(self.S2-self.S0))
self.E3 = (self.H3-self.H0)-((self.T0)*(self.S3-self.S0))
self.E4 = (self.H4-self.H0)-((self.T0)*(self.S4-self.S0))
self.E5 = (self.H5-self.H0)-((self.T0)*(self.S5-self.S0))
self.E6 = (self.H6-self.H0)-((self.T0)*(self.S6-self.S0))
self.E7 = (self.H7-self.H0)-((self.T0)*(self.S7-self.S0))
self.E8 = (self.H8-self.H0)-((self.T0)*(self.S8-self.S0))
#Evaporator ekserji yıkımı
self.Ie = self.msource*(self.E5-self.E6) - self.morc*(self.E3-self.E2)
self.etaevap2 = ((self.morc*(self.E3-self.E2))/(self.msource*(self.E5-self.E6)))*100
#Kondenser ekserji yıkımı
self.Ic = self.morc*(self.E4-self.E1) - self.msink*(self.E8-self.E7)
self.etacond2 = ((self.msink*(self.E8-self.E7))/(self.morc*(self.E4-self.E1)))*100
#Türbin ekserji yıkımı
self.It = self.morc*(self.E3- self.E4) - self.Wt
self.etatur2 = (self.Wt/(self.morc*(self.E3-self.E4)))*100
#Pompa ekserji yıkımı
self.Ip = self.morc*(self.E1-self.E2) + self.Wp
self.etapump2 = ((self.morc*(self.E2-self.E1))/self.Wp)*100
self.Itotal =self.Ie + self.Ic + self.It + self.Ip
#Sisteme sağlanan ekserji
self.Exin = (self.H5-self.H6-((self.T0)*(self.S5-self.S6)))*self.msource
#Sistemin ekserji verimi
self.etaexergy = (self.Wnet/self.Exin)*100
#Kurulum maliyetleri
#Evaporatör kurulum maliyeti
self.dTlneva = abs(((self.Tsource-self.T3)-(self.Teout-self.T2))/log((self.Tsource-self.T3)/(self.Teout-self.T2)))
self.Aeva = self.Qevap/(self.Uevap*1000*self.dTlneva)
self.CICEva = 1010*(self.Aeva)**(0.8)
#Kondenser kurulum maliyeti
self.dTlncond = abs(((self.T4-self.Tcout)-(self.T1-self.Tsink))/log((self.T4-self.Tcout)/(self.T1-self.Tsink)))
self.Acond = self.Qcond/(self.Ucond*1000*self.dTlncond)
self.CICCond = 516.62*(self.Acond)**(0.6)
#Pompa kurulum maliyeti
self.CICPump = 200*(self.Wp/1000)**(0.65)
self.CICTurb = 516.62*(self.Wt/1000)**(0.75)
self.EIC = self.CICEva + self.CICCond + self.CICPump + self.CICTurb
self.CEIC = 0.20*self.EIC
#Yapısal maliyetler
self.CSC = 0.25*self.EIC
#Servis faliyetleri
self.CSF = 0.20*self.EIC
#Beklenmedik durumlar
self.CCONT = 0.06*self.EIC
#Arazi maliyeti
self.CLC = 0.1*self.EIC
#Organik akışkan maliyeti
self.CWM = 0
#Soğutucu akışkan maliyeti
self.CCW = 0
#Çeşitli giderler
self.CVC = 0.05*self.EIC
#Sabit yatırım maliyeti
#self.FIC = self.EIC + self.CEIC + self.CSC + self.CSF + self.CCONT + self.CLC
self.FIC = 1.75*self.EIC
#Toplam yatırım maliyeti
self.TIC = self.FIC + self.CVC + self.CWM + self.CCW
#Anapara geri kazanım maliyeti
self.inew = (self.i/100)
self.CRF = (self.inew*(1+self.inew)**self.N)/(((1+self.inew)**self.N)-1)
self.Zsc = self.TIC
self.CRC = (self.CRF)*(self.Zsc)
self.phi = (1.5/100)*self.Zsc
self.LCOE = (self.CRC + self.phi)/((self.Wnet/1000)*self.n)
a = (self.Wnet/1000)*self.n*self.Cel-self.phi
b = a-(self.inew*self.Zsc)
print(a)
print(b)
self.PB = log10(a/b)/log10(1+self.inew)
self.SIC = self.EIC/(self.Wnet/1000)
print(f"Aeva: {self.Aeva}")
print(f"Acond: {self.Acond}")
print(f"CICEva: {self.CICEva}")
print(f"CICCond: {self.CICCond}")
print(f"CICPump: {self.CICPump}")
print(f"CICTurb: {self.CICTurb}")
print(f"dTlneva: {self.dTlneva}")
print(f"dTlncond: {self.dTlncond}")
self.text_1.SetValue(f'η: {self.Eff:.4f} % '
f'ηII: {self.etaexergy:.4f} % '
f'Wnet: {self.Wnet:.2f} W '
f'Equipment installation cost: {self.EIC:.2f} $ '
f'Fixed term cost: {self.FIC:.2f} $ '
f'Total term cost: {self.TIC:.2f} $ '
f'Capital recovery factor: {self.CRF:.4f} '
f'Capital recovery cost: {self.CRC:.2f} $ '
f'Levelized cost of energy: {self.LCOE:.4f} $/kWh '
f'Specific investment cost: {self.SIC:.2f} $/kW '
f'Payback time: {self.PB:.2f} yr')
i = 0
T = [self.T1,self.T2,self.T3,self.T4]
P = [self.P1,self.P2,self.P3,self.P4]
V = [self.V1,self.V2,self.V3,self.V4]
H = [self.H1,self.H2,self.H3,self.H4]
S = [self.S1,self.S2,self.S3,self.S4]
while (i<4):
self.list_ctrl_1.SetItem(i,0,f'{i+1}')
self.list_ctrl_1.SetItem(i,1,f'{T[i]:.2f}')
self.list_ctrl_1.SetItem(i,2,f'{P[i]:.2f}')
self.list_ctrl_1.SetItem(i,3,f'{V[i]:.8f}')
self.list_ctrl_1.SetItem(i,4,f'{H[i]:.1f}')
self.list_ctrl_1.SetItem(i,5,f'{S[i]:.4f}')
i = i + 1
self.list_ctrl_1.SetItem(0,6,CP.PhaseSI('T',T[0],'Q',0,self.fluid))
self.list_ctrl_1.SetItem(1,6,CP.PhaseSI('S',S[1],'T',T[1],self.fluid))
self.list_ctrl_1.SetItem(2,6,CP.PhaseSI('T',T[2],'Q',1,self.fluid))
self.list_ctrl_1.SetItem(3,6,CP.PhaseSI('S',S[3],'T',T[3],self.fluid))
self.list_ctrl_2.SetItem(0,0,f'{self.morc:.4f} kg/s')
self.list_ctrl_2.SetItem(0,1,f'{self.msink:.4f} kg/s')
self.list_ctrl_2.SetItem(0,2,f'{self.Qö:.2f} W')
self.list_ctrl_2.SetItem(0,3,f'{self.Qb:.2f} W')
self.list_ctrl_2.SetItem(0,4,f'{self.Qevap:.2f} W')
self.list_ctrl_2.SetItem(0,5,f'{self.Qc:.2f} W')
self.list_ctrl_2.SetItem(0,6,f'{self.Teout:.2f} K')
self.list_ctrl_2.SetItem(0,7,f'{self.Tcout:.2f} K')
self.list_ctrl_2.SetItem(0,8,f'{self.Wp:.2f} W')
self.list_ctrl_2.SetItem(0,9,f'{self.Wt:.2f} W')
self.list_ctrl_2.SetItem(0,10,f'{self.Pratio:.2f} ')
self.list_ctrl_2.SetItem(0,11,f'{self.Wnet:.2f} W')
self.list_ctrl_2.SetItem(0,12,f'{self.Eff:.2f} %')
self.list_ctrl_2.SetItem(2,0,f'{self.etaevap2:.2f} %')
self.list_ctrl_2.SetItem(2,1,f'{self.etacond2:.2f} %')
self.list_ctrl_2.SetItem(2,2,f'{self.etatur2:.2f} %')
self.list_ctrl_2.SetItem(2,3,f'{self.etapump2:.2f} %')
self.list_ctrl_2.SetItem(2,4,f'{self.Ie:.2f} W')
self.list_ctrl_2.SetItem(2,5,f'{self.Ic:.2f} W')
self.list_ctrl_2.SetItem(2,6,f'{self.It:.2f} W')
self.list_ctrl_2.SetItem(2,7,f'{self.Ip:.2f} W')
self.list_ctrl_2.SetItem(2,8,f'{self.Exin:.4f} W')
self.list_ctrl_2.SetItem(2,9,f'{self.etaexergy:.2f} %')
#Plotting
pp = PropertyPlot(self.fluid, 'TS', unit_system='EUR', tp_limits='ORC')
pp.calc_isolines(CoolProp.iQ, num=11)
cycle = StateContainer()
if (T[3]==self.T1g):
cycle[0,"T"] = T[0]
cycle[0,"S"] = S[0]
cycle[1,"T"] = T[1]
cycle[1,"S"] = S[1]
cycle[3,"T"] = self.T3f
cycle[3,"S"] = self.S3f
cycle[4,"T"] = T[2]
cycle[4,"S"] = S[2]
cycle[5,"T"] = T[3]
cycle[5,"S"] = S[3]
cycle[6,"T"] = T[0]
cycle[6,"S"] = S[0]
else:
cycle[0,"T"] = T[0]
cycle[0,"S"] = S[0]
cycle[1,"T"] = T[1]
cycle[1,"S"] = S[1]
cycle[3,"T"] = self.T3f
cycle[3,"S"] = self.S3f
cycle[4,"T"] = T[2]
cycle[4,"S"] = S[2]
cycle[5,"T"] = T[3]
cycle[5,"S"] = S[3]
cycle[6,"T"] = self.T1g
cycle[6,"S"] = self.S1g
cycle[7,"T"] = T[0]
cycle[7,"S"] = S[0]
pp.draw_process(cycle)
pp.show()
pp.figure.set_size_inches(5, 5) #ORC şeması ayarlandıktan sonra T-s diyagramı buradan küçültülecek
FigureCanvas(self.plot_panel, -1, pp.figure)
plt.close()
#self.Layout()
print(cycle)
print(f"ifcond: {CP.PhaseSI('S',self.S4,'T',self.T4,self.fluid)}")
print(f"Qcon: {self.Qc}")
print(f"Tsink: {self.Tsink}")
print(f"P3: {self.P3}")
print(f"H3: {self.H3}")
print(f"H4: {self.H4}")
print(f"H4s: {self.H4s}")
print(f"morc: {self.morc}")
print(f"Tcout: {self.Tcout}")
print(f"Teout: {self.Teout}")
print(f"Tpe: {self.Tpe}")
print(f"T1: {self.T1g}")
print(f"T2: {self.T2}")
print(f"T3: {self.T3}")
print(f"T4: {self.T4}")
print(f"Qö: {self.Qö}")
print(f"Qb: {self.Qb}")
print(f"Eff: {self.Eff}")
print(f"Wnet: {self.Wnet}")
event.Skip()
except Exception as e:
if (CP.PhaseSI('S',self.S4,'T',self.T4,self.fluid) == 'twophase') and (self.fluid in {"R404A", "R407C"}):
dlg = wx.MessageDialog(None, "Two-phase values for pseudo-pure substances are not defined!", "Error!", wx.OK | wx.ICON_HAND| wx.STAY_ON_TOP, pos=wx.DefaultPosition)
dlg.CenterOnScreen
dlg.ShowModal()
return
else:
dlg = wx.MessageDialog(None, "Cycle cannot be completed! | Out of library values!", "Error!", wx.OK | wx.ICON_HAND| wx.STAY_ON_TOP, pos=wx.DefaultPosition)
dlg.CenterOnScreen
dlg.ShowModal()
return
if (self.T4<self.Tsink):
dlg = wx.MessageDialog(None, "Cycle cannot be completed! | Try different values!", "Error!", wx.OK | wx.ICON_HAND| wx.STAY_ON_TOP, pos=wx.DefaultPosition)
dlg.CenterOnScreen
dlg.ShowModal()
return
elif (CP.PhaseSI('S',S[1],'T',T[1],self.fluid) != "liquid"):
dlg = wx.MessageDialog(None, "Cycle cannot be completed! | Try different values!", "Error!", wx.OK | wx.ICON_HAND| wx.STAY_ON_TOP, pos=wx.DefaultPosition)
dlg.CenterOnScreen
dlg.ShowModal()
return
elif (self.T1>self.T4):
dlg = wx.MessageDialog(None, "Cycle cannot be completed! | Try different values!", "Error!", wx.OK | wx.ICON_HAND| wx.STAY_ON_TOP, pos=wx.DefaultPosition)
dlg.CenterOnScreen
dlg.ShowModal()
return
return
# end of class MyFrame
def _resize_image(self, target_width):
# Resmi boyutlandır (hedef genişlik ile orantılı yap)
target_height = (target_width * self.image_1.GetHeight()) // self.image_1.GetWidth()
return self.image_1.Scale(target_width, target_height, wx.IMAGE_QUALITY_HIGH).ConvertToBitmap()
def on_resize(self, event):
new_width = floor(self.GetSize()[0] / 2.6) # Yeni pencere genişliği
self.bitmap_1 = self._resize_image(new_width)
self.yellow_panel.DestroyChildren() # Sarı panel içindeki tüm bileşenleri temizle
wx.StaticBitmap(self.yellow_panel, -1, self.bitmap_1, style=wx.BORDER_SIMPLE | wx.FULL_REPAINT_ON_RESIZE)
self.sizer_3.Layout() # Sizer'ları güncelle
event.Skip()
def onComboSelect1(self, event):
self.combo_box_1 = event.GetEventObject()
self.fluid = self.combo_box_1.GetValue()
event.Skip()
def onComboSelect2(self, event):
self.evap_ht_src_unit = event.GetEventObject()
secim = self.evap_ht_src_unit.GetValue()
if secim == 'K':
self.Tunit1 = 0
elif secim == '°C':
self.Tunit1 = 273.15
event.Skip()
def onComboSelect3(self, event):
self.evap_flw_rate_unit = event.GetEventObject()
secim = self.evap_flw_rate_unit.GetValue()
if (secim == 'kg/s'):
self.Tunit2 = 1
elif (secim == 'kg/h'):
self.Tunit2 = 0.0002777778
event.Skip()
def onComboSelect4(self, event):
self.combo_box_2 = event.GetEventObject()
self.fluid = self.combo_box_2.GetValue()
event.Skip()
def onComboSelect5(self, event):
self.combo_box_3 = event.GetEventObject()
self.fluid = self.combo_box_3.GetValue()
event.Skip()
def onComboSelect6(self, event):
self.combo_box_4 = event.GetEventObject()
self.evaptype = self.combo_box_4.GetValue()
event.Skip()
def onComboSelect7(self, event):
self.combo_box_5 = event.GetEventObject()
self.condtype = self.combo_box_5.GetValue()
event.Skip()
def onComboSelect9(self, event):
self.cond_cool_temp_unit = event.GetEventObject()
secim = self.cond_cool_temp_unit.GetValue()
if secim == 'K':
self.Tunit3 = 0
elif secim == '°C':
self.Tunit3 = 273.15
event.Skip()
def OnAboutBox(self, event):
description = """ NeuORC is a preliminary organic rankine cycle calculator designed for educational purposes.
It was developed at Necmettin Erbakan University and incorporates features for designing systems.
NeuORC makes use of the CoolProp library to calculate the thermodynamic properties of fluids."""
licence = """NeuORC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation, either version 3 of the License,
or (at your option) any later version.
NeuORC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>."""
info = wx.adv.AboutDialogInfo()
info.SetIcon(wx.Icon(resource_path('Unilogo2.png'), wx.BITMAP_TYPE_PNG))
info.SetName('NeuORC')
info.SetVersion('v1.0')
info.SetDescription(description)
info.SetCopyright('''(C) 2007 - 2023 Mehmet Berk Azdural
Academic Advisors:
Prof. Ali Kahraman
Asst. Prof. Sadık Ata''')
info.SetWebSite("mazdural@gmail.com")
info.SetLicence(licence)
wx.adv.AboutBox(info)
#class MyFrame(wx.Frame):
class MyApp(wx.App):
def OnInit(self):
self.frame = MyFrame()
self.SetTopWindow(self.frame)
self.frame.Show()
return True
# end of class MyApp
if __name__ == "__main__":
app = MyApp(0)
app.MainLoop()