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.
- ahuora_builder/__init__.py +0 -0
- ahuora_builder/arc_manager.py +33 -0
- ahuora_builder/build_state.py +57 -0
- ahuora_builder/custom/PIDController.py +494 -0
- ahuora_builder/custom/PySMOModel.py +178 -0
- ahuora_builder/custom/SimpleEffectivenessHX_DH.py +727 -0
- ahuora_builder/custom/__init__.py +0 -0
- ahuora_builder/custom/add_initial_dynamics.py +35 -0
- ahuora_builder/custom/custom_compressor.py +107 -0
- ahuora_builder/custom/custom_cooler.py +33 -0
- ahuora_builder/custom/custom_heat_exchanger.py +183 -0
- ahuora_builder/custom/custom_heat_exchanger_1d.py +258 -0
- ahuora_builder/custom/custom_heater.py +41 -0
- ahuora_builder/custom/custom_pressure_changer.py +34 -0
- ahuora_builder/custom/custom_pump.py +107 -0
- ahuora_builder/custom/custom_separator.py +371 -0
- ahuora_builder/custom/custom_tank.py +133 -0
- ahuora_builder/custom/custom_turbine.py +132 -0
- ahuora_builder/custom/custom_valve.py +300 -0
- ahuora_builder/custom/custom_variable.py +29 -0
- ahuora_builder/custom/direct_steam_injection.py +371 -0
- ahuora_builder/custom/energy/__init__.py +0 -0
- ahuora_builder/custom/energy/acBus.py +280 -0
- ahuora_builder/custom/energy/ac_property_package.py +279 -0
- ahuora_builder/custom/energy/battery.py +170 -0
- ahuora_builder/custom/energy/bus.py +182 -0
- ahuora_builder/custom/energy/energy_mixer.py +195 -0
- ahuora_builder/custom/energy/energy_splitter.py +228 -0
- ahuora_builder/custom/energy/grid.py +173 -0
- ahuora_builder/custom/energy/hydro.py +169 -0
- ahuora_builder/custom/energy/link.py +137 -0
- ahuora_builder/custom/energy/load.py +155 -0
- ahuora_builder/custom/energy/mainDistributionBoard.py +257 -0
- ahuora_builder/custom/energy/power_property_package.py +253 -0
- ahuora_builder/custom/energy/solar.py +176 -0
- ahuora_builder/custom/energy/storage.py +230 -0
- ahuora_builder/custom/energy/storage_wrapper +0 -0
- ahuora_builder/custom/energy/tests/__init__.py +0 -0
- ahuora_builder/custom/energy/tests/test_bus.py +44 -0
- ahuora_builder/custom/energy/tests/test_energy_mixer.py +46 -0
- ahuora_builder/custom/energy/tests/test_mdb.py +49 -0
- ahuora_builder/custom/energy/transformer.py +187 -0
- ahuora_builder/custom/energy/transformer_property_package.py +267 -0
- ahuora_builder/custom/energy/transmissionLine.py +228 -0
- ahuora_builder/custom/energy/wind.py +206 -0
- ahuora_builder/custom/hda_ideal_VLE.py +1341 -0
- ahuora_builder/custom/hda_reaction.py +182 -0
- ahuora_builder/custom/heat_exchanger_1d_wrapper.py +31 -0
- ahuora_builder/custom/integration_block.py +106 -0
- ahuora_builder/custom/inverted.py +81 -0
- ahuora_builder/custom/performance_curves.py +1 -0
- ahuora_builder/custom/reactions/__init__.py +0 -0
- ahuora_builder/custom/reactions/hda_stoich.py +10 -0
- ahuora_builder/custom/simple_separator.py +680 -0
- ahuora_builder/custom/tests/__init__.py +0 -0
- ahuora_builder/custom/tests/test_SimpleEffectivenessHX_DH.py +91 -0
- ahuora_builder/custom/tests/test_custom_tank.py +70 -0
- ahuora_builder/custom/tests/test_direct_steam_injection.py +41 -0
- ahuora_builder/custom/tests/test_simple_separator.py +46 -0
- ahuora_builder/custom/tests/test_waterpipe.py +46 -0
- ahuora_builder/custom/thermal_utility_systems/desuperheater.py +624 -0
- ahuora_builder/custom/thermal_utility_systems/header.py +889 -0
- ahuora_builder/custom/thermal_utility_systems/simple_heat_pump.py +567 -0
- ahuora_builder/custom/thermal_utility_systems/steam_header.py +353 -0
- ahuora_builder/custom/thermal_utility_systems/steam_user.py +944 -0
- ahuora_builder/custom/thermal_utility_systems/temp.py +349 -0
- ahuora_builder/custom/thermal_utility_systems/tests/test_desuperheater.py +142 -0
- ahuora_builder/custom/thermal_utility_systems/tests/test_header.py +998 -0
- ahuora_builder/custom/thermal_utility_systems/tests/test_ntu_hx.py +129 -0
- ahuora_builder/custom/thermal_utility_systems/tests/test_simple_heat_pump.py +120 -0
- ahuora_builder/custom/thermal_utility_systems/tests/test_steam_header.py +703 -0
- ahuora_builder/custom/thermal_utility_systems/tests/test_steam_user.py +277 -0
- ahuora_builder/custom/thermal_utility_systems/tests/test_waterpipe.py +36 -0
- ahuora_builder/custom/thermal_utility_systems/tests/test_willans_turbine.py +253 -0
- ahuora_builder/custom/thermal_utility_systems/willans_turbine.py +804 -0
- ahuora_builder/custom/translator.py +129 -0
- ahuora_builder/custom/updated_pressure_changer.py +1404 -0
- ahuora_builder/custom/valve_wrapper.py +38 -0
- ahuora_builder/custom/water_tank_with_units.py +456 -0
- ahuora_builder/diagnostics/__init__.py +0 -0
- ahuora_builder/diagnostics/infeasibilities.py +40 -0
- ahuora_builder/diagnostics/tests/__init__.py +0 -0
- ahuora_builder/diagnostics/tests/test_infeasibilities.py +28 -0
- ahuora_builder/flowsheet_manager.py +542 -0
- ahuora_builder/flowsheet_manager_type.py +20 -0
- ahuora_builder/generate_python_file.py +440 -0
- ahuora_builder/methods/BlockContext.py +84 -0
- ahuora_builder/methods/__init__.py +0 -0
- ahuora_builder/methods/adapter.py +355 -0
- ahuora_builder/methods/adapter_library.py +549 -0
- ahuora_builder/methods/adapter_methods.py +80 -0
- ahuora_builder/methods/expression_parsing.py +105 -0
- ahuora_builder/methods/load_unit_model.py +147 -0
- ahuora_builder/methods/slice_manipulation.py +7 -0
- ahuora_builder/methods/tests/__init__.py +0 -0
- ahuora_builder/methods/tests/test_expression_parsing.py +15 -0
- ahuora_builder/methods/units_handler.py +129 -0
- ahuora_builder/ml_wizard.py +101 -0
- ahuora_builder/port_manager.py +20 -0
- ahuora_builder/properties_manager.py +44 -0
- ahuora_builder/property_package_manager.py +78 -0
- ahuora_builder/solver.py +38 -0
- ahuora_builder/tear_manager.py +98 -0
- ahuora_builder/tests/__init__.py +0 -0
- ahuora_builder/tests/test_generate_python_file/__init__.py +0 -0
- ahuora_builder/tests/test_generate_python_file/configurations/compressor_generated.py +63 -0
- ahuora_builder/tests/test_generate_python_file/configurations/heat_exchanger_generated.py +70 -0
- ahuora_builder/tests/test_generate_python_file/configurations/pump_generated.py +84 -0
- ahuora_builder/tests/test_generate_python_file/configurations/recycle_generated.py +73 -0
- ahuora_builder/tests/test_generate_python_file/test_generate_python_file.py +108 -0
- ahuora_builder/tests/test_solver/__init__.py +0 -0
- ahuora_builder/tests/test_solver/configurations/BT_PR.json +59 -0
- ahuora_builder/tests/test_solver/configurations/BT_PR_solved.json +59 -0
- ahuora_builder/tests/test_solver/configurations/bus.json +99 -0
- ahuora_builder/tests/test_solver/configurations/bus_solved.json +50 -0
- ahuora_builder/tests/test_solver/configurations/compound_separator.json +377 -0
- ahuora_builder/tests/test_solver/configurations/compound_separator_solved.json +374 -0
- ahuora_builder/tests/test_solver/configurations/compressor.json +38 -0
- ahuora_builder/tests/test_solver/configurations/compressor_solved.json +68 -0
- ahuora_builder/tests/test_solver/configurations/constraints.json +44 -0
- ahuora_builder/tests/test_solver/configurations/constraints_solved.json +59 -0
- ahuora_builder/tests/test_solver/configurations/control.json +39 -0
- ahuora_builder/tests/test_solver/configurations/control_solved.json +68 -0
- ahuora_builder/tests/test_solver/configurations/dynamic_tank.json +733 -0
- ahuora_builder/tests/test_solver/configurations/dynamic_tank_solved.json +846 -0
- ahuora_builder/tests/test_solver/configurations/elimination.json +39 -0
- ahuora_builder/tests/test_solver/configurations/elimination_solved.json +68 -0
- ahuora_builder/tests/test_solver/configurations/expressions.json +68 -0
- ahuora_builder/tests/test_solver/configurations/expressions_solved.json +104 -0
- ahuora_builder/tests/test_solver/configurations/header.json +1192 -0
- ahuora_builder/tests/test_solver/configurations/header_solved.json +761 -0
- ahuora_builder/tests/test_solver/configurations/heat_exchanger.json +63 -0
- ahuora_builder/tests/test_solver/configurations/heat_exchanger_solved.json +104 -0
- ahuora_builder/tests/test_solver/configurations/heat_pump.json +137 -0
- ahuora_builder/tests/test_solver/configurations/heat_pump_solved.json +104 -0
- ahuora_builder/tests/test_solver/configurations/machine_learning.json +2156 -0
- ahuora_builder/tests/test_solver/configurations/machine_learning_solved.json +266 -0
- ahuora_builder/tests/test_solver/configurations/mass_flow_tear.json +77 -0
- ahuora_builder/tests/test_solver/configurations/mass_flow_tear_solved.json +68 -0
- ahuora_builder/tests/test_solver/configurations/milk_heater.json +521 -0
- ahuora_builder/tests/test_solver/configurations/milk_heater_solved.json +311 -0
- ahuora_builder/tests/test_solver/configurations/mixer.json +44 -0
- ahuora_builder/tests/test_solver/configurations/mixer_solved.json +86 -0
- ahuora_builder/tests/test_solver/configurations/optimization.json +62 -0
- ahuora_builder/tests/test_solver/configurations/optimization_solved.json +59 -0
- ahuora_builder/tests/test_solver/configurations/propane_heat_pump.json +167 -0
- ahuora_builder/tests/test_solver/configurations/propane_heat_pump_solved.json +158 -0
- ahuora_builder/tests/test_solver/configurations/propane_recycle.json +141 -0
- ahuora_builder/tests/test_solver/configurations/propane_recycle_solved.json +104 -0
- ahuora_builder/tests/test_solver/configurations/pump.json +64 -0
- ahuora_builder/tests/test_solver/configurations/pump_solved.json +59 -0
- ahuora_builder/tests/test_solver/configurations/pump_unit_conversions.json +63 -0
- ahuora_builder/tests/test_solver/configurations/recycle.json +49 -0
- ahuora_builder/tests/test_solver/configurations/recycle_solved.json +50 -0
- ahuora_builder/tests/test_solver/configurations/sb_vapor_frac.json +29 -0
- ahuora_builder/tests/test_solver/configurations/sb_vapor_frac_solved.json +29 -0
- ahuora_builder/tests/test_solver/configurations/solar.json +67 -0
- ahuora_builder/tests/test_solver/configurations/solar_solved.json +50 -0
- ahuora_builder/tests/test_solver/configurations/vapor_frac_target.json +67 -0
- ahuora_builder/tests/test_solver/configurations/vapor_frac_target_solved.json +68 -0
- ahuora_builder/tests/test_solver/test_solve_models.py +250 -0
- ahuora_builder/timing.py +65 -0
- ahuora_builder/types/__init__.py +1 -0
- ahuora_builder/unit_model_manager.py +48 -0
- ahuora_builder-0.1.0.dist-info/METADATA +14 -0
- ahuora_builder-0.1.0.dist-info/RECORD +167 -0
- ahuora_builder-0.1.0.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
|
|
3
|
+
from pyomo.environ import (
|
|
4
|
+
check_optimal_termination,
|
|
5
|
+
ConcreteModel,
|
|
6
|
+
Constraint,
|
|
7
|
+
Expression,
|
|
8
|
+
Param,
|
|
9
|
+
units as pyunits,
|
|
10
|
+
value,
|
|
11
|
+
Var,
|
|
12
|
+
)
|
|
13
|
+
from pyomo.util.check_units import assert_units_consistent, assert_units_equivalent
|
|
14
|
+
|
|
15
|
+
from idaes.core import FlowsheetBlock
|
|
16
|
+
from idaes.models.unit_models.heat_exchanger_ntu import (
|
|
17
|
+
HeatExchangerNTU as HXNTU,
|
|
18
|
+
HXNTUInitializer,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
from idaes.models.properties.modular_properties.base.generic_property import (
|
|
22
|
+
GenericParameterBlock,
|
|
23
|
+
)
|
|
24
|
+
from idaes.models_extra.column_models.properties.MEA_solvent import (
|
|
25
|
+
configuration as aqueous_mea,
|
|
26
|
+
)
|
|
27
|
+
from idaes.core.util.model_statistics import degrees_of_freedom
|
|
28
|
+
from idaes.core.solvers import get_solver
|
|
29
|
+
from idaes.core.util.testing import initialization_tester, PhysicalParameterTestBlock
|
|
30
|
+
from idaes.core.util.exceptions import ConfigurationError, InitializationError
|
|
31
|
+
from idaes.core.initialization import (
|
|
32
|
+
BlockTriangularizationInitializer,
|
|
33
|
+
InitializationStatus,
|
|
34
|
+
)
|
|
35
|
+
from idaes.core.util import DiagnosticsToolbox
|
|
36
|
+
from idaes.models.properties import iapws95
|
|
37
|
+
|
|
38
|
+
def test_ntu_hx():
|
|
39
|
+
m = ConcreteModel()
|
|
40
|
+
m.fs = FlowsheetBlock(dynamic=False)
|
|
41
|
+
m.fs.properties = iapws95.Iapws95ParameterBlock(
|
|
42
|
+
phase_presentation=iapws95.PhaseType.MIX,
|
|
43
|
+
state_vars=iapws95.StateVars.PH
|
|
44
|
+
)
|
|
45
|
+
import math
|
|
46
|
+
|
|
47
|
+
m.fs.unit = HXNTU(
|
|
48
|
+
hot_side={
|
|
49
|
+
"property_package": m.fs.properties,
|
|
50
|
+
"has_pressure_change": False,
|
|
51
|
+
},
|
|
52
|
+
cold_side={
|
|
53
|
+
"property_package": m.fs.properties,
|
|
54
|
+
"has_pressure_change": False,
|
|
55
|
+
},
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
# Hot fluid
|
|
59
|
+
m.fs.unit.hot_side_inlet.flow_mol[0].fix(60.54879)
|
|
60
|
+
m.fs.unit.hot_side_inlet.enth_mol[0].fix(m.fs.properties.htpx(p=202650*pyunits.Pa, T=392.23*pyunits.K))
|
|
61
|
+
#m.fs.unit.hot_side_inlet.temperature[0].fix(392.23)
|
|
62
|
+
m.fs.unit.hot_side_inlet.pressure[0].fix(202650)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
# Cold fluid
|
|
66
|
+
m.fs.unit.cold_side_inlet.flow_mol[0].fix(63.01910)
|
|
67
|
+
m.fs.unit.cold_side_inlet.enth_mol[0].fix(m.fs.properties.htpx(p=202650*pyunits.Pa, T=326.36*pyunits.K))
|
|
68
|
+
#m.fs.unit.cold_side_inlet.temperature[0].fix(326.36)
|
|
69
|
+
m.fs.unit.cold_side_inlet.pressure[0].fix(202650)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
# Unit design variables
|
|
73
|
+
m.fs.unit.area.fix(100)
|
|
74
|
+
m.fs.unit.heat_transfer_coefficient.fix(200)
|
|
75
|
+
e = 0.7
|
|
76
|
+
m.fs.unit.effectiveness.fix(e)
|
|
77
|
+
|
|
78
|
+
# m.fs.unit.hot_side.deltaP.fix(-2000)
|
|
79
|
+
# m.fs.unit.cold_side.deltaP.fix(-2000)
|
|
80
|
+
|
|
81
|
+
m.fs.unit.initialize()
|
|
82
|
+
|
|
83
|
+
solver = get_solver()
|
|
84
|
+
results = solver.solve(m, tee=True)
|
|
85
|
+
|
|
86
|
+
m.fs.unit.report()
|
|
87
|
+
print(value(m.fs.unit.NTU[0]))
|
|
88
|
+
print(value(m.fs.unit.heat_duty[0]))
|
|
89
|
+
print(value(m.fs.unit.Cmin[0]))
|
|
90
|
+
print(value(m.fs.unit.Cmax[0]))
|
|
91
|
+
|
|
92
|
+
if value(m.fs.unit.hot_side.properties_in[0].flow_mol * m.fs.unit.hot_side.properties_in[0].cp_mol) < value(m.fs.unit.cold_side.properties_in[0].flow_mol * m.fs.unit.cold_side.properties_in[0].cp_mol):
|
|
93
|
+
Cmin = value(
|
|
94
|
+
m.fs.unit.hot_side.properties_in[0].flow_mol
|
|
95
|
+
* m.fs.unit.hot_side.properties_in[0].cp_mol
|
|
96
|
+
)
|
|
97
|
+
Cmax = value(
|
|
98
|
+
m.fs.unit.cold_side.properties_in[0].flow_mol
|
|
99
|
+
* m.fs.unit.cold_side.properties_in[0].cp_mol
|
|
100
|
+
)
|
|
101
|
+
else:
|
|
102
|
+
Cmax = value(
|
|
103
|
+
m.fs.unit.hot_side.properties_in[0].flow_mol
|
|
104
|
+
* m.fs.unit.hot_side.properties_in[0].cp_mol
|
|
105
|
+
)
|
|
106
|
+
Cmin = value(
|
|
107
|
+
m.fs.unit.hot_side.properties_in[0].flow_mol
|
|
108
|
+
* m.fs.unit.hot_side.properties_in[0].cp_mol
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
NTU = value(m.fs.unit.heat_transfer_coefficient[0] * m.fs.unit.area / Cmin)
|
|
112
|
+
Q_duty = value(Cmin * e * (m.fs.unit.hot_side.properties_in[0].temperature - m.fs.unit.cold_side.properties_in[0].temperature))
|
|
113
|
+
# Cmin = 5
|
|
114
|
+
# Cmax = 5
|
|
115
|
+
#NTU = 18
|
|
116
|
+
#Q_duty = 20
|
|
117
|
+
assert math.isclose(value(m.fs.unit.Cmin[0]), Cmin, rel_tol=1e-5), (
|
|
118
|
+
f"Cmin mismatch: model={value(m.fs.unit.Cmin[0])}, calculated={Cmin}"
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
assert math.isclose(value(m.fs.unit.Cmax[0]), Cmax, rel_tol=1e-5), (
|
|
122
|
+
f"Cmax mismatch: model={value(m.fs.unit.Cmax[0])}, calculated={Cmax}"
|
|
123
|
+
)
|
|
124
|
+
assert math.isclose(value(m.fs.unit.NTU[0]), NTU, rel_tol=1e-5), (
|
|
125
|
+
f"NTU mismatch: model={value(m.fs.unit.NTU[0])}, calculated={NTU}"
|
|
126
|
+
)
|
|
127
|
+
assert math.isclose(value(m.fs.unit.heat_duty[0]), Q_duty, rel_tol=1e-5), (
|
|
128
|
+
f"Heat duty mismatch: model={value(m.fs.unit.heat_duty[0])}, calculated={Q_duty}"
|
|
129
|
+
)
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
|
|
3
|
+
from ahuora_builder.custom.thermal_utility_systems.simple_heat_pump import (
|
|
4
|
+
SimpleHeatPump,
|
|
5
|
+
)
|
|
6
|
+
|
|
7
|
+
import pyomo.environ as pyo
|
|
8
|
+
from idaes.core import FlowsheetBlock
|
|
9
|
+
from idaes.core.util.model_statistics import degrees_of_freedom
|
|
10
|
+
#from property_packages.build_package import build_package # build package still broken for windows users
|
|
11
|
+
from idaes.models.properties.general_helmholtz import (
|
|
12
|
+
HelmholtzParameterBlock,
|
|
13
|
+
PhaseType,
|
|
14
|
+
StateVars,
|
|
15
|
+
AmountBasis,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
from pyomo.network import Arc, SequentialDecomposition
|
|
19
|
+
import idaes.logger as idaeslog
|
|
20
|
+
import math
|
|
21
|
+
|
|
22
|
+
def _make_case():
|
|
23
|
+
m = pyo.ConcreteModel()
|
|
24
|
+
m.fs = FlowsheetBlock(dynamic = False)
|
|
25
|
+
m.fs.water = HelmholtzParameterBlock(
|
|
26
|
+
pure_component="h2o",
|
|
27
|
+
phase_presentation=PhaseType.LG,
|
|
28
|
+
state_vars=StateVars.PH,
|
|
29
|
+
amount_basis=AmountBasis.MOLE,
|
|
30
|
+
)
|
|
31
|
+
#build_package("helmholtz", ["water"], ["Liq", "Vap"])
|
|
32
|
+
|
|
33
|
+
m.fs.hp = SimpleHeatPump(source={
|
|
34
|
+
"property_package": m.fs.water,
|
|
35
|
+
"has_pressure_change": False,
|
|
36
|
+
}, sink={
|
|
37
|
+
"property_package": m.fs.water,
|
|
38
|
+
"has_pressure_change": False,
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
# Set source (hot side) conditions
|
|
42
|
+
T_source_in = (80 + 273.15) * pyo.units.K # K
|
|
43
|
+
P_source_in = 4e5 * pyo.units.Pa # Pa
|
|
44
|
+
F_source_in = 29 * 15.4 * pyo.units.mol / pyo.units.s # mol/s
|
|
45
|
+
|
|
46
|
+
m.fs.hp.source_inlet.flow_mol.fix(F_source_in) # mol/s
|
|
47
|
+
m.fs.hp.source_inlet.pressure.fix(P_source_in) # 4 Bar
|
|
48
|
+
m.fs.hp.source_inlet.enth_mol.fix(
|
|
49
|
+
m.fs.water.htpx(T_source_in , m.fs.hp.source_inlet.pressure[0])
|
|
50
|
+
) # J/mol
|
|
51
|
+
m.fs.hp.approach_temperature.fix(10) # K
|
|
52
|
+
|
|
53
|
+
# Set sink (cold side) conditions
|
|
54
|
+
T_sink_in = (90 + 273.15) * pyo.units.K # K
|
|
55
|
+
P_sink_in = 8e5 * pyo.units.Pa # Pa
|
|
56
|
+
F_sink_in = 1.1 * 15.4 * pyo.units.mol / pyo.units.s # mol/s
|
|
57
|
+
|
|
58
|
+
m.fs.hp.sink_inlet.flow_mol.fix(F_sink_in) # mol/s
|
|
59
|
+
m.fs.hp.sink_inlet.pressure.fix(P_sink_in) # 10 Bar
|
|
60
|
+
m.fs.hp.sink_inlet.enth_mol.fix(
|
|
61
|
+
m.fs.water.htpx(T_sink_in, m.fs.hp.sink_inlet.pressure[0])
|
|
62
|
+
) # J/mol
|
|
63
|
+
|
|
64
|
+
return m
|
|
65
|
+
|
|
66
|
+
def _assert_solution(m):
|
|
67
|
+
eps_rel = 1e-4
|
|
68
|
+
eps_abs = 0.1
|
|
69
|
+
m.fs.hp.initialize()
|
|
70
|
+
|
|
71
|
+
assert degrees_of_freedom(m) == 0
|
|
72
|
+
|
|
73
|
+
solver = pyo.SolverFactory("ipopt")
|
|
74
|
+
solver.solve(m, tee=True)
|
|
75
|
+
|
|
76
|
+
# Check heat balances Qsink = Qsource + W
|
|
77
|
+
Q_sink = pyo.value(m.fs.hp.sink_inlet.flow_mol[0] * (m.fs.hp.sink_outlet.enth_mol[0] - m.fs.hp.sink_inlet.enth_mol[0] ))
|
|
78
|
+
Q_source = pyo.value(m.fs.hp.source_inlet.flow_mol[0] * (m.fs.hp.source_inlet.enth_mol[0] - m.fs.hp.source_outlet.enth_mol[0] ))
|
|
79
|
+
|
|
80
|
+
assert Q_sink - pyo.value(m.fs.hp.work_mechanical[0]) - Q_source == pytest.approx(0, rel=eps_rel, abs=eps_abs)
|
|
81
|
+
assert abs(pyo.value(m.fs.hp.source.heat[0])) == pytest.approx(Q_source, rel=eps_rel, abs=eps_abs)
|
|
82
|
+
assert abs(pyo.value(m.fs.hp.sink.heat[0])) == pytest.approx(Q_sink, rel=eps_rel, abs=eps_abs)
|
|
83
|
+
|
|
84
|
+
# Check that CoP is calculated correctly
|
|
85
|
+
assert pyo.value(m.fs.hp.coefficient_of_performance) == pytest.approx(Q_sink / pyo.value(m.fs.hp.work_mechanical[0]), rel=eps_rel, abs=eps_abs)
|
|
86
|
+
|
|
87
|
+
# Check that duties and CoP are as expected from datasheet
|
|
88
|
+
assert pyo.value(m.fs.hp.coefficient_of_performance) == pytest.approx(1.9, rel=0.05, abs=0.2)
|
|
89
|
+
assert pyo.value(m.fs.hp.sink.heat[0]) == pytest.approx(720e3, rel=0.05, abs=50e3)
|
|
90
|
+
|
|
91
|
+
m.fs.hp.report()
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def test_heat_pump_with_work_and_efficiency():
|
|
95
|
+
m = _make_case()
|
|
96
|
+
# Fix efficiency to the Ovolondo heat pump
|
|
97
|
+
m.fs._ = pyo.Constraint(expr=m.fs.hp.efficiency == 0.3305 + 0.2723 * pyo.tanh((m.fs.hp.delta_temperature_lift[0] - 57.64) / 74.19))
|
|
98
|
+
m.fs.hp.approach_temperature.fix(10) # K
|
|
99
|
+
# Fix mechanical work to the example
|
|
100
|
+
m.fs.hp.work_mechanical.fix(380e3) # W
|
|
101
|
+
|
|
102
|
+
assert degrees_of_freedom(m) == 0
|
|
103
|
+
|
|
104
|
+
_assert_solution(m)
|
|
105
|
+
|
|
106
|
+
def test_heat_pump_with_sink_outlet_and_efficiency():
|
|
107
|
+
m = _make_case()
|
|
108
|
+
|
|
109
|
+
# Fix efficiency to the Ovolondo heat pump
|
|
110
|
+
m.fs._ = pyo.Constraint(expr=m.fs.hp.efficiency == 0.3305 + 0.2723 * pyo.tanh((m.fs.hp.delta_temperature_lift[0] - 57.64) / 74.19))
|
|
111
|
+
m.fs.hp.approach_temperature.fix(10) # K
|
|
112
|
+
# Fix sink outlet temperature to the Ovolondo heat pump
|
|
113
|
+
T_sink_out = (171 + 273.15) * pyo.units.K # K
|
|
114
|
+
m.fs.hp.sink_outlet.enth_mol.fix(
|
|
115
|
+
m.fs.water.htpx(T_sink_out , m.fs.hp.sink_inlet.pressure[0])
|
|
116
|
+
) # J/mol
|
|
117
|
+
|
|
118
|
+
assert degrees_of_freedom(m) == 0
|
|
119
|
+
|
|
120
|
+
_assert_solution(m)
|