Skip to content

Commit eb9ec7a

Browse files
committed
Merge remote-tracking branch 'upstream/main'
2 parents d29229f + 1c337b9 commit eb9ec7a

File tree

156 files changed

+5603
-2309
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

156 files changed

+5603
-2309
lines changed

.github/actions/run-examples/examples_for_idaes_ci.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
pytest plugin for testing IDAES "through" IDAES/examples within the IDAES/idaes-pse CI
33
"""
4+
45
from contextlib import contextmanager
56
from dataclasses import dataclass, field
67
import fnmatch

.github/workflows/typos.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ equil = "equil"
3636
astroid = "astroid"
3737
# delt == delta
3838
delt = "delt"
39+
# Minimal Infeasible System
40+
mis = "mis"
41+
MIS = "MIS"
3942
# TEMPORARY - Remove after example update
4043
upadate = "upadate"
4144

@@ -44,4 +47,4 @@ RTO = "RTO"
4447
PN = "PN"
4548
hd = "hd"
4649
Tge = "Tge"
47-
iy = "iy"
50+
iy = "iy"

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/psf/black
3-
rev: 22.3.0
3+
rev: 24.3.0
44
hooks:
55
- id: black
66
language_version: python3

.pylint/idaes_transform.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
55
See #1159 for more information.
66
"""
7+
78
from dataclasses import dataclass
89
import sys
910
import functools

.pylint/pylintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ disable=no-self-argument,
1919
arguments-differ,
2020
abstract-method,
2121
arguments-renamed,
22-
unused-argument, # w have cases where a general high level method passes arguments that simpler methods do not need
22+
unused-argument, # we have cases where a general high level method passes arguments that simpler methods do not need
2323
redefined-outer-name,
2424
anomalous-backslash-in-string,
2525
unspecified-encoding,
@@ -29,6 +29,7 @@ disable=no-self-argument,
2929
too-many-lines,
3030
use-implicit-booleaness-not-comparison, # implicit booleaness can be hard to follow
3131
consider-using-f-string, # should fix, but a lot of effort
32+
no-member, # Triggers many false positives from Pyomo due to diamond structure
3233

3334
[IMPORTS]
3435
ignored-modules=cvalsim,almsim

docs/reference_guides/core/var_like_expr.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ In these cases, it is possible that a user might mistake the `Expression` for a
2020
.. autoclass:: IndexedVarLikeExpression
2121
:members:
2222

23-
.. autoclass:: _GeneralVarLikeExpressionData
23+
.. autoclass:: VarLikeExpressionData
2424
:members:
2525

docs/reference_guides/model_libraries/power_generation/unit_models/cross_flow_heat_exchanger_1D.rst

Lines changed: 323 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 276 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,276 @@
1+
Heater1D
2+
========
3+
4+
.. index::
5+
pair: idaes.models_extra.power_generation.unit_models.heater_1D;Heater1D
6+
7+
.. module:: idaes.models_extra.power_generation.unit_models.heater_1D
8+
9+
This model is for a gas trim heater modeled as gas being blown perpendicularly across banks of hollow tubes,
10+
which are heated by resistive heating. Note that the ``finite_elements`` option in the control
11+
volume config should be set to an integer factor of ``number_passes`` in order for the
12+
discretization equations to make sense as a cross-flow heat exchanger.
13+
14+
Example
15+
-------
16+
17+
.. code-block:: python
18+
19+
import pyomo.environ as pyo
20+
21+
from idaes.core import FlowsheetBlock
22+
import idaes.core.util.scaling as iscale
23+
from idaes.models.properties.modular_properties import GenericParameterBlock
24+
from idaes.models_extra.power_generation.properties.natural_gas_PR import (
25+
get_prop,
26+
EosType,
27+
)
28+
from idaes.models_extra.power_generation.unit_models import Heater1D
29+
from idaes.core.util.model_statistics import degrees_of_freedom
30+
31+
optarg = {
32+
"constr_viol_tol": 1e-8,
33+
"nlp_scaling_method": "user-scaling",
34+
"linear_solver": "ma57",
35+
"OF_ma57_automatic_scaling": "yes",
36+
"max_iter": 350,
37+
"tol": 1e-8,
38+
"halt_on_ampl_error": "no",
39+
}
40+
41+
m = pyo.ConcreteModel()
42+
m.fs = FlowsheetBlock(dynamic=False)
43+
m.fs.h2_side_prop_params = GenericParameterBlock(
44+
**get_prop(["H2", "H2O", "Ar", "N2"], {"Vap"}, eos=EosType.IDEAL),
45+
doc="H2O + H2 gas property parameters",
46+
)
47+
m.fs.heater = Heater1D(
48+
property_package=m.fs.h2_side_prop_params,
49+
has_holdup=True,
50+
dynamic=False,
51+
has_fluid_holdup=False,
52+
has_pressure_change=pressure_drop,
53+
finite_elements=4,
54+
tube_arrangement="in-line",
55+
transformation_method="dae.finite_difference",
56+
transformation_scheme="BACKWARD",
57+
)
58+
59+
heater = m.fs.heater
60+
61+
heater.inlet.flow_mol.fix(5102.5)
62+
heater.inlet.temperature.fix(938.83)
63+
heater.inlet.pressure.fix(1.2e5)
64+
heater.inlet.mole_frac_comp[0, "H2"].fix(0.57375)
65+
heater.inlet.mole_frac_comp[0, "H2O"].fix(0.42517)
66+
heater.inlet.mole_frac_comp[0, "Ar"].fix(0.00086358)
67+
heater.inlet.mole_frac_comp[0, "N2"].fix(0.00021589)
68+
69+
heater.di_tube.fix(0.0525018)
70+
heater.thickness_tube.fix(0.0039116)
71+
heater.pitch_x.fix(0.1)
72+
heater.pitch_y.fix(0.1)
73+
heater.length_tube_seg.fix(10)
74+
heater.number_passes.fix(1)
75+
heater.rfouling = 0.0001
76+
heater.fcorrection_htc_shell.fix(1)
77+
heater.cp_wall = 502.4
78+
if pressure_drop:
79+
heater.fcorrection_dp_shell.fix(1)
80+
81+
heater.number_columns_per_pass.fix(40)
82+
heater.number_rows_per_pass.fix(40)
83+
heater.electric_heat_duty.fix(3.6504e06)
84+
85+
pp = m.fs.h2_side_prop_params
86+
pp.set_default_scaling("enth_mol_phase", 1e-3)
87+
pp.set_default_scaling("pressure", 1e-5)
88+
pp.set_default_scaling("temperature", 1e-2)
89+
pp.set_default_scaling("flow_mol", 1e-3)
90+
91+
_mf_scale = {
92+
"H2": 1,
93+
"H2O": 1,
94+
"N2": 10,
95+
"Ar": 10,
96+
}
97+
for comp, s in _mf_scale.items():
98+
pp.set_default_scaling("mole_frac_comp", s, index=comp)
99+
pp.set_default_scaling("mole_frac_phase_comp", s, index=("Vap", comp))
100+
pp.set_default_scaling("flow_mol_phase_comp", s * 1e-3, index=("Vap", comp))
101+
102+
shell = heater.control_volume
103+
iscale.set_scaling_factor(shell.area, 1e-1)
104+
iscale.set_scaling_factor(shell.heat, 1e-6)
105+
iscale.set_scaling_factor(shell.enthalpy_flow_dx, 1e-7)
106+
iscale.set_scaling_factor(heater.heat_holdup, 1e-8)
107+
108+
iscale.calculate_scaling_factors(m)
109+
110+
initializer = m.fs.heat_exchanger.default_initializer(
111+
solver="ipopt",
112+
solver_options=optarg
113+
)
114+
initializer.initialize(m.fs.heat_exchanger)
115+
116+
117+
118+
119+
Heater Geometry
120+
---------------
121+
=========================== =========== =============================================================================================
122+
Variable Index Sets Doc
123+
=========================== =========== =============================================================================================
124+
``number_columns_per_pass`` None Number of columns of tube per pass
125+
``number_rows_per_pass`` None Number of rows of tube per pass
126+
``number_passes`` None Number of tube banks of ``nrow_tube * ncol_inlet`` tubes
127+
``pitch_x`` None Distance between tubes parallel to flow, measured from center-of-tube to center-of-tube
128+
``pitch_y`` None Distance between tubes perpendicular to flow, measured from center-of-tube to center-of-tube
129+
``length_tube_seg`` None Length of tube segment perpendicular to flow in each pass
130+
``area_flow_shell`` None Reference to flow area on control volume
131+
``length_flow_shell`` None Reference to flow length on control volume
132+
``area_flow_shell_min`` None Minimum flow area on shell side
133+
``di_tube`` None Inner diameter of tubes
134+
``thickness_tube`` None Thickness of tube wall.
135+
=========================== =========== =============================================================================================
136+
137+
============================ =========== ===========================================================================
138+
Expression Index Sets Doc
139+
============================ =========== ===========================================================================
140+
``nrow_tube`` None Total number of rows of tube
141+
``do_tube`` None Outer diameter of tube (equal to ``di_tube+2*thickness_tube``)
142+
``pitch_x_to_do`` None Ratio of ``pitch_x`` to ``do_tube``
143+
``pitch_y_to_do`` None Ratio of ``pitch_y`` to ``do_tube``
144+
``area_wall_seg`` None Total cross-sectional area of tube per pass
145+
``total_heat_transfer_area`` None Total heat transfer area, as measured on outer surface of tubes
146+
============================ =========== ===========================================================================
147+
148+
=========================== =========== =================================================================================================
149+
Constraint Index Sets Doc
150+
=========================== =========== =================================================================================================
151+
``length_flow_shell_eqn`` None Constrains flow length from control volume to equal value implied by geometry
152+
``area_flow_shell_eqn`` None Constrains flow cross-sectional area from control volume to equal value implied by geometry
153+
``area_flow_shell_min_eqn`` None Constraints ``area_flow_shell_min`` to equal value determined by geometry
154+
=========================== =========== =================================================================================================
155+
156+
Performance Equations
157+
-----------------------
158+
159+
================================== ============ =================================================================================
160+
Variable Index Sets Doc
161+
================================== ============ =================================================================================
162+
``electric_heat_duty`` time Electric heat duty supplied to entire heater unit
163+
``fcorrection_htc_shell`` time, length Correction factor for convective heat transfer
164+
``conv_heat_transfer_coeff_shell`` time, length Convective heat transfer coefficient
165+
``temp_wall_shell`` time, length Wall temperature of tube
166+
``temp_wall_center`` time, length Temperature at center of tube wall
167+
``v_shell`` time, length Flow velocity through minimum area
168+
``N_Re_shell`` time, length Reynolds number
169+
``N_Nu_shell`` time, length Nusselt number
170+
================================== ============ =================================================================================
171+
172+
=========================== =========== =================================================================================
173+
Parameter Index Sets Doc
174+
=========================== =========== =================================================================================
175+
``therm_cond_wall`` None Thermal conductivity of tube wall
176+
``density_wall`` None Mass density of tube wall metal
177+
``cp_wall`` None Tube wall heat capacity (mass basis)
178+
``rfouling_shell`` None Fouling resistance on shell side
179+
``f_arrangement`` None Adjustment factor depending on ``tube_arrangement`` in config
180+
=========================== =========== =================================================================================
181+
182+
====================================== ============ =================================================================================
183+
Constraint Index Sets Doc
184+
====================================== ============ =================================================================================
185+
``v_shell_eqn`` time, length Calculates velocity of flow through shell using ``area_flow_shell_min``
186+
``N_Re_shell_eqn`` time, length Calculates the Reynolds number
187+
``conv_heat_transfer_coeff_shell_eqn`` time, length Calculates the convective heat transfer coefficient
188+
``N_Nu_shell_eqn`` time, length Calculate the Nusselt number
189+
``heat_shell_eqn`` time, length Calculates heat transfer per unit length
190+
``temp_wall_shell_eqn`` time, length Calculate the wall temperature of the outer tube
191+
``temp_wall_center_eqn`` time, length Overall energy balance on tube metal
192+
====================================== ============ =================================================================================
193+
194+
====================================== ============ ===================================================================================
195+
Expression Index Sets Doc
196+
====================================== ============ ===================================================================================
197+
``total_heat_transfer_coeff_shell`` time Returns ``conv_heat_transfer_coeff_shell``. Could be extended to include radiation.
198+
====================================== ============ ===================================================================================
199+
200+
Pressure Change Equations
201+
-------------------------
202+
203+
=========================== ============ =================================================================================
204+
Parameter Index Sets Doc
205+
=========================== ============ =================================================================================
206+
``fcorrection_dp_shell`` None Correction factor for pressure drop
207+
=========================== ============ =================================================================================
208+
209+
=========================== ============ =================================================================================
210+
Variable Index Sets Doc
211+
=========================== ============ =================================================================================
212+
``fcorrection_dp_shell`` None Correction factor for pressure drop
213+
``friction_factor_shell`` time, length Friction factor
214+
=========================== ============ =================================================================================
215+
216+
================================== ============ =================================================================================
217+
Constraint Index Sets Doc
218+
================================== ============ =================================================================================
219+
``friction_factor_shell_eqn`` time, length Calculates the friction factor
220+
``deltaP_shell_eqn`` time, length Sets ``deltaP_shell`` based on the friction factor and physical properties
221+
================================== ============ =================================================================================
222+
223+
224+
Holdup Equations
225+
----------------
226+
227+
Created when ``has_holdup=True`` in the config.
228+
229+
=========================== ============ =================================================================================
230+
Variable Index Sets Doc
231+
=========================== ============ =================================================================================
232+
``heat_holdup`` time, length Energy holdup per unit length of flow path
233+
=========================== ============ =================================================================================
234+
235+
=========================== ============ =================================================================================
236+
Constraint Index Sets Doc
237+
=========================== ============ =================================================================================
238+
``heat_holdup_eqn`` time, length Defines heat holdup in terms of geometry and physical properties
239+
=========================== ============ =================================================================================
240+
241+
Dynamic Equations
242+
-----------------
243+
244+
Created when ``dynamic=True`` in the config.
245+
246+
=========================== ============ =================================================================================
247+
Derivative Variable Index Sets Doc
248+
=========================== ============ =================================================================================
249+
``heat_accumulation`` time, length Energy accumulation in tube wall per unit length of shell flow path per unit time
250+
=========================== ============ =================================================================================
251+
252+
253+
Initialization
254+
--------------
255+
256+
A simple initialization method that first initializes the control volume without heat transfer,
257+
then adds heat transfer in and solves it again, then finally solves the entire model.
258+
259+
260+
Heater1D Class
261+
--------------
262+
263+
.. autoclass:: Heater1D
264+
:members:
265+
266+
Heater1DData Class
267+
------------------
268+
269+
.. autoclass:: Heater1DData
270+
:members:
271+
272+
Heater1DInitializer Class
273+
-------------------------
274+
275+
.. autoclass:: Heater1DInitializer
276+
:members:

docs/reference_guides/model_libraries/power_generation/unit_models/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,5 @@ Unit Models
2626
waterpipe
2727
boiler_heat_exchanger_3streams
2828
feedwater_heater_0D_dynamic
29+
cross_flow_heat_exchanger_1D
30+
heater_1D

idaes/apps/caprese/common/config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"""
1717
import enum
1818
from pyomo.environ import SolverFactory
19-
from pyomo.core.base.var import _GeneralVarData
19+
from pyomo.core.base.var import VarData
2020

2121

2222
class ControlInitOption(enum.Enum):
@@ -94,7 +94,7 @@ def validate_list_of_vardata(varlist):
9494
if not isinstance(varlist, list):
9595
raise TypeError("Not a list of VarData")
9696
for var in varlist:
97-
if not isinstance(var, _GeneralVarData):
97+
if not isinstance(var, VarData):
9898
raise TypeError("Not a list of VarData")
9999
return varlist
100100

@@ -107,7 +107,7 @@ def validate_list_of_vardata_value_tuples(varvaluelist):
107107
raise TypeError("Item in list is not a tuple")
108108
if not len(item) == 2:
109109
raise ValueError("Tuple in list does not have correct length")
110-
if not isinstance(item[0], _GeneralVarData):
110+
if not isinstance(item[0], VarData):
111111
raise TypeError("First entry is not a VarData")
112112
item = (item[0], float(item[1]))
113113
return varvaluelist

0 commit comments

Comments
 (0)