ProcessModel#

class ProcessModel(*, simulate=True, scenario=None, **kwargs)[source]#

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 create_model methods for the process model to initialize its key components.

It may help to look at how ProcessModel objects are created (approximately):

def __new__(cls, simulate=None, scenario=None, **kwargs):
    if scenario is None:
        self.scenario = cls.Scenario(**kwargs)
    else:
        # The Scenario object can be initialized through the `as_scenario` class method.
        self.scenario = cls.as_scenario(scenario)

    # No need to recreate a process model for repeated scenarios.
    if scenario in cls.cache: return cls.cache[scenario]
    self = super().__new__()

    # The thermodynamic property package is given by the `create_thermo` method.
    self.load_thermo(self.create_thermo())

    # If no system is returned by the `create_system` method, a new system is created from flowsheet units.
    self.flowsheet = bst.Flowsheet()
    system = self.create_system()
    if system is None: system = self.flowsheet.create_system()

    # This saves the system as self.system and all units/streams as attributes by ID.
    # For example, Stream('feedstock') will be stored as self.feestock.
    self.load_system(system)

    # A Model object is loaded from the `create_model` method.
    # The model will be stored as self.model and all parameters and metrics as attributes by function name.
    # For example:
    #
    # @model.metric
    # def MSP(): return self.tea.solve_price(self.product)
    #
    # ^ This becomes self.MSP.
    self.load_model(self.create_model())

    if simulate: self.system.simulate()
    self.cache[scenario] = self
    return self
Scenario: type#

class-attribute Class which defines arguments to the process model using the layout of a python dataclass: https://docs.python.org/3/library/dataclasses.html

default_scenario = AbstractMethod#

This method allows the process model to default the scenario. It should return a Scenario object.

as_scenario = AbstractMethod#

class method This method allows the process model to interpret objects (e.g., strings, numbers) as a Scenario.

create_thermo = AbstractMethod#

This method should return a chemicals or thermo object. BioSTEAM will automatically set it as the thermodynmic property package.

create_system = AbstractMethod#

This method should create unit operations and connect them. It can return a system object, optionally. Otherwise, BioSTEAM will take care of creating the system from the units and saves it as the self.system attribute. All streams and unit operations are also saved as attributes by their ID.

create_model = AbstractMethod#

This method should return a model object. The model will be saved as a self.model attribute. All pareameters and metrics of the model object will also be saved as attributes by their function names.

show(metadata=True)[source]#

Print representation of process model.