(special_uo) Combo UOΒΆ

Instantiation

a) direct

"""Direct instance creation."""

tmp_uo = ComboUO(
    # All unit operations should have the same time vector.
    t=np.linspace(0, 100, 1001),
    sub_uo_list=[concentration_template.concentration,
                 buffer_exchange_template.buffer_exchange,
                 flow_through_template.flow_through],
    uo_id="combo_uo",
    gui_title="Combo UO, direct instance"  # Optional.
)

b) using parameters and attributes

PARAMETERS = {
    # Required.
    "uo_id": str,
    # Required.
    "sub_uo_list": List[UnitOperation],
    # Optional.
    "gui_title": str,  # default: ComboUO
}
ATTRIBUTES = {
    # `ComboUO` has no specific attributes,
    # apart from the ones in `PARAMETERS`.

    # Additional attributes are inherited from `UnitOperation`.
    # See `examples/templates/add_on_attributes.py`.
    # Add them to the list if needed.
}

Additional Add-On Attributes are available for each bio_rtd.core.UnitOperation.

"""1. Define a time step and a simulation time vector."""
t = np.linspace(0, 100, 1001)  # it must start with 0
dt = t[1]  # time step

"""2. Use `PARAMETERS` and `ATTRIBUTES` as a template.

Copy/Paste templates.
Replace variable types with values.
Remove or comment out the ones that are not needed.

"""

uo_pars = {
    # Required.
    "uo_id": "uf_df",
    # Required.
    "sub_uo_list": [concentration_template.concentration,
                    buffer_exchange_template.buffer_exchange,
                    flow_through_template.flow_through],
    # Optional.
    # "gui_title": str,  # default: ComboUO
}

uo_attr = {
    # `ComboUO` has no specific attributes,
    # apart from the ones in `PARAMETERS`.

    # Additional attributes are inherited from `UnitOperation`.
    # See `examples/templates/add_on_attributes.py`.
    # Add them to the list if needed.
}

"""3. Instantiate unit operation and populate attributes."""

cstr = ComboUO(t, **uo_pars)

# Can be omitted.
for key, value in uo_attr.items():
    # Make sure attribute exist.
    assert hasattr(cstr, key), f"`{key}` is wrong."
    # Override value.
    setattr(cstr, key, value)

# Voila :)