ahuora-builder 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. ahuora_builder/__init__.py +0 -0
  2. ahuora_builder/arc_manager.py +33 -0
  3. ahuora_builder/build_state.py +57 -0
  4. ahuora_builder/custom/PIDController.py +494 -0
  5. ahuora_builder/custom/PySMOModel.py +178 -0
  6. ahuora_builder/custom/SimpleEffectivenessHX_DH.py +727 -0
  7. ahuora_builder/custom/__init__.py +0 -0
  8. ahuora_builder/custom/add_initial_dynamics.py +35 -0
  9. ahuora_builder/custom/custom_compressor.py +107 -0
  10. ahuora_builder/custom/custom_cooler.py +33 -0
  11. ahuora_builder/custom/custom_heat_exchanger.py +183 -0
  12. ahuora_builder/custom/custom_heat_exchanger_1d.py +258 -0
  13. ahuora_builder/custom/custom_heater.py +41 -0
  14. ahuora_builder/custom/custom_pressure_changer.py +34 -0
  15. ahuora_builder/custom/custom_pump.py +107 -0
  16. ahuora_builder/custom/custom_separator.py +371 -0
  17. ahuora_builder/custom/custom_tank.py +133 -0
  18. ahuora_builder/custom/custom_turbine.py +132 -0
  19. ahuora_builder/custom/custom_valve.py +300 -0
  20. ahuora_builder/custom/custom_variable.py +29 -0
  21. ahuora_builder/custom/direct_steam_injection.py +371 -0
  22. ahuora_builder/custom/energy/__init__.py +0 -0
  23. ahuora_builder/custom/energy/acBus.py +280 -0
  24. ahuora_builder/custom/energy/ac_property_package.py +279 -0
  25. ahuora_builder/custom/energy/battery.py +170 -0
  26. ahuora_builder/custom/energy/bus.py +182 -0
  27. ahuora_builder/custom/energy/energy_mixer.py +195 -0
  28. ahuora_builder/custom/energy/energy_splitter.py +228 -0
  29. ahuora_builder/custom/energy/grid.py +173 -0
  30. ahuora_builder/custom/energy/hydro.py +169 -0
  31. ahuora_builder/custom/energy/link.py +137 -0
  32. ahuora_builder/custom/energy/load.py +155 -0
  33. ahuora_builder/custom/energy/mainDistributionBoard.py +257 -0
  34. ahuora_builder/custom/energy/power_property_package.py +253 -0
  35. ahuora_builder/custom/energy/solar.py +176 -0
  36. ahuora_builder/custom/energy/storage.py +230 -0
  37. ahuora_builder/custom/energy/storage_wrapper +0 -0
  38. ahuora_builder/custom/energy/tests/__init__.py +0 -0
  39. ahuora_builder/custom/energy/tests/test_bus.py +44 -0
  40. ahuora_builder/custom/energy/tests/test_energy_mixer.py +46 -0
  41. ahuora_builder/custom/energy/tests/test_mdb.py +49 -0
  42. ahuora_builder/custom/energy/transformer.py +187 -0
  43. ahuora_builder/custom/energy/transformer_property_package.py +267 -0
  44. ahuora_builder/custom/energy/transmissionLine.py +228 -0
  45. ahuora_builder/custom/energy/wind.py +206 -0
  46. ahuora_builder/custom/hda_ideal_VLE.py +1341 -0
  47. ahuora_builder/custom/hda_reaction.py +182 -0
  48. ahuora_builder/custom/heat_exchanger_1d_wrapper.py +31 -0
  49. ahuora_builder/custom/integration_block.py +106 -0
  50. ahuora_builder/custom/inverted.py +81 -0
  51. ahuora_builder/custom/performance_curves.py +1 -0
  52. ahuora_builder/custom/reactions/__init__.py +0 -0
  53. ahuora_builder/custom/reactions/hda_stoich.py +10 -0
  54. ahuora_builder/custom/simple_separator.py +680 -0
  55. ahuora_builder/custom/tests/__init__.py +0 -0
  56. ahuora_builder/custom/tests/test_SimpleEffectivenessHX_DH.py +91 -0
  57. ahuora_builder/custom/tests/test_custom_tank.py +70 -0
  58. ahuora_builder/custom/tests/test_direct_steam_injection.py +41 -0
  59. ahuora_builder/custom/tests/test_simple_separator.py +46 -0
  60. ahuora_builder/custom/tests/test_waterpipe.py +46 -0
  61. ahuora_builder/custom/thermal_utility_systems/desuperheater.py +624 -0
  62. ahuora_builder/custom/thermal_utility_systems/header.py +889 -0
  63. ahuora_builder/custom/thermal_utility_systems/simple_heat_pump.py +567 -0
  64. ahuora_builder/custom/thermal_utility_systems/steam_header.py +353 -0
  65. ahuora_builder/custom/thermal_utility_systems/steam_user.py +944 -0
  66. ahuora_builder/custom/thermal_utility_systems/temp.py +349 -0
  67. ahuora_builder/custom/thermal_utility_systems/tests/test_desuperheater.py +142 -0
  68. ahuora_builder/custom/thermal_utility_systems/tests/test_header.py +998 -0
  69. ahuora_builder/custom/thermal_utility_systems/tests/test_ntu_hx.py +129 -0
  70. ahuora_builder/custom/thermal_utility_systems/tests/test_simple_heat_pump.py +120 -0
  71. ahuora_builder/custom/thermal_utility_systems/tests/test_steam_header.py +703 -0
  72. ahuora_builder/custom/thermal_utility_systems/tests/test_steam_user.py +277 -0
  73. ahuora_builder/custom/thermal_utility_systems/tests/test_waterpipe.py +36 -0
  74. ahuora_builder/custom/thermal_utility_systems/tests/test_willans_turbine.py +253 -0
  75. ahuora_builder/custom/thermal_utility_systems/willans_turbine.py +804 -0
  76. ahuora_builder/custom/translator.py +129 -0
  77. ahuora_builder/custom/updated_pressure_changer.py +1404 -0
  78. ahuora_builder/custom/valve_wrapper.py +38 -0
  79. ahuora_builder/custom/water_tank_with_units.py +456 -0
  80. ahuora_builder/diagnostics/__init__.py +0 -0
  81. ahuora_builder/diagnostics/infeasibilities.py +40 -0
  82. ahuora_builder/diagnostics/tests/__init__.py +0 -0
  83. ahuora_builder/diagnostics/tests/test_infeasibilities.py +28 -0
  84. ahuora_builder/flowsheet_manager.py +542 -0
  85. ahuora_builder/flowsheet_manager_type.py +20 -0
  86. ahuora_builder/generate_python_file.py +440 -0
  87. ahuora_builder/methods/BlockContext.py +84 -0
  88. ahuora_builder/methods/__init__.py +0 -0
  89. ahuora_builder/methods/adapter.py +355 -0
  90. ahuora_builder/methods/adapter_library.py +549 -0
  91. ahuora_builder/methods/adapter_methods.py +80 -0
  92. ahuora_builder/methods/expression_parsing.py +105 -0
  93. ahuora_builder/methods/load_unit_model.py +147 -0
  94. ahuora_builder/methods/slice_manipulation.py +7 -0
  95. ahuora_builder/methods/tests/__init__.py +0 -0
  96. ahuora_builder/methods/tests/test_expression_parsing.py +15 -0
  97. ahuora_builder/methods/units_handler.py +129 -0
  98. ahuora_builder/ml_wizard.py +101 -0
  99. ahuora_builder/port_manager.py +20 -0
  100. ahuora_builder/properties_manager.py +44 -0
  101. ahuora_builder/property_package_manager.py +78 -0
  102. ahuora_builder/solver.py +38 -0
  103. ahuora_builder/tear_manager.py +98 -0
  104. ahuora_builder/tests/__init__.py +0 -0
  105. ahuora_builder/tests/test_generate_python_file/__init__.py +0 -0
  106. ahuora_builder/tests/test_generate_python_file/configurations/compressor_generated.py +63 -0
  107. ahuora_builder/tests/test_generate_python_file/configurations/heat_exchanger_generated.py +70 -0
  108. ahuora_builder/tests/test_generate_python_file/configurations/pump_generated.py +84 -0
  109. ahuora_builder/tests/test_generate_python_file/configurations/recycle_generated.py +73 -0
  110. ahuora_builder/tests/test_generate_python_file/test_generate_python_file.py +108 -0
  111. ahuora_builder/tests/test_solver/__init__.py +0 -0
  112. ahuora_builder/tests/test_solver/configurations/BT_PR.json +59 -0
  113. ahuora_builder/tests/test_solver/configurations/BT_PR_solved.json +59 -0
  114. ahuora_builder/tests/test_solver/configurations/bus.json +99 -0
  115. ahuora_builder/tests/test_solver/configurations/bus_solved.json +50 -0
  116. ahuora_builder/tests/test_solver/configurations/compound_separator.json +377 -0
  117. ahuora_builder/tests/test_solver/configurations/compound_separator_solved.json +374 -0
  118. ahuora_builder/tests/test_solver/configurations/compressor.json +38 -0
  119. ahuora_builder/tests/test_solver/configurations/compressor_solved.json +68 -0
  120. ahuora_builder/tests/test_solver/configurations/constraints.json +44 -0
  121. ahuora_builder/tests/test_solver/configurations/constraints_solved.json +59 -0
  122. ahuora_builder/tests/test_solver/configurations/control.json +39 -0
  123. ahuora_builder/tests/test_solver/configurations/control_solved.json +68 -0
  124. ahuora_builder/tests/test_solver/configurations/dynamic_tank.json +733 -0
  125. ahuora_builder/tests/test_solver/configurations/dynamic_tank_solved.json +846 -0
  126. ahuora_builder/tests/test_solver/configurations/elimination.json +39 -0
  127. ahuora_builder/tests/test_solver/configurations/elimination_solved.json +68 -0
  128. ahuora_builder/tests/test_solver/configurations/expressions.json +68 -0
  129. ahuora_builder/tests/test_solver/configurations/expressions_solved.json +104 -0
  130. ahuora_builder/tests/test_solver/configurations/header.json +1192 -0
  131. ahuora_builder/tests/test_solver/configurations/header_solved.json +761 -0
  132. ahuora_builder/tests/test_solver/configurations/heat_exchanger.json +63 -0
  133. ahuora_builder/tests/test_solver/configurations/heat_exchanger_solved.json +104 -0
  134. ahuora_builder/tests/test_solver/configurations/heat_pump.json +137 -0
  135. ahuora_builder/tests/test_solver/configurations/heat_pump_solved.json +104 -0
  136. ahuora_builder/tests/test_solver/configurations/machine_learning.json +2156 -0
  137. ahuora_builder/tests/test_solver/configurations/machine_learning_solved.json +266 -0
  138. ahuora_builder/tests/test_solver/configurations/mass_flow_tear.json +77 -0
  139. ahuora_builder/tests/test_solver/configurations/mass_flow_tear_solved.json +68 -0
  140. ahuora_builder/tests/test_solver/configurations/milk_heater.json +521 -0
  141. ahuora_builder/tests/test_solver/configurations/milk_heater_solved.json +311 -0
  142. ahuora_builder/tests/test_solver/configurations/mixer.json +44 -0
  143. ahuora_builder/tests/test_solver/configurations/mixer_solved.json +86 -0
  144. ahuora_builder/tests/test_solver/configurations/optimization.json +62 -0
  145. ahuora_builder/tests/test_solver/configurations/optimization_solved.json +59 -0
  146. ahuora_builder/tests/test_solver/configurations/propane_heat_pump.json +167 -0
  147. ahuora_builder/tests/test_solver/configurations/propane_heat_pump_solved.json +158 -0
  148. ahuora_builder/tests/test_solver/configurations/propane_recycle.json +141 -0
  149. ahuora_builder/tests/test_solver/configurations/propane_recycle_solved.json +104 -0
  150. ahuora_builder/tests/test_solver/configurations/pump.json +64 -0
  151. ahuora_builder/tests/test_solver/configurations/pump_solved.json +59 -0
  152. ahuora_builder/tests/test_solver/configurations/pump_unit_conversions.json +63 -0
  153. ahuora_builder/tests/test_solver/configurations/recycle.json +49 -0
  154. ahuora_builder/tests/test_solver/configurations/recycle_solved.json +50 -0
  155. ahuora_builder/tests/test_solver/configurations/sb_vapor_frac.json +29 -0
  156. ahuora_builder/tests/test_solver/configurations/sb_vapor_frac_solved.json +29 -0
  157. ahuora_builder/tests/test_solver/configurations/solar.json +67 -0
  158. ahuora_builder/tests/test_solver/configurations/solar_solved.json +50 -0
  159. ahuora_builder/tests/test_solver/configurations/vapor_frac_target.json +67 -0
  160. ahuora_builder/tests/test_solver/configurations/vapor_frac_target_solved.json +68 -0
  161. ahuora_builder/tests/test_solver/test_solve_models.py +250 -0
  162. ahuora_builder/timing.py +65 -0
  163. ahuora_builder/types/__init__.py +1 -0
  164. ahuora_builder/unit_model_manager.py +48 -0
  165. ahuora_builder-0.1.0.dist-info/METADATA +14 -0
  166. ahuora_builder-0.1.0.dist-info/RECORD +167 -0
  167. ahuora_builder-0.1.0.dist-info/WHEEL +4 -0
@@ -0,0 +1,549 @@
1
+ from idaes.models.unit_models import (
2
+ Pump,
3
+ Heater,
4
+ Mixer,
5
+ StateJunction,
6
+ HeatExchanger,
7
+ Turbine,
8
+ PressureChanger,
9
+ )
10
+ from idaes.models.unit_models.heat_exchanger import delta_temperature_underwood_callback
11
+ from idaes.models.unit_models.pressure_changer import ThermodynamicAssumption
12
+ from idaes.models.unit_models.separator import SplittingType, EnergySplittingType
13
+ from ahuora_builder.custom.heat_exchanger_1d_wrapper import HeatExchanger1DWrapper
14
+ from . import adapter_methods as methods
15
+ from ..custom.custom_heat_exchanger import CustomHeatExchanger
16
+ from ..custom.PySMOModel import PySMOModel
17
+ from ..custom.energy.link import Link
18
+ from ..custom.energy.power_property_package import PowerParameterBlock
19
+ from ..custom.energy.ac_property_package import acParameterBlock
20
+ from ..custom.energy.transformer_property_package import transformerParameterBlock
21
+ from ..custom.updated_pressure_changer import Compressor
22
+ from ..custom.energy.solar import Solar
23
+ from ..custom.custom_valve import Valve
24
+ from ..custom.energy.wind import Wind
25
+ from ..custom.energy.energy_mixer import EnergyMixer
26
+ from ..custom.energy.bus import Bus
27
+ from ..custom.energy.acBus import acBus
28
+ from ..custom.energy.transmissionLine import transmissionLine
29
+ from ..custom.valve_wrapper import ValveWrapper
30
+ from ..custom.energy.load import Load
31
+ from ..custom.energy.hydro import Hydro
32
+ from ..custom.energy.transformer import Transformer
33
+ from ..custom.energy.storage import Storage
34
+ from ..custom.direct_steam_injection import Dsi
35
+ from ..custom.translator import GenericTranslator
36
+ from idaes.models.control.controller import ControllerType, ControllerMVBoundType
37
+ from ..custom.PIDController import PIDController2
38
+ from ..custom.energy.grid import Grid
39
+ from ..custom.custom_heater import DynamicHeater
40
+ from ..custom.custom_tank import CustomTank
41
+ from ..custom.custom_compressor import CustomCompressor
42
+ from ..custom.custom_pump import CustomPump
43
+ from ..custom.integration_block import IntegrationBlock
44
+ from idaes.models.unit_models.cstr import CSTR
45
+ from ..custom.energy.energy_splitter import EnergySplitter
46
+ from ..custom.custom_turbine import CustomTurbine
47
+ from ..custom.energy.mainDistributionBoard import MDB
48
+ from ..custom.custom_separator import CustomSeparator
49
+ from ..custom.custom_variable import CustomVariable
50
+ from ..custom.thermal_utility_systems.steam_header import SteamHeader
51
+ from ..custom.thermal_utility_systems.header import simple_header
52
+ from ..custom.reactions.hda_stoich import HDAStoichiometricReactor
53
+ from ..custom.custom_heat_exchanger_1d import CustomHeatExchanger1D
54
+ from ..custom.thermal_utility_systems.simple_heat_pump import SimpleHeatPump
55
+ from ..custom.thermal_utility_systems.steam_user import SteamUser
56
+ from ..custom.thermal_utility_systems.desuperheater import Desuperheater
57
+ from idaes.models_extra.power_generation.unit_models.waterpipe import WaterPipe
58
+ from ..custom.SimpleEffectivenessHX_DH import HeatExchangerEffectiveness
59
+ from idaes.models.unit_models.heat_exchanger_lc import HeatExchangerLumpedCapacitance
60
+ from idaes.models_extra.column_models.plate_heat_exchanger import PlateHeatExchanger
61
+ from ..custom.custom_cooler import CustomCooler
62
+
63
+ class UnitModelConstructor:
64
+ """
65
+ Schema for adapter library items
66
+ """
67
+
68
+ def __init__(self, model_constructor: type, arg_parsers: dict):
69
+ # idaes model constructor
70
+ self.model_constructor: type = model_constructor
71
+ # dictionary of argument parsers
72
+ self.arg_parsers: dict[str,methods.AdapterBase] = arg_parsers
73
+
74
+
75
+
76
+ """
77
+ A dictionary of adapters for the idaes model constructors
78
+ """
79
+ AdapterLibrary: dict[str, UnitModelConstructor] = {
80
+ "pump": UnitModelConstructor(
81
+ CustomPump,
82
+ {
83
+ "property_package": methods.PropertyPackage(),
84
+ "dynamic": methods.Constant(False),
85
+ "power_property_package": methods.PowerPropertyPackage(),
86
+
87
+ },
88
+ ),
89
+ "heater": UnitModelConstructor(
90
+ DynamicHeater,
91
+ {
92
+ "property_package": methods.PropertyPackage(),
93
+ "has_pressure_change": methods.Value(),
94
+ "dynamic": methods.Value(),
95
+ "has_holdup": methods.Value(),
96
+ },
97
+ ),
98
+ "compressor": UnitModelConstructor(
99
+ CustomCompressor,
100
+ {
101
+ "property_package": methods.PropertyPackage(),
102
+ "power_property_package": methods.PowerPropertyPackage(),
103
+ "dynamic": methods.Constant(False),
104
+ },
105
+ ),
106
+ "turbine": UnitModelConstructor(
107
+ CustomTurbine,
108
+ {
109
+ "property_package": methods.PropertyPackage(),
110
+ "power_property_package": methods.PowerPropertyPackage(),
111
+ "dynamic": methods.Constant(False),
112
+ "calculation_method": methods.Constant("isentropic"),
113
+ },
114
+ ),
115
+ "willans_turbine": UnitModelConstructor(
116
+ CustomTurbine,
117
+ {
118
+ "property_package": methods.PropertyPackage(),
119
+ "power_property_package": methods.PowerPropertyPackage(),
120
+ "dynamic": methods.Constant(False),
121
+ "calculation_method": methods.Constant("simple_willans"),
122
+ },
123
+ ),
124
+ "pl_turbine": UnitModelConstructor(
125
+ CustomTurbine,
126
+ {
127
+ "property_package": methods.PropertyPackage(),
128
+ "power_property_package": methods.PowerPropertyPackage(),
129
+ "dynamic": methods.Constant(False),
130
+ "calculation_method": methods.Constant("part_load_willans"),
131
+ }
132
+ ),
133
+ "dts_turbine": UnitModelConstructor(
134
+ CustomTurbine,
135
+ {
136
+ "property_package": methods.PropertyPackage(),
137
+ "power_property_package": methods.PowerPropertyPackage(),
138
+ "dynamic": methods.Constant(False),
139
+ "calculation_method": methods.Constant("Tsat_willans"),
140
+ }
141
+ ),
142
+ "bs_turbine": UnitModelConstructor(
143
+ CustomTurbine,
144
+ {
145
+ "property_package": methods.PropertyPackage(),
146
+ "power_property_package": methods.PowerPropertyPackage(),
147
+ "dynamic": methods.Constant(False),
148
+ "calculation_method": methods.Constant("BPST_willans"),
149
+ }
150
+ ),
151
+ "cs_turbine": UnitModelConstructor(
152
+ CustomTurbine,
153
+ {
154
+ "property_package": methods.PropertyPackage(),
155
+ "power_property_package": methods.PowerPropertyPackage(),
156
+ "dynamic": methods.Constant(False),
157
+ "calculation_method": methods.Constant("CT_willans"),
158
+ }
159
+ ),
160
+ "mixer": UnitModelConstructor(
161
+ Mixer,
162
+ {
163
+ "property_package": methods.PropertyPackage(),
164
+ "num_inlets": methods.Value(),
165
+ },
166
+ ),
167
+ "Tank": UnitModelConstructor(
168
+ CustomTank,
169
+ {
170
+ "property_package": methods.PropertyPackage(),
171
+ "dynamic": methods.Value(),
172
+ "has_holdup": methods.Value(),
173
+ "tank_type": methods.Constant("vertical_cylindrical_tank"),
174
+ "has_heat_transfer": methods.Constant(True),
175
+ }
176
+ ),
177
+ "heatExchanger": UnitModelConstructor(
178
+ CustomHeatExchanger,
179
+ {
180
+ "delta_temperature_callback": methods.Constant(
181
+ delta_temperature_underwood_callback
182
+ ),
183
+ "hot_side": methods.Dictionary(
184
+ {
185
+ "property_package": methods.PropertyPackage(),
186
+ "has_pressure_change": methods.Constant(True),
187
+ }
188
+ ),
189
+ "cold_side": methods.Dictionary(
190
+ {
191
+ "property_package": methods.PropertyPackage(),
192
+ "has_pressure_change": methods.Constant(True),
193
+ }
194
+ ),
195
+ "dynamic": methods.Constant(False),
196
+ },
197
+ ),
198
+ "heatPump": UnitModelConstructor(
199
+ SimpleHeatPump,
200
+ {
201
+ "source": methods.Dictionary(
202
+ {
203
+ "property_package": methods.PropertyPackage(),
204
+ "has_pressure_change": methods.Constant(False),
205
+ }
206
+ ),
207
+ "sink": methods.Dictionary(
208
+ {
209
+ "property_package": methods.PropertyPackage(),
210
+ "has_pressure_change": methods.Constant(False),
211
+ }
212
+ ),
213
+ "dynamic": methods.Constant(False),
214
+ },
215
+ ),
216
+ "valve": UnitModelConstructor(
217
+ ValveWrapper, # type: ignore
218
+ {
219
+ "property_package": methods.PropertyPackage(),
220
+ "enable_coefficients": methods.Value(),
221
+ "valve_function": methods.Value(),
222
+ "dynamic": methods.Constant(False),
223
+ },
224
+ ),
225
+ "cooler": UnitModelConstructor(
226
+ CustomCooler,
227
+ {
228
+ "property_package": methods.PropertyPackage(),
229
+ "has_pressure_change": methods.Value(),
230
+ "dynamic": methods.Constant(False),
231
+ },
232
+ ),
233
+ "splitter": UnitModelConstructor(
234
+ CustomSeparator,
235
+ {
236
+ "property_package": methods.PropertyPackage(),
237
+ "num_outlets": methods.Value(),
238
+ },
239
+ ),
240
+ "phaseSeparator": UnitModelConstructor(
241
+ CustomSeparator,
242
+ {
243
+ "property_package": methods.PropertyPackage(),
244
+ "num_outlets": methods.Value(),
245
+ "split_basis": methods.Constant(
246
+ SplittingType.phaseFlow
247
+ ),
248
+ "energy_split_basis": methods.Constant(
249
+ EnergySplittingType.enthalpy_split
250
+ ),
251
+ },
252
+ ),
253
+ "compoundSeparator": UnitModelConstructor(
254
+ CustomSeparator,
255
+ {
256
+ "property_package": methods.PropertyPackage(),
257
+ "num_outlets": methods.Value(),
258
+ "split_basis": methods.Constant(
259
+ SplittingType.componentFlow
260
+ ),
261
+ },
262
+ ),
263
+ "machineLearningBlock": UnitModelConstructor(PySMOModel, {
264
+ "property_package": methods.PropertyPackage(),
265
+ "model": methods.Value(),
266
+ "ids": methods.Value(),
267
+ "unitopNames": methods.Value(),
268
+ "num_inlets": methods.Value(),
269
+ "num_outlets": methods.Value(),
270
+ }),
271
+ "link": UnitModelConstructor(
272
+ Link,
273
+ {
274
+ "property_package": methods.PowerPropertyPackage(),
275
+ },
276
+ ),
277
+ "solar": UnitModelConstructor(
278
+ Solar,
279
+ {
280
+ "property_package": methods.PowerPropertyPackage(),
281
+ },
282
+ ),
283
+ "wind": UnitModelConstructor(
284
+ Wind,
285
+ {
286
+ "property_package": methods.PowerPropertyPackage(),
287
+ },
288
+ ),
289
+ "energy_mixer": UnitModelConstructor(
290
+ EnergyMixer,
291
+ {
292
+ "property_package": methods.PowerPropertyPackage(),
293
+ "num_inlets": methods.Value(),
294
+ },
295
+ ),
296
+ "bus": UnitModelConstructor(
297
+ Bus,
298
+ {
299
+ "property_package": methods.PowerPropertyPackage(),
300
+ "num_inlets": methods.Value(),
301
+
302
+ },
303
+ ),
304
+ "acBus": UnitModelConstructor(
305
+ acBus,
306
+ {
307
+ "property_package": methods.acPropertyPackage(),
308
+ "num_inlets": methods.Value(),
309
+ "num_outlets": methods.Value(),
310
+ },
311
+ ),
312
+ "transmissionLine": UnitModelConstructor(
313
+ transmissionLine,
314
+ {
315
+ "property_package": methods.PowerPropertyPackage(),
316
+ "num_inlets": methods.Value(),
317
+ "num_outlets": methods.Value(),
318
+ },
319
+ ),
320
+ "load": UnitModelConstructor(
321
+ Load,
322
+ {
323
+ "property_package": methods.PowerPropertyPackage(),
324
+ },
325
+ ),
326
+ "hydro": UnitModelConstructor(
327
+ Hydro,
328
+ {
329
+ "property_package": methods.PowerPropertyPackage(),
330
+ },
331
+ ),
332
+
333
+ "transformer": UnitModelConstructor(
334
+ Transformer,
335
+ {
336
+ "property_package": methods.PowerPropertyPackage(),
337
+ },
338
+ ),
339
+ "storage": UnitModelConstructor(
340
+ Storage,
341
+ {
342
+ "property_package": methods.PowerPropertyPackage(),
343
+ "has_holdup": methods.Value(),
344
+ "dynamic": methods.Value(),
345
+ },
346
+ ),
347
+ "direct_steam_injection": UnitModelConstructor(
348
+ Dsi,
349
+ {
350
+ "property_package": methods.PropertyPackage(),
351
+ "steam_property_package": methods.PropertyPackage(),
352
+ },
353
+ ),
354
+ "translator": UnitModelConstructor(
355
+ GenericTranslator,
356
+ {
357
+ "inlet_property_package": methods.PropertyPackage(),
358
+ "outlet_property_package": methods.PropertyPackage(),
359
+ "translator_type": methods.Value(),
360
+ },
361
+ ),
362
+ "pid_controller": UnitModelConstructor(
363
+ PIDController2,
364
+ {
365
+ "dynamic": methods.Constant(True),
366
+ "controller_type": methods.Constant(ControllerType.PI),
367
+ "calculate_initial_integral": methods.Constant(True),
368
+ "mv_bound_type": methods.Constant(ControllerMVBoundType.SMOOTH_BOUND),
369
+ },
370
+ ),
371
+ "custom_variable": UnitModelConstructor(
372
+ CustomVariable,
373
+ {},
374
+ ),
375
+ "grid": UnitModelConstructor(
376
+ Grid,
377
+ {
378
+ "property_package": methods.PowerPropertyPackage(),
379
+ },
380
+ ),
381
+ "integration": UnitModelConstructor(
382
+ IntegrationBlock,
383
+ {
384
+ },
385
+ ),
386
+ "stoich_hda": UnitModelConstructor(
387
+ HDAStoichiometricReactor,
388
+ {
389
+ "property_package": methods.ReactorPropertyPackage(),
390
+ "has_heat_transfer": methods.Constant(True),
391
+ #"has_heat_of_reaction": methods.Value(),
392
+ #"has_pressure_change": methods.Value(),
393
+ "has_holdup": methods.Constant(False),
394
+ "dynamic": methods.Constant(False),
395
+ "reaction_package": methods.ReactionPackage(),
396
+ },
397
+ ),
398
+ "stoich_hda": UnitModelConstructor(
399
+ HDAStoichiometricReactor,
400
+ {
401
+ "property_package": methods.ReactorPropertyPackage(),
402
+ "has_heat_transfer": methods.Constant(True),
403
+ #"has_heat_of_reaction": methods.Value(),
404
+ #"has_pressure_change": methods.Value(),
405
+ "has_holdup": methods.Constant(False),
406
+ "dynamic": methods.Constant(False),
407
+ "reaction_package": methods.ReactionPackage(),
408
+ },
409
+ ),
410
+ "RCT_CSTR": UnitModelConstructor(
411
+ CSTR,
412
+ {
413
+ "property_package": methods.ReactorPropertyPackage(),
414
+ "has_heat_transfer": methods.Value(),
415
+ "has_heat_of_reaction": methods.Value(),
416
+ "has_pressure_change": methods.Value(),
417
+ "has_holdup": methods.Value(),
418
+ "dynamic": methods.Value(),
419
+ "reaction_package": methods.ReactionPackage(),
420
+ },
421
+
422
+ ),
423
+ "energy_splitter": UnitModelConstructor(
424
+ EnergySplitter,
425
+ {
426
+ "property_package": methods.PowerPropertyPackage(),
427
+ "num_inlets": methods.Value(),
428
+ "num_outlets": methods.Value(),
429
+ },
430
+ ),
431
+ "mdb": UnitModelConstructor(
432
+ MDB,
433
+ {
434
+ "property_package": methods.PowerPropertyPackage(),
435
+ "num_inlets": methods.Value(),
436
+ "num_outlets": methods.Value(),
437
+ }
438
+ ),
439
+ "header": UnitModelConstructor(
440
+ SteamHeader,
441
+ {
442
+ "property_package": methods.PropertyPackage(),
443
+ "num_inlets": methods.Value(),
444
+ "num_outlets": methods.Value(),
445
+ },
446
+ ),
447
+ "simple_header": UnitModelConstructor(
448
+ simple_header,
449
+ {
450
+ "property_package": methods.PropertyPackage(),
451
+ "num_inlets": methods.Value(),
452
+ "num_outlets": methods.Value(),
453
+ },
454
+ ),
455
+ "heat_exchanger_1d": UnitModelConstructor(
456
+ HeatExchanger1DWrapper,
457
+ {
458
+ "hot_side": methods.Dictionary({
459
+ "property_package": methods.PropertyPackage(),
460
+ "transformation_method": methods.Value(),
461
+ "transformation_scheme": methods.Value(),
462
+ "has_pressure_change": methods.Constant(False),
463
+ }),
464
+ "cold_side": methods.Dictionary({
465
+ "property_package": methods.PropertyPackage(),
466
+ "transformation_method": methods.Value(),
467
+ "transformation_scheme": methods.Value(),
468
+ "has_pressure_change": methods.Constant(False),
469
+ }),
470
+ "finite_elements": methods.Value(),
471
+ "collocation_points": methods.Value(),
472
+ "flow_type": methods.Value(),
473
+ },
474
+ ),
475
+ "steam_user": UnitModelConstructor(
476
+ SteamUser,
477
+ {
478
+ "property_package": methods.PropertyPackage(),
479
+ }
480
+ ),
481
+ "desuperheater": UnitModelConstructor(
482
+ Desuperheater,
483
+ {
484
+ "property_package": methods.PropertyPackage(),
485
+ }
486
+ ),
487
+ "heat_exchanger_ntu": UnitModelConstructor(
488
+ HeatExchangerEffectiveness,
489
+ {
490
+ "hot_side": methods.Dictionary(
491
+ {
492
+ "property_package": methods.PropertyPackage(),
493
+ "has_pressure_change": methods.Constant(True),
494
+ }
495
+ ),
496
+ "cold_side": methods.Dictionary(
497
+ {
498
+ "property_package": methods.PropertyPackage(),
499
+ "has_pressure_change": methods.Constant(True),
500
+ }
501
+ ),
502
+ "dynamic": methods.Constant(False),
503
+ },
504
+ ),
505
+ "waterpipe": UnitModelConstructor(
506
+ WaterPipe,
507
+ {
508
+ "property_package": methods.PropertyPackage(),
509
+ "has_heat_transfer": methods.Constant(False),
510
+ "has_pressure_change": methods.Constant(True),
511
+ }
512
+ ),
513
+ "heat_exchanger_lc": UnitModelConstructor(
514
+ HeatExchangerLumpedCapacitance,
515
+ {
516
+ "hot_side": methods.Dictionary(
517
+ {
518
+ "property_package": methods.PropertyPackage(),
519
+ "has_pressure_change": methods.Constant(False),
520
+ }
521
+ ),
522
+ "cold_side": methods.Dictionary(
523
+ {
524
+ "property_package": methods.PropertyPackage(),
525
+ "has_pressure_change": methods.Constant(False),
526
+ }
527
+ ),
528
+ "dynamic_heat_balance": methods.Constant(False),
529
+ },
530
+ ),
531
+ "plate_heat_exchanger": UnitModelConstructor(
532
+ PlateHeatExchanger,
533
+ {
534
+ "hot_side": methods.Dictionary(
535
+ {
536
+ "property_package": methods.PropertyPackage(),
537
+ "has_pressure_change": methods.Constant(True),
538
+ }
539
+ ),
540
+ "cold_side": methods.Dictionary(
541
+ {
542
+ "property_package": methods.PropertyPackage(),
543
+ "has_pressure_change": methods.Constant(True),
544
+ }
545
+ ),
546
+ "dynamic": methods.Constant(False),
547
+ },
548
+ ),
549
+ }
@@ -0,0 +1,80 @@
1
+ from typing import Any, Callable
2
+ from abc import ABC, abstractmethod
3
+ from idaes.core.base.property_base import PhysicalParameterBlock
4
+ from idaes.core.base.reaction_base import ReactionParameterBlock
5
+ from ..flowsheet_manager_type import FlowsheetManager
6
+ from ahuora_builder_types import PropertyPackageId
7
+
8
+
9
+
10
+
11
+ class AdapterBase(ABC):
12
+ """
13
+ Base class for adapter methods
14
+ """
15
+
16
+ @abstractmethod
17
+ def run(self, value, flowsheet_manager: FlowsheetManager) -> Any:
18
+ pass
19
+
20
+
21
+ class PropertyPackage(AdapterBase):
22
+ """Get a property package by ID"""
23
+
24
+ def run(self, id: PropertyPackageId, flowsheet_manager: FlowsheetManager) -> PhysicalParameterBlock:
25
+ return flowsheet_manager.property_packages.get(id)
26
+
27
+ class ReactionPackage(AdapterBase):
28
+ """Get a reaction package"""
29
+ def run(self, id: str, flowsheet_manager: FlowsheetManager) -> ReactionParameterBlock:
30
+ return flowsheet_manager.model.fs.reaction_params
31
+
32
+ class ReactorPropertyPackage(AdapterBase):
33
+ def run(self,value,flowsheet_manager) -> PhysicalParameterBlock:
34
+ return flowsheet_manager.model.fs.peng_robinson
35
+
36
+
37
+ class Value(AdapterBase):
38
+ """Do not modify the value passed"""
39
+
40
+ def run(self, value: Any,flowsheet_manager) -> Any:
41
+ return value
42
+
43
+
44
+ class Constant(AdapterBase):
45
+ """Always return the argument passed"""
46
+ def __init__(self,constant) -> None:
47
+ self._constant = constant
48
+
49
+ def run(self, value, flowsheet_manager) -> Callable:
50
+ return self._constant
51
+
52
+
53
+ class Dictionary(AdapterBase):
54
+ """Validate a dictionary against a schema and adapt the values"""
55
+ def __init__(self,schema) -> None:
56
+ self._schema = schema
57
+
58
+ def run(self, dictionary: dict, flowsheet_manager) -> Callable[[dict[str, Callable]], dict]:
59
+ schema = self._schema
60
+
61
+ result = {}
62
+ for item, adapter in schema.items():
63
+ # TODO: do we need to handle optional items better?
64
+ result[item] = adapter.run(dictionary.get(item, None),flowsheet_manager)
65
+ return result
66
+
67
+
68
+ class PowerPropertyPackage(AdapterBase):
69
+ def run(self,value,flowsheet_manager) -> PhysicalParameterBlock:
70
+ return flowsheet_manager.model.fs.power_pp # See __init__ method of Flowsheet_Manager.py
71
+
72
+ class acPropertyPackage(AdapterBase):
73
+ def run(self,value,flowsheet_manager) -> PhysicalParameterBlock:
74
+ return flowsheet_manager.model.fs.ac_pp # See __init__ method of Flowsheet_Manager.py
75
+
76
+ class TransformerPropertyPackage(AdapterBase):
77
+ def run(self,value,flowsheet_manager) -> PhysicalParameterBlock:
78
+ return flowsheet_manager.model.fs.tr_pp # See __init__ method of Flowsheet_Manager.py
79
+
80
+