Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Reactor Examples Properties #95

Merged
merged 33 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
896a572
fix props and notebooks using eg_ideal
bpaul4 Mar 18, 2024
ab07411
fix other props package using same components
bpaul4 Mar 18, 2024
6841865
update doc, test, usr notebooks
bpaul4 Mar 18, 2024
9af8025
make sure doc notebooks are executed and show output
bpaul4 Mar 18, 2024
37d6e7f
Merge branch 'main' into fix-eg-props
lbianchi-lbl Mar 18, 2024
5b87348
update properties from correct sources
bpaul4 May 20, 2024
d4c2828
regenerate outdated notebooks
bpaul4 May 20, 2024
e072e53
Merge branch 'fix-eg-props' of https://github.com/bpaul4/examples int…
bpaul4 May 20, 2024
4e2b0b2
Merge branch 'main' into fix-eg-props
bpaul4 May 20, 2024
8ac5148
fix typos
bpaul4 May 20, 2024
1c148ee
fix cstr_doc
bpaul4 May 22, 2024
86d88a9
regenerate outdated test, doc, usr files
bpaul4 May 23, 2024
d83c308
address reviewer comments
bpaul4 Jun 11, 2024
fe2e4a7
add property tests for egprod_ideal
bpaul4 Jun 11, 2024
add0c5a
very minor updates for tests to pass with new criteria
bpaul4 Jun 11, 2024
b65a64b
regenerate doc, test, usr files
bpaul4 Jun 11, 2024
c919a48
add tests for eg_h2o_ideal, clean up
bpaul4 Jun 11, 2024
8937818
address more reviewer comments
bpaul4 Jun 13, 2024
2170ce2
revert eg_h2o_ideal lower pressure bound
bpaul4 Jun 13, 2024
ebb3b1a
regenerate some notebooks
bpaul4 Jun 13, 2024
ef7ffb3
fix test failures
bpaul4 Jun 13, 2024
ca52af7
add cp_mol tests using enthalpy, use single comp props in tests
bpaul4 Jul 10, 2024
d29a040
simplify fix states lines
bpaul4 Jul 10, 2024
744da66
remove non-enthalpy heat capacity tests
bpaul4 Jul 10, 2024
9669184
add RPP4 tests
bpaul4 Jul 10, 2024
48e7e14
add sulfuric acid tests, cleanup a bit
bpaul4 Jul 11, 2024
4a6e1e8
very small tweaks to notebook results checks
bpaul4 Jul 11, 2024
660836a
reformulate ethylene glycol psat to correct equation form
bpaul4 Jul 11, 2024
ab6ae12
run black on changed Python files
bpaul4 Jul 11, 2024
0770106
Merge branch 'main' into fix-eg-props
bpaul4 Jul 11, 2024
182f2d5
Merge branch 'main' into fix-eg-props
andrewlee94 Aug 19, 2024
f77ffd2
remove heat capacity methods
bpaul4 Aug 19, 2024
2a9b7b5
Merge branch 'fix-eg-props' of https://github.com/bpaul4/examples int…
bpaul4 Aug 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
210 changes: 118 additions & 92 deletions idaes_examples/notebooks/docs/unit_models/operations/eg_h2o_ideal.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,110 +36,136 @@


# ---------------------------------------------------------------------
# Configuration dictionary for an ideal ethylene oxide, water,
# sulfuric acid, and ethylene glycol system
# Configuration dictionary for an ideal ethylene glycol and water system

# Data Sources:
# [1] The Properties of Gases and Liquids (1987)
# 4th edition, Chemical Engineering Series - Robert C. Reid
# [2] Perry's Chemical Engineers' Handbook 7th Ed.
# [3] NIST Chemistry WebBook, https://webbook.nist.gov/chemistry/
# Retrieved 23rd September, 2021
# Retrieved 18th March, 2024

config_dict = {
# Specifying components
"components": {
'water':
{"type": Component,
"elemental_composition": {"H": 2, "O": 1},
"dens_mol_liq_comp": Perrys,
"enth_mol_liq_comp": Perrys,
"enth_mol_ig_comp": RPP4,
"pressure_sat_comp": RPP4,
"phase_equilibrium_form": {("Vap", "Liq"): fugacity},
"parameter_data": {
"mw": (18.015E-3, pyunits.kg/pyunits.mol), # [1]
"pressure_crit": (221.2e5, pyunits.Pa), # [1]
"temperature_crit": (647.3, pyunits.K), # [1]
"dens_mol_liq_comp_coeff": {
'eqn_type': 2,
'1': (-13.851, pyunits.kmol/pyunits.m**3), # [2]pg. 2-98
'2': (0.64038, pyunits.kmol/pyunits.m**3/pyunits.K),
'3': (-0.00191, pyunits.kmol/pyunits.m**3/pyunits.K**2),
'4': (1.8211E-6, pyunits.kmol/pyunits.m**3/pyunits.K**3)},
"cp_mol_ig_comp_coeff": {
'A': (3.194E1, pyunits.J/pyunits.mol/pyunits.K), # [1]
'B': (1.436E-3, pyunits.J/pyunits.mol/pyunits.K**2),
'C': (2.432E-5, pyunits.J/pyunits.mol/pyunits.K**3),
'D': (-1.176E-8, pyunits.J/pyunits.mol/pyunits.K**4)},
"cp_mol_liq_comp_coeff": {
'1': (2.7637E2, pyunits.J/pyunits.kmol/pyunits.K), # [2]
'2': (-2.0901, pyunits.J/pyunits.kmol/pyunits.K**2),
'3': (8.125E-3, pyunits.J/pyunits.kmol/pyunits.K**3),
'4': (-1.4116E-5, pyunits.J/pyunits.kmol/pyunits.K**4),
'5': (9.3701E-9, pyunits.J/pyunits.kmol/pyunits.K**5)},
"enth_mol_form_liq_comp_ref": (
-285.83e3, pyunits.J/pyunits.mol), # [3]
"enth_mol_form_vap_comp_ref": (
-241.836e3, pyunits.J/pyunits.mol), # [3]
"pressure_sat_comp_coeff": {'A': (-7.76451, None), # [1]
'B': (1.45838, None),
'C': (-2.77580, None),
'D': (-1.23303, None)}}},
'ethylene_glycol':
{"type": Component,
"elemental_composition": {"C": 2, "H": 6, "O": 2},
"dens_mol_liq_comp": Perrys,
"enth_mol_liq_comp": Perrys,
"enth_mol_ig_comp": RPP4,
"pressure_sat_comp": RPP4,
"phase_equilibrium_form": {("Vap", "Liq"): fugacity},
"parameter_data": {
"mw": (62.069E-3, pyunits.kg/pyunits.mol), # [1]
"pressure_crit": (77e5, pyunits.Pa), # [1]
"temperature_crit": (645, pyunits.K), # [1]
"dens_mol_liq_comp_coeff": {
'eqn_type': 1,
'1': (1.315, pyunits.kmol*pyunits.m**-3), # [2] pg. 2-98
'2': (0.25125, None),
'3': (720, pyunits.K),
'4': (0.21868, None)},
"cp_mol_ig_comp_coeff": {
'A': (3.570E1, pyunits.J/pyunits.mol/pyunits.K), # [1]
'B': (2.483E-1, pyunits.J/pyunits.mol/pyunits.K**2),
'C': (-1.497E-4, pyunits.J/pyunits.mol/pyunits.K**3),
'D': (3.010E-8, pyunits.J/pyunits.mol/pyunits.K**4)},
"cp_mol_liq_comp_coeff": {
'1': (3.5540E1, pyunits.J/pyunits.kmol/pyunits.K), # [2]
'2': (4.3678E-1, pyunits.J/pyunits.kmol/pyunits.K**2),
'3': (-1.8486E-4, pyunits.J/pyunits.kmol/pyunits.K**3),
'4': (0, pyunits.J/pyunits.kmol/pyunits.K**4),
'5': (0, pyunits.J/pyunits.kmol/pyunits.K**5)},
"enth_mol_form_liq_comp_ref": (
-455.24e3, pyunits.J/pyunits.mol), # [3]
"enth_mol_form_vap_comp_ref": (
-389.37e3, pyunits.J/pyunits.mol), # [3]
"pressure_sat_comp_coeff": {'A': (13.6299, None), # [1]
'B': (6022.18, None),
'C': (-28.25, None),
'D': (0, None)}}}},

"water": {
"type": Component,
"elemental_composition": {"H": 2, "O": 1},
"dens_mol_liq_comp": Perrys,
"enth_mol_liq_comp": Perrys,
"enth_mol_ig_comp": RPP4,
"pressure_sat_comp": RPP4,
"phase_equilibrium_form": {("Vap", "Liq"): fugacity},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It probably doesn't merit changing here, but we should pretty much always be using log fugacity for phase equilibrium.

"parameter_data": {
"mw": (18.015e-3, pyunits.kg / pyunits.mol), # [1] pg. 667
"pressure_crit": (221.2e5, pyunits.Pa), # [1] pg. 667
"temperature_crit": (647.3, pyunits.K), # [1] pg. 667
"dens_mol_liq_comp_coeff": { # [2] pg. 2-98
"eqn_type": 1,
"1": (5.459, pyunits.kmol * pyunits.m**-3),
"2": (0.30542, None),
"3": (647.13, pyunits.K),
"4": (0.081, None),
},
"cp_mol_ig_comp_coeff": { # [1] pg. 668
"A": (3.224e1, pyunits.J / pyunits.mol / pyunits.K),
"B": (1.924e-3, pyunits.J / pyunits.mol / pyunits.K**2),
"C": (1.055e-5, pyunits.J / pyunits.mol / pyunits.K**3),
"D": (-3.596e-9, pyunits.J / pyunits.mol / pyunits.K**4),
},
"cp_mol_liq_comp_coeff": { # [2] pg. 2-174
"1": (2.7637e5, pyunits.J / pyunits.kmol / pyunits.K),
"2": (-2.0901e3, pyunits.J / pyunits.kmol / pyunits.K**2),
"3": (8.1250, pyunits.J / pyunits.kmol / pyunits.K**3),
"4": (-1.4116e-2, pyunits.J / pyunits.kmol / pyunits.K**4),
"5": (9.3701e-6, pyunits.J / pyunits.kmol / pyunits.K**5),
},
"enth_mol_form_liq_comp_ref": (
-285.830e3,
pyunits.J / pyunits.mol,
), # [3] updated 5/10/24
"enth_mol_form_vap_comp_ref": (
-241.826e3,
pyunits.J / pyunits.mol,
), # [3] updated 5/10/24
"pressure_sat_comp_coeff": {
"A": (-7.76451, None), # [1] pg. 669
"B": (1.45838, None),
"C": (-2.77580, None),
"D": (-1.23303, None),
},
},
},
"ethylene_glycol": {
"type": Component,
"elemental_composition": {"C": 2, "H": 6, "O": 2},
"dens_mol_liq_comp": Perrys,
"enth_mol_liq_comp": Perrys,
"enth_mol_ig_comp": RPP4,
"pressure_sat_comp": RPP4,
"phase_equilibrium_form": {("Vap", "Liq"): fugacity},
"parameter_data": {
"mw": (62.069e-3, pyunits.kg / pyunits.mol), # [1] pg. 676
"pressure_crit": (77e5, pyunits.Pa), # [1] pg. 676
"temperature_crit": (645, pyunits.K), # [1] pg. 676
"dens_mol_liq_comp_coeff": { # [2] pg. 2-95
"eqn_type": 1,
"1": (1.3151, pyunits.kmol * pyunits.m**-3),
"2": (0.25125, None),
"3": (719.7, pyunits.K),
"4": (0.2187, None),
},
"cp_mol_ig_comp_coeff": { # [1] pg. 677
"A": (3.570e1, pyunits.J / pyunits.mol / pyunits.K),
"B": (2.483e-1, pyunits.J / pyunits.mol / pyunits.K**2),
"C": (-1.497e-4, pyunits.J / pyunits.mol / pyunits.K**3),
"D": (3.010e-8, pyunits.J / pyunits.mol / pyunits.K**4),
},
"cp_mol_liq_comp_coeff": { # [2] pg. 2-171
"1": (3.5540e4, pyunits.J / pyunits.kmol / pyunits.K),
"2": (4.3678e2, pyunits.J / pyunits.kmol / pyunits.K**2),
"3": (-1.8486e-1, pyunits.J / pyunits.kmol / pyunits.K**3),
"4": (0, pyunits.J / pyunits.kmol / pyunits.K**4),
"5": (0, pyunits.J / pyunits.kmol / pyunits.K**5),
},
"enth_mol_form_liq_comp_ref": (
-460.0e3,
pyunits.J / pyunits.mol,
), # [3] updated 5/10/24
"enth_mol_form_vap_comp_ref": (
-394.4e3,
pyunits.J / pyunits.mol,
), # [3] updated 5/10/24
# [1] pg. 678 pressure sat coef values for alternative equation form
# ln Pvp = A - B/(T + C) with A = 13.6299, B = 6022.18, C = -28.25
# reformulated for generic property supported form
# ln Pvp = [(1 - x)^-1 * (A*x + B*x^1.5 + C*x^3 + D*x^6)] * Pc where x = 1 - T/Tc
"pressure_sat_comp_coeff": {
"A": (-16.4022, None),
"B": (10.0100, None),
"C": (-6.5216, None),
"D": (-11.1182, None),
},
},
},
},
# Specifying phases
"phases": {'Liq': {"type": LiquidPhase,
"equation_of_state": Ideal}},

"phases": {"Liq": {"type": LiquidPhase, "equation_of_state": Ideal}},
# Set base units of measurement
"base_units": {"time": pyunits.s,
"length": pyunits.m,
"mass": pyunits.kg,
"amount": pyunits.mol,
"temperature": pyunits.K},

"base_units": {
"time": pyunits.s,
"length": pyunits.m,
"mass": pyunits.kg,
"amount": pyunits.mol,
"temperature": pyunits.K,
},
# Specifying state definition
"state_definition": FpcTP,
"state_bounds": {"flow_mol_phase_comp": (0, 100, 1000,
pyunits.mol/pyunits.s),
"temperature": (273.15, 298.15, 450, pyunits.K),
"pressure": (1e3, 1e5, 1e6, pyunits.Pa)},
"state_bounds": {
"flow_mol_phase_comp": (0, 100, 1000, pyunits.mol / pyunits.s),
"temperature": (273.15, 298.15, 450, pyunits.K),
"pressure": (1e3, 1e5, 1e6, pyunits.Pa),
},
"pressure_ref": (1e5, pyunits.Pa),
"temperature_ref": (298.15, pyunits.K)}
"temperature_ref": (298.15, pyunits.K),
}
Original file line number Diff line number Diff line change
Expand Up @@ -583,18 +583,18 @@
"\n",
"assert value(\n",
" m.fs.PERMEATE.inlet.flow_mol_phase_comp[0, \"Liq\", \"water\"]\n",
") == pytest.approx(0.1426, rel=1e-3)\n",
") == pytest.approx(0.14258566, rel=1e-5)\n",
"assert value(\n",
" m.fs.PERMEATE.inlet.flow_mol_phase_comp[0, \"Liq\", \"ethylene_glycol\"]\n",
") == pytest.approx(0.0002667, rel=1e-3)\n",
") == pytest.approx(0.000266748768, rel=1e-5)\n",
"assert value(\n",
" m.fs.RETENTATE.inlet.flow_mol_phase_comp[0, \"Liq\", \"water\"]\n",
") == pytest.approx(0.1974, rel=1e-3)\n",
") == pytest.approx(0.19741534, rel=1e-5)\n",
"assert value(\n",
" m.fs.RETENTATE.inlet.flow_mol_phase_comp[0, \"Liq\", \"ethylene_glycol\"]\n",
") == pytest.approx(0.6597, rel=1e-3)\n",
"assert value(m.fs.separation_factor) == pytest.approx(1038, rel=1e-3)\n",
"assert value(m.fs.pervap.heat_duty[0]) == pytest.approx(5813, rel=1e-3)"
") == pytest.approx(0.65973425, rel=1e-5)\n",
"assert value(m.fs.separation_factor) == pytest.approx(1037.6188, rel=1e-5)\n",
"assert value(m.fs.pervap.heat_duty[0]) == pytest.approx(5812.7111, rel=1e-5)"
]
},
{
Expand Down Expand Up @@ -671,18 +671,18 @@
"\n",
"assert value(\n",
" m.fs.PERMEATE.inlet.flow_mol_phase_comp[0, \"Liq\", \"water\"]\n",
") == pytest.approx(0.1426, rel=1e-3)\n",
") == pytest.approx(0.14258566, rel=1e-5)\n",
"assert value(\n",
" m.fs.PERMEATE.inlet.flow_mol_phase_comp[0, \"Liq\", \"ethylene_glycol\"]\n",
") == pytest.approx(0.0002667, rel=1e-3)\n",
") == pytest.approx(0.000266748768, rel=1e-5)\n",
"assert value(\n",
" m.fs.RETENTATE.inlet.flow_mol_phase_comp[0, \"Liq\", \"water\"]\n",
") == pytest.approx(0.6998, rel=1e-3)\n",
") == pytest.approx(0.69981938, rel=1e-5)\n",
"assert value(\n",
" m.fs.RETENTATE.inlet.flow_mol_phase_comp[0, \"Liq\", \"ethylene_glycol\"]\n",
") == pytest.approx(0.1573, rel=1e-3)\n",
"assert value(m.fs.separation_factor) == pytest.approx(100.0, rel=1e-3)\n",
"assert value(m.fs.pervap.heat_duty[0]) == pytest.approx(5813, rel=1e-3)"
") == pytest.approx(0.15733020, rel=1e-5)\n",
"assert value(m.fs.separation_factor) == pytest.approx(100.000067, rel=1e-5)\n",
"assert value(m.fs.pervap.heat_duty[0]) == pytest.approx(5812.7111, rel=1e-5)"
]
},
{
Expand Down Expand Up @@ -719,9 +719,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.12"
"version": "3.9.18"
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}
Loading
Loading