bio_rtd.uo.surge_tank

Surge tanks.

Unit operations that accept various flow rate profiles and provide constant or box-shaped profile.

CSTR

class bio_rtd.uo.surge_tank.CSTR(t, uo_id, gui_title='CSTR')[source]

Bases: bio_rtd.core.UnitOperation

Simulation of CSTR with ideal mixing.

Accepts constant, box-shaped or box-shaped periodic flow rate profiles.

Provides constant or box-shaped flow rate profile.

Parameters
  • t (ndarray) – Simulation time vector. Starts with 0 and has a constant time step.

  • uo_id (str) – Unique identifier.

  • gui_title (str) – Readable title for GUI. Default = “CSTR”.

Notes

Target upper fill volume can be defined via:

Initial fill volume can be defined via:

The concentration of pre-filled part is defined by c_init. Empty array (default) means that all components are 0.

Examples

>>> t = _np.linspace(0, 100, 1001)  # min
>>> cstr = CSTR(t, uo_id="sample_cstr")
>>> # Size of the surge tank.
>>> cstr.v_void = 140  # mL
>>> cstr.starts_empty = True  # optional
>>> f_in = _np.zeros_like(t)
>>> f_in[0:800] = 12.5  # mL/min
>>> c_in = _np.zeros([1, t.size])
>>> c_in[0][0:800] = 2.5  # mg/mL
>>> f_out, c_out = cstr.evaluate(f_in, c_in)
>>> f_out
array([0., 0., 0., ..., 0., 0., 0.])
>>> f_out[105:115]
array([ 0. ,  0. ,  0. ,  0. ,  0. ,  0. , 12.5, 12.5, 12.5, 12.5])
>>> c_out
array([[0., 0., 0., ..., 0., 0., 0.]])
>>> c_out[0][105:115]
array([0. , 0. , 0. , 0. , 0. , 0. , 2.5, 2.5, 2.5, 2.5])
>>> # Pre-filled with buffer (and no product).
>>> cstr.starts_empty = False
>>> cstr.v_init_ratio = 1  # starts completely pre-filled (default)
>>> f_out, c_out = cstr.evaluate(f_in, c_in)
>>> f_out
array([12.5, 12.5, 12.5, ...,  0. ,  0. ,  0. ])
>>> c_out
array([[0.02232143, 0.04444445, 0.06637082, ..., 0.42450783, 0.42073445,
        0.41699166]])
v_void: float

Target upper fluid volume (max fill level) in the CSTR.

rt_target: float

Target mean residence time in the CSTR.

Max fill level = rt_target * outlet flow rate.

v_min: float

Target lowest fill level in the CSTR.

Only valid for periodic inlet flow rate profile.

Upper fill level is calculated at runtime.

v_min_ratio: float

Ratio between max and min fill levels in the CSTR.

Only valid for periodic inlet flow rate profile.

Absolute fill levels are calculated at runtime.

v_init: float

Initial pre-fill level - absolute value.

v_init_ratio: float

Initial pre-fill level as a share of max fill level.

starts_empty: bool

CSTR has a 0 initial fill level.

If True it overrides v_init and v_init_ratio.

c_init

Pre-fill buffer composition. Default = array([]) = all 0

evaluate(f_in, c_in)

Evaluate the propagation throughout the unit operation.

Parameters
  • c_in (ndarray) – Inlet concentration profile with shape (n_species, n_time_steps).

  • f_in (array) – Inlet flow rate profile with shape (n_time_steps,).

Return type

Tuple[ndarray, ndarray]

Returns

  • f_out – Outlet flow rate profile.

  • c_out – Outlet concentration profile.

get_result()

Returns existing flow rate and concentration profiles.

Return type

Tuple[ndarray, ndarray]

Returns

  • f_out – Outlet flow rate profile.

  • c_out – Outlet concentration profile.

property log

Reference of the RtdLogger instance.

Setter also plants instance data tree into passed logger.

If logger is requested, but not yet set, then a bio_rtd.logger.DefaultLogger is instantiated.

Return type

RtdLogger

set_logger_from_parent(parent_id, logger)

Inherit logger from parent.

Parameters
  • parent_id (str) – Unique identifier of parent instance.

  • logger (RtdLogger) – Logger from parent instance.

uo_id: str

Unique identifier of the instance

gui_title: str

Readable title for GUI

gui_hidden: bool

Hide the of the unit operation (default False).

discard_inlet_until_t: float

Discard inlet until given time.

discard_inlet_until_min_c: _np.ndarray

Discard inlet until given concentration is reached.

discard_inlet_until_min_c_rel: _np.ndarray

Discard inlet until given concentration relative to is reached.

Specified concentration is relative to the max concentration.

discard_inlet_n_cycles: int

Discard first n cycles of the periodic inlet flow rate profile.

discard_outlet_until_t: float

Discard outlet until given time.

discard_outlet_until_min_c: _np.ndarray

Discard outlet until given concentration is reached.

discard_outlet_until_min_c_rel: _np.ndarray

Discard outlet until given concentration relative to is reached.

Specified concentration is relative to the max concentration.

discard_outlet_n_cycles: int

Discard first n cycles of the periodic outlet flow rate profile.

adj_par_list

List of adjustable parameters exposed to the GUI.

Type

list of bio_rtd.adj_par.AdjustableParameter

TwoAlternatingCSTRs

class bio_rtd.uo.surge_tank.TwoAlternatingCSTRs(t, uo_id, gui_title='TwoAlternatingCSTRs')[source]

Bases: bio_rtd.core.UnitOperation

Simulation of Two alternating CSTRs with ideal mixing.

Accepts constant, box-shaped or periodic box-shaped flow rate profiles.

Provides constant or box-shaped flow rate profile.

Parameters
  • t (ndarray) – Simulation time vector. Starts with 0 and has a constant time step.

  • uo_id (str) – Unique identifier.

  • gui_title (str) – Readable title for GUI. Default = “TwoAlternatingCSTRs”.

Notes

Define how many periods a CSTR collects in one cycle (applies to periodic inlet only):

Define when the switch occurs for periodic inlet:

Define when the switch occurs for constant inlet (one should be defined):

Define leftover volume after discharge (optional, max one):

collect_n_periods: int

How many periods of a periodic inlet a surge tank collects.

Default = 1.

Only relevant for periodic inlet flow rate profile.

relative_role_switch_time: float

When CSTRs switch roles within the inlet flow rate off time.

Default = 0.9.

This is valid for the first cycle. In case of leftover material, the first two cycles are shorter, thus the switch occurs earlier in following cycles.

In case of inlet periodic box-shaped flow rate profile, the CSTRs can their switch role (providing or collecting) at any time when the inlet flow rate if off.

In terms of RTD it is desirable to start releasing material as soon as collection phase ends. However additional safety margin might be applied in order to allow some cycle-to-cycle variability in a real process.

evaluate(f_in, c_in)

Evaluate the propagation throughout the unit operation.

Parameters
  • c_in (ndarray) – Inlet concentration profile with shape (n_species, n_time_steps).

  • f_in (array) – Inlet flow rate profile with shape (n_time_steps,).

Return type

Tuple[ndarray, ndarray]

Returns

  • f_out – Outlet flow rate profile.

  • c_out – Outlet concentration profile.

get_result()

Returns existing flow rate and concentration profiles.

Return type

Tuple[ndarray, ndarray]

Returns

  • f_out – Outlet flow rate profile.

  • c_out – Outlet concentration profile.

property log

Reference of the RtdLogger instance.

Setter also plants instance data tree into passed logger.

If logger is requested, but not yet set, then a bio_rtd.logger.DefaultLogger is instantiated.

Return type

RtdLogger

set_logger_from_parent(parent_id, logger)

Inherit logger from parent.

Parameters
  • parent_id (str) – Unique identifier of parent instance.

  • logger (RtdLogger) – Logger from parent instance.

uo_id: str

Unique identifier of the instance

gui_title: str

Readable title for GUI

gui_hidden: bool

Hide the of the unit operation (default False).

discard_inlet_until_t: float

Discard inlet until given time.

discard_inlet_until_min_c: _np.ndarray

Discard inlet until given concentration is reached.

discard_inlet_until_min_c_rel: _np.ndarray

Discard inlet until given concentration relative to is reached.

Specified concentration is relative to the max concentration.

discard_inlet_n_cycles: int

Discard first n cycles of the periodic inlet flow rate profile.

discard_outlet_until_t: float

Discard outlet until given time.

discard_outlet_until_min_c: _np.ndarray

Discard outlet until given concentration is reached.

discard_outlet_until_min_c_rel: _np.ndarray

Discard outlet until given concentration relative to is reached.

Specified concentration is relative to the max concentration.

discard_outlet_n_cycles: int

Discard first n cycles of the periodic outlet flow rate profile.

adj_par_list

List of adjustable parameters exposed to the GUI.

Type

list of bio_rtd.adj_par.AdjustableParameter

t_cycle: float

The duration (time) of cycle after which CSTRs switch roles.

In case of constant inlet profile, one of t_cycle and v_cycle needs to be defined.

In case of periodic inlet flow rate, this value should not be defined.

v_cycle: float

Collected volume after which CSTRs switch roles.

In case of constant inlet profile, one of v_cycle and t_cycle needs to be defined.

In case of periodic inlet flow rate, this value should not be defined.

v_leftover: float

What amount of fluid stays in CSTR after discharge.

Only one of v_leftover and v_leftover_rel should be defined. If none are defined, then the leftover is set to 0.

v_leftover_rel: float

Relative amount of fluid that stays in CSTR after discharge.

Relative to the amount of collected material in one cycle.

Only one of v_leftover_rel and v_leftover should be defined. If none are defined, then the leftover is set to 0.