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, the unit will not be registered in flowsheet. The ID defaults to the variable assigned in the source code. If no variable is assigned, a unique ID will be chosen.

  • ins (Sequence[Stream | str], 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 (Sequence[Stream | str], 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 to settings.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 the purchase_costs and installed_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, and F_M dictionaries.

Examples

Creating a Unit

-pipe- notation

Inheriting from Unit

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: frozenset[str] = frozenset({})#

class-attribute Cost items that need to be summed across operation modes for flexible operation (e.g., filtration membranes).

_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.

_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.

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.

response(name)[source]#

Register response for convergence model prediction.

property net_power: float#

Net power consumption [kW].

property net_duty: float#

Net duty including heat transfer losses [kJ/hr].

property net_cooling_duty: float#

Net cooling duty including heat transfer losses [kJ/hr].

property net_heating_duty: float#

Net cooling duty including heat transfer losses [kJ/hr].

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 transferred 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:
define_credit(name, stream)[source]#

Define an inlet or outlet stream as a fee/credit by name.

Parameters:
define_fee(name, stream)#

Define an inlet or outlet stream as a fee/credit by name.

Parameters:
get_design_result(key, units)[source]#

Return design result in a new set of units of measure.

Parameters:
  • key (str) – Name of design result.

  • units (str) – 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
set_design_result(key, units, value)[source]#

Set design result in given the units of measure.

Parameters:
  • key (str) – Name of design result.

  • units (str) – Units of measure.

  • value (float) – Value of the design result.

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.set_design_result('Total volume', 'm3', 1000)
1000
>>> tank.get_design_result('Total volume', 'm3')
1000.0
convert_design_result(key, units, value)[source]#

Convert design result in given units to the stored units of measure.

Parameters:
  • key – Name of design result.

  • units – Units of measure.

  • value – Value of the design result.

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.convert_design_result('Total volume', 'ft3', 1000)
28.31
_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 purchase_cost: float#

Total purchase cost [USD].

property installed_cost: float#

Total installed equipment cost [USD].

property utility_cost: float#

Total utility cost [USD/hr].

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.

empty()[source]#

Empty all unit operation results and outlet flows.

simulate(run=None, design_kwargs=None, cost_kwargs=None)[source]#

Run rigorous simulation and determine all design requirements.

Parameters:
  • run (bool, optional) – Whether to run mass and energy balance or to assume the same inlet and outlet conditions. Defaults to True.

  • design_kwargs (dict, optional) – Keyword arguments passed to _design method.

  • cost_kwargs (dict, optional) – Keyword arguments passed to _cost method.

results(with_units=True, include_utilities=True, include_total_cost=True, include_installed_cost=True, include_zeros=True, external_utilities=None, key_hook=None, basis=None)[source]#

Return key results from simulation as a DataFrame if with_units is True or as a Series otherwise.

property mol_in: ndarray[tuple[Any, ...], dtype[float]]#

Molar flows going in [kmol/hr].

property mol_out: ndarray[tuple[Any, ...], dtype[float]]#

Molar flows going out [kmol/hr].

property z_mol_in: ndarray[tuple[Any, ...], dtype[float]]#

Molar fractions going in [kmol/hr].

property z_mol_out: ndarray[tuple[Any, ...], dtype[float]]#

Molar fractions going in.

property F_mol_in: float#

Net molar flow going in [kmol/hr].

property F_mol_out: float#

Net molar flow going out [kmol/hr].

property mass_in: ndarray[tuple[Any, ...], dtype[float]]#

Mass flows going in [kg/hr].

property mass_out: ndarray[tuple[Any, ...], dtype[float]]#

Mass flows going out [kg/hr].

property z_mass_in: ndarray[tuple[Any, ...], dtype[float]]#

Mass fractions going in.

property z_mass_out: ndarray[tuple[Any, ...], dtype[float]]#

Mass fractions going out.

property F_mass_in: float#

Net mass flow going in [kg/hr].

property F_mass_out: float#

Net mass flow going out [kg/hr].

property vol_in: ndarray[tuple[Any, ...], dtype[float]]#

Volumetric flows going in [m3/hr].

property F_vol_in: float#

Net volumetric flow going in [m3/hr].

property z_vol_in: ndarray[tuple[Any, ...], dtype[float]]#

Volumetric fractions going in.

property vol_out: ndarray[tuple[Any, ...], dtype[float]]#

Volumetric flows going out [m3/hr].

property F_vol_out: float#

Net volumetric flow going out [m3/hr].

property z_vol_out: ndarray[tuple[Any, ...], dtype[float]]#

Volumetric fractions going out.

property H_in: float#

Enthalpy flow going in [kJ/hr].

property H_out: float#

Enthalpy flow going out [kJ/hr].

property Hf_in: float#

Enthalpy of formation flow going in [kJ/hr].

property Hf_out: float#

Enthalpy of formation flow going out [kJ/hr].

property Hnet: float#

Net enthalpy flow, including enthalpies of formation [kJ/hr].

property ID#

Unique identification (str). If set as ‘’, it will choose a default ID.

class SuperpositionInlet(port, sink=None)#
property C#

Isobaric heat capacity flow rate [kJ/K/hr].

property Cn#

Molar isobaric heat capacity [J/mol/K].

property Cp#

Isobaric heat capacity [J/g/K].

property F_mass#

Total mass flow rate [kg/hr].

property F_mol#

Total molar flow rate [kmol/hr].

property F_vol#

Total volumetric flow rate [m3/hr].

property G#

Gibb’s free energy (including heats of formation) [kJ/hr].

property H#

Enthalpy flow rate [kJ/hr].

property HHV#

Higher heating value flow rate [kJ/hr].

property Hf#

Enthalpy of formation flow rate [kJ/hr].

property Hnet#

Total enthalpy flow rate (including heats of formation) [kJ/hr].

property Hvap#

Enthalpy of vaporization flow rate [kJ/hr].

property ID#

Unique identification (str). If set as ‘’, it will choose a default ID.

property LHV#

Lower heating value flow rate [kJ/hr].

property MW#

Overall molecular weight.

property P#

Pressure [Pa].

property P_vapor#

Vapor pressure of liquid.

property Pr#

Prandtl number [-].

property S#

Absolute entropy flow rate [kJ/hr/K].

property T#

Temperature [K].

property V#

Molar volume [m^3/mol].

property alpha#

Thermal diffusivity [m^2/s].

property as_stream#

Does nothing.

property available_chemicals#

All chemicals with nonzero flow.

property bubble_point_at_P#

Return a BubblePointResults object with all data on the bubble point at constant pressure.

Parameters:

IDs – Chemicals that participate in equilibrium. Defaults to all chemicals in equilibrium.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, T=350, units='kg/hr')
>>> s1.bubble_point_at_P()
BubblePointValues(T=357.14, P=101325, IDs=('Water', 'Ethanol'), z=[0.836 0.164], y=[0.492 0.508])
property bubble_point_at_T#

Return a BubblePointResults object with all data on the bubble point at constant temperature.

Parameters:
  • T – Temperature [K].

  • IDs – Chemicals that participate in equilibrium. Defaults to all chemicals in equilibrium.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, T=350, units='kg/hr')
>>> s1.bubble_point_at_T()
BubblePointValues(T=350.00, P=76463, IDs=('Water', 'Ethanol'), z=[0.836 0.164], y=[0.488 0.512])
property characterization_factors#
property copy#

Return a copy of the stream.

Examples

Create a copy of a new stream:

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, units='kg/hr')
>>> s1_copy = s1.copy('s1_copy')
>>> s1_copy.show(flow='kg/hr')
Stream: s1_copy
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kg/hr): Water    20
              Ethanol  10

Warning

Prices, and LCA characterization factors are not copied.

property copy_flow#

Copy flow rates of another stream to self.

Parameters:
  • other – Flow rates will be copied from here.

  • IDs – Chemical IDs.

  • remove – If True, copied chemicals will be removed from stream.

  • exclude – If True, exclude designated chemicals when copying.

Examples

Initialize streams:

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, units='kg/hr')
>>> s2 = tmo.Stream('s2')

Copy all flows:

>>> s2.copy_flow(s1)
>>> s2.show(flow='kg/hr')
Stream: s2
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kg/hr): Water    20
              Ethanol  10

Reset and copy just water flow:

>>> s2.empty()
>>> s2.copy_flow(s1, 'Water')
>>> s2.show(flow='kg/hr')
Stream: s2
phase: 'l', T: 298.15 K, P: 101325 Pa
flow: 20 kg/hr Water

Reset and copy all flows except water:

>>> s2.empty()
>>> s2.copy_flow(s1, 'Water', exclude=True)
>>> s2.show(flow='kg/hr')
Stream: s2
phase: 'l', T: 298.15 K, P: 101325 Pa
flow: 10 kg/hr Ethanol

Cut and paste flows:

>>> s2.copy_flow(s1, remove=True)
>>> s2.show(flow='kg/hr')
Stream: s2
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kg/hr): Water    20
              Ethanol  10
>>> s1.show()
Stream: s1
phase: 'l', T: 298.15 K, P: 101325 Pa
flow: 0

Its also possible to copy flows from a multistream:

>>> s1.phases = ('g', 'l')
>>> s1.imol['g', 'Water'] = 10
>>> s2.copy_flow(s1, remove=True)
>>> s2.show()
Stream: s2
phase: 'l', T: 298.15 K, P: 101325 Pa
flow: 10 kmol/hr Water
>>> s1.show()
MultiStream: s1
phases: ('g', 'l'), T: 298.15 K, P: 101325 Pa
 flow: 0

Copy flows except except water and remove water:

>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, units='kg/hr')
>>> s2 = tmo.Stream('s2')
>>> s2.copy_flow(s1, 'Water', exclude=True, remove=True)
>>> s1.show('wt')
Stream: s1
phase: 'l', T: 298.15 K, P: 101325 Pa
flow: 20 kg/hr Water
>>> s2.show('wt')
Stream: s2
phase: 'l', T: 298.15 K, P: 101325 Pa
flow: 10 kg/hr Ethanol
property copy_like#

Copy all conditions of another stream.

Examples

Copy data from another stream with the same property package:

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, units='kg/hr')
>>> s2 = tmo.Stream('s2', Water=2, units='kg/hr')
>>> s1.copy_like(s2)
>>> s1.show(flow='kg/hr')
Stream: s1
phase: 'l', T: 298.15 K, P: 101325 Pa
flow: 2 kg/hr Water

Copy data from another stream with a different property package:

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, units='kg/hr')
>>> tmo.settings.set_thermo(['Water'], cache=True)
>>> s2 = tmo.Stream('s2', Water=2, units='kg/hr')
>>> s1.copy_like(s2)
>>> s1.show(flow='kg/hr')
Stream: s1
phase: 'l', T: 298.15 K, P: 101325 Pa
flow: 2 kg/hr Water
property copy_phase#

Copy phase from another stream.

property copy_thermal_condition#

Copy thermal conditions (T and P) of another stream.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=2, units='kg/hr')
>>> s2 = tmo.Stream('s2', Water=1, units='kg/hr', T=300.00)
>>> s1.copy_thermal_condition(s2)
>>> s1.show(flow='kg/hr')
Stream: s1
phase: 'l', T: 300 K, P: 101325 Pa
flow: 2 kg/hr Water
property cost#

Total cost of stream [USD/hr].

property dew_point_at_P#

Return a DewPointResults object with all data on the dew point at constant pressure.

Parameters:

IDs – Chemicals that participate in equilibrium. Defaults to all chemicals in equilibrium.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, T=350, units='kg/hr')
>>> s1.dew_point_at_P()
DewPointValues(T=368.62, P=101325, IDs=('Water', 'Ethanol'), z=[0.836 0.164], x=[0.983 0.017])
property dew_point_at_T#

Return a DewPointResults object with all data on the dew point at constant temperature.

Parameters:

IDs – Chemicals that participate in equilibrium. Defaults to all chemicals in equilibrium.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, T=350, units='kg/hr')
>>> s1.dew_point_at_T()
DewPointValues(T=350.00, P=49058, IDs=('Water', 'Ethanol'), z=[0.836 0.164], x=[0.984 0.016])
disconnect()#

Disconnect stream from unit.

disconnect_sink()#

Disconnect stream from sink.

disconnect_source()#

Disconnect stream from source.

property display_notation#

Create a DisplayNotation object where default units for representation are stored.

Examples

Its possible to change the default units of measure for the Stream show method:

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water'], cache=True)
>>> tmo.Stream.display_notation.flow = '.2g'
>>> stream = tmo.Stream('stream', Water=1.324, units='kg/hr')
>>> stream.show()
Stream: stream
phase: 'l', T: 298.15 K, P: 101325 Pa
flow: 0.073 kmol/hr Water
>>> # Change back to kmol/hr
>>> tmo.Stream.display_notation.flow = '.3g'
property display_units#

Create a DisplayUnits object where default units for representation are stored.

Examples

Its possible to change the default units of measure for the Stream show method:

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water'], cache=True)
>>> tmo.Stream.display_units.flow = 'kg/hr'
>>> stream = tmo.Stream('stream', Water=1, units='kg/hr')
>>> stream.show()
Stream: stream
phase: 'l', T: 298.15 K, P: 101325 Pa
flow: 1 kg/hr Water
>>> # Change back to kmol/hr
>>> tmo.Stream.display_units.flow = 'kmol/hr'
property empty#

Empty stream flow rates.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, units='kg/hr')
>>> s1.empty()
>>> s1.F_mol
0
property empty_negative_flows#

Replace flows of all components with negative values with 0.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=1, Ethanol=-1)
>>> s1.empty_negative_flows()
>>> s1.show()
Stream: s1
phase: 'l', T: 298.15 K, P: 101325 Pa
flow: 1 kmol/hr Water
property epsilon#

Relative permittivity [-].

property flow_proxy#

Return a new stream that shares flow rate data with this one.

See also

link_with, proxy

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, units='kg/hr')
>>> s2 = s1.flow_proxy()
>>> s2.mol is s1.mol
True
property get_CF#

Returns the life-cycle characterization factor on a kg basis given the impact indicator key.

Parameters:
  • key – Key of impact indicator.

  • basis – Basis of characterization factor. Mass is the only valid dimension (for now). Defaults to ‘kg’.

  • units – Units of impact indicator. Before using this argument, the default units of the impact indicator should be defined with settings.define_impact_indicator. Units must also be dimensionally consistent with the default units.

property get_atomic_flow#

Return flow rate of atom [kmol / hr] given the atomic symbol.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water'], cache=True)
>>> stream = tmo.Stream(Water=1)
>>> stream.get_atomic_flow('H') # kmol/hr of H
2.0
>>> stream.get_atomic_flow('O') # kmol/hr of O
1.0
property get_atomic_flows#

Return dictionary of atomic flow rates [kmol / hr].

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water'], cache=True)
>>> stream = tmo.Stream(Water=1)
>>> stream.get_atomic_flows()
{'H': 2.0, 'O': 1.0}
property get_bubble_point#

Return a BubblePoint object capable of computing bubble points.

Parameters:

IDs – Chemicals that participate in equilibrium. Defaults to all chemicals in equilibrium.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, T=350, units='kg/hr')
>>> s1.get_bubble_point()
BubblePoint([Water, Ethanol])
property get_concentration#

Return concentration of given chemicals.

Parameters:
  • IDs – IDs of chemicals.

  • units – Units of measure. Defaults to kmol/m3.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol', 'Methanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, Methanol=10, units='m3/hr')
>>> s1.get_concentration(['Water', 'Ethanol']) # kg/m3
array([27.673,  4.261])
>>> s1.get_concentration(['Water', 'Ethanol'], 'g/L')
array([498.532, 196.291])
property get_data#

Return a StreamData object containing data on material flow rates, temperature, pressure, and phase(s).

See also

Stream.set_data

Examples

Get and set data from stream at different conditions

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water'], cache=True)
>>> stream = tmo.Stream('stream', Water=10)
>>> data = stream.get_data()
>>> stream.vle(V=0.5, P=101325)
>>> data_vle = stream.get_data()
>>> stream.set_data(data)
>>> stream.show()
Stream: stream
phase: 'l', T: 298.15 K, P: 101325 Pa
flow: 10 kmol/hr Water
>>> stream.set_data(data_vle)
>>> stream.show()
MultiStream: stream
phases: ('g', 'l'), T: 373.12 K, P: 101325 Pa
flow (kmol/hr): (g) Water  5
                (l) Water  5

Note that only StreamData objects are valid for this method:

>>> stream.set_data({'T': 298.15})
Traceback (most recent call last):
ValueError: stream_data must be a StreamData object; not dict
property get_dew_point#

Return a DewPoint object capable of computing dew points.

Parameters:

IDs – Chemicals that participate in equilibrium. Defaults to all chemicals in equilibrium.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, T=350, units='kg/hr')
>>> s1.get_dew_point()
DewPoint([Water, Ethanol])
property get_downstream_units#

Return a set of all units downstream.

property get_flow#

Return an flow rates in requested units.

Parameters:
  • units – Units of measure.

  • key – Chemical identifiers.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, units='kg/hr')
>>> s1.get_flow('kg/hr', 'Water')
20.0
property get_impact#

Return hourly rate of the impact indicator given the key.

property get_mass_composition#

Return mass fraction of given chemicals.

Parameters:

IDs – IDs of chemicals.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol', 'Methanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, Methanol=10, units='kg/hr')
>>> s1.get_mass_fraction(('Water', 'Ethanol'))
array([0.5 , 0.25])
property get_mass_fraction#

Return mass fraction of given chemicals.

Parameters:

IDs – IDs of chemicals.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol', 'Methanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, Methanol=10, units='kg/hr')
>>> s1.get_mass_fraction(('Water', 'Ethanol'))
array([0.5 , 0.25])
property get_molar_composition#

Return molar fraction of given chemicals.

Parameters:

IDs – IDs of chemicals.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol', 'Methanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, Methanol=10, units='kmol/hr')
>>> s1.get_molar_fraction(('Water', 'Ethanol'))
array([0.5 , 0.25])
property get_molar_fraction#

Return molar fraction of given chemicals.

Parameters:

IDs – IDs of chemicals.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol', 'Methanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, Methanol=10, units='kmol/hr')
>>> s1.get_molar_fraction(('Water', 'Ethanol'))
array([0.5 , 0.25])
property get_normalized_mass#

Return normalized mass fractions of given chemicals. The sum of the result is always 1.

Parameters:

IDs – IDs of chemicals to be normalized.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol', 'Methanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, Methanol=10, units='kg/hr')
>>> s1.get_normalized_mass(('Water', 'Ethanol'))
array([0.667, 0.333])
property get_normalized_mol#

Return normalized molar fractions of given chemicals. The sum of the result is always 1.

Parameters:

IDs – IDs of chemicals to be normalized.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol', 'Methanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, Methanol=10, units='kmol/hr')
>>> s1.get_normalized_mol(('Water', 'Ethanol'))
array([0.667, 0.333])
property get_normalized_vol#

Return normalized mass fractions of given chemicals. The sum of the result is always 1.

Parameters:

IDs – IDs of chemicals to be normalized.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol', 'Methanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, Methanol=10, units='m3/hr')
>>> s1.get_normalized_vol(('Water', 'Ethanol'))
array([0.667, 0.333])
property get_property#

Return property in requested units.

Parameters:
  • name – Name of property.

  • units – Units of measure. Defaults to the property’s original units of measure.

property get_total_flow#

Get total flow rate in given units.

Parameters:

units – Units of measure.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, units='kg/hr')
>>> s1.get_total_flow('kg/hr')
30.0
property get_upstream_units#

Return a set of all units upstream.

property get_volumetric_composition#

Return volumetric fraction of given chemicals.

Parameters:

IDs – IDs of chemicals.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol', 'Methanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, Methanol=10, units='m3/hr')
>>> s1.get_volumetric_fraction(('Water', 'Ethanol'))
array([0.5 , 0.25])
property get_volumetric_fraction#

Return volumetric fraction of given chemicals.

Parameters:

IDs – IDs of chemicals.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol', 'Methanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, Methanol=10, units='m3/hr')
>>> s1.get_volumetric_fraction(('Water', 'Ethanol'))
array([0.5 , 0.25])
property h#

Specific enthalpy [kJ/kmol].

property hf#

Specific enthalpy of formation [kJ/kmol].

property hvap#

Enthalpy of vaporization flow rate [kJ/hr].

property imass#

Flow rate indexer with data [kg/hr].

property imol#

Flow rate indexer with data [kmol/hr].

property in_thermal_equilibrium#

Return whether or not stream is in thermal equilibrium with another stream.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> stream = Stream(Water=1, T=300)
>>> other = Stream(Water=1, T=300)
>>> stream.in_thermal_equilibrium(other)
True
property isempty#

Return whether or not stream is empty.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water'], cache=True)
>>> stream = tmo.Stream()
>>> stream.isempty()
True
isfeed()#

Return whether stream has a sink but no source.

isproduct()#

Return whether stream has a source but no sink.

property ivol#

Flow rate indexer with data [m3/hr].

property kappa#

Thermal conductivity [W/m/k].

Link with another stream.

Parameters:

other

See also

flow_proxy, proxy

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, units='kg/hr')
>>> s2 = tmo.Stream('s2')
>>> s2.link_with(s1)
>>> s1.mol is s2.mol
True
>>> s2.thermal_condition is s1.thermal_condition
True
>>> s1.phase = 'g'
>>> s2.phase
'g'
property liquid_fraction#

Molar liquid fraction.

property lle#

An object that can perform liquid-liquid equilibrium on the stream.

property lle_chemicals#

Chemicals cabable of vapor-liquid equilibrium.

property main_chemical#

ID of chemical with the largest mol fraction in stream.

property mass#

Mass flow rates [kg/hr].

property mix_flows#

Mix all other streams into this one, ignoring its initial contents. This method does not alter the stream phase and ignores the pressure and energy balances.

property mix_from#

Mix all other streams into this one, ignoring its initial contents.

Notes

When streams at different pressures are mixed, BioSTEAM assumes valves reduce the pressure of the streams being mixed to prevent backflow (pressure needs to decrease in the direction of flow according to Bernoulli’s principle). The outlet pressure will be the minimum pressure of all streams being mixed.

Examples

Mix two streams with the same thermodynamic property package:

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, units='kg/hr')
>>> s2 = s1.copy('s2')
>>> s1.mix_from([s1, s2])
>>> s1.show(flow='kg/hr')
Stream: s1
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kg/hr): Water    40
              Ethanol  20

It’s also possible to mix streams with different property packages so long as all chemicals are defined in the mixed stream’s property package:

>>> tmo.settings.set_thermo(['Water'], cache=True)
>>> s1 = tmo.Stream('s1', Water=40, units='kg/hr')
>>> tmo.settings.set_thermo(['Ethanol'], cache=True)
>>> s2 = tmo.Stream('s2', Ethanol=20, units='kg/hr')
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s_mix = tmo.Stream('s_mix')
>>> s_mix.mix_from([s1, s2])
>>> s_mix.show(flow='kg/hr')
Stream: s_mix
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kg/hr): Water    40
              Ethanol  20

Mixing empty streams is fine too:

>>> s1.empty(); s2.empty(); s_mix.mix_from([s1, s2])
>>> s_mix.show()
Stream: s_mix
phase: 'l', T: 298.15 K, P: 101325 Pa
flow: 0
property mol#

Molar flow rates [kmol/hr].

property mu#

Hydrolic viscosity [Pa*s].

property nu#

Kinematic viscosity [m^2/s].

property phase#

Phase of stream.

property phases#

All phases present.

property price#

Price of stream per unit mass [USD/kg].

property print#

Print in a format that you can use recreate the stream.

Parameters:

units – Units of measure for material flow rates. Defaults to ‘kmol/hr’

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream(ID='s1',
...                 Water=20, Ethanol=10, units='kg/hr',
...                 T=298.15, P=101325, phase='l')
>>> s1.print(units='kg/hr')
Stream(ID='s1', phase='l', T=298.15, P=101325, Water=20, Ethanol=10, units='kg/hr')
>>> s1.print() # Units default to kmol/hr
Stream(ID='s1', phase='l', T=298.15, P=101325, Water=1.11, Ethanol=0.2171, units='kmol/hr')
property proxy#

Return a new stream that shares all data with this one.

See also

link_with, flow_proxy

Warning

Price and characterization factor data is not shared

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, units='kg/hr')
>>> s2 = s1.proxy()
>>> s2.imol is s1.imol and s2.thermal_condition is s1.thermal_condition
True
property receive_vent#

Receive vapors from another stream by vapor-liquid equilibrium between a gas and liquid stream assuming only a small amount of chemicals in vapor-liquid equilibrium is present

Examples

The energy balance is performed by default:

>>> import thermosteam as tmo
>>> chemicals = tmo.Chemicals(['Water', 'Ethanol', 'Methanol', tmo.Chemical('N2', phase='g')], cache=True)
>>> tmo.settings.set_thermo(chemicals)
>>> s1 = tmo.Stream('s1', N2=20, units='m3/hr', phase='g', T=330)
>>> s2 = tmo.Stream('s2', Water=10, Ethanol=2, T=330)
>>> s1.receive_vent(s2)
>>> s1.show(flow='kmol/hr')
Stream: s1
phase: 'g', T: 323.12 K, P: 101325 Pa
flow (kmol/hr): Water    0.0799
                Ethanol  0.0887
                N2       0.739

Set energy balance to false to receive vent isothermally:

>>> import thermosteam as tmo
>>> chemicals = tmo.Chemicals(['Water', 'Ethanol', 'Methanol', tmo.Chemical('N2', phase='g')], cache=True)
>>> tmo.settings.set_thermo(chemicals)
>>> s1 = tmo.Stream('s1', N2=20, units='m3/hr', phase='g', T=330)
>>> s2 = tmo.Stream('s2', Water=10, Ethanol=2, T=330)
>>> s1.receive_vent(s2, energy_balance=False)
>>> s1.show(flow='kmol/hr')
Stream: s1
phase: 'g', T: 330 K, P: 101325 Pa
flow (kmol/hr): Water    0.112
                Ethanol  0.123
                N2       0.739
property reduce_phases#

Remove empty phases.

property rescale#

Multiply flow rate by given scale.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=1)
>>> s1.scale(100)
>>> s1.F_mol
100.0
property reset#

Convinience method for resetting flow rate and thermal condition data.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=1)
>>> s1.reset(T=300.1, Ethanol=1, phase='g', units='kg/hr', total_flow=2)
>>> s1.show('cwt')
Stream: s1
phase: 'g', T: 300.1 K, P: 101325 Pa
flow: 2 kg/hr Ethanol
property reset_cache#

Reset cache regarding equilibrium methods.

property reset_flow#

Convinience method for resetting flow rate data.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=1)
>>> s1.reset_flow(Ethanol=1, phase='g', units='kg/hr', total_flow=2)
>>> s1.show('cwt')
Stream: s1
phase: 'g', T: 298.15 K, P: 101325 Pa
flow: 2 kg/hr Ethanol
property rho#

Density [kg/m^3].

property s#

Specific enthalpy [kJ/kmol].

property sanity_check#

Raise an InfeasibleRegion error if flow rates are infeasible.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water'], cache=True)
>>> s1 = tmo.Stream('s1')
>>> s1.sanity_check()
>>> s1.mol[0] = -1.
>>> s1.sanity_check()
Traceback (most recent call last):
InfeasibleRegion: negative material flow rate is infeasible
property scale#

Multiply flow rate by given scale.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=1)
>>> s1.scale(100)
>>> s1.F_mol
100.0
property separate_out#

Separate out given stream from this one.

Examples

Separate out another stream with the same thermodynamic property package:

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=30, Ethanol=10, units='kg/hr')
>>> s2 = tmo.Stream('s2', Water=10, Ethanol=5, units='kg/hr')
>>> s1.separate_out(s2)
>>> s1.show(flow='kg/hr')
Stream: s1
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kg/hr): Water    20
              Ethanol  5

It’s also possible to separate out streams with different property packages so long as all chemicals are defined in the mixed stream’s property package:

>>> tmo.settings.set_thermo(['Water'], cache=True)
>>> s1 = tmo.Stream('s1', Water=40, units='kg/hr')
>>> tmo.settings.set_thermo(['Ethanol'], cache=True)
>>> s2 = tmo.Stream('s2', Ethanol=20, units='kg/hr')
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s_mix = tmo.Stream.sum([s1, s2], 's_mix')
>>> s_mix.separate_out(s2)
>>> s_mix.show(flow='kg/hr')
Stream: s_mix
phase: 'l', T: 298.15 K, P: 101325 Pa
flow: 40 kg/hr Water

Removing empty streams is fine too:

>>> s1.empty(); s_mix.separate_out(s1)
>>> s_mix.show(flow='kg/hr')
Stream: s_mix
phase: 'l', T: 298.15 K, P: 101325 Pa
flow: 40 kg/hr Water
property set_CF#

Set the life-cycle characterization factor on a kg basis given the impact indicator key and the units of measure.

Parameters:
  • key – Key of impact indicator.

  • value – Characterization factor value.

  • basis – Basis of characterization factor. Mass is the only valid dimension (for now). Defaults to ‘kg’.

  • units – Units of impact indicator. Before using this argument, the default units of the impact indicator should be defined with settings.define_impact_indicator. Units must also be dimensionally consistent with the default units.

property set_data#

Set material flow rates, temperature, pressure, and phase(s) through a StreamData object

See also

Stream.get_data

property set_flow#

Set flow rates in given units.

Parameters:
  • data – Flow rate data.

  • units – Units of measure.

  • key – Chemical identifiers.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream(ID='s1', Water=20, Ethanol=10, units='kg/hr')
>>> s1.set_flow(10, 'kg/hr', 'Water')
>>> s1.get_flow('kg/hr', 'Water')
10.0
property set_property#

Set property in given units.

Parameters:
  • name – Name of property.

  • value – New value of property.

  • units – Units of measure.

property set_total_flow#

Set total flow rate in given units keeping the composition constant.

Parameters:
  • value – New total flow rate.

  • units – Units of measure.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, units='kg/hr')
>>> s1.set_total_flow(1.0,'kg/hr')
>>> s1.get_total_flow('kg/hr')
0.9999999999999999
property shares_flow_rate_with#

Return whether other stream shares data with this one.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water'], cache=True)
>>> s1 = tmo.Stream('s1')
>>> other = s1.flow_proxy()
>>> s1.shares_flow_rate_with(other)
True
>>> s1 = tmo.MultiStream('s1', phases=('l', 'g'))
>>> s1['g'].shares_flow_rate_with(s1)
True
>>> s2 = tmo.MultiStream('s2', phases=('l', 'g'))
>>> s1['g'].shares_flow_rate_with(s2)
False
>>> s1['g'].shares_flow_rate_with(s2['g'])
False
>>> s1 = tmo.MultiStream('s1')
>>> other = s1.flow_proxy()
>>> s1.shares_flow_rate_with(other)
True
>>> s1 = tmo.MultiStream('s1', phases=('l', 'g'))
>>> s1.shares_flow_rate_with(s1['g'])
True
>>> s2 = tmo.MultiStream('s2', phases=('l', 'g'))
>>> s2.shares_flow_rate_with(s1['g'])
False
>>> s1.shares_flow_rate_with(s2)
False
property show#

Print all specifications.

Parameters:
  • layout – Convenience paramater for passing flow, composition, and N. Must have the form {‘%’ or ‘’}{‘wt’, ‘mol’ or ‘vol’}{# or ‘’}. For example: ‘%wt100’ corresponds to compostion=True, flow=’kg/hr’, and N=100.

  • T – Temperature units.

  • P – Pressure units.

  • flow – Flow rate units.

  • composition – Whether to show composition.

  • N – Number of compounds to display.

  • IDs – IDs of compounds to display. Defaults to all chemicals.

  • sort – Whether to sort flows in descending order.

  • df – Whether to return a pandas DataFrame.

Examples

Show a stream’s composition by weight for only the top 2 chemicals with the highest mass fractions:

>>> import biosteam as bst
>>> bst.settings.set_thermo(['Water', 'Ethanol', 'Methanol', 'Propanol'])
>>> stream = bst.Stream('stream', Water=0.5, Ethanol=1.5, Methanol=0.2, Propanol=0.3, units='kg/hr')
>>> stream.show('cwt2s') # Alternatively: stream.show(composition=True, flow='kg/hr', N=2, sort=True)
Stream: stream
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (%): Ethanol  60
          Water    20
          ...      20
          -------  2.5 kg/hr
property sigma#

Surface tension [N/m].

property sink: AbstractUnit#

Inlet location.

property sle#

An object that can perform solid-liquid equilibrium on the stream.

property solid_fraction#

Molar solid fraction.

property source: AbstractUnit#

Outlet location.

property split_to#

Split molar flow rate from this stream to two others given the split fraction or an array of split fractions.

Examples

>>> import thermosteam as tmo
>>> chemicals = tmo.Chemicals(['Water', 'Ethanol'], cache=True)
>>> tmo.settings.set_thermo(chemicals)
>>> s = tmo.Stream('s', Water=20, Ethanol=10, units='kg/hr')
>>> s1 = tmo.Stream('s1')
>>> s2 = tmo.Stream('s2')
>>> split = chemicals.kwarray(dict(Water=0.5, Ethanol=0.1))
>>> s.split_to(s1, s2, split)
>>> s1.show(flow='kg/hr')
Stream: s1
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kg/hr): Water    10
              Ethanol  1
>>> s2.show(flow='kg/hr')
Stream: s2
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kg/hr): Water    10
              Ethanol  9
property sum#

Return a new Stream object that represents the sum of all given streams.

Examples

Sum two streams:

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, units='kg/hr')
>>> s_sum = tmo.Stream.sum([s1, s1], 's_sum')
>>> s_sum.show(flow='kg/hr')
Stream: s_sum
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kg/hr): Water    40
              Ethanol  20

Sum two streams with new property package:

>>> thermo = tmo.Thermo(['Water', 'Ethanol', 'Methanol'], cache=True)
>>> s_sum = tmo.Stream.sum([s1, s1], 's_sum', thermo)
>>> s_sum.show(flow='kg/hr')
Stream: s_sum
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kg/hr): Water    40
              Ethanol  20
property thermal_condition#

Contains the temperature and pressure conditions of the stream.

Unlink stream from other streams.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, units='kg/hr')
>>> s2 = tmo.Stream('s2')
>>> s2.link_with(s1)
>>> s1.unlink()
>>> s2.mol is s1.mol
False
>>> s1.phases = s2.phases = ('l', 'g')
>>> s2.link_with(s1)
>>> s1.imol.data is s2.imol.data
True
>>> s1.unlink()
>>> s1.imol.data is s2.imol.data
False

MultiStream phases cannot be unlinked:

>>> s1 = tmo.MultiStream(None, phases=('l', 'g'))
>>> s1['g'].unlink()
Traceback (most recent call last):
RuntimeError: phase is locked; stream cannot be unlinked
property vapor_fraction#

Molar vapor fraction.

property vle#

An object that can perform vapor-liquid equilibrium on the stream.

property vle_chemicals#

Chemicals cabable of liquid-liquid equilibrium.

property vlle#

An object that can perform vapor-liquid-liquid equilibrium on the stream.

property vlle_chemicals#

Chemicals cabable of liquid-liquid equilibrium.

property vol#

Volumetric flow rates [m3/hr].

property z_mass#

Mass composition.

property z_mol#

Molar composition.

property z_vol#

Volumetric composition.

class SuperpositionOutlet(port, source=None)#
property C#

Isobaric heat capacity flow rate [kJ/K/hr].

property Cn#

Molar isobaric heat capacity [J/mol/K].

property Cp#

Isobaric heat capacity [J/g/K].

property F_mass#

Total mass flow rate [kg/hr].

property F_mol#

Total molar flow rate [kmol/hr].

property F_vol#

Total volumetric flow rate [m3/hr].

property G#

Gibb’s free energy (including heats of formation) [kJ/hr].

property H#

Enthalpy flow rate [kJ/hr].

property HHV#

Higher heating value flow rate [kJ/hr].

property Hf#

Enthalpy of formation flow rate [kJ/hr].

property Hnet#

Total enthalpy flow rate (including heats of formation) [kJ/hr].

property Hvap#

Enthalpy of vaporization flow rate [kJ/hr].

property ID#

Unique identification (str). If set as ‘’, it will choose a default ID.

property LHV#

Lower heating value flow rate [kJ/hr].

property MW#

Overall molecular weight.

property P#

Pressure [Pa].

property P_vapor#

Vapor pressure of liquid.

property Pr#

Prandtl number [-].

property S#

Absolute entropy flow rate [kJ/hr/K].

property T#

Temperature [K].

property V#

Molar volume [m^3/mol].

property alpha#

Thermal diffusivity [m^2/s].

property as_stream#

Does nothing.

property available_chemicals#

All chemicals with nonzero flow.

property bubble_point_at_P#

Return a BubblePointResults object with all data on the bubble point at constant pressure.

Parameters:

IDs – Chemicals that participate in equilibrium. Defaults to all chemicals in equilibrium.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, T=350, units='kg/hr')
>>> s1.bubble_point_at_P()
BubblePointValues(T=357.14, P=101325, IDs=('Water', 'Ethanol'), z=[0.836 0.164], y=[0.492 0.508])
property bubble_point_at_T#

Return a BubblePointResults object with all data on the bubble point at constant temperature.

Parameters:
  • T – Temperature [K].

  • IDs – Chemicals that participate in equilibrium. Defaults to all chemicals in equilibrium.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, T=350, units='kg/hr')
>>> s1.bubble_point_at_T()
BubblePointValues(T=350.00, P=76463, IDs=('Water', 'Ethanol'), z=[0.836 0.164], y=[0.488 0.512])
property characterization_factors#
property copy#

Return a copy of the stream.

Examples

Create a copy of a new stream:

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, units='kg/hr')
>>> s1_copy = s1.copy('s1_copy')
>>> s1_copy.show(flow='kg/hr')
Stream: s1_copy
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kg/hr): Water    20
              Ethanol  10

Warning

Prices, and LCA characterization factors are not copied.

property copy_flow#

Copy flow rates of another stream to self.

Parameters:
  • other – Flow rates will be copied from here.

  • IDs – Chemical IDs.

  • remove – If True, copied chemicals will be removed from stream.

  • exclude – If True, exclude designated chemicals when copying.

Examples

Initialize streams:

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, units='kg/hr')
>>> s2 = tmo.Stream('s2')

Copy all flows:

>>> s2.copy_flow(s1)
>>> s2.show(flow='kg/hr')
Stream: s2
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kg/hr): Water    20
              Ethanol  10

Reset and copy just water flow:

>>> s2.empty()
>>> s2.copy_flow(s1, 'Water')
>>> s2.show(flow='kg/hr')
Stream: s2
phase: 'l', T: 298.15 K, P: 101325 Pa
flow: 20 kg/hr Water

Reset and copy all flows except water:

>>> s2.empty()
>>> s2.copy_flow(s1, 'Water', exclude=True)
>>> s2.show(flow='kg/hr')
Stream: s2
phase: 'l', T: 298.15 K, P: 101325 Pa
flow: 10 kg/hr Ethanol

Cut and paste flows:

>>> s2.copy_flow(s1, remove=True)
>>> s2.show(flow='kg/hr')
Stream: s2
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kg/hr): Water    20
              Ethanol  10
>>> s1.show()
Stream: s1
phase: 'l', T: 298.15 K, P: 101325 Pa
flow: 0

Its also possible to copy flows from a multistream:

>>> s1.phases = ('g', 'l')
>>> s1.imol['g', 'Water'] = 10
>>> s2.copy_flow(s1, remove=True)
>>> s2.show()
Stream: s2
phase: 'l', T: 298.15 K, P: 101325 Pa
flow: 10 kmol/hr Water
>>> s1.show()
MultiStream: s1
phases: ('g', 'l'), T: 298.15 K, P: 101325 Pa
 flow: 0

Copy flows except except water and remove water:

>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, units='kg/hr')
>>> s2 = tmo.Stream('s2')
>>> s2.copy_flow(s1, 'Water', exclude=True, remove=True)
>>> s1.show('wt')
Stream: s1
phase: 'l', T: 298.15 K, P: 101325 Pa
flow: 20 kg/hr Water
>>> s2.show('wt')
Stream: s2
phase: 'l', T: 298.15 K, P: 101325 Pa
flow: 10 kg/hr Ethanol
property copy_like#

Copy all conditions of another stream.

Examples

Copy data from another stream with the same property package:

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, units='kg/hr')
>>> s2 = tmo.Stream('s2', Water=2, units='kg/hr')
>>> s1.copy_like(s2)
>>> s1.show(flow='kg/hr')
Stream: s1
phase: 'l', T: 298.15 K, P: 101325 Pa
flow: 2 kg/hr Water

Copy data from another stream with a different property package:

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, units='kg/hr')
>>> tmo.settings.set_thermo(['Water'], cache=True)
>>> s2 = tmo.Stream('s2', Water=2, units='kg/hr')
>>> s1.copy_like(s2)
>>> s1.show(flow='kg/hr')
Stream: s1
phase: 'l', T: 298.15 K, P: 101325 Pa
flow: 2 kg/hr Water
property copy_phase#

Copy phase from another stream.

property copy_thermal_condition#

Copy thermal conditions (T and P) of another stream.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=2, units='kg/hr')
>>> s2 = tmo.Stream('s2', Water=1, units='kg/hr', T=300.00)
>>> s1.copy_thermal_condition(s2)
>>> s1.show(flow='kg/hr')
Stream: s1
phase: 'l', T: 300 K, P: 101325 Pa
flow: 2 kg/hr Water
property cost#

Total cost of stream [USD/hr].

property dew_point_at_P#

Return a DewPointResults object with all data on the dew point at constant pressure.

Parameters:

IDs – Chemicals that participate in equilibrium. Defaults to all chemicals in equilibrium.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, T=350, units='kg/hr')
>>> s1.dew_point_at_P()
DewPointValues(T=368.62, P=101325, IDs=('Water', 'Ethanol'), z=[0.836 0.164], x=[0.983 0.017])
property dew_point_at_T#

Return a DewPointResults object with all data on the dew point at constant temperature.

Parameters:

IDs – Chemicals that participate in equilibrium. Defaults to all chemicals in equilibrium.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, T=350, units='kg/hr')
>>> s1.dew_point_at_T()
DewPointValues(T=350.00, P=49058, IDs=('Water', 'Ethanol'), z=[0.836 0.164], x=[0.984 0.016])
disconnect()#

Disconnect stream from unit.

disconnect_sink()#

Disconnect stream from sink.

disconnect_source()#

Disconnect stream from source.

property display_notation#

Create a DisplayNotation object where default units for representation are stored.

Examples

Its possible to change the default units of measure for the Stream show method:

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water'], cache=True)
>>> tmo.Stream.display_notation.flow = '.2g'
>>> stream = tmo.Stream('stream', Water=1.324, units='kg/hr')
>>> stream.show()
Stream: stream
phase: 'l', T: 298.15 K, P: 101325 Pa
flow: 0.073 kmol/hr Water
>>> # Change back to kmol/hr
>>> tmo.Stream.display_notation.flow = '.3g'
property display_units#

Create a DisplayUnits object where default units for representation are stored.

Examples

Its possible to change the default units of measure for the Stream show method:

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water'], cache=True)
>>> tmo.Stream.display_units.flow = 'kg/hr'
>>> stream = tmo.Stream('stream', Water=1, units='kg/hr')
>>> stream.show()
Stream: stream
phase: 'l', T: 298.15 K, P: 101325 Pa
flow: 1 kg/hr Water
>>> # Change back to kmol/hr
>>> tmo.Stream.display_units.flow = 'kmol/hr'
property empty#

Empty stream flow rates.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, units='kg/hr')
>>> s1.empty()
>>> s1.F_mol
0
property empty_negative_flows#

Replace flows of all components with negative values with 0.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=1, Ethanol=-1)
>>> s1.empty_negative_flows()
>>> s1.show()
Stream: s1
phase: 'l', T: 298.15 K, P: 101325 Pa
flow: 1 kmol/hr Water
property epsilon#

Relative permittivity [-].

property flow_proxy#

Return a new stream that shares flow rate data with this one.

See also

link_with, proxy

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, units='kg/hr')
>>> s2 = s1.flow_proxy()
>>> s2.mol is s1.mol
True
property get_CF#

Returns the life-cycle characterization factor on a kg basis given the impact indicator key.

Parameters:
  • key – Key of impact indicator.

  • basis – Basis of characterization factor. Mass is the only valid dimension (for now). Defaults to ‘kg’.

  • units – Units of impact indicator. Before using this argument, the default units of the impact indicator should be defined with settings.define_impact_indicator. Units must also be dimensionally consistent with the default units.

property get_atomic_flow#

Return flow rate of atom [kmol / hr] given the atomic symbol.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water'], cache=True)
>>> stream = tmo.Stream(Water=1)
>>> stream.get_atomic_flow('H') # kmol/hr of H
2.0
>>> stream.get_atomic_flow('O') # kmol/hr of O
1.0
property get_atomic_flows#

Return dictionary of atomic flow rates [kmol / hr].

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water'], cache=True)
>>> stream = tmo.Stream(Water=1)
>>> stream.get_atomic_flows()
{'H': 2.0, 'O': 1.0}
property get_bubble_point#

Return a BubblePoint object capable of computing bubble points.

Parameters:

IDs – Chemicals that participate in equilibrium. Defaults to all chemicals in equilibrium.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, T=350, units='kg/hr')
>>> s1.get_bubble_point()
BubblePoint([Water, Ethanol])
property get_concentration#

Return concentration of given chemicals.

Parameters:
  • IDs – IDs of chemicals.

  • units – Units of measure. Defaults to kmol/m3.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol', 'Methanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, Methanol=10, units='m3/hr')
>>> s1.get_concentration(['Water', 'Ethanol']) # kg/m3
array([27.673,  4.261])
>>> s1.get_concentration(['Water', 'Ethanol'], 'g/L')
array([498.532, 196.291])
property get_data#

Return a StreamData object containing data on material flow rates, temperature, pressure, and phase(s).

See also

Stream.set_data

Examples

Get and set data from stream at different conditions

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water'], cache=True)
>>> stream = tmo.Stream('stream', Water=10)
>>> data = stream.get_data()
>>> stream.vle(V=0.5, P=101325)
>>> data_vle = stream.get_data()
>>> stream.set_data(data)
>>> stream.show()
Stream: stream
phase: 'l', T: 298.15 K, P: 101325 Pa
flow: 10 kmol/hr Water
>>> stream.set_data(data_vle)
>>> stream.show()
MultiStream: stream
phases: ('g', 'l'), T: 373.12 K, P: 101325 Pa
flow (kmol/hr): (g) Water  5
                (l) Water  5

Note that only StreamData objects are valid for this method:

>>> stream.set_data({'T': 298.15})
Traceback (most recent call last):
ValueError: stream_data must be a StreamData object; not dict
property get_dew_point#

Return a DewPoint object capable of computing dew points.

Parameters:

IDs – Chemicals that participate in equilibrium. Defaults to all chemicals in equilibrium.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, T=350, units='kg/hr')
>>> s1.get_dew_point()
DewPoint([Water, Ethanol])
property get_downstream_units#

Return a set of all units downstream.

property get_flow#

Return an flow rates in requested units.

Parameters:
  • units – Units of measure.

  • key – Chemical identifiers.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, units='kg/hr')
>>> s1.get_flow('kg/hr', 'Water')
20.0
property get_impact#

Return hourly rate of the impact indicator given the key.

property get_mass_composition#

Return mass fraction of given chemicals.

Parameters:

IDs – IDs of chemicals.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol', 'Methanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, Methanol=10, units='kg/hr')
>>> s1.get_mass_fraction(('Water', 'Ethanol'))
array([0.5 , 0.25])
property get_mass_fraction#

Return mass fraction of given chemicals.

Parameters:

IDs – IDs of chemicals.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol', 'Methanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, Methanol=10, units='kg/hr')
>>> s1.get_mass_fraction(('Water', 'Ethanol'))
array([0.5 , 0.25])
property get_molar_composition#

Return molar fraction of given chemicals.

Parameters:

IDs – IDs of chemicals.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol', 'Methanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, Methanol=10, units='kmol/hr')
>>> s1.get_molar_fraction(('Water', 'Ethanol'))
array([0.5 , 0.25])
property get_molar_fraction#

Return molar fraction of given chemicals.

Parameters:

IDs – IDs of chemicals.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol', 'Methanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, Methanol=10, units='kmol/hr')
>>> s1.get_molar_fraction(('Water', 'Ethanol'))
array([0.5 , 0.25])
property get_normalized_mass#

Return normalized mass fractions of given chemicals. The sum of the result is always 1.

Parameters:

IDs – IDs of chemicals to be normalized.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol', 'Methanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, Methanol=10, units='kg/hr')
>>> s1.get_normalized_mass(('Water', 'Ethanol'))
array([0.667, 0.333])
property get_normalized_mol#

Return normalized molar fractions of given chemicals. The sum of the result is always 1.

Parameters:

IDs – IDs of chemicals to be normalized.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol', 'Methanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, Methanol=10, units='kmol/hr')
>>> s1.get_normalized_mol(('Water', 'Ethanol'))
array([0.667, 0.333])
property get_normalized_vol#

Return normalized mass fractions of given chemicals. The sum of the result is always 1.

Parameters:

IDs – IDs of chemicals to be normalized.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol', 'Methanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, Methanol=10, units='m3/hr')
>>> s1.get_normalized_vol(('Water', 'Ethanol'))
array([0.667, 0.333])
property get_property#

Return property in requested units.

Parameters:
  • name – Name of property.

  • units – Units of measure. Defaults to the property’s original units of measure.

property get_total_flow#

Get total flow rate in given units.

Parameters:

units – Units of measure.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, units='kg/hr')
>>> s1.get_total_flow('kg/hr')
30.0
property get_upstream_units#

Return a set of all units upstream.

property get_volumetric_composition#

Return volumetric fraction of given chemicals.

Parameters:

IDs – IDs of chemicals.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol', 'Methanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, Methanol=10, units='m3/hr')
>>> s1.get_volumetric_fraction(('Water', 'Ethanol'))
array([0.5 , 0.25])
property get_volumetric_fraction#

Return volumetric fraction of given chemicals.

Parameters:

IDs – IDs of chemicals.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol', 'Methanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, Methanol=10, units='m3/hr')
>>> s1.get_volumetric_fraction(('Water', 'Ethanol'))
array([0.5 , 0.25])
property h#

Specific enthalpy [kJ/kmol].

property hf#

Specific enthalpy of formation [kJ/kmol].

property hvap#

Enthalpy of vaporization flow rate [kJ/hr].

property imass#

Flow rate indexer with data [kg/hr].

property imol#

Flow rate indexer with data [kmol/hr].

property in_thermal_equilibrium#

Return whether or not stream is in thermal equilibrium with another stream.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> stream = Stream(Water=1, T=300)
>>> other = Stream(Water=1, T=300)
>>> stream.in_thermal_equilibrium(other)
True
property isempty#

Return whether or not stream is empty.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water'], cache=True)
>>> stream = tmo.Stream()
>>> stream.isempty()
True
isfeed()#

Return whether stream has a sink but no source.

isproduct()#

Return whether stream has a source but no sink.

property ivol#

Flow rate indexer with data [m3/hr].

property kappa#

Thermal conductivity [W/m/k].

Link with another stream.

Parameters:

other

See also

flow_proxy, proxy

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, units='kg/hr')
>>> s2 = tmo.Stream('s2')
>>> s2.link_with(s1)
>>> s1.mol is s2.mol
True
>>> s2.thermal_condition is s1.thermal_condition
True
>>> s1.phase = 'g'
>>> s2.phase
'g'
property liquid_fraction#

Molar liquid fraction.

property lle#

An object that can perform liquid-liquid equilibrium on the stream.

property lle_chemicals#

Chemicals cabable of vapor-liquid equilibrium.

property main_chemical#

ID of chemical with the largest mol fraction in stream.

property mass#

Mass flow rates [kg/hr].

property mix_flows#

Mix all other streams into this one, ignoring its initial contents. This method does not alter the stream phase and ignores the pressure and energy balances.

property mix_from#

Mix all other streams into this one, ignoring its initial contents.

Notes

When streams at different pressures are mixed, BioSTEAM assumes valves reduce the pressure of the streams being mixed to prevent backflow (pressure needs to decrease in the direction of flow according to Bernoulli’s principle). The outlet pressure will be the minimum pressure of all streams being mixed.

Examples

Mix two streams with the same thermodynamic property package:

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, units='kg/hr')
>>> s2 = s1.copy('s2')
>>> s1.mix_from([s1, s2])
>>> s1.show(flow='kg/hr')
Stream: s1
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kg/hr): Water    40
              Ethanol  20

It’s also possible to mix streams with different property packages so long as all chemicals are defined in the mixed stream’s property package:

>>> tmo.settings.set_thermo(['Water'], cache=True)
>>> s1 = tmo.Stream('s1', Water=40, units='kg/hr')
>>> tmo.settings.set_thermo(['Ethanol'], cache=True)
>>> s2 = tmo.Stream('s2', Ethanol=20, units='kg/hr')
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s_mix = tmo.Stream('s_mix')
>>> s_mix.mix_from([s1, s2])
>>> s_mix.show(flow='kg/hr')
Stream: s_mix
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kg/hr): Water    40
              Ethanol  20

Mixing empty streams is fine too:

>>> s1.empty(); s2.empty(); s_mix.mix_from([s1, s2])
>>> s_mix.show()
Stream: s_mix
phase: 'l', T: 298.15 K, P: 101325 Pa
flow: 0
property mol#

Molar flow rates [kmol/hr].

property mu#

Hydrolic viscosity [Pa*s].

property nu#

Kinematic viscosity [m^2/s].

property phase#

Phase of stream.

property phases#

All phases present.

property price#

Price of stream per unit mass [USD/kg].

property print#

Print in a format that you can use recreate the stream.

Parameters:

units – Units of measure for material flow rates. Defaults to ‘kmol/hr’

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream(ID='s1',
...                 Water=20, Ethanol=10, units='kg/hr',
...                 T=298.15, P=101325, phase='l')
>>> s1.print(units='kg/hr')
Stream(ID='s1', phase='l', T=298.15, P=101325, Water=20, Ethanol=10, units='kg/hr')
>>> s1.print() # Units default to kmol/hr
Stream(ID='s1', phase='l', T=298.15, P=101325, Water=1.11, Ethanol=0.2171, units='kmol/hr')
property proxy#

Return a new stream that shares all data with this one.

See also

link_with, flow_proxy

Warning

Price and characterization factor data is not shared

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, units='kg/hr')
>>> s2 = s1.proxy()
>>> s2.imol is s1.imol and s2.thermal_condition is s1.thermal_condition
True
property receive_vent#

Receive vapors from another stream by vapor-liquid equilibrium between a gas and liquid stream assuming only a small amount of chemicals in vapor-liquid equilibrium is present

Examples

The energy balance is performed by default:

>>> import thermosteam as tmo
>>> chemicals = tmo.Chemicals(['Water', 'Ethanol', 'Methanol', tmo.Chemical('N2', phase='g')], cache=True)
>>> tmo.settings.set_thermo(chemicals)
>>> s1 = tmo.Stream('s1', N2=20, units='m3/hr', phase='g', T=330)
>>> s2 = tmo.Stream('s2', Water=10, Ethanol=2, T=330)
>>> s1.receive_vent(s2)
>>> s1.show(flow='kmol/hr')
Stream: s1
phase: 'g', T: 323.12 K, P: 101325 Pa
flow (kmol/hr): Water    0.0799
                Ethanol  0.0887
                N2       0.739

Set energy balance to false to receive vent isothermally:

>>> import thermosteam as tmo
>>> chemicals = tmo.Chemicals(['Water', 'Ethanol', 'Methanol', tmo.Chemical('N2', phase='g')], cache=True)
>>> tmo.settings.set_thermo(chemicals)
>>> s1 = tmo.Stream('s1', N2=20, units='m3/hr', phase='g', T=330)
>>> s2 = tmo.Stream('s2', Water=10, Ethanol=2, T=330)
>>> s1.receive_vent(s2, energy_balance=False)
>>> s1.show(flow='kmol/hr')
Stream: s1
phase: 'g', T: 330 K, P: 101325 Pa
flow (kmol/hr): Water    0.112
                Ethanol  0.123
                N2       0.739
property reduce_phases#

Remove empty phases.

property rescale#

Multiply flow rate by given scale.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=1)
>>> s1.scale(100)
>>> s1.F_mol
100.0
property reset#

Convinience method for resetting flow rate and thermal condition data.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=1)
>>> s1.reset(T=300.1, Ethanol=1, phase='g', units='kg/hr', total_flow=2)
>>> s1.show('cwt')
Stream: s1
phase: 'g', T: 300.1 K, P: 101325 Pa
flow: 2 kg/hr Ethanol
property reset_cache#

Reset cache regarding equilibrium methods.

property reset_flow#

Convinience method for resetting flow rate data.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=1)
>>> s1.reset_flow(Ethanol=1, phase='g', units='kg/hr', total_flow=2)
>>> s1.show('cwt')
Stream: s1
phase: 'g', T: 298.15 K, P: 101325 Pa
flow: 2 kg/hr Ethanol
property rho#

Density [kg/m^3].

property s#

Specific enthalpy [kJ/kmol].

property sanity_check#

Raise an InfeasibleRegion error if flow rates are infeasible.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water'], cache=True)
>>> s1 = tmo.Stream('s1')
>>> s1.sanity_check()
>>> s1.mol[0] = -1.
>>> s1.sanity_check()
Traceback (most recent call last):
InfeasibleRegion: negative material flow rate is infeasible
property scale#

Multiply flow rate by given scale.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=1)
>>> s1.scale(100)
>>> s1.F_mol
100.0
property separate_out#

Separate out given stream from this one.

Examples

Separate out another stream with the same thermodynamic property package:

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=30, Ethanol=10, units='kg/hr')
>>> s2 = tmo.Stream('s2', Water=10, Ethanol=5, units='kg/hr')
>>> s1.separate_out(s2)
>>> s1.show(flow='kg/hr')
Stream: s1
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kg/hr): Water    20
              Ethanol  5

It’s also possible to separate out streams with different property packages so long as all chemicals are defined in the mixed stream’s property package:

>>> tmo.settings.set_thermo(['Water'], cache=True)
>>> s1 = tmo.Stream('s1', Water=40, units='kg/hr')
>>> tmo.settings.set_thermo(['Ethanol'], cache=True)
>>> s2 = tmo.Stream('s2', Ethanol=20, units='kg/hr')
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s_mix = tmo.Stream.sum([s1, s2], 's_mix')
>>> s_mix.separate_out(s2)
>>> s_mix.show(flow='kg/hr')
Stream: s_mix
phase: 'l', T: 298.15 K, P: 101325 Pa
flow: 40 kg/hr Water

Removing empty streams is fine too:

>>> s1.empty(); s_mix.separate_out(s1)
>>> s_mix.show(flow='kg/hr')
Stream: s_mix
phase: 'l', T: 298.15 K, P: 101325 Pa
flow: 40 kg/hr Water
property set_CF#

Set the life-cycle characterization factor on a kg basis given the impact indicator key and the units of measure.

Parameters:
  • key – Key of impact indicator.

  • value – Characterization factor value.

  • basis – Basis of characterization factor. Mass is the only valid dimension (for now). Defaults to ‘kg’.

  • units – Units of impact indicator. Before using this argument, the default units of the impact indicator should be defined with settings.define_impact_indicator. Units must also be dimensionally consistent with the default units.

property set_data#

Set material flow rates, temperature, pressure, and phase(s) through a StreamData object

See also

Stream.get_data

property set_flow#

Set flow rates in given units.

Parameters:
  • data – Flow rate data.

  • units – Units of measure.

  • key – Chemical identifiers.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream(ID='s1', Water=20, Ethanol=10, units='kg/hr')
>>> s1.set_flow(10, 'kg/hr', 'Water')
>>> s1.get_flow('kg/hr', 'Water')
10.0
property set_property#

Set property in given units.

Parameters:
  • name – Name of property.

  • value – New value of property.

  • units – Units of measure.

property set_total_flow#

Set total flow rate in given units keeping the composition constant.

Parameters:
  • value – New total flow rate.

  • units – Units of measure.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, units='kg/hr')
>>> s1.set_total_flow(1.0,'kg/hr')
>>> s1.get_total_flow('kg/hr')
0.9999999999999999
property shares_flow_rate_with#

Return whether other stream shares data with this one.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water'], cache=True)
>>> s1 = tmo.Stream('s1')
>>> other = s1.flow_proxy()
>>> s1.shares_flow_rate_with(other)
True
>>> s1 = tmo.MultiStream('s1', phases=('l', 'g'))
>>> s1['g'].shares_flow_rate_with(s1)
True
>>> s2 = tmo.MultiStream('s2', phases=('l', 'g'))
>>> s1['g'].shares_flow_rate_with(s2)
False
>>> s1['g'].shares_flow_rate_with(s2['g'])
False
>>> s1 = tmo.MultiStream('s1')
>>> other = s1.flow_proxy()
>>> s1.shares_flow_rate_with(other)
True
>>> s1 = tmo.MultiStream('s1', phases=('l', 'g'))
>>> s1.shares_flow_rate_with(s1['g'])
True
>>> s2 = tmo.MultiStream('s2', phases=('l', 'g'))
>>> s2.shares_flow_rate_with(s1['g'])
False
>>> s1.shares_flow_rate_with(s2)
False
property show#

Print all specifications.

Parameters:
  • layout – Convenience paramater for passing flow, composition, and N. Must have the form {‘%’ or ‘’}{‘wt’, ‘mol’ or ‘vol’}{# or ‘’}. For example: ‘%wt100’ corresponds to compostion=True, flow=’kg/hr’, and N=100.

  • T – Temperature units.

  • P – Pressure units.

  • flow – Flow rate units.

  • composition – Whether to show composition.

  • N – Number of compounds to display.

  • IDs – IDs of compounds to display. Defaults to all chemicals.

  • sort – Whether to sort flows in descending order.

  • df – Whether to return a pandas DataFrame.

Examples

Show a stream’s composition by weight for only the top 2 chemicals with the highest mass fractions:

>>> import biosteam as bst
>>> bst.settings.set_thermo(['Water', 'Ethanol', 'Methanol', 'Propanol'])
>>> stream = bst.Stream('stream', Water=0.5, Ethanol=1.5, Methanol=0.2, Propanol=0.3, units='kg/hr')
>>> stream.show('cwt2s') # Alternatively: stream.show(composition=True, flow='kg/hr', N=2, sort=True)
Stream: stream
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (%): Ethanol  60
          Water    20
          ...      20
          -------  2.5 kg/hr
property sigma#

Surface tension [N/m].

property sink: AbstractUnit#

Inlet location.

property sle#

An object that can perform solid-liquid equilibrium on the stream.

property solid_fraction#

Molar solid fraction.

property source: AbstractUnit#

Outlet location.

property split_to#

Split molar flow rate from this stream to two others given the split fraction or an array of split fractions.

Examples

>>> import thermosteam as tmo
>>> chemicals = tmo.Chemicals(['Water', 'Ethanol'], cache=True)
>>> tmo.settings.set_thermo(chemicals)
>>> s = tmo.Stream('s', Water=20, Ethanol=10, units='kg/hr')
>>> s1 = tmo.Stream('s1')
>>> s2 = tmo.Stream('s2')
>>> split = chemicals.kwarray(dict(Water=0.5, Ethanol=0.1))
>>> s.split_to(s1, s2, split)
>>> s1.show(flow='kg/hr')
Stream: s1
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kg/hr): Water    10
              Ethanol  1
>>> s2.show(flow='kg/hr')
Stream: s2
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kg/hr): Water    10
              Ethanol  9
property sum#

Return a new Stream object that represents the sum of all given streams.

Examples

Sum two streams:

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, units='kg/hr')
>>> s_sum = tmo.Stream.sum([s1, s1], 's_sum')
>>> s_sum.show(flow='kg/hr')
Stream: s_sum
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kg/hr): Water    40
              Ethanol  20

Sum two streams with new property package:

>>> thermo = tmo.Thermo(['Water', 'Ethanol', 'Methanol'], cache=True)
>>> s_sum = tmo.Stream.sum([s1, s1], 's_sum', thermo)
>>> s_sum.show(flow='kg/hr')
Stream: s_sum
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kg/hr): Water    40
              Ethanol  20
property thermal_condition#

Contains the temperature and pressure conditions of the stream.

Unlink stream from other streams.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, units='kg/hr')
>>> s2 = tmo.Stream('s2')
>>> s2.link_with(s1)
>>> s1.unlink()
>>> s2.mol is s1.mol
False
>>> s1.phases = s2.phases = ('l', 'g')
>>> s2.link_with(s1)
>>> s1.imol.data is s2.imol.data
True
>>> s1.unlink()
>>> s1.imol.data is s2.imol.data
False

MultiStream phases cannot be unlinked:

>>> s1 = tmo.MultiStream(None, phases=('l', 'g'))
>>> s1['g'].unlink()
Traceback (most recent call last):
RuntimeError: phase is locked; stream cannot be unlinked
property vapor_fraction#

Molar vapor fraction.

property vle#

An object that can perform vapor-liquid equilibrium on the stream.

property vle_chemicals#

Chemicals cabable of liquid-liquid equilibrium.

property vlle#

An object that can perform vapor-liquid-liquid equilibrium on the stream.

property vlle_chemicals#

Chemicals cabable of liquid-liquid equilibrium.

property vol#

Volumetric flow rates [m3/hr].

property z_mass#

Mass composition.

property z_mol#

Molar composition.

property z_vol#

Volumetric composition.

_N_ins: int = 1#

class-attribute Expected number of inlet streams. Defaults to 1.

_N_outs: int = 1#

class-attribute Expected number of outlet streams. Defaults to 1

_graphics: UnitGraphics = 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.

_ins_size_is_fixed: bool = True#

class-attribute Whether the number of streams in ins is fixed.

_outs_size_is_fixed: bool = True#

class-attribute Whether the number of streams in outs is fixed.

_run = AbstractMethod#

Run mass and energy balances and update outlet streams (without user-defined specifications).

add_bounded_numerical_specification(f=None, *args, **kwargs)#

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

Process specifications

Notes

This method also works as a decorator.

add_specification(f=None, run=None, args=(), impacted_units=None, prioritize=None)#

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[AbstractUnit, ...], 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

Process specifications

Notes

This method also works as a decorator.

auxiliary(name, cls, ins=None, outs=(), thermo=None, register=False, **kwargs)#

Create and register an auxiliary unit operation. Inlet and outlet streams automatically become auxlets so that parent unit streams will not disconnect.

auxiliary_unit_names: tuple[str, ...] = ()#

Auxiliary unit operation names.

property auxiliary_units: list[AbstractUnit]#

Return list of all auxiliary units.

auxin(stream, thermo=None)#

Define auxiliary unit inlet. This method has two behaviors:

  • If the stream is not connected to this unit, define the Stream object’s source 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.

auxlet(stream, thermo=None)#

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.

auxout(stream, thermo=None)#

Define auxiliary unit 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.

diagram(radius=0, upstream=True, downstream=True, file=None, format=None, display=True, auxiliaries=-1, **graph_attrs)#

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.

property effluent: AbstractStream#

Equivalent to outs[0] when the number of outlets is 1.

property feed: AbstractStream#

Equivalent to ins[0] when the number of inlets is 1.

property flat_ins: Sequence[AbstractStream]#

List of all inlet single-phase streams.

property flat_outs: Sequence[AbstractStream]#

List of all outlet single-phase streams.

get_ash_disposal_cost()#

Return the ash disposal cost [USD/hr].

get_ash_disposal_flow()#

Return the ash disposal flow rate [kg/hr].

get_auxiliary_units_with_names()#

Return list of name - auxiliary unit pairs.

get_downstream_units(ends=None, universal=True, downstream_units=None)#

Return a set of all units downstream.

get_fuel_cost()#

Return the fuel cost [USD/hr].

get_fuel_flow()#

Return the fuel 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_nested_auxiliary_units_with_names(depth=-1)#

Return list of all auxiliary units, including nested ones.

get_node()#

Return unit node attributes for graphviz.

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].

get_upstream_units(ends=None, universal=True, upstream_units=None)#

Return a set of all units upstream.

property influent: AbstractStream#

Equivalent to ins[0] when the number of inlets is 1.

property inlet: AbstractStream#

Equivalent to ins[0] when the number of inlets is 1.

property ins: Sequence[AbstractStream]#

List of all inlet streams.

line: str = 'Unit'#

class-attribute Name denoting the type of Unit class. Defaults to the class name of the first child class

neighborhood(radius=1, upstream=True, downstream=True, ends=None, universal=None)#

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 units.

  • upstream (bool, optional) – Whether to include upstream units.

  • ends (AbstractStream, optional) – Streams that mark the end of the neighborhood.

  • universal (bool, optional) – Whether to include universal units.

property nested_auxiliary_units: list[AbstractUnit]#

Return list of all auxiliary units, including nested ones.

property outlet: AbstractStream#

Equivalent to outs[0] when the number of outlets is 1.

property outs: Sequence[AbstractStream]#

List of all outlet streams.

path_from(units, inclusive=False, system=None)#

Return a tuple of units and systems starting from units until this one (not inclusive by default).

path_until(units, inclusive=False, system=None)#

Return a tuple of units and systems starting from this one until the end units (not inclusive by default).

property product: AbstractStream#

Equivalent to outs[0] when the number of outlets is 1.

run()#

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).

run_until(units, inclusive=False, system=None)#

Run all units and converge all systems starting from this one until the end units (not inclusive by default).

See also

path_until

show(layout=None, T=None, P=None, flow=None, composition=None, N=None, IDs=None, sort=None, data=True)#

Prints information on unit.

auxins#

dict[int, stream] Auxiliary inlets by index.

auxouts#

dict[int, stream] Auxiliary outlets by index.

run_after_specifications: bool#

Whether to run mass and energy balance after calling specification functions

prioritize: bool#

Whether to prioritize unit operation specification within recycle loop (if any).