Cascade classifier
A cascade classifier, a column of stages that separates particles.
- Class:
CascadeClassifierSystem - Import:
from skcomplex.systems.engineering.processes import CascadeClassifierSystem - Field:
engineering/processes - Topics:
separation,cascade,stocks and flows,ode - References:
- Barsky 2020
Use this system
The block imports the class and simulates the system with its default parameters and its tuned run settings.
from skcomplex.systems.engineering.processes import CascadeClassifierSystem
trajectory = CascadeClassifierSystem().prepare().simulate()
Parameters
The model parameters take these defaults, and set_params changes them.
| Parameter | Default |
|---|---|
n_stages |
10 |
k |
0.6 |
feed_stage |
None |
feed |
1.0 |
solver |
'auto' |
backend |
'auto' |
Tags
The system with its default parameters has these capability tags, which solvers and analyses check.
| Tag | Values |
|---|---|
| Time | continuous |
| Space | none |
| Laws | rate |
| Randomness | deterministic |
| Domains | real |
| Structure | fixed |
Class
The source of the class shows how it builds its components from its model parameters.
class CascadeClassifierSystem(BaseSystem):
"""A cascade classifier, a column of stages that separates particles.
An air flow separates them. The particles separated are of a narrow size class. Material leaves every stage at unit
rate, a fraction `k` upwards and `1 - k` downwards. The top stage releases into the fine product and the bottom
stage into the coarse product. Material of one size class is fed into one stage at a constant rate. At steady state
the share of the feed that ends in the fine product is
`F_f = (1 - ((1 - k) / k)^(z + 1 - i)) / (1 - ((1 - k) / k)^(z + 1))` for `z` stages and feeding at stage `i`
counted from the top, Barsky's fractional extraction.
The system has the material `stage_<i>.m` of each stage from the top, and the accumulated products `fine.m` and
`coarse.m`.
Args:
n_stages:
The number of stages `z`.
k:
The distribution coefficient, the fraction of material moving up from a stage.
feed_stage:
The stage that receives the feed, counted from 1 at the top, or `None` for the middle stage.
feed:
The feed rate.
label:
The label of the system, which names it when it is nested in another one.
solver:
The solver of the problem, or `'auto'` for the one the system chooses.
backend:
The backend that evaluates the compiled functions, or `'auto'` for the one the system chooses.
Examples:
>>> from skcomplex.systems.engineering.processes import CascadeClassifierSystem
>>> len(CascadeClassifierSystem(n_stages=4).prepare().system_.interactions)
5
"""
field = 'engineering/processes'
topics = ('separation', 'cascade', 'stocks and flows', 'ode')
references = ('Barsky 2020',)
until = 50.0
dt = 0.5
def __init__(
self,
n_stages: int = 10,
*,
k: float = 0.6,
feed_stage: int | None = None,
feed: float = 1.0,
label: str = 'system',
solver: BaseSolver | str = 'auto',
backend: BaseBackend | str = 'auto',
) -> None:
super().__init__(label, solver=solver, backend=backend)
self.n_stages = n_stages
self.k = k
self.feed_stage = feed_stage
self.feed = feed
def _prepare(self, context: Sequence[Observable] | None = None) -> None:
"""Set `system_` to the components of the system built from its model parameters."""
super()._prepare(context)
entry = (self.n_stages + 1) // 2 if self.feed_stage is None else self.feed_stage
stages = [StageElement(f'stage_{index}') for index in range(1, self.n_stages + 1)]
labels = ['fine', *(stage.label for stage in stages), 'coarse']
interactions = [
FeedInteraction('feed', target=f'stage_{entry}', feed=self.feed),
*(
StageSplitInteraction(
f'split_{index}',
target=labels[index],
above=labels[index - 1],
below=labels[index + 1],
k=self.k,
)
for index in range(1, self.n_stages + 1)
),
]
self.system_ = System(
self.label,
elements=[StageElement('fine'), *stages, StageElement('coarse')],
interactions=interactions,
)
Components
The system uses these element and interaction classes, each with its nearest class of the core.
Elements:
StageElement, fromElement
Interactions:
FeedInteraction, fromInteractionStageSplitInteraction, fromInteraction
class StageElement(Element):
"""Stage of a process, a stock of material `m`.
Args:
label:
The label of the stage.
m:
The initial material of the stage.
Examples:
>>> from skcomplex.systems.engineering.processes import StageElement
>>> StageElement('stage', m=2.0).m
2.0
"""
def __init__(self, label: str, *, m: Annotated[object, RealSet.closed_open(0, oo)] = 0.0) -> None:
super().__init__(label)
self.m = m
class FeedInteraction(Interaction):
"""Constant feed of material into a stage, at the rate `feed`.
Args:
label:
The label of the interaction.
target:
The path of the stage that receives the feed.
feed:
The feed rate.
Examples:
>>> from skcomplex.systems.engineering.processes import FeedInteraction
>>> FeedInteraction('feed', target='stage_1', feed=2.0).feed
2.0
"""
law_classes = (RateLaw,)
def __init__(
self,
label: str,
*,
target: Role,
feed: Annotated[float, RealSet.closed_open(0, oo)] = 0.0,
) -> None:
super().__init__(label)
self.target = target
self.feed = feed
def _prepare(self, context: SimpleNamespace) -> None:
"""Set the constant feed of the stage.
Args:
context:
The namespace of the elements a binding of the roles names.
"""
super()._prepare(context)
self.laws_: list[BaseLaw] = [RateLaw(context.target.m.diff(context.t), context.feed)]
class StageSplitInteraction(Interaction):
"""Material that leaves a stage at unit rate, a fraction `k` upwards and `1 - k` downwards.
The flow `up` carries `k m` to the stage above and the flow `down` carries `(1 - k) m` to the stage below.
Args:
label:
The label of the interaction.
target:
The path of the stage the material leaves.
above:
The path of the stage above.
below:
The path of the stage below.
k:
The distribution coefficient, the fraction of material moving up.
Examples:
>>> from skcomplex.systems.engineering.processes import StageSplitInteraction
>>> StageSplitInteraction('split', target='stage_2', above='stage_1', below='stage_3').k
0.6
"""
law_classes = (RateLaw,)
def __init__(
self,
label: str,
*,
target: Role,
above: Role,
below: Role,
k: Annotated[float, RealSet.closed(0, 1)] = 0.6,
) -> None:
super().__init__(label)
self.target = target
self.above = above
self.below = below
self.k = k
def _prepare(self, context: SimpleNamespace) -> None:
"""Set the flows up and down out of the stage.
Args:
context:
The namespace of the elements a binding of the roles names.
"""
super()._prepare(context)
s = context
m = s.target.m
self.laws_: list[BaseLaw] = [
RateLaw({m: -1, s.above.m: +1}, s.k * m, label='up'),
RateLaw({m: -1, s.below.m: +1}, (1 - s.k) * m, label='down'),
]
Equations
The equations are those that symbolic returns for the system with its default parameters.
fine.m: diff(m_fine(t), t) == k_split_1*m_stage_1(t)
stage_1.m: diff(m_stage_1(t), t) == (k_split_1 - 1)*m_stage_1(t) - k_split_1*m_stage_1(t) + k_split_2*m_stage_2(t)
stage_2.m: diff(m_stage_2(t), t) == -(k_split_1 - 1)*m_stage_1(t) + (k_split_2 - 1)*m_stage_2(t) - k_split_2*m_stage_2(t) + k_split_3*m_stage_3(t)
stage_3.m: diff(m_stage_3(t), t) == -(k_split_2 - 1)*m_stage_2(t) + (k_split_3 - 1)*m_stage_3(t) - k_split_3*m_stage_3(t) + k_split_4*m_stage_4(t)
stage_4.m: diff(m_stage_4(t), t) == -(k_split_3 - 1)*m_stage_3(t) + (k_split_4 - 1)*m_stage_4(t) - k_split_4*m_stage_4(t) + k_split_5*m_stage_5(t)
stage_5.m: diff(m_stage_5(t), t) == -(k_split_4 - 1)*m_stage_4(t) + (k_split_5 - 1)*m_stage_5(t) - k_split_5*m_stage_5(t) + k_split_6*m_stage_6(t) + feed_feed
stage_6.m: diff(m_stage_6(t), t) == -(k_split_5 - 1)*m_stage_5(t) + (k_split_6 - 1)*m_stage_6(t) - k_split_6*m_stage_6(t) + k_split_7*m_stage_7(t)
stage_7.m: diff(m_stage_7(t), t) == -(k_split_6 - 1)*m_stage_6(t) + (k_split_7 - 1)*m_stage_7(t) - k_split_7*m_stage_7(t) + k_split_8*m_stage_8(t)
stage_8.m: diff(m_stage_8(t), t) == -(k_split_7 - 1)*m_stage_7(t) + (k_split_8 - 1)*m_stage_8(t) - k_split_8*m_stage_8(t) + k_split_9*m_stage_9(t)
stage_9.m: diff(m_stage_9(t), t) == k_split_10*m_stage_10(t) - (k_split_8 - 1)*m_stage_8(t) + (k_split_9 - 1)*m_stage_9(t) - k_split_9*m_stage_9(t)
stage_10.m: diff(m_stage_10(t), t) == (k_split_10 - 1)*m_stage_10(t) - k_split_10*m_stage_10(t) - (k_split_9 - 1)*m_stage_9(t)
coarse.m: diff(m_coarse(t), t) == -(k_split_10 - 1)*m_stage_10(t)