-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathCodeLibrary.py
4359 lines (3299 loc) · 249 KB
/
CodeLibrary.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
from fileinput import filename
import os
from re import A
from tokenize import String
from typing import Union, Dict, Literal
import win32com.client as win32
import numpy as np
import time
#from scripy import optimize
"""Created on the 24.05.2022
@author: Richard ten Hagen
@author contact: [email protected]
API for controlling the Aspen Python Interface automatically
If you change it, update it, fix something just email me such that I can also update my version to keep it as coherent as possible
"""
class Simulation():
"""Class which starts a Simulation interface instance
Args:
AspenFileName: Name of the Aspenfile on which you are working with
WorkingDirectoryPath: Path to the Folder where we will be working
VISIBITLITY: Toggles the opening and interactive running of the Aspen simulation
"""
AspenSimulation = win32.gencache.EnsureDispatch("Apwn.Document")
def __init__(self, AspenFileName:str, WorkingDirectoryPath:str, VISIBILITY:bool = True):
print("The current Directory is : ")
print(os.getcwd()) #Returns the Directory where it is currently working
os.chdir(WorkingDirectoryPath) #Changes the Directory to ..../AspenSimulation
print("The new Directory where you should also have your Aspen file is : ")
print(os.getcwd())
self.AspenSimulation.InitFromArchive2(os.path.abspath(AspenFileName))
print("The Aspen is active now. If you dont want to see aspen open again take VISIBITLY as False \n")
self.AspenSimulation.Visible = VISIBILITY
def CloseAspen(self):
AspenFileName = self.Give_AspenDocumentName()
print(AspenFileName)
self.AspenSimulation.Close(os.path.abspath(AspenFileName))
print("\nAspen should be closed now")
#This just shortens the path you need to call for Streams and Blocks
@property
def BLK(self):
"""Property: Defines Path to the Block node in Aspen File system.
Aspendocument is defined in the Class Simulation initialization
"""
return self.AspenSimulation.Tree.Elements("Data").Elements("Blocks")
@property
def STRM(self):
"""Property: Defines Path to the Streamnode node in Aspen File system.
Aspendocument is defined in the Class Simulation initialization
"""
return self.AspenSimulation.Tree.Elements("Data").Elements("Streams")
#Type definition to simplify the type hinting:
Phnum = Literal[1,2,3]
Ph = Literal["L", "V", "S"]
##############################################################################################################################
#PPPPPPPPPPPPP OOOOOOOOOoOOOO W W Eeeeeeeeeeeeeee RRRRRRRRRRRRRRR
# P O O W W E R R
# P O O W W E R R
# P O O W W W E R R
# P O O W W w E RRRRRRRRRRRRRRRR
#PPPPPPPPPPPP O O W W W Eeeeeeeeeeeeeee RR
# O O W W W E R R
# O O W W W W E R R
# O O W W W W E R R
# O O W W W W E R R
# OOOOOOOOOOOOOOO W W Eeeeeeeeeeeeeee R R
###################################################################################################################################
####Generalized Powerfunctions:
#Related to Placing Blocks, connecting, removing and such things:
def BlockDelete(self, Blockname:str) ->None:
"""Removes Block with given Name from the Aspen Simulation
All data (Input+Outputs+Simulationdata+InitialValues) connected to this Block will be deleted in Aspen.
"""
self.BLK.Elements.Remove(Blockname)
def BlockPlace(self, Blockname:str, EquipmentType: Literal["RCSTR", "RPlug", "DSTWU", "Flash2", "Mixer", "Heater", "Radfrac", "Splitter", "RYield"])-> None:
"""Adds only a BLOCK with given Name on the Aspen Simulation Sheet.
No data (Input+Outputs+Simulationdata+InitialValues) are added yet. The Block is "empty".
Args:
Blockname: which contains the Name of the Stream in Aspen
EquipmentType: Name of Equipment in Aspen. Can be: "RCSTR", "RPlug", "DSTWU", "Flash2", "Mixer", "Heater", "Radfrac", "Splitter", "RYield",
"""
compositstring = Blockname + "!" + EquipmentType
print(compositstring)
self.BLK.Elements.Add(compositstring)
def StreamPlace(self, Streamname:str, Streamtype: Literal["MATERIAL", "HEAT", ""]) -> None: #Stream types are: "MATERIAL", "HEAT" or ""
"""Adds only a STREAM with given Name on the Aspen Simulation Sheet.
No data (Input+Outputs+Simulationdata+InitialValues) are added yet. The Stream is "empty"
Args:
Streamname: String which contains the Name of the Stream in Aspen
Streamtype: Can be "MATERIAL", "HEAT" or ""
"""
compositstring = Streamname + "!" + Streamtype
print(compositstring)
self.STRM.Elements.Add(compositstring)
def StreamDelete(self, Streamname:str) -> None:
"""Removes STREAM with given Name from the Aspen Simulation
All data (Input+Outputs+Simulationdata+InitialValues) connected to this STREAM will be deleted in Aspen.
Args:
Streamname: String which contains the Name of the Stream in Aspen
"""
self.STRM.Elements.Remove(Streamname)
def StreamConnect(self, Blockname:str, Streamname:str, Portname:str) -> None: #Portnames for destillation column is: "D(OUT)" , "B(OUT)", "F(IN)"
"""Connects Block with given Stream
Args:
Blockname: String which contains the Name of the Block in Aspen
Streamname: String which contains the Name of the Stream in Aspen
Portnames: String which could be for example: "D(OUT)" , "B(OUT)", "F(IN)
"""
self.BLK.Elements(Blockname).Elements("Ports").Elements(Portname).Elements.Add(Streamname)
def StreamDisconnect(self, Blockname:str, Streamname:str, Portname:str) -> None: #Portnames for destillation column is: "D(OUT)" , "B(OUT)", "F(IN)"
"""Disconnects Block from given Stream
Args:
Blockname: String which contains the Name of the Block in Aspen
Streamname: String which contains the Name of the Stream in Aspen
Portnames: String which could be for example: "D(OUT)" , "B(OUT)", "F(IN)
"""
self.BLK.Elements(Blockname).Elements("Ports").Elements(Portname).Elements.Remove(Streamname)
def StreamDeleteALL(self) -> None:
"""Removes ALL STREAMS from the Aspen Simulation
All data (Input+Outputs+Simulationdata+InitialValues) connected to this Block will be deleted in Aspen.
"""
self.STRM.RemoveAll
def BlockDeleteALL(self) -> None:
"""Removes ALL BLOCKS from the Aspen Simulation
All data (Input+Outputs+Simulationdata+InitialValues) connected to this Block will be deleted in Aspen.
"""
self.BLK.RemoveAll
#POWERFUNCTION for Running the Simulation:
def VisibilityChange(self,VISIBILITY: bool) -> None:
""" De/Activates Aspensheet graphics from being rendered.
Args:
Visibility: String "FALSE" for more speed or "TRUE" for manual usage of Aspen
"""
self.AspenSimulation.Visible = VISIBILITY
def SheetCheckIfInputsAreComplete(self) -> bool:
"""Check if all Inputs are given on the entire Sheet, returns "0x00002081 = HAP_RESULTS_SUCCESS|HAP_INPUT_COMPLETE|HAP_ENABLED"
Checks if the Aspen Expert system thinks all necessary Inputs are given and the Simulation can be run
Args:
Blockname: String which contains the Name of the Block in Aspen
return: TRUE or FALSE????????????
"""
return self.AspenSimulation.COMPSTATUS
def BlockCheckIfInputsAreComplete(self, Blockname: str) -> bool:
"""
Checks if the Aspen Expert system thinks all necessary Inputs are given and the Simulation can be run
Args:
Blockname: String which contains the Name of the Block in Aspen
return: TRUE or FALSE????????????
"""
return self.BLK.Elements(Blockname).COMPSTATUS
def StreamCheckIfInputsAreComplete(self, Streamname:str) -> bool:
"""
Checks if the Aspen Expert system thinks all necessary Inputs are given and the Simulation can be run
Args:
Streamname: String which contains the Name of the Block in Aspen
return: TRUE or FALSE????????????
"""
return self.STRM.Elements(Streamname).COMPSTATUS
def Give_AspenDocumentName(self) -> String:
"""Returns name of Aspen document"""
return self.AspenSimulation.FullName
def DialogSuppression(self, TrueOrFalse: bool) -> None:
"""Supresses Aspen Popups
Args:
TrueOrFalse: can be True or False """
self.AspenSimulation.SuppressDialogs = TrueOrFalse
def EngineRun(self) -> None:
"""Runs Simulation, synonymous with pressing the playbutton"""
self.AspenSimulation.Run2()
def EngineStop(self) -> None:
"""Stops Simulation, synonymous to pressing the red square button"""
self.AspenSimulation.Stop()
def EngineReinit(self) -> None:
"""Reinitalizes the Entire Simulation, synonymous to pressing the Reset button
Other possible functions you might need are: BlockReinit(Blockname), StreamReinit(Streamname)
"""
self.AspenSimulation.Reinit()
def BlockReinit(self, Blockname:str) -> None:
"""Reinitalizes the Block with given Name,
Synonymous to pressing the Reset button, Other possible functions you might need are: BlockReinit(Blockname), StreamReinit(Streamname), EngineReinit()
Args:
Blockname: String which contains the Name of the Block in Aspen
"""
self.BLK.Elements(Blockname).Reinit()
def StreamReinit(self, Streamname:str) -> None:
"""Reinitalizes the Stream with given Name,
Synonymous to pressing the Reset button, Other possible functions you might need are: BlockReinit(Blockname), StreamReinit(Streamname), EngineReinit()
Args:
Streamname: String which contains the Name of the Stream in Aspen
"""
self.STRM.Elements(Streamname).Reinit()
#def EngineGiveSettings(self):
# return self.AspenSimulation.EngineFilesSettings????
#POWERFUNCTION for Saving Reports and such things
def Save(self) -> None:
"""Saves Current Simulation (.apw), Inputs and all Values connected to it."""
self.AspenSimulation.Save()
def SaveAs(self, Filename:str, overwrite:bool = True) -> None:
"""Saves the current Aspen Simulation,(.apw) with a new name with/out overwritting.
Args:
Filename: String which gives the File name.
overwrite: Should file be overwritten when the File already exists? True or False, standard is True
"""
self.AspenSimulation.SaveAs(Filename, overwrite)
def ExportBackupFile(self, filename:str) -> None:
"""Saves BackupFile (.bkp) of Aspen Simulation with a given name.
Args:
Filename: String which gives the File name.
"""
self.AspenSimulation.Export(1, filename)
def ExportReportFile(self, filename:str) -> None:
"""Saves ReportFile (.rep or .txt) of Aspen Simulation with a given name.
Args:
Filename: String which gives the File name.
"""
self.AspenSimulation.Export(2, filename)
def ExportSummaryFile(self, filename:str) -> None:
"""Saves SummaryFile (.sum) of Aspen Simulation with a given name.
Args:
Filename: String which gives the File name.
"""
self.AspenSimulation.Export(3, filename)
def ExportInputFile(self, filename:str) -> None:
"""Saves InputFile (.inp aka txt) of Aspen Simulation with a given name.
Args:
Filename: String which gives the File name.
"""
self.AspenSimulation.Export(4, filename) #"HAPEXP_INPUT"
def ExportInputFileWithGraphics(self, filename:str) -> None:
"""Saves InputFile (.inp aka txt) of Aspen Simulation with a given name.
Args:
Filename: String which gives the File name.
"""
self.AspenSimulation.Export(5, filename)
def ExportRunMessagesFile(self, filename:str) -> None:
"""Saves Messages, Errors, Warnings and diagnostics from running the Simulation for each run.
Args:
Filename: String which gives the File name.
"""
self.AspenSimulation.Export(6, filename)
def ExportFlowDrivenDynamicSimulationFile(self, filename:str) -> None:
"""Export a Flowdriven simulation report
Args:
Filename: String which gives the File name.
"""
self.AspenSimulation.Export(9, filename)
def ExportPressureDrivenDynamicSimulationFile(self, filename:str) -> None:
"""Export a Pressure driven simulation report
Args:
Filename: String which gives the File name.
"""
self.AspenSimulation.Export(10, filename)
def ExportFlowsheetdrawingFile(self, filename:str) -> None:
"""Export a Drawing of the Flowsheet
Args:
Filename: String which gives the File name.
"""
self.AspenSimulation.Export(11, filename) #"HAPEXP_DXF"
########################################################################################################################################
########### N N PPPPPPPPPPP U U TTTTTTTTTTTTTTTTTTTTTTTT
# N N N P P U U T
# N N N P P U U T
# N N N P P U U T
# N N N PPPPPPPPPPP U U T
# N N N P U U T
# N N N P U U T
# N N N P U U T
########### N N P UUUUUUUUUUUUUUUUU T
############################################################################################################################################
###DSTWU
def BLK_DSTWU_GET_ME_ALL_INPUTS_BACK(self, Blockname:str) -> Dict[str, Union[str,float,int]]:
"""Retrieves all the Inputs and returns Dictionary with Values
Does not include all aspects of a Aspen Simulationsheet, for this look at Exports
Args:
Blockname: String which gives the name of Block.
"""
StageRefluxOption = self.BLK.Elements(Blockname).Elements("Input").Elements("OPT_NTRR").Value
NumberOfStages = self.BLK.Elements(Blockname).Elements("Input").Elements("NSTAGE").Value
RefluxRatio = self.BLK.Elements(Blockname).Elements("Input").Elements("RR").Value
CondenserPressure = self.BLK.Elements(Blockname).Elements("Input").Elements("PTOP").Value
ReboilerPressure = self.BLK.Elements(Blockname).Elements("Input").Elements("PBOT").Value
LightkeyComponent = self.BLK.Elements(Blockname).Elements("Input").Elements("LIGHTKEY").Value
HeavykeyComponent = self.BLK.Elements(Blockname).Elements("Input").Elements("HEAVYKEY").Value
LightkeyRecovery = self.BLK.Elements(Blockname).Elements("Input").Elements("RECOVL").Value
HeavykeyRecovery = self.BLK.Elements(Blockname).Elements("Input").Elements("RECOVH").Value
CondenserOption = self.BLK.Elements(Blockname).Elements("Input").Elements("OPT_RDV").Value
DestillVaporFraction = self.BLK.Elements(Blockname).Elements("Input").Elements("RDV").Value
GenerateTableOption = self.BLK.Elements(Blockname).Elements("Input").Elements("PLOT").Value
GenerateTable_FirstStage = self.BLK.Elements(Blockname).Elements("Input").Elements("LOWER").Value
GenerateTable_LastStage = self.BLK.Elements(Blockname).Elements("Input").Elements("UPPER").Value
GenerateTable_StageNumber = self.BLK.Elements(Blockname).Elements("Input").Elements("NPOINT").Value
CalculateHeightequivalentHETP_Option = self.BLK.Elements(Blockname).Elements("Input").Elements("OPT_CALHETP").Value
CalculateHeightequivalentHETP_PackedHeight = self.BLK.Elements(Blockname).Elements("Input").Elements("PACK_HEIGHT").Value
FreewaterOption = self.BLK.Elements(Blockname).Elements("Input").Elements("BLKOPFREWAT").Value
MaxNumberFlashIterations = self.BLK.Elements(Blockname).Elements("Input").Elements("MAXIT").Value
FlashConvergenceTolerance =self.BLK.Elements(Blockname).Elements("Input").Elements("FLASH_TOL").Value
MaxNumberMinStageIterations = self.BLK.Elements(Blockname).Elements("Input").Elements("MAXIT").Value
KvalueTolerance = self.BLK.Elements(Blockname).Elements("Input").Elements("K_TOL").Value
ProductTempTolerance = self.BLK.Elements(Blockname).Elements("Input").Elements("TEMP_TOL").Value
Dictionary = {
"StageRefluxOption": StageRefluxOption,
"NumberOfStages" : NumberOfStages,
"RefluxRatio":RefluxRatio,
"CondenserPressure":CondenserPressure,
"ReboilerPressure":ReboilerPressure,
"LightkeyComponent":LightkeyComponent,
"HeavykeyComponent":HeavykeyComponent,
"LightkeyRecovery":LightkeyRecovery,
"HeavykeyRecovery":HeavykeyRecovery,
"CondenserOption":CondenserOption,
"DestillVaporFraction":DestillVaporFraction,
"GenerateTableOption":GenerateTableOption,
"GenerateTable_FirstStage":GenerateTable_FirstStage,
"GenerateTable_LastStage":GenerateTable_LastStage,
"GenerateTable_StageNumber":GenerateTable_StageNumber,
"CalculateHeightequivalentHETP_Option" : CalculateHeightequivalentHETP_Option,
"alculateHeightequivalentHETP_CPackedHeight":CalculateHeightequivalentHETP_PackedHeight,
"FreewaterOption":FreewaterOption,
"MaxNumberFlashIterations":MaxNumberFlashIterations,
"FlashConvergenceTolerance":FlashConvergenceTolerance,
"MaxNumberMinStageIterations":MaxNumberMinStageIterations,
"KvalueTolerance":KvalueTolerance,
"ProductTempTolerance":ProductTempTolerance,
}
return Dictionary
def BLK_DSTWU_SET_ALL_INPUTS(self, Blockname:str, Dictionary: Dict[str, Union[str,float,int]] ) ->None:
"""Takes Dictionary with Values set the ones which are given in Aspen.
The Original Dictionary with its specific format can be found via "BLK_DSTWU_GET_ME_ALL_INPUTS_BACK"
Args:
Blockname: String which gives the name of Block.
Dictionary: Dictionary which contains all the Input variables.
"""
try:
self.BLK.Elements(Blockname).Elements("Input").Elements("OPT_NTRR").Value = Dictionary.get("StageRefluxOption")
try:
self.BLK.Elements(Blockname).Elements("Input").Elements("NSTAGE").Value = Dictionary.get("NumberOfStages")
except Exception:
pass
try:
self.BLK.Elements(Blockname).Elements("Input").Elements("RR").Value = Dictionary.get("RefluxRatio")
except Exception:
pass
self.BLK.Elements(Blockname).Elements("Input").Elements("PTOP").Value = Dictionary.get("CondenserPressure")
self.BLK.Elements(Blockname).Elements("Input").Elements("PBOT").Value = Dictionary.get("ReboilerPressure")
self.BLK.Elements(Blockname).Elements("Input").Elements("LIGHTKEY").Value = Dictionary.get("LightkeyComponent")
self.BLK.Elements(Blockname).Elements("Input").Elements("HEAVYKEY").Value = Dictionary.get("HeavykeyComponent")
self.BLK.Elements(Blockname).Elements("Input").Elements("RECOVL").Value = Dictionary.get("LightkeyRecovery")
self.BLK.Elements(Blockname).Elements("Input").Elements("RECOVH").Value = Dictionary.get("HeavykeyRecovery")
self.BLK.Elements(Blockname).Elements("Input").Elements("OPT_RDV").Value = Dictionary.get("CondenserOption")
self.BLK.Elements(Blockname).Elements("Input").Elements("RDV").Value = Dictionary.get("DestillVaporFraction")
self.BLK.Elements(Blockname).Elements("Input").Elements("PLOT").Value = Dictionary.get("GenerateTableOption")
try:
self.BLK.Elements(Blockname).Elements("Input").Elements("LOWER").Value = Dictionary.get("GenerateTable_FirstStage")
self.BLK.Elements(Blockname).Elements("Input").Elements("UPPER").Value = Dictionary.get("GenerateTable_LastStage")
except Exception:
pass
self.BLK.Elements(Blockname).Elements("Input").Elements("NPOINT").Value = Dictionary.get("GenerateTable_StageNumber")
self.BLK.Elements(Blockname).Elements("Input").Elements("OPT_CALHETP").Value = Dictionary.get("CalculateHeightequivalentHETP_Option")
try:
self.BLK.Elements(Blockname).Elements("Input").Elements("PACK_HEIGHT").Value = Dictionary.get("CalculateHeightequivalentHETP_PackedHeight")
except Exception:
pass
self.BLK.Elements(Blockname).Elements("Input").Elements("BLKOPFREWAT").Value = Dictionary.get("FreewaterOption")
self.BLK.Elements(Blockname).Elements("Input").Elements("FLASH_MAXIT").Value = Dictionary.get("MaxNumberFlashIterations")
self.BLK.Elements(Blockname).Elements("Input").Elements("FLASH_TOL").Value = Dictionary.get("FlashConvergenceTolerance")
self.BLK.Elements(Blockname).Elements("Input").Elements("MAXIT").Value = Dictionary.get("MaxNumberMinStageIterations")
self.BLK.Elements(Blockname).Elements("Input").Elements("K_TOL").Value = Dictionary.get("KvalueTolerance")
self.BLK.Elements(Blockname).Elements("Input").Elements("TEMP_TOL").Value = Dictionary.get("ProductTempTolerance")
except Exception:
pass
###DSTWU
#PAGE 1 Specification:
#Choice between giving Number of Stages or Refluxratio:
def BLK_DSTWU_Set_StageRefluxOption(self,Blockname:str, StageRefluxOption: Literal["NSTAGE", "RR"]) -> None: #you can chose NSTAGE or RR
self.BLK.Elements(Blockname).Elements("Input").Elements("OPT_NTRR").Value = StageRefluxOption
#if you chose: NSTAGE
def BLK_DSTWU_Set_NumberOfStages(self,Blockname, nstages):
self.BLK.Elements(Blockname).Elements("Input").Elements("NSTAGE").Value = nstages
#if you chose: RR
def BLK_DSTWU_Set_Refluxratio(self,Blockname, Refluxratio):
self.BLK.Elements(Blockname).Elements("Input").Elements("RR").Value = Refluxratio
def BLK_DSTWU_Set_CondenserPressure(self, Blockname, CondenserPressure):
self.BLK.Elements(Blockname).Elements("Input").Elements("PTOP").Value = CondenserPressure
def BLK_DSTWU_Set_ReboilerPressure(self, Blockname, ReboilerPressure):
self.BLK.Elements(Blockname).Elements("Input").Elements("PBOT").Value = ReboilerPressure
def BLK_DSTWU_Set_LightkeyComponent(self, Blockname,LightkeyComponent):
self.BLK.Elements(Blockname).Elements("Input").Elements("LIGHTKEY").Value = LightkeyComponent
def BLK_DSTWU_Set_HeavykeyComponent(self, Blockname,HeavykeyComponent):
self.BLK.Elements(Blockname).Elements("Input").Elements("HEAVYKEY").Value = HeavykeyComponent
def BLK_DSTWU_Set_LightkeyRecovery(self, Blockname,LightkeyRecovery):
self.BLK.Elements(Blockname).Elements("Input").Elements("RECOVL").Value = LightkeyRecovery
def BLK_DSTWU_Set_HeavykeyRecovery(self, Blockname,HeavykeyRecovery):
self.BLK.Elements(Blockname).Elements("Input").Elements("RECOVH").Value = HeavykeyRecovery
#Choice between Condenser specification
def BLK_DSTWU_Set_CondenserOption(self, Blockname:str, CondenserOption: Literal["LIQUID", "VAPOR", "VAPLIQ"]): #LIQUID VAPOR or VAPLIQ
self.BLK.Elements(Blockname).Elements("Input").Elements("OPT_RDV").Value = CondenserOption
#if you chose: LIQUID or VAPOR:
#you dont need to add anything
#if you chose: VAPLIQ:
def BLK_DSTWU_Set_VAPLIQ_DestillVaporFraction(self, Blockname, DestillVaporFraction):
self.BLK.Elements(Blockname).Elements("Input").Elements("RDV").Value = DestillVaporFraction
#PAGE 2 Calculation Options:
def BLK_DSTWU_Set_GenerateTableOption(self, Blockname:str, GenerateTableOption: Literal["YES", "NO"]) -> None: #YES or NO
self.BLK.Elements(Blockname).Elements("Input").Elements("PLOT").Value = GenerateTableOption
#if you chose YES then you need to input this:
def BLK_DSTWU_Set_GenerateTable_FirstStage(self, Blockname, FirstStage):
self.BLK.Elements(Blockname).Elements("Input").Elements("LOWER").Value = FirstStage
def BLK_DSTWU_Set_GenerateTable_LastStage(self, Blockname, LastStage):
self.BLK.Elements(Blockname).Elements("Input").Elements("UPPER").Value = LastStage
def BLK_DSTWU_Set_GenerateTable_StageNumber(self, Blockname, StageNumber):
self.BLK.Elements(Blockname).Elements("Input").Elements("NPOINT").Value = StageNumber
def BLK_DSTWU_Set_CalculateHeightequivalentHETP_Option(self, Blockname:str, CalculateHeightequivalentHETP_Option: Literal["YES", "NO"]) -> None: #YES or NO
self.BLK.Elements(Blockname).Elements("Input").Elements("OPT_CALHETP").Value = CalculateHeightequivalentHETP_Option
#if you chose YES then you need to input this:
def BLK_DSTWU_Set_CalculateHeightequivalentHETP_PackedHeight(self, Blockname:str, PackedHeight: Literal["YES", "NO"]) -> None: #YES or NO
self.BLK.Elements(Blockname).Elements("Input").Elements("PACK_HEIGHT").Value = PackedHeight
#PAGE 3 Convergence:
def BLK_DSTWU_Set_FreewaterOption(self, Blockname:str, FreewaterOption: Literal["YES", "NO", "DIRTY"]) -> None: #This can be YES, NO, DIRTY
self.BLK.Elements(Blockname).Elements("Input").Elements("BLKOPFREWAT").Value = FreewaterOption
def BLK_DSTWU_Set_MaxNumberFlashIterations(self, Blockname, MaxNumberFlashIterations):
self.BLK.Elements(Blockname).Elements("Input").Elements("FLASH_MAXIT").Value = MaxNumberFlashIterations
def BLK_DSTWU_Set_FlashConvergenceTolerance(self, Blockname, FlashConvergenceTolerance):
self.BLK.Elements(Blockname).Elements("Input").Elements("FLASH_TOL").Value = FlashConvergenceTolerance
def BLK_DSTWU_Set_MaxNumberMinStageIterations(self, Blockname, MaxNumberMinStageIterations):
self.BLK.Elements(Blockname).Elements("Input").Elements("MAXIT").Value = MaxNumberMinStageIterations
def BLK_DSTWU_Set_KvalueTolerance(self, Blockname, KvalueTolerance):
self.BLK.Elements(Blockname).Elements("Input").Elements("K_TOL").Value = KvalueTolerance
def BLK_DSTWU_Set_ProductTempTolerance(self, Blockname, ProductTempTolerance):
self.BLK.Elements(Blockname).Elements("Input").Elements("TEMP_TOL").Value = ProductTempTolerance
def BLK_MIXER_GET_ME_ALL_INPUTS_BACK(self, Blockname:str) -> Dict[str, Union[str,float,int]]:
"""Retrieves all the Inputs and returns Dictionary with Values
Does not include all aspects of a Aspen Simulationsheet, for this look at Exports
Args:
Blockname: String which gives the name of Block.
"""
Pressure = self.BLK.Elements(Blockname).Elements("Input").Elements("PRES").Value
Phase = self.BLK.Elements(Blockname).Elements("Input").Elements("Phase").Value #This can be V L or S
Nphase = self.BLK.Elements(Blockname).Elements("Input").Elements("NPhase").Value
TemperatureEstimation = self.BLK.Elements(Blockname).Elements("Input").Elements("T_EST").Value
MaximumIterations = self.BLK.Elements(Blockname).Elements("Input").Elements("MAXIT").Value
ErrorTolerance = self.BLK.Elements(Blockname).Elements("Input").Elements("TOL").Value
Dictionary = {
"Pressure": Pressure ,
"Phase" : Phase ,
"Nphase": Nphase,
"TemperatureEstimate": TemperatureEstimation ,
"MaximumIterations": MaximumIterations ,
"ErrorTolerance": ErrorTolerance ,
}
return Dictionary
def BLK_MIXER_SET_ALL_INPUTS(self, Blockname:str, Dictionary: Dict[str, Union[str,float,int]]) -> None:
"""Takes Dictionary with Values set the ones which are given in Aspen.
The Original Dictionary with its specific format can be found via "BLK_DSTWU_GET_ME_ALL_INPUTS_BACK"
Args:
Blockname: String which gives the name of Block.
Dictionary: Dictionary which contains all the Input variables.
"""
self.BLK.Elements(Blockname).Elements("Input").Elements("PRES").Value = Dictionary.get("Pressure")
self.BLK.Elements(Blockname).Elements("Input").Elements("Phase").Value = Dictionary.get("Phase") #This can be V L or S
self.BLK.Elements(Blockname).Elements("Input").Elements("NPhase").Value = Dictionary.get("Nphase")
self.BLK.Elements(Blockname).Elements("Input").Elements("T_EST").Value = Dictionary.get("TemperatureEstimate")
self.BLK.Elements(Blockname).Elements("Input").Elements("MAXIT").Value = Dictionary.get("MaximumIteration")
self.BLK.Elements(Blockname).Elements("Input").Elements("TOL").Value = Dictionary.get("ErrorTolerance")
##MIXER:
def BLK_MIXER_Set_Pressure(self, Blockname:str, Pressure:float):
self.BLK.Elements(Blockname).Elements("Input").Elements("PRES").Value = Pressure
def BLK_MIXER_Set_Phases(self, Blockname:str, Phase: Ph, Phasenumber: Phnum):
self.BLK.Elements(Blockname).Elements("Input").Elements("Phase").Value = Phase #This can be V L or S
self.BLK.Elements(Blockname).Elements("Input").Elements("NPhase").Value = Phasenumber
def BLK_MIXER_Set_TemperatureEstimate(self, Blockname:str, TempEstimate:float): #OPTIONAL
self.BLK.Elements(Blockname).Elements("Input").Elements("T_EST").Value = TempEstimate
def BLK_MIXER_Set_MaximumIteration(self, Blockname:str, MaximumIteration:int): #OPTIONAL
self.BLK.Elements(Blockname).Elements("Input").Elements("MAXIT").Value = MaximumIteration
def BLK_MIXER_Set_ErrorTolerance(self, Blockname:str, ErrorTolerance:float): #OPTIONAL
self.BLK.Elements(Blockname).Elements("Input").Elements("TOL").Value = ErrorTolerance
def BLK_HEATER_GET_ME_ALL_INPUTS_BACK(self, Blockname:str) -> Dict[str, Union[str,float,int]]:
"""Retrieves all the Inputs and returns Dictionary with Values
Does not include all aspects of a Aspen Simulationsheet, for this look at Exports
Args:
Blockname: String which gives the name of Block.
"""
FlashTypeOption =self.BLK.Elements(Blockname).Elements("Input").Elements("SPEC_OPT").Value
Temperature =self.BLK.Elements(Blockname).Elements("Input").Elements("TEMP").Value
TemperatureChange =self.BLK.Elements(Blockname).Elements("Input").Elements("DELT").Value
DegreesSuperheating =self.BLK.Elements(Blockname).Elements("Input").Elements("DEGSUP").Value
DegreesSubcooling =self.BLK.Elements(Blockname).Elements("Input").Elements("DEGSUB").Value
Pressure =self.BLK.Elements(Blockname).Elements("Input").Elements("PRES").Value
Duty =self.BLK.Elements(Blockname).Elements("Input").Elements("DUTY").Value
Vaporfraction =self.BLK.Elements(Blockname).Elements("Input").Elements("VFRAC").Value
PressureDropCorrelation =self.BLK.Elements(Blockname).Elements("Input").Elements("DPPARM").Value
Phase =self.BLK.Elements(Blockname).Elements("Input").Elements("Phase").Value #This can be V L or S
Phasenumber =self.BLK.Elements(Blockname).Elements("Input").Elements("NPhase").Value #This can be 1,2,3
TemperatureEstimation =self.BLK.Elements(Blockname).Elements("Input").Elements("T_EST").Value
PressureEstimation =self.BLK.Elements(Blockname).Elements("Input").Elements("P_EST").Value
MaximumIteration =self.BLK.Elements(Blockname).Elements("Input").Elements("MAXIT").Value
ErrorTolerance = self.BLK.Elements(Blockname).Elements("Input").Elements("TOL").Value
Dictionary = {
"FlashTypeOption": FlashTypeOption ,
"Temperature" : Temperature ,
"TemperatureChange": TemperatureChange,
"DegreesSuperheating": DegreesSuperheating ,
"DegreesSubcooling": DegreesSubcooling ,
"Pressure": Pressure ,
"Duty": Duty ,
"Vaporfraction": Vaporfraction ,
"PressureDropCorrelation": PressureDropCorrelation ,
"Phase": Phase ,
"Phasenumber": Phasenumber ,
"TemperatureEstimation": TemperatureEstimation ,
"PressureEstimation": PressureEstimation ,
"MaximumIteration": MaximumIteration ,
"ErrorTolerance": ErrorTolerance,
}
return Dictionary
def BLK_HEATER_SET_ALL_INPUTS(self, Blockname:str, Dictionary: Dict[str, Union[str,float,int]]) -> None:
"""Takes Dictionary with Values set the ones which are given in Aspen.
The Original Dictionary with its specific format can be found via "BLK_DSTWU_GET_ME_ALL_INPUTS_BACK"
Args:
Blockname: String which gives the name of Block.
Dictionary: Dictionary which contains all the Input variables.
"""
self.BLK.Elements(Blockname).Elements("Input").Elements("SPEC_OPT").Value = Dictionary.get("FlashTypeOption")
self.BLK.Elements(Blockname).Elements("Input").Elements("TEMP").Value = Dictionary.get("Temperature")
self.BLK.Elements(Blockname).Elements("Input").Elements("DELT").Value = Dictionary.get("TemperatureChange")
self.BLK.Elements(Blockname).Elements("Input").Elements("DEGSUP").Value = Dictionary.get("DegreesSuperheating")
self.BLK.Elements(Blockname).Elements("Input").Elements("DEGSUB").Value = Dictionary.get("DegreesSubcooling")
self.BLK.Elements(Blockname).Elements("Input").Elements("PRES").Value = Dictionary.get("Pressure")
self.BLK.Elements(Blockname).Elements("Input").Elements("DUTY").Value = Dictionary.get("Duty")
self.BLK.Elements(Blockname).Elements("Input").Elements("VFRAC").Value = Dictionary.get("Vaporfraction")
self.BLK.Elements(Blockname).Elements("Input").Elements("DPPARM").Value = Dictionary.get("PressureDropCorrelation")
self.BLK.Elements(Blockname).Elements("Input").Elements("Phase").Value = Dictionary.get("Phase") #This can be V L or S
self.BLK.Elements(Blockname).Elements("Input").Elements("NPhase").Value = Dictionary.get("Phasenumber") #This can be 1,2,3
self.BLK.Elements(Blockname).Elements("Input").Elements("T_EST").Value = Dictionary.get("TemperatureEstimation")
self.BLK.Elements(Blockname).Elements("Input").Elements("P_EST").Value = Dictionary.get("PressureEstimation")
self.BLK.Elements(Blockname).Elements("Input").Elements("MAXIT").Value = Dictionary.get("MaximumIteration")
self.BLK.Elements(Blockname).Elements("Input").Elements("TOL").Value = Dictionary.get("ErrorTolerance")
## HEATER
#Page 1 Flash specification
def BLK_HEATER_Set_FlashTypeOption(self, Blockname:str, FlashTypeOption: Literal["TP", "TD", "TV", "TDPPARM", "PD", "PV", "PDT" , "PDEGSUP", "PDEGSUB", "DDPPARM", "VDPPARM", "DEGSUPDPPARM", "DEGSUBDPPARM", "DTV", "DTD", "DTDPPARM"]) -> None: #You can chose between: TP, TD, TV, TDPPARM, PD, PV, PDT,PDEGSUP, PDEGSUB, DDPPARM, VDPPARM, DEGSUPDPPARM, DEGSUBDPPARM, DTV, DTD, DTDPPARM
self.BLK.Elements(Blockname).Elements("Input").Elements("SPEC_OPT").Value = FlashTypeOption
def BLK_HEATER_Set_Temperature(self, Blockname, Temperature):
self.BLK.Elements(Blockname).Elements("Input").Elements("TEMP").Value = Temperature
def BLK_HEATER_Set_TemperatureChange(self, Blockname, TemperatureChange):
self.BLK.Elements(Blockname).Elements("Input").Elements("DELT").Value =TemperatureChange
def BLK_HEATER_Set_DegreesSuperheating(self, Blockname, DegreesSuperheating):
self.BLK.Elements(Blockname).Elements("Input").Elements("DEGSUP").Value = DegreesSuperheating
def BLK_HEATER_Set_DegreesSubcooling(self, Blockname, DegreesSubcooling):
self.BLK.Elements(Blockname).Elements("Input").Elements("DEGSUB").Value = DegreesSubcooling
def BLK_HEATER_Set_Pressure(self, Blockname, Pressure):
self.BLK.Elements(Blockname).Elements("Input").Elements("PRES").Value = Pressure
def BLK_HEATER_Set_Duty(self, Blockname, Duty):
self.BLK.Elements(Blockname).Elements("Input").Elements("DUTY").Value = Duty
def BLK_HEATER_Set_Vaporfraction(self, Blockname, Vaporfraction):
self.BLK.Elements(Blockname).Elements("Input").Elements("VFRAC").Value = Vaporfraction
def BLK_HEATER_Set_PressureDropCorrelation(self, Blockname, PressureDropCorrelation):
self.BLK.Elements(Blockname).Elements("Input").Elements("DPPARM").Value = PressureDropCorrelation
def BLK_HEATER_Set_Phases(self, Blockname:str, Phase: Ph, Phasenumber: Phnum) -> None:
self.BLK.Elements(Blockname).Elements("Input").Elements("Phase").Value = Phase #This can be V L or S
self.BLK.Elements(Blockname).Elements("Input").Elements("NPhase").Value = Phasenumber #This can be 1,2,3
#Page 2 Flash Option
def BLK_HEATER_Set_TemperatureEstimation(self, Blockname, TemperatureEstimation):
self.BLK.Elements(Blockname).Elements("Input").Elements("T_EST").Value = TemperatureEstimation
def BLK_HEATER_Set_PressureEstimation(self, Blockname, PressureEstimation):
self.BLK.Elements(Blockname).Elements("Input").Elements("P_EST").Value = PressureEstimation
def BLK_HEATER_Set_MaximumIteration(self, Blockname, MaximumIteration): #OPTIONAL
self.BLK.Elements(Blockname).Elements("Input").Elements("MAXIT").Value = MaximumIteration
def BLK_HEATER_Set_ErrorTolerance(self, Blockname, ErrorTolerance): #OPTIONAL
self.BLK.Elements(Blockname).Elements("Input").Elements("TOL").Value = ErrorTolerance
def BLK_CISTR_GET_ME_ALL_INPUTS_BACK(self, Blockname:str): #-> Dict[str, Union[str,float,int]]
"""Retrieves all the Inputs and returns Dictionary with Values
Does not include all aspects of a Aspen Simulationsheet, for this look at Exports
Args:
Blockname: String which gives the name of Block.
"""
SpecificationOption = self.BLK.Elements(Blockname).Elements("Input").Elements("SPEC_OPT").Value
Pressure = self.BLK.Elements(Blockname).Elements("Input").Elements("PRES").Value
Temperature =self.BLK.Elements(Blockname).Elements("Input").Elements("TEMP").Value
Duty = self.BLK.Elements(Blockname).Elements("Input").Elements("DUTY").Value
VaporFraction=self.BLK.Elements(Blockname).Elements("Input").Elements("VFRAC").Value
Phase =self.BLK.Elements(Blockname).Elements("Input").Elements("PHASE").Value #This can be V L or S
Phasenumber= self.BLK.Elements(Blockname).Elements("Input").Elements("NPHASE").Value #This can be 1,2,3
Specification_type= self.BLK.Elements(Blockname).Elements("Input").Elements("SPEC_TYPE").Value #This selects what input is needed:
VolumeReactor= self.BLK.Elements(Blockname).Elements("Input").Elements("VOL").Value
ResidencetimeReactor = self.BLK.Elements(Blockname).Elements("Input").Elements("RES_TIME").Value
Specification_PhaseHoldup= self.BLK.Elements(Blockname).Elements("Input").Elements("SPEC_PHASE").Value
VolumeFrac_of_PhaseHoldup = self.BLK.Elements(Blockname).Elements("Input").Elements("REACT_VOL_FR").Value
Volume_of_PhaseHoldup = self.BLK.Elements(Blockname).Elements("Input").Elements("REACT_VOL").Value
Residencetime_of_PhaseHoldup = self.BLK.Elements(Blockname).Elements("Input").Elements("PH_RES_TIME").Value
StreamnameNode = self.BLK.Elements(Blockname).Elements("Ports").Elements("F(IN)").Elements
ActivateReactions_or_not = self.BLK.Elements(Blockname).Elements("Input").Elements("REACSYS").Value
ActivateCrystalization_or_not = self.BLK.Elements(Blockname).Elements("Input").Elements("CRYSTSYS").Value
ActivateAgitation_or_not = self.BLK.Elements(Blockname).Elements("Input").Elements("AGITATOR").Value
AgitatorRotationrate = self.BLK.Elements(Blockname).Elements("Input").Elements("AGITRATE").Value
AgitatorImpellerDiameter = self.BLK.Elements(Blockname).Elements("Input").Elements("IMPELLR_DIAM").Value
AgitatorPowernumber = self.BLK.Elements(Blockname).Elements("Input").Elements("POWERNUMBER").Value
PSDCalculation_Option = self.BLK.Elements(Blockname).Elements("Input").Elements("OPT_PSD").Value
PSDParticalGrowthModel = self.BLK.Elements(Blockname).Elements("Input").Elements("CONST_METHOD").Value
CatalystPresentOption = self.BLK.Elements(Blockname).Elements("Input").Elements("CAT_PRESENT").Value
IgnoreCatalystVolume = self.BLK.Elements(Blockname).Elements("Input").Elements("IGN_CAT_VOL").Value
WeightOfCatalystLoaded = self.BLK.Elements(Blockname).Elements("Input").Elements("CATWT").Value
ParticleDensity = self.BLK.Elements(Blockname).Elements("Input").Elements("CAT_RHO").Value
BedVoidage = self.BLK.Elements(Blockname).Elements("Input").Elements("BED_VOIDAGE").Value
Dictionary = {
"SpecificationOption":SpecificationOption,
"Pressure":Pressure,
"Temperature":Temperature,
"Duty":Duty,
"VaporFraction":VaporFraction,
"Phase":Phase,
"Phasenumber":Phasenumber,
"Specification_type":Specification_type,
"VolumeReactor":VolumeReactor,
"ResidencetimeReactor":ResidencetimeReactor,
"Specification_PhaseHoldup":Specification_PhaseHoldup,
"VolumeFrac_of_PhaseHoldup": VolumeFrac_of_PhaseHoldup,
"Volume_of_PhaseHoldup":Volume_of_PhaseHoldup,
"Residencetime_of_PhaseHoldup":Residencetime_of_PhaseHoldup,
"Activate_Reaction":ActivateReactions_or_not,
"Activate_Crystalization":ActivateCrystalization_or_not,
"Activate_Agitation":ActivateAgitation_or_not,
"AgitatorRotationrate":AgitatorRotationrate,
"AgitatorImpellerDiameter":AgitatorImpellerDiameter,
"AgitatorPowernumber":AgitatorPowernumber,
"PSDCalculation_Option":PSDCalculation_Option,
"PSDParticalGrowthModel":PSDParticalGrowthModel,
"CatalystPresentOption":CatalystPresentOption,
"IgnoreCatalystVolume":IgnoreCatalystVolume,
"WeightOfCatalystLoaded":WeightOfCatalystLoaded,
"ParticleDensity":ParticleDensity,
"BedVoidage":BedVoidage
}
return Dictionary
def BLK_CISTR_SET_ALL_INPUTS(self, Blockname:str, Dictionary: Dict[str, Union[str,float,int]]) -> None:
"""Takes Dictionary with Values set the ones which are given in Aspen.
The Original Dictionary with its specific format can be found via "BLK_DSTWU_GET_ME_ALL_INPUTS_BACK"
Args:
Blockname: String which gives the name of Block.
Dictionary: Dictionary which contains all the Input variables.
"""
self.BLK.ELements(Blockname).Elements("Input").Elements("SPEC_OPT").Value = Dictionary.get("SpecificationOption")
self.BLK.Elements(Blockname).Elements("Input").Elements("PRES").Value = Dictionary.get("Pressure")
self.BLK.Elements(Blockname).Elements("Input").Elements("TEMP").Value = Dictionary.get("Temperature")
self.BLK.Elements(Blockname).Elements("Input").Elements("DUTY").Value = Dictionary.get("Duty")
self.BLK.Elements(Blockname).Elements("Input").Elements("VFRAC").Value = Dictionary.get("VaporFraction")
self.BLK.Elements(Blockname).Elements("Input").Elements("PHASE").Value = Dictionary.get("Phase") #This can be V L or S
self.BLK.Elements(Blockname).Elements("Input").Elements("NPHASE").Value = Dictionary.get("Phasenumber") #This can be 1,2,3
self.BLK.Elements(Blockname).Elements("Input").Elements("SPEC_TYPE").Value = Dictionary.get("Specification_type") #This selects what input is needed:
self.BLK.Elements(Blockname).Elements("Input").Elements("VOL").Value = Dictionary.get("VolumeReactor")
self.BLK.Elements(Blockname).Elements("Input").Elements("RES_TIME").Value = Dictionary.get("ResidencetimeReactor")
self.BLK.Elements(Blockname).Elements("Input").Elements("SPEC_PHASE").Value = Dictionary.get("Specification_Phase")
self.BLK.Elements(Blockname).Elements("Input").Elements("REACT_VOL_FR").Value = Dictionary.get("VolumeFrac_of_Phase")
self.BLK.Elements(Blockname).Elements("Input").Elements("REACT_VOL").Value = Dictionary.get("Volume_of_Phase")
self.BLK.Elements(Blockname).Elements("Input").Elements("PH_RES_TIME").Value = Dictionary.get("Residencetime_of_Holdup")
StreamnameNode = self.BLK.Elements(Blockname).Elements("Ports").Elements("F(IN)").Elements
for Streamname in StreamnameNode:
self.BLK.Elements(Blockname).Elements("Input").Elements("PROD_PHASE").Elements(Streamname).Value = Dictionary.get("Streamphase")
self.BLK.Elements(Blockname).Elements("Input").Elements("REACSYS").Value = Dictionary.get("ActivateReactions_or_not")
self.BLK.Elements(Blockname).Elements("Input").Elements("CRYSTSYS").Value = Dictionary.get("ActivateCrystalization_or_not")
self.BLK.Elements(Blockname).Elements("Input").Elements("AGITATOR").Value = Dictionary.get("ActivateAgitation_or_not")
self.BLK.Elements(Blockname).Elements("Input").Elements("AGITRATE").Value = Dictionary.get("Rotationrate")
self.BLK.Elements(Blockname).Elements("Input").Elements("IMPELLR_DIAM").Value = Dictionary.get("ImpellerDiameter")
self.BLK.Elements(Blockname).Elements("Input").Elements("POWERNUMBER").Value = Dictionary.get("Powernumber")
self.BLK.Elements(Blockname).Elements("Input").Elements("OPT_PSD").Value = Dictionary.get("CalculationOption")
self.BLK.Elements(Blockname).Elements("Input").Elements("CONST_METHOD").Value = Dictionary.get("ParticalGrowthModel")
self.BLK.Elements(Blockname).Elements("Input").Elements("CAT_PRESENT").Value = Dictionary.get("CatalystPresentOption")
self.BLK.Elements(Blockname).Elements("Input").Elements("IGN_CAT_VOL").Value = Dictionary.get("IgnoreCatalystVolume")
self.BLK.Elements(Blockname).Elements("Input").Elements("CATWT").Value = Dictionary.get("WeightOfCatalystLoaded")
self.BLK.Elements(Blockname).Elements("Input").Elements("CAT_RHO").Value = Dictionary.get("ParticleDensity")
self.BLK.Elements(Blockname).Elements("Input").Elements("BED_VOIDAGE").Value = Dictionary.get("BedVoidage")
##CISTR:
#PAGE 1 Specifications
def BLK_CISTR_Set_Pressure(self, Blockname, Pressure):
self.BLK.Elements(Blockname).Elements("Input").Elements("PRES").Value = Pressure
def BLK_CISTR_Set_Temperature(self, Blockname, Temperature):
self.BLK.ELements(Blockname).Elements("Input").Elements("SPEC_OPT").Value = "TEMP"
self.BLK.Elements(Blockname).Elements("Input").Elements("TEMP").Value = Temperature
def BLK_CISTR_Set_Duty(self, Blockname ,Duty):
self.BLK.ELements(Blockname).Elements("Input").Elements("SPEC_OPT").Value = "DUTY"
self.BLK.Elements(Blockname).Elements("Input").Elements("DUTY").Value = Duty
def BLK_CISTR_Set_VaporFraction(self, Blockname, VaporFraction):
self.BLK.ELements(Blockname).Elements("Input").Elements("SPEC_OPT").Value = "VFRAC"
self.BLK.Elements(Blockname).Elements("Input").Elements("VFRAC").Value = VaporFraction
def BLK_CISTR_Set_Phases(self, Blockname:str, Phase:Ph, Phasenumber:Phnum) -> None:
self.BLK.Elements(Blockname).Elements("Input").Elements("PHASE").Value = Phase #This can be V L
self.BLK.Elements(Blockname).Elements("Input").Elements("NPHASE").Value = Phasenumber #This can be 1,2,3
def BLK_CISTR_Set_Specification_type(self,Blockname:str, Specification_type: Literal["TOT-VOL", "RES-TIME", "TOT-VOL-PH-VOL", "TOT-VOL-PH-VOL-FRAC", "TOT-VOL-PH-RES-TIME", "RES-TIME-PH-VOL-FRAC"]) -> None:
self.BLK.Elements(Blockname).Elements("Input").Elements("SPEC_TYPE").Value = Specification_type #This selects what input is needed:
#The easy ones are: "TOT-VOL" or "RES-TIME"
#If there is only one Phase then you can chose these:
#"TOT-VOL-PH-VOL" "TOT-VOL-PH-VOL-FRAC" "TOT-VOL-PH-RES-TIME" "RES-TIME-PH-VOL-FRAC"
def BLK_CISTR_Set_Volume(self,Blockname, VolumeReactor):
self.BLK.Elements(Blockname).Elements("Input").Elements("VOL").Value = VolumeReactor
def BLK_CISTR_Set_ResidenceTime(self,Blockname, ResidencetimeReactor):
self.BLK.Elements(Blockname).Elements("Input").Elements("RES_TIME").Value = ResidencetimeReactor
def BLK_CISTR_Set_Specification_PhaseHoldup(self, Blockname, Specification_Phase):
self.BLK.Elements(Blockname).Elements("Input").Elements("SPEC_PHASE").Value = Specification_Phase
def BLK_CISTR_Set_VolumeFrac_of_PhaseHoldup(self, Blockname, VolumeFrac_of_Phase):
self.BLK.Elements(Blockname).Elements("Input").Elements("REACT_VOL_FR").Value = VolumeFrac_of_Phase
def BLK_CISTR_Set_Volume_of_PhaseHoldup(self, Blockname, Volume_of_Phase):
self.BLK.Elements(Blockname).Elements("Input").Elements("REACT_VOL").Value = Volume_of_Phase
def BLK_CISTR_Set_Residencetime_of_PhaseHoldup(self, Blockname, Residencetime_of_Holdup):
self.BLK.Elements(Blockname).Elements("Input").Elements("PH_RES_TIME").Value = Residencetime_of_Holdup
###PAGE 2 Streams
def BLK_CISTR_Set_Productstream_phase(self, Blockname, Streamname, Streamphase):
self.BLK.Elements(Blockname).Elements("Input").Elements("PROD_PHASE").Elements(Streamname).Value = Streamphase
###PAGE 3 Kinetics
def BLK_CISTR_Set_Activate_Reaction(self, Blockname:str, ActivateReactions_or_not: Literal["YES", "NO"]):
self.BLK.Elements(Blockname).Elements("Input").Elements("REACSYS").Value = ActivateReactions_or_not
######## KINETICS IS STILL MISSING!!!!!! #######
def BLK_CISTR_Set_Activate_Crystalization(self, Blockname:str, ActivateCrystalization_or_not: Literal["YES", "NO"]):
self.BLK.Elements(Blockname).Elements("Input").Elements("CRYSTSYS").Value = ActivateCrystalization_or_not
def BLK_CISTR_Set_Activate_Agitation(self, Blockname:str, ActivateAgitation_or_not: Literal["YES", "NO"], Rotationrate:float, ImpellerDiameter:float, Powernumber:float):
self.BLK.Elements(Blockname).Elements("Input").Elements("AGITATOR").Value = ActivateAgitation_or_not
self.BLK.Elements(Blockname).Elements("Input").Elements("AGITRATE").Value = Rotationrate
self.BLK.Elements(Blockname).Elements("Input").Elements("IMPELLR_DIAM").Value = ImpellerDiameter
self.BLK.Elements(Blockname).Elements("Input").Elements("POWERNUMBER").Value = Powernumber
###PAGE 4 Particle Size Determination PSD
def BLK_CISTR_Set_Calculation_Option(self, Blockname:str, CalculationOption: Literal["COPY" ,"CONSTANT"]) -> None:
self.BLK.Elements(Blockname).Elements("Input").Elements("OPT_PSD").Value = CalculationOption
def BLK_CISTR_Set_ParticalGrowthModel(self, Blockname:str, ParticalGrowthModel: Literal["DELTAD-NUM", "DELTAD-MASS", "DELTAV-NUM", "EQUI-MASS", "EQUI-SURFACE", "EQUI_NUMBER"]) -> None:
self.BLK.Elements(Blockname).Elements("Input").Elements("CONST_METHOD").Value = ParticalGrowthModel
###PAGE 5 Component Attributes
###PAGE 6 Utilites
###PAGE 7 Catalysts
def BLK_CISTR_Set_CatalystPresent(self, Blockname:str, CatalystPresentOption: Literal["YES" ,"NO"]) -> None:
self.BLK.Elements(Blockname).Elements("Input").Elements("CAT_PRESENT").Value = CatalystPresentOption
def BLK_CISTR_Set_IgnoreCatalystVolume(self, Blockname:str, IgnoreCatalystVolume: Literal["YES" ,"NO"]) -> None:
self.BLK.Elements(Blockname).Elements("Input").Elements("IGN_CAT_VOL").Value = IgnoreCatalystVolume
def BLK_CISTR_Set_WeightOfCatalystLoaded(self, Blockname, WeightOfCatalystLoaded):
self.BLK.Elements(Blockname).Elements("Input").Elements("CATWT").Value = WeightOfCatalystLoaded
def BLK_CISTR_Set_ParticleDensity(self, Blockname, ParticleDensity):
self.BLK.Elements(Blockname).Elements("Input").Elements("CAT_RHO").Value = ParticleDensity
def BLK_CISTR_Set_BedVoidage(self, Blockname, BedVoidage):
self.BLK.Elements(Blockname).Elements("Input").Elements("BED_VOIDAGE").Value = BedVoidage