Skip to content

Commit

Permalink
improve new tutorial
Browse files Browse the repository at this point in the history
yoelcortes committed Jan 16, 2025
1 parent 446a568 commit 243c4f2
Showing 3 changed files with 37 additions and 31 deletions.
19 changes: 15 additions & 4 deletions biosteam/process_tools/process_model.py
Original file line number Diff line number Diff line change
@@ -96,10 +96,21 @@ def show(self):

class ProcessModel:
"""
ProcessModel is an abstract class which has missing (i.e., "abstract")
attributes and methods. The user must define a `Scenario` dataclass which
determines all inputs to the process model. Additionally, the user must
define the `as_scenario`, `create_thermo`, `create_system`, and
ProcessModel objects allow us to write code for many related configurations
with ease. It streamlines the process of creating a model, including:
* Defining **scenarios** to compare.
* Creating the **thermodynamic property package**.
* Forming the **system** from unit operations.
* Setting up the evaluation **model**.
Additionally, all objects created within the process model
(e.g., chemicals, streams, units, systems) can be easily accessed as attributes.
The first step is to inherit from the ProcessModel abstract class.
An abstract class has missing (or "abstract") attributes/methods which
the user must define to complete the class. The user must define a
`Scenario` dataclass, and `as_scenario`, `create_thermo`, `create_system`,
`create_model` methods for the process model to initialize its key components.
It may help to look at how ProcessModel objects are created (approximately):
Original file line number Diff line number Diff line change
@@ -4,9 +4,24 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Comparative techno-economic analysis\n",
"\n",
"Techno-economic analysis (TEA) of emerging and conceptual technologies rarely provides a good estimate of economic viability. In fact, economic indicators are largely overly optimistic due to biased assumptions and unforseen expenses. The real power of early-stage TEA is the ability to **compare** technologies under harmonized assumptions and establish key **performance targets** that technologies need to meet for market competitiveness. Perfoming comparative techno-economic analysis under harmonized assumptions, however, can be challenging due to the complexity of managing many biorefinery codes. In this chapter, we demonstrate how BioSTEAM can facilitate the evaluation and comparison of many configuration **scenarios** through ProcessModel objects.\n",
"\n",
"As a demonstrative case study, we will perform economic analysis of cellulosic ethanol production for two alternative biorefinery configurations: one processing cornstover with dilute acid pretreatment [1] and another processing switchgrass with AFEX pretreatment [2]. For simplicity, assumptions on fermentation performance in the switchgrass biorefinery are the same as in the cornstover biorefinery.\n",
"\n",
"## Process models\n",
"\n",
"ProcessModel objects allow us to write code for multiple related configurations with ease. It streamlines system creation and provides an easy handle to access objects within a model configuration (e.g., chemicals, streams, units, systems). ProcessModel is an abstract class which has missing (or \"abstract\") attributes and methods. The user must define a `Scenario` dataclass which determines all inputs to the process model. Additionally, the user must define the `as_scenario`, `create_thermo`, `create_system`, and `create_model` methods for the process model to initialize its key components. \n",
"ProcessModel objects allow us to write code for many related configurations with ease. It streamlines the process of creating a model, including:\n",
"\n",
"* Defining **scenarios** to compare.\n",
"* Creating the **thermodynamic property package**.\n",
"* Forming the **system** from unit operations.\n",
"* Setting up the evaluation **model**.\n",
"\n",
"Additionally, all objects created within the process model (e.g., chemicals, streams, units, systems) can be easily accessed as attributes.\n",
"\n",
"The first step is to inherit from the ProcessModel abstract class. An abstract class has missing (or \"abstract\") attributes/methods which the user must define to complete the class. The user must define a `Scenario` dataclass, and `as_scenario`, `create_thermo`, `create_system`, `create_model` methods for the process model to initialize its key components. \n",
"\n",
"It may help to look at how ProcessModel objects are created (approximately):\n",
" \n",
@@ -48,9 +63,7 @@
" self.cache[scenario] = self\n",
" return self\n",
"\n",
"```\n",
" \n",
"In this chapter, we will create a ProcessModel object to facilitate the economic analysis of cellulosic ethanol production for two alternative biorefinery configurations: one processing cornstover with dilute acid pretreatment [1] and another processing switchgrass with AFEX pretreatment [2]. For simplicity, assumptions on fermentation performance in the switchgrass biorefinery are the same as in the cornstover biorefinery."
"```"
]
},
{
@@ -76,31 +89,18 @@
" \n",
" @classmethod\n",
" def as_scenario(cls, scenario):\n",
" \"\"\"\n",
" This method allows the process model to interpret objects \n",
" (e.g., strings, numbers) as a Scenario.\n",
" \"\"\"\n",
" # Interpret strings in the form of '{feedstock}/{pretreatment}' as a scenario.\n",
" feedstock, pretreatment = scenario.split('/')\n",
" return cls.Scenario(feedstock, pretreatment)\n",
" \n",
" def create_thermo(self):\n",
" \"\"\"\n",
" This method should return a chemicals or thermo object.\n",
" BioSTEAM will automatically set it as the thermodynmic property package.\n",
" \"\"\"\n",
" return cellulosic.create_cellulosic_ethanol_chemicals()\n",
" \n",
" def create_system(self):\n",
" \"\"\"\n",
" This method should create unit operations and connect them.\n",
" It can return a system object, optionally. Otherwise, BioSTEAM will \n",
" take care of creating the system from these units and saves \n",
" it as the `self.system` attribute.\n",
" All streams and unit operations are also saved as attributes by their ID.\n",
" \"\"\"\n",
" # Here we create the units and connect them.\n",
" # BioSTEAM can take care of creating the system.\n",
" cellulosic.load_process_settings()\n",
" scenario = self.scenario # The input paremters to the process model are saved here.\n",
" scenario = self.scenario # The input parameters to the process model are saved here.\n",
" if self.scenario.feedstock == 'cornstover':\n",
" feedstock = bst.Stream(\n",
" ID='feedstock',\n",
@@ -178,12 +178,7 @@
" area=600,\n",
" )\n",
" \n",
" def create_model(self):\n",
" \"\"\"\n",
" This method should return a model object. The model will be saved as a self.model attribute. \n",
" All pareameters and metrics of the model object will also be saved as attributes by their \n",
" function names.\n",
" \"\"\"\n",
" def create_model(self): # We create the Model object here.\n",
" system = self.system # BioSTEAM automaticaly creates the system and saves it as self.system\n",
" self.tea = tea = create_cellulosic_ethanol_tea(system)\n",
" model = bst.Model(system)\n",
2 changes: 1 addition & 1 deletion docs/tutorial/index.txt
Original file line number Diff line number Diff line change
@@ -55,7 +55,7 @@ User guide
:caption: Automation

Uncertainty_and_sensitivity
Process_models
Comparative_techno-economic_analysis
Operational_flexibility

.. grid-item::

0 comments on commit 243c4f2

Please sign in to comment.