{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# -pipe- notation"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Connecting unit operations can be simplified through -pipe- notation. Here we create a process with multiple units and connect them as a demonstration. With -pipe- notation you can get stream outputs and set stream inputs in the following format:"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"# U1-n -> U1.outs[n]\n",
"# U1-[0, 1] -> [U1.outs[i] for i in [0, 1]]\n",
"# s1-U1 -> U1.ins[:] = [s1]\n",
"# s1-n-U1 -> U1.ins[n] = s1\n",
"# [s1, s2]-U1 -> U1.ins[:] = [s1, s2]\n",
"# U1-n1-n2-U2 -> U2.ins[n2] = U1.outs[n1]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"As an example, create 2 feeds, 2 Mixers and 2 Splitters:"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"tags": [
"nbval-ignore-output"
]
},
"outputs": [
{
"data": {
"text/html": [
"\n",
" \n",
" "
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import biosteam as bst\n",
"from biosteam.units import Mixer, Splitter\n",
"bst.nbtutorial() # Ignore warnings and reset local BioSTEAM preferences\n",
"\n",
"# Set property pacakge\n",
"bst.settings.set_thermo(['Water'])\n",
"\n",
"# Set feed stream and units\n",
"feed1 = bst.Stream('feed1')\n",
"M1 = Mixer('M1', outs='s1')\n",
"S1 = Splitter('S1', outs=('s2', 'product1'), split=0.5)\n",
"feed2 = bst.Stream('feed2')\n",
"M2 = Mixer('M2', outs='s3')\n",
"S2 = Splitter('S2', outs=('recycle', 'product2'), split=0.5)\n",
"bst.main_flowsheet.diagram()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now connect streams linearly along the units, and create a loop between S2 and M1:"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"tags": [
"nbval-ignore-output"
]
},
"outputs": [
{
"data": {
"text/html": [
"\n",
" \n",
" "
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# In -pipe- notation:\n",
"(feed1, S2-0)-M1-S1\n",
"(feed2, S1-0)-M2-S2\n",
"\n",
"# Without -pipe- notation:\n",
"# M1.ins[:] = (feed1, S2.outs[0])\n",
"# S1.ins[:] = M1.outs\n",
"# M2.ins[:] = (feed2, S1.outs[0])\n",
"# S2.ins[:] = M2.outs\n",
"\n",
"bst.main_flowsheet.diagram()"
]
}
],
"metadata": {
"celltoolbar": "Tags",
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
}
},
"nbformat": 4,
"nbformat_minor": 2
}