<jupyter_start><jupyter_text>Creating a Unit All unit operations are created by passing a name and both inlet and outlet streams. The parent [Unit](../Unit.txt) class does nothing when simulated, but is used here as a general example that applies to all Unit child classes (e.g. heat exchangers, mixers) which do implement modeling algorithms.   Key parameters Initialize a Unit object with an `ID`, `ins` streams, and `outs` streams. Either an iterable of Stream objects, or a Stream object may work for `ins` and `outs`:<jupyter_code>from biosteam import Unit, Stream, settings, main_flowsheet
settings.set_thermo(['Water'])
ins = Stream('in0')
outs = [Stream('out0')]
U1 = Unit(ID='U1', ins=ins, outs=outs)
U1.show(data=False) # Passing data as False returns only stream names<jupyter_output>Unit: U1
ins...
[0] in0
outs...
[0] out0<jupyter_text>You can also view a diagram to check connections:<jupyter_code>U1.diagram()<jupyter_output><empty_output><jupyter_text>IDs for Stream objects can also be used instead:<jupyter_code>U2 = Unit('U2', ins='', outs=['']) # Empty strings default unused IDs
U2.show(data=False)<jupyter_output>Unit: U2
ins...
[0] s1
outs...
[0] s2<jupyter_text>Parameter defaults By default, a unique `ID` is chosen, missing streams are given to `ins`, and empty streams to `outs`:<jupyter_code>unit = Unit()
unit.show(data=False)<jupyter_output>Unit: U3
ins...
[0] missing stream
outs...
[0] s3<jupyter_text>For either `ins` or `outs`, if None is given, missing streams are initialized. If an empty iterable is given, empty streams are initialized:<jupyter_code>U4 = Unit('U4', ins=None, outs=None)
U4.show(data=False)
U5 = Unit('U5', ins=(), outs=())
U5.show(data=False)<jupyter_output>Unit: U5
ins...
[0] s4
outs...
[0] s5<jupyter_text>The number of default streams is different for each Unit subclass:<jupyter_code>from biosteam import Mixer, Splitter
Mixer().show(data=False)
Splitter(split=0.5).show(data=False)<jupyter_output>Splitter: S1
ins...
[0] missing stream
outs...
[0] s7
[1] s8<jupyter_text>Notice how the starting letter for default IDs vary between unit operations. This is because default names follow the "area naming convention" as explained in the following section.  Area naming convention Default IDs for unit operations follow the area naming convention based on {letter}{area + number} where the letter depends on the unit operation as follows:* C: Centrifuge* D: Distillation column* E: Evaporator* F: Flash tank* H: Heat exchange* M: Mixer* P: Pump (including conveying belt)* R: Reactor* S: Splitter (including solid/liquid separator)* T: Tank or bin for storage* U: Other units* J: Junction, not a physical unit (serves to adjust streams)* PS: Process specificiation, not a physical unit (serves to adjust streams) Continue creating unit operations following the area naming convention:<jupyter_code>Mixer().show(data=False)
Splitter(split=0.5).show(data=False)
Splitter(split=0.5).show(data=False)<jupyter_output>Splitter: S3
ins...
[0] missing stream
outs...
[0] s12
[1] s13<jupyter_text>Notice how there were no name conflicts for default IDs.  Create a mixer following the area naming convention, this time starting from nunber 101:<jupyter_code>Mixer(100).show(data=False)<jupyter_output>Mixer: M101
ins...
[0] missing stream
[1] missing stream
outs...
[0] s14
{'fraction_non_alphanumeric': 0.1141566265060241, 'fraction_numerical': 0.020481927710843374, 'mean_word_length': 5.805327868852459, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '184372', 'license': 'MIT', 'n_tokens_mistral': 1106, 'n_tokens_neox': 1055, 'n_words': 402, 'path': 'docs/tutorial/Creating_a_Unit.ipynb', 'repo_name': 'yoelcortes/biosteam', 'size': '3320'}