##############################################################################
# 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 splitter model.
"""
from __future__ import division
# Import Python libraries
import logging
# Import Pyomo libraries
from pyomo.common.config import ConfigValue, In
# Import IDAES cores
from idaes.core import UnitBlockData, declare_process_block_class, \
Holdup0D, HoldupStatic, CONFIG_Base
from idaes.core.util.config import is_parameter_block, list_of_strings
from idaes.core.util.misc import add_object_ref
__author__ = "Andrew Lee"
# Set up logger
logger = logging.getLogger('idaes.unit_model')
[docs]@declare_process_block_class("Splitter")
class SplitterData(UnitBlockData):
"""
Standard Splitter Unit Class
"""
CONFIG = CONFIG_Base()
# Set default values of inherited attributes
CONFIG.get('dynamic')._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"""))
CONFIG.declare("outlet_list", ConfigValue(
domain=list_of_strings,
description="List of outlet names",
doc="""A list containing names of outlets (default = None)
- None - default single outlet
- list - a list of names for outlets"""))
CONFIG.declare("num_outlets", ConfigValue(
domain=int,
description="Number of outlets to unit",
doc="""Argument indication number (int) of outlets to construct
(default = None). Not used if outlet_list arg is provided.
- None - use outlet_list arg instead
- int - Outlets will be named with sequential numbers from 1
to num_outlets"""))
CONFIG.declare("energy_split_type", ConfigValue(
default='temperature',
domain=In(['temperature', 'enth_mol', 'enth_mass', 'energy_balance']),
description="Energy splitting method",
doc="""Argument indiciating method to use when splitting material
flows between outlets, **default** - 'temperature'. **Valid values:** {
**'temperature'** - equate temperatures in outlet streams, **'enth_mol'** -
equate specific molar enthalpies in each outlet, **'enth_mass'** - equate
specific mass enthalpies in each outlet, **'energy_balance'** - split using an
energy balance with a split fraction.}"""))
[docs] def build(self):
"""
Begin building model (pre-DAE transformation).
Args:
None
Returns:
None
"""
# Call UnitModel.build to setup dynamics
super(SplitterData, self).build()
# If no arguments provided for outlets, default to num_outlets = 2
if self.config.outlet_list is None and self.config.num_outlets is None:
self.config.num_outlets = 2
# Build Holdup Block
if (self.config.include_holdup is True or
self.config.has_equilibrium_reactions is True or
self.config.has_phase_equilibrium is True):
self.holdup = Holdup0D()
else:
self.holdup = HoldupStatic()
[docs] def post_transform_build(self):
"""
Continue model construction after DAE transformation.
Args:
None
Returns:
None
"""
# Construct Inlets
self.build_inlets(inlets=self.config.inlet_list,
num_inlets=self.config.num_inlets)
# Build Outlets
self.build_outlets(outlets=self.config.outlet_list,
num_outlets=self.config.num_outlets,
energy_split_type=self.config.energy_split_type)
# Make references to split fractions
self._make_refs()
def _make_refs(self):
"""
Make references to split fraction variables at unit level.
Args:
None
Returns:
None
"""
add_object_ref(self, "split_fraction",
self.holdup.outlet_splitter.split_fraction)