##############################################################################
# Institute for the Design of Advanced Energy Systems Process Systems
# Engineering Framework (IDAES PSE Framework) Copyright (c) 2018, by the
# software owners: The Regents of the University of California, through
# Lawrence Berkeley National Laboratory, National Technology & Engineering
# Solutions of Sandia, LLC, Carnegie Mellon University, West Virginia
# University Research Corporation, et al. All rights reserved.
#
# Please see the files COPYRIGHT.txt and LICENSE.txt for full copyright and
# license information, respectively. Both files are also available online
# at the URL "https://github.com/IDAES/idaes".
##############################################################################
"""
Standard IDAES product block.
"""
from __future__ import division
# Import Python libraries
import logging
# Import Pyomo libraries
from pyomo.network import Port
from pyomo.common.config import ConfigValue, In
# Import IDAES cores
from idaes.core import UnitBlockData, declare_process_block_class, \
HoldupStatic, CONFIG_Base
from idaes.core.util.config import is_parameter_block, list_of_strings
__author__ = "Andrew Lee"
# Set up logger
logger = logging.getLogger('idaes.unit_model')
[docs]@declare_process_block_class("Product")
class ProductData(UnitBlockData):
"""
Standard Product Block Class
"""
CONFIG = CONFIG_Base()
# Set dynamic flag, as model is only steady-state
CONFIG.dynamic = False
CONFIG.get('dynamic')._default = False
CONFIG.get('dynamic')._domain = In([False])
# Set default values of inherited attributes
CONFIG.get('include_holdup')._default = False
CONFIG.get("material_balance_type")._default = 'component_phase'
CONFIG.get("energy_balance_type")._default = 'total'
CONFIG.get("momentum_balance_type")._default = 'total'
CONFIG.get("has_rate_reactions")._default = False
CONFIG.get("has_equilibrium_reactions")._default = False
CONFIG.get("has_phase_equilibrium")._default = False
CONFIG.get("has_mass_transfer")._default = False
CONFIG.get("has_heat_transfer")._default = False
CONFIG.get("has_work_transfer")._default = False
CONFIG.get("has_pressure_change")._default = False
# Add unit model attributes
CONFIG.declare("property_package", ConfigValue(
default=None,
domain=is_parameter_block,
description="Property package to use for holdup",
doc="""Property parameter object used to define property calculations
(default = 'use_parent_value')
- 'use_parent_value' - get package from parent (default = None)
- a ParameterBlock object"""))
CONFIG.declare("property_package_args", ConfigValue(
default={},
description="Arguments to use for constructing property packages",
doc="""A dict of arguments to be passed to the PropertyBlockData
and used when constructing these
(default = 'use_parent_value')
- 'use_parent_value' - get package from parent (default = None)
- a dict (see property package for documentation)"""))
CONFIG.declare("inlet_list", ConfigValue(
domain=list_of_strings,
description="List of inlet names",
doc="""A list containing names of inlets (default = None)
- None - default single inlet
- list - a list of names for inlets"""))
CONFIG.declare("num_inlets", ConfigValue(
domain=int,
description="Number of inlets to unit",
doc="""Argument indication number (int) of inlets to construct
(default = None). Not used if inlet_list arg is provided.
- None - use inlet_list arg instead
- int - Inlets will be named with sequential numbers from 1
to num_inlets"""))
[docs] def build(self):
"""
Begin building model (pre-DAE transformation).
Args:
None
Returns:
None
"""
# Call UnitModel.build to setup dynamics
super(ProductData, self).build()
# Build Holdup Block
self.holdup = HoldupStatic()
[docs] def post_transform_build(self):
"""
Continue model construction after DAE transformation.
Args:
None
Returns:
None
"""
# Make references to state variables
self._set_product_references()
# Build Inlets
self.build_inlets(inlets=self.config.inlet_list,
num_inlets=self.config.num_inlets)
def _set_product_references(self):
"""
Create references to product state variables.
Args:
None
Returns:
None
"""
# Use a Pyomo Port to collect the product state variables
def product_rule(b, t):
return b.holdup.properties[t].declare_port_members()
p = Port(self.time,
rule=product_rule,
doc="Product object")
setattr(self, "product", p)
[docs] def display(blk, display_block=False, ostream=None, prefix=""):
"""
Display the contents of Product unit.
Args:
display_block : indicates whether to display the entire Block
object (default = False).
ostream : output stream (default = None)
prefix : str to append to each line of output (default = '')
Returns:
None
"""
if display_block:
blk.display()
else:
blk.product.display()