MassBalance#

class MassBalance(ID='', ins=None, outs=(), thermo=None, **kwargs)[source]#

Create a Unit object that changes net input flow rates to satisfy output flow rates. This calculation is based on mass balance equations for specified IDs.

Parameters:
  • ins (Stream], optional) – Inlet stream. Doesn’t actually affect mass balance. It’s just to show the position in the process.

  • outs (Stream], optional) – Outlet stream. Doesn’t actually affect mass balance. It’s just to show the position in the process.

  • chemical_IDs (tuple[str]) – Chemicals that will be used to solve mass balance linear equations. The number of chemicals must be same as the number of input streams varied.

  • variable_inlets (Iterable[Stream]) – Inlet streams that can vary in net flow rate to accomodate for the mass balance.

  • constant_inlets (Iterable[Stream], optional) – Inlet streams that cannot vary in flow rates.

  • constant_outlets (Iterable[Stream], optional) – Outlet streams that cannot vary in flow rates.

  • is_exact=True (bool, optional) – True if exact flow rate solution is required for the specified IDs.

  • balance='flow' ({'flow', 'composition'}, optional) –

    • ‘flow’: Satisfy output flow rates

    • ’composition’: Satisfy net output molar composition

Examples

MassBalance are Unit objects that serve to alter flow rates of selected chemicals and input streams to satisfy the mass balance. The example below uses the MassBalance object to satisfy the target flow rate feeding the mixer M1:

>>> from biosteam import System, Stream, settings, main_flowsheet
>>> from biosteam.units import (Mixer, Splitter, StorageTank, Pump,
...                             Flash, MassBalance)
>>> main_flowsheet.set_flowsheet('mass_balance_example')
>>> settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> water = Stream('water',
...                Water=40,
...                units='lb/s',
...                T=350, P=101325)
>>> ethanol = Stream('ethanol',
...                  Ethanol=190, Water=30,
...                  T=300, P=101325)
>>> target = Stream('target',
...                 Ethanol=500, Water=500)
>>> T1 = StorageTank('T1', outs='s1')
>>> T2 = StorageTank('T2', outs='s2')
>>> P1 = Pump('P1', P=101325, outs='s3')
>>> P2 = Pump('P2', P=101325, outs='s4')
>>> M1 = Mixer('M1', outs='s5')
>>> S1 = Splitter('S1', outs=('s6', 's7'), split=0.5)
>>> F1 = Flash('F1', outs=('s8', 's9'), V=0.5, P =101325)
>>> MB1 = MassBalance('MB1', outs='s6_2',
...                   variable_inlets=[water, ethanol],
...                   constant_inlets=[S1-0],
...                   constant_outlets=[target],
...                   chemical_IDs=('Ethanol', 'Water'),
...                   description='Adjust flow rate of feed to mixer')
>>> # Connect units
>>> water-T1-P1
<Pump: P1>
>>> ethanol-T2-P2
<Pump: P2>
>>> [P1-0, P2-0, MB1-0]-M1-F1-1-S1-0-MB1
<MassBalance: MB1>
>>> sys = main_flowsheet.create_system('sys')
>>> # Make diagram to view system
>>> # sys.diagram()
>>> sys.simulate();
>>> target.show()
Stream: target
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kmol/hr): Water    500
                Ethanol  500
line: str = 'Mass balance'#

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

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

prioritize: bool#

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

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.