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