-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated heater and heat exchanger tests w ASU
- Loading branch information
Mahaki Leach
committed
Dec 2, 2024
1 parent
ba569dd
commit bc53b0f
Showing
4 changed files
with
137 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# Build and solve a heater block. | ||
from ..build_package import build_package | ||
from pytest import approx | ||
|
||
# Import objects from pyomo package | ||
from pyomo.environ import ConcreteModel, SolverFactory, value, units | ||
|
||
# Import the main FlowsheetBlock from IDAES. The flowsheet block will contain the unit model | ||
from idaes.core import FlowsheetBlock | ||
from idaes.core.util.model_statistics import degrees_of_freedom | ||
from idaes.models.unit_models.heater import Heater | ||
from idaes.core.util.tables import _get_state_from_port | ||
|
||
def assert_approx(value, expected_value, error_margin): | ||
percent_error = error_margin / 100 | ||
tolerance = abs(percent_error * expected_value) | ||
assert approx(value, abs=tolerance) == expected_value | ||
|
||
def test_heater_bt(): | ||
m = ConcreteModel() | ||
m.fs = FlowsheetBlock(dynamic=False) | ||
m.fs.properties = build_package("peng-robinson", ["benzene", "toluene"], ["Liq", "Vap"]) | ||
|
||
m.fs.heater = Heater(property_package=m.fs.properties) | ||
|
||
m.fs.heater.inlet.flow_mol.fix(1000/3600) | ||
m.fs.heater.inlet.mole_frac_comp[0, "benzene"].fix(0.4) | ||
m.fs.heater.inlet.mole_frac_comp[0, "toluene"].fix(0.6) | ||
m.fs.heater.inlet.pressure.fix(101325) | ||
m.fs.heater.inlet.temperature.fix(353) | ||
m.fs.heater.heat_duty.fix(459.10147722222354) | ||
|
||
m.fs.heater.initialize() | ||
|
||
assert degrees_of_freedom(m) == 0 | ||
|
||
solver = SolverFactory('ipopt') | ||
solver.solve(m, tee=True) | ||
|
||
assert_approx(value(_get_state_from_port(m.fs.heater.outlet,0).temperature), 363, 0.2) | ||
assert value(m.fs.heater.outlet.pressure[0]) == approx(101325) | ||
assert value(m.fs.heater.outlet.flow_mol[0]) == approx(1000/3600) | ||
|
||
def test_heater_asu(): | ||
m = ConcreteModel() | ||
m.fs = FlowsheetBlock(dynamic=False) | ||
m.fs.properties = build_package("peng-robinson", ["argon", "nitrogen", "oxygen"], ["Liq", "Vap"]) | ||
|
||
m.fs.heater = Heater(property_package=m.fs.properties) | ||
|
||
m.fs.heater.inlet.flow_mol.fix(units.convert(1 * units.kilomol/units.hour, units.mol/units.s)) # mol/s | ||
m.fs.heater.inlet.mole_frac_comp[0, "argon"].fix(0.33) | ||
m.fs.heater.inlet.mole_frac_comp[0, "nitrogen"].fix(0.33) | ||
m.fs.heater.inlet.mole_frac_comp[0, "oxygen"].fix(0.33) | ||
m.fs.heater.inlet.pressure.fix(100000) | ||
m.fs.heater.inlet.temperature.fix(units.convert_temp_C_to_K(25)) | ||
m.fs.heater.outlet.temperature.fix(units.convert_temp_C_to_K(50)) | ||
|
||
m.fs.heater.initialize() | ||
|
||
assert degrees_of_freedom(m) == 0 | ||
|
||
solver = SolverFactory('ipopt') | ||
solver.solve(m, tee=True) | ||
|
||
assert_approx(value(m.fs.heater.heat_duty[0]), 183.856, 1) # 1% tolerance | ||
|
||
m.fs.heater2 = Heater(property_package=m.fs.properties) | ||
|
||
m.fs.heater2.inlet.flow_mol.fix(units.convert(1 * units.kilomol/units.hour, units.mol/units.s)) # mol/s | ||
m.fs.heater2.inlet.mole_frac_comp[0, "argon"].fix(0.33) | ||
m.fs.heater2.inlet.mole_frac_comp[0, "nitrogen"].fix(0.33) | ||
m.fs.heater2.inlet.mole_frac_comp[0, "oxygen"].fix(0.33) | ||
m.fs.heater2.inlet.pressure.fix(100000) | ||
m.fs.heater2.inlet.temperature.fix(units.convert_temp_C_to_K(25)) | ||
m.fs.heater2.outlet.temperature.fix(units.convert_temp_C_to_K(-15)) | ||
|
||
m.fs.heater2.initialize() | ||
|
||
assert degrees_of_freedom(m) == 0 | ||
|
||
solver = SolverFactory('ipopt') | ||
solver.solve(m, tee=True) | ||
|
||
assert_approx(value(m.fs.heater2.heat_duty[0]), -292.5, 1) # 1% tolerance |