Skip to content

Commit

Permalink
Fix Reactor Examples Properties (#95)
Browse files Browse the repository at this point in the history
* fix props and notebooks using eg_ideal

* fix other props package using same components

* update doc, test, usr notebooks

* make sure doc notebooks are executed and show output

* update properties from correct sources

* regenerate outdated notebooks

* fix typos

* fix cstr_doc

* regenerate outdated test, doc, usr files

* address reviewer comments

* add property tests for egprod_ideal

* very minor updates for tests to pass with new criteria

* regenerate doc, test, usr files

* add tests for eg_h2o_ideal, clean up

* address more reviewer comments

* revert eg_h2o_ideal lower pressure bound

* regenerate some notebooks

* fix test failures

* add cp_mol tests using enthalpy, use single comp props in tests

* simplify fix states lines

* remove non-enthalpy heat capacity tests

* add RPP4 tests

* add sulfuric acid tests, cleanup a bit

* very small tweaks to notebook results checks

* reformulate ethylene glycol psat to correct equation form

* run black on changed Python files

* remove heat capacity methods

---------

Co-authored-by: Ludovico Bianchi <[email protected]>
Co-authored-by: Andrew Lee <[email protected]>
  • Loading branch information
3 people authored Aug 22, 2024
1 parent e0d3966 commit fdf703b
Show file tree
Hide file tree
Showing 28 changed files with 8,744 additions and 8,017 deletions.
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},
"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

0 comments on commit fdf703b

Please sign in to comment.