Unit#
- class Unit(ID='', ins=None, outs=(), thermo=None, **kwargs)[source]#
Abstract class for Unit objects. Child objects must contain
_run
,_design
and_cost
methods to estimate stream outlets of a Unit and find design and cost information.- Parameters:
ID (
str
, optional) – A unique identification. If ID is None, unit will not be registered in flowsheet. By default, a unique ID will be chosen.ins (
Stream
], optional) – Inlet streams or IDs to initialize inlet streams. If empty tuple, streams with default IDs will be created. By default, streams will be missing.outs (
Stream
], optional) – Outlet streams or IDs to initialize outlet streams. By default, streams with unique IDs will be created. If None, streams will be missing.thermo (
Thermo
, optional) – Thermo object to initialize inlet and outlet streams. Defaults tosettings.thermo
.
Notes
The free on board (f.o.b.) purchase costs and installed equipment costs (i.e. bare-module cost) for each item in the
baseline_purchase_costs
dictionary and in auxiliary units are automatically added to thepurchase_costs
andinstalled_costs
dictionaries.As explained in [1], the f.o.b. purchase cost is given by:
\[C_{P} = C_{Pb}F_{D}F_{P}F_{M}\]And the installed equipment cost is given by:
\[C_{BM} = C_{Pb} (F_{BM} + F_{D}F_{P}F_{M} - 1)\]- Where:
\(C_{Pb}\): Baseline purchase cost.
\(F_{BM}\): Bare module factor.
\(F_{D}\): Design factor.
\(F_{P}\): Pressure factor.
\(F_{M}\): Material factor.
Values for the bare-module, design, pressure, and material factors of each equipment should be stored in the
F_BM
,F_D
,F_P
, andF_M
dictionaries.Examples
References
-
_units:
dict
[str
,str
] = {}# class-attribute Units of measure for
design_results
dictionary.
-
_F_BM_default:
dict
[str
,float
] = {}# class-attribute Default bare-module factors for each purchase cost item. Items in this dictionary are copied to the
F_BM
attribute during initialization.
-
_materials_and_maintenance: frozen:py:class:set[
str
] = frozenset({})# class-attribute Cost items that need to be summed across operation modes for flexible operation (e.g., filtration membranes).
-
auxiliary_unit_names:
tuple
[str
, ...] = ()# class-attribute Name of attributes that are auxiliary units. These units will be accounted for in the purchase and installed equipment costs without having to add these costs in the
baseline_purchase_costs
dictionary. Heat and power utilities are also automatically accounted for.
-
line:
str
= 'Unit'# class-attribute Name denoting the type of Unit class. Defaults to the class name of the first child class
-
_default_equipment_lifetime:
int
|dict
[str
,int
] = {}# class-attribute Lifetime of equipment. Defaults to lifetime of production venture. Use an integer to specify the lifetime for all items in the unit purchase costs. Use a dictionary to specify the lifetime of each purchase cost item.
- _graphics: :py:class:`~biosteam.Unit`Graphics = UnitGraphics(node={'shape': 'box', 'style': 'filled', 'gradientangle': '0', 'width': '0.6', 'height': '0.6', 'orientation': '0.0', 'peripheries': '1', 'margin': 'default', 'fontname': 'Arial'}, edge_in=({'headport': 'c'},), edge_out=({'tailport': 'c'},))#
class-attribute Settings for diagram representation. Defaults to a box with the same number of inlet and outlet edges as
_N_ins
and_N_outs
.
- _run = AbstractMethod#
Run mass and energy balances and update outlet streams (without user-defined specifications).
- _design = AbstractMethod#
Add design requirements to the
design_results
dictionary.
- _cost = AbstractMethod#
Add itemized purchase costs to the
baseline_purchase_costs
dictionary.
-
heat_utilities:
list
[HeatUtility
, ...]# All heat utilities associated to unit. Cooling and heating requirements are stored here (including auxiliary requirements).
-
power_utility:
PowerUtility
# Electric utility associated to unit (including auxiliary requirements).
-
F_BM:
dict
[str
,float
]# All bare-module factors for each purchase cost. Defaults to values in the class attribute
_F_BM_default
.
-
F_D:
dict
[str
,float
]# All design factors for each purchase cost item in
baseline_purchase_costs
.
-
F_P:
dict
[str
,float
]# All pressure factors for each purchase cost item in
baseline_purchase_costs
.
-
F_M:
dict
[str
,float
]# All material factors for each purchase cost item in
baseline_purchase_costs
.
-
design_results:
dict
[str
, object]# All design requirements excluding utility requirements and detailed auxiliary unit requirements.
-
baseline_purchase_costs:
dict
[str
,float
]# All baseline purchase costs without accounting for design, pressure, and material factors.
-
purchase_costs:
dict
[str
,float
]# Itemized purchase costs (including auxiliary units) accounting for design, pressure, and material factors (i.e.,
F_D
,F_P
,F_M
). Items here are automatically updated at the end of unit simulation.
-
installed_costs:
dict
[str
,float
]# All installed costs accounting for bare module, design, pressure, and material factors. Items here are automatically updated at the end of unit simulation.
-
equipment_lifetime:
int
|dict
[str
,int
]# Lifetime of equipment. Defaults to values in the class attribute
_default_equipment_lifetime
. Use an integer to specify the lifetime for all items in the unit purchase costs. Use a dictionary to specify the lifetime of each purchase cost item.
-
run_after_specifications:
bool
# Whether to run mass and energy balance after calling specification functions
-
parallel:
dict
[str
,int
]# Name-number pairs of baseline purchase costs and auxiliary unit operations in parallel. Use ‘self’ to refer to the main unit. Capital and heat and power utilities in parallel will become proportional to this value.
-
responses:
set
[GenericResponse]# Unit design decisions that must be solved to satisfy specifications. While adding responses is optional, simulations benefit from responses by being able to predict better guesses.
- add_power_utility(power)[source]#
Add power utility [kW]. Use a positive value for consumption and a negative for production.
- create_heat_utility(agent=None, heat_transfer_efficiency=None)[source]#
Create heat utility object associated to unit.
- add_heat_utility(unit_duty, T_in, T_out=None, agent=None, heat_transfer_efficiency=None, hxn_ok=False)[source]#
Add utility requirement given the duty and inlet and outlet temperatures.
- Parameters:
unit_duty (
float
) – Unit duty requirement [kJ/hr]T_in (
float
) – Inlet process stream temperature [K]T_out (
float
, optional) – Outlet process stream temperature [K]agent (
UtilityAgent
, optional) – Utility agent to use. Defaults to a suitable agent from predefined heating/cooling utility agents.heat_transfer_efficiency (
float
, optional) – Enforced fraction of heat transfered from utility (due to losses to environment).hxn_ok (
bool
, optional) – Whether heat utility can be satisfied within a heat exchanger network.
- define_utility(name, stream)[source]#
Define an inlet or outlet stream as a utility by name.
- Parameters:
name (
str
) – Name of utility, as defined insettings.stream_utility_prices
.stream (
Stream
) – Inlet or outlet utility stream.
- get_design_result(key, units)[source]#
Return design result in a new set of units of measure.
Examples
>>> import biosteam as bst >>> bst.settings.set_thermo(['Water'], cache=True) >>> feed = bst.Stream(None, Water=100) >>> tank = bst.StorageTank(None, feed) >>> tank.simulate() >>> tank.get_design_result('Total volume', 'm3') 1214.19 >>> tank.get_design_result('Total volume', 'L') 1214191.0
- add_specification(f=None, run=None, args=(), impacted_units=None, prioritize=None)[source]#
Add a specification.
- Parameters:
f (
Callable
, optional) – Specification function runned for mass and energy balance.run (
bool
, optional) – Whether to run the built-in mass and energy balance after specifications. Defaults to False.args (
tuple
, optional) – Arguments to pass to the specification function.impacted_units (
tuple`[:py:class:`~biosteam.Unit
,...
], optional) – Other units impacted by specification. The system will make sure to run itermediate upstream units when simulating.prioritize (
bool
, optional) – Whether to prioritize the unit operation within a recycle loop (if any).
Examples
See also
Notes
This method also works as a decorator.
- add_bounded_numerical_specification(f=None, *args, **kwargs)[source]#
Add a bounded numerical specification that solves x where f(x) = 0 using an inverse quadratic interpolation solver.
- Parameters:
f (Callable) – Objective function in the form of f(x, *args).
x (float, optional) – Root guess.
x0 (float) – Root bracket. Solution must lie within x0 and x1.
x1 (float) – Root bracket. Solution must lie within x0 and x1.
xtol (float, optional) – Solver stops when the root lies within xtol. Defaults to 0.
ytol (float, optional) – Solver stops when the f(x) lies within ytol of the root. Defaults to 5e-8.
args (tuple, optional) – Arguments to pass to f.
maxiter – Maximum number of iterations. Defaults to 50.
checkiter (bool, optional) – Whether to raise a Runtime error when tolerance could not be satisfied before the maximum number of iterations. Defaults to True.
checkroot (bool, optional) – Whether satisfying both tolerances, xtol and ytol, are required for termination. Defaults to False.
checkbounds (bool, optional) – Whether to raise a ValueError when in a bounded solver when the root is not certain to lie within bounds (i.e. f(x0) * f(x1) > 0.). Defaults to True.
Examples
See also
Notes
This method also works as a decorator.
- run()[source]#
Run mass and energy balance. This method also runs specifications user defined specifications unless it is being run within a specification (to avoid infinite loops).
- path_from(units, inclusive=False, system=None)[source]#
Return a tuple of units and systems starting from units until this one (not inclusive by default).
- path_until(units, inclusive=False, system=None)[source]#
Return a tuple of units and systems starting from this one until the end units (not inclusive by default).
- run_until(units, inclusive=False, system=None)[source]#
Run all units and converge all systems starting from this one until the end units (not inclusive by default).
See also
- _summary(design_kwargs=None, cost_kwargs=None, lca_kwargs=None)[source]#
Run design/cost/LCA algorithms and compile results.
- property specifications: list[ProcessSpecification]#
Process specifications as a list of process specification objects.
- property baseline_purchase_cost: float#
Total baseline purchase cost, without accounting for design , pressure, and material factors [USD].
- property nested_auxiliary_units: list[Unit]#
Return list of all auxiliary units, including nested ones.
- get_nested_auxiliary_units_with_names(depth=-1)[source]#
Return list of all auxiliary units, including nested ones.
- auxiliary(name, cls, ins=None, outs=(), thermo=None, **kwargs)[source]#
Create and register an auxiliary unit operation. Inlet and outlet streams automatically become auxlets so that parent unit streams will not disconnect.
- auxlet(stream, thermo=None)[source]#
Define auxiliary unit inlet or outlet. This method has two behaviors:
If the stream is not connected to this unit, define the Stream object’s source or sink to be this unit without actually connecting it to this unit.
If the stream is already connected to this unit, return a superposition stream which can be connected to auxiliary units without being disconnected from this unit.
- mass_balance_error()[source]#
Return error in stoichiometric mass balance. If positive, mass is being created. If negative, mass is being destroyed.
- atomic_balance_error()[source]#
Return a dictionary of errors in stoichiometric atomic balances. If value is positive, the atom is being created. If negative, the atom is being destroyed.
- simulate(run=None, design_kwargs=None, cost_kwargs=None)[source]#
Run rigorous simulation and determine all design requirements.
- results(with_units=True, include_utilities=True, include_total_cost=True, include_installed_cost=False, include_zeros=True, external_utilities=None, key_hook=None)[source]#
Return key results from simulation as a DataFrame if with_units is True or as a Series otherwise.
- neighborhood(radius=1, upstream=True, downstream=True, ends=None, facilities=None)[source]#
Return a set of all neighboring units within given radius.
- Parameters:
radius (
int
, optional) – Maximum number streams between neighbors.downstream (
bool
, optional) – Whether to include downstream operations.upstream (
bool
, optional) – Whether to include upstream operations.ends (
Stream
, optional) – Streams that mark the end of the neighborhood.facilities (
bool
, optional) – Whether to include facilities.
- diagram(radius=0, upstream=True, downstream=True, file=None, format=None, display=True, auxiliaries=-1, **graph_attrs)[source]#
Display a Graphviz diagram of the unit and all neighboring units within given radius.
- Parameters:
radius (
int
, optional) – Maximum number streams between neighbors.downstream (
bool
, optional) – Whether to show downstream operations.upstream (
bool
, optional) – Whether to show upstream operations.file (
str
, optional) –Must be one of the following:
[str] File name to save diagram.
[None] Display diagram in console.
format (
str
, optional) – Format of file.display (
bool
, optional) – Whether to display diagram in console or to return the graphviz object.auxiliaries (
bool
, optional) – Depth of auxiliary units to display.
- show(layout=None, T=None, P=None, flow=None, composition=None, N=None, IDs=None, sort=None, data=True)[source]#
Prints information on unit.
- property ID#
Unique identification (str). If set as ‘’, it will choose a default ID.
- get_ash_disposal_cost()#
Return the ash disposal cost [USD/hr].
- get_ash_disposal_flow()#
Return the ash disposal flow rate [kg/hr].
- get_natural_gas_cost()#
Return the natural gas cost [USD/hr].
- get_natural_gas_flow()#
Return the natural gas flow rate [kg/hr].
- get_process_water_cost()#
Return the process water cost [USD/hr].
- get_process_water_flow()#
Return the process water flow rate [kg/hr].
- get_reverse_osmosis_water_cost()#
Return the reverse osmosis water cost [USD/hr].
- get_reverse_osmosis_water_flow()#
Return the reverse osmosis water flow rate [kg/hr].