Skip to content

Processes

Processes: stocks of material in engineered flows.

BathtubSystem(water=50.0, *, inflow=5.0, outflow=5.0, label='system', solver='auto', backend='auto')

Bases: StockFlowSystem

A bathtub, one stock of water with an inflow and an outflow.

The inflow is from the faucet and the outflow is through the drain. The drain empties the tub at outflow gallons per minute while there is water, and the faucet opens to inflow gallons per minute after five minutes. With equal flows the level falls for five minutes and then stays constant. The system has the water tub.water in gallons and the flows tub.faucet and tub.drain in gallons per minute, over minutes.

Parameters:

Name Type Description Default
water float

The initial water in the tub, in gallons.

50.0
inflow float

The inflow after five minutes, in gallons per minute.

5.0
outflow float

The outflow, in gallons per minute.

5.0
label str

The label of the system, which names it when it is nested in another one.

'system'
solver BaseSolver | str

The solver of the problem, or 'auto' for the one the system chooses.

'auto'
backend BaseBackend | str

The backend that evaluates the compiled functions, or 'auto' for the one the system chooses.

'auto'

Examples:

>>> from skcomplex.systems.engineering.processes import BathtubSystem
>>> BathtubSystem(water=20.0).prepare().system_.elements[0].values['water']
20.0
Source code in src/skcomplex/systems/engineering/processes/_processes.py
194
195
196
197
198
199
200
201
202
203
204
205
206
207
def __init__(
    self,
    water: float = 50.0,
    *,
    inflow: float = 5.0,
    outflow: float = 5.0,
    label: str = 'system',
    solver: BaseSolver | str = 'auto',
    backend: BaseBackend | str = 'auto',
) -> None:
    super().__init__(label=label, solver=solver, backend=backend)
    self.water = water
    self.inflow = inflow
    self.outflow = outflow

CascadeClassifierSystem(n_stages=10, *, k=0.6, feed_stage=None, feed=1.0, label='system', solver='auto', backend='auto')

Bases: 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.

Parameters:

Name Type Description Default
n_stages int

The number of stages z.

10
k float

The distribution coefficient, the fraction of material moving up from a stage.

0.6
feed_stage int | None

The stage that receives the feed, counted from 1 at the top, or None for the middle stage.

None
feed float

The feed rate.

1.0
label str

The label of the system, which names it when it is nested in another one.

'system'
solver BaseSolver | str

The solver of the problem, or 'auto' for the one the system chooses.

'auto'
backend BaseBackend | str

The backend that evaluates the compiled functions, or 'auto' for the one the system chooses.

'auto'

Examples:

>>> from skcomplex.systems.engineering.processes import CascadeClassifierSystem
>>> len(CascadeClassifierSystem(n_stages=4).prepare().system_.interactions)
5
Source code in src/skcomplex/systems/engineering/processes/_processes.py
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
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

FeedInteraction(label, *, target, feed=0.0)

Bases: Interaction

Constant feed of material into a stage, at the rate feed.

Parameters:

Name Type Description Default
label str

The label of the interaction.

required
target Role

The path of the stage that receives the feed.

required
feed Annotated[float, closed_open(0, oo)]

The feed rate.

0.0

Examples:

>>> from skcomplex.systems.engineering.processes import FeedInteraction
>>> FeedInteraction('feed', target='stage_1', feed=2.0).feed
2.0
Source code in src/skcomplex/systems/engineering/processes/_processes.py
73
74
75
76
77
78
79
80
81
82
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

FoodReliefSystem(affected=100000.0, *, ration=0.0005, onset=10.0, shipping_delay=14.0, cover=7.0, stock_time=7.0, label='system', solver='auto', backend='auto')

Bases: BaseSystem

A food relief system.

A pipeline ships food to a warehouse and distributes it to people in need. A disaster at onset leaves affected people who need a daily ration. The relief agency ships food at the need plus corrections that close the gaps between the warehouse stock and its desired cover of the need, and between the food in transit and the need over the shipping delay. Shipped food enters the pipeline and arrives at the warehouse through a third-order material delay. The warehouse distributes the need while its stock lasts. Food is conserved, so almost nothing reaches the people in the first days after the disaster, and the gap closes as the pipeline fills. The structure follows the relief food example of Bala, Arshad and Noh (2017, Section 4.11), with illustrative parameters in tonnes and days.

The system has the food stocks relief.in_transit and relief.warehouse in tonnes, and the flows relief.shipping, relief.arrivals, and relief.distribution in tonnes per day, over days. The observables of the system are relief.need and relief.shipments.

Parameters:

Name Type Description Default
affected float

The number of people in need after the disaster.

100000.0
ration float

The daily ration in tonnes per person.

0.0005
onset float

The day of the disaster.

10.0
shipping_delay float

The average time from shipping to arrival, in days.

14.0
cover float

The desired warehouse stock in days of need.

7.0
stock_time float

The time to correct the warehouse stock, in days.

7.0
label str

The label of the system, which names it when it is nested in another one.

'system'
solver BaseSolver | str

The solver of the problem, or 'auto' for the one the system chooses.

'auto'
backend BaseBackend | str

The backend that evaluates the compiled functions, or 'auto' for the one the system chooses.

'auto'

Examples:

>>> from skcomplex.systems.engineering.processes import FoodReliefSystem
>>> FoodReliefSystem(shipping_delay=7.0).prepare().system_.elements[0].shipping_delay
7.0
Source code in src/skcomplex/systems/engineering/processes/_systems.py
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
def __init__(
    self,
    affected: float = 1e5,
    *,
    ration: float = 5e-4,
    onset: float = 10.0,
    shipping_delay: float = 14.0,
    cover: float = 7.0,
    stock_time: float = 7.0,
    label: str = 'system',
    solver: BaseSolver | str = 'auto',
    backend: BaseBackend | str = 'auto',
) -> None:
    super().__init__(label, solver=solver, backend=backend)
    self.affected = affected
    self.ration = ration
    self.onset = onset
    self.shipping_delay = shipping_delay
    self.cover = cover
    self.stock_time = stock_time

GrainStorageSystem(stock=1000.0, on_order=10000.0, *, desired_stock=6000.0, release_fraction=0.025, receiving_delay=10.0, adjustment_delay=5.0, label='system', solver='auto', backend='auto')

Bases: StockFlowSystem

A retail grain store, whose stock oscillates.

Its orders through a supply line make the stock oscillate. The grain stock gains the receiving rate on_order / receiving_delay and loses the release rate release_fraction stock, and the grain on order gains the procurement rate (desired_stock - stock) / adjustment_delay and loses the receiving rate. The orders ignore the grain already on order, so the supply line overshoots and the stock, the receiving rate, and the procurement oscillate in weeks before they settle, with the stock below the desired one at desired_stock / (1 + release_fraction adjustment_delay), 5333 tonnes for the defaults, where the release balances the receiving. The defaults are those of the grain storage example of Bala, Arshad and Noh (2017), in tonnes and weeks.

The system has the stocks store.stock and store.on_order in tonnes, and the flows store.procurement, store.receiving, and store.release in tonnes per week, over weeks.

Parameters:

Name Type Description Default
stock float

The initial grain stock.

1000.0
on_order float

The initial grain on order.

10000.0
desired_stock float

The desired grain stock.

6000.0
release_fraction float

The fraction of the stock released per week.

0.025
receiving_delay float

The average time for grain on order to arrive, in weeks.

10.0
adjustment_delay float

The time to close the gap between the desired and the current stock, in weeks.

5.0
label str

The label of the system, which names it when it is nested in another one.

'system'
solver BaseSolver | str

The solver of the problem, or 'auto' for the one the system chooses.

'auto'
backend BaseBackend | str

The backend that evaluates the compiled functions, or 'auto' for the one the system chooses.

'auto'

Examples:

>>> from skcomplex.systems.engineering.processes import GrainStorageSystem
>>> GrainStorageSystem(receiving_delay=5.0).prepare().system_.elements[0].values['receiving_delay']
5.0
Source code in src/skcomplex/systems/engineering/processes/_grain_storage.py
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
def __init__(
    self,
    stock: float = 1000.0,
    on_order: float = 10000.0,
    *,
    desired_stock: float = 6000.0,
    release_fraction: float = 0.025,
    receiving_delay: float = 10.0,
    adjustment_delay: float = 5.0,
    label: str = 'system',
    solver: BaseSolver | str = 'auto',
    backend: BaseBackend | str = 'auto',
) -> None:
    super().__init__(label=label, solver=solver, backend=backend)
    self.stock = stock
    self.on_order = on_order
    self.desired_stock = desired_stock
    self.release_fraction = release_fraction
    self.receiving_delay = receiving_delay
    self.adjustment_delay = adjustment_delay

IrrigationSchemeInteraction(label, *, target)

Bases: Interaction

Flows of water between the reservoir, the soil, and the groundwater of an irrigation scheme.

The flows read the stocks and the parameters of the element the role target binds.

Parameters:

Name Type Description Default
label str

The label of the interaction.

required
target Role

The path of the element that holds the stocks and the parameters.

required

Examples:

>>> from skcomplex.systems.engineering.processes import IrrigationSchemeInteraction
>>> IrrigationSchemeInteraction('flows', target='scheme').target
'scheme'
Source code in src/skcomplex/systems/engineering/processes/_systems.py
349
350
351
def __init__(self, label: str, *, target: Role) -> None:
    super().__init__(label)
    self.target = target

IrrigationSystem(*, river_inflow=0.5, seasonality=0.9, reservoir_capacity=80.0, potential_et=0.4, canal_loss=0.2, pump_capacity=0.2, label='system', solver='auto', backend='auto')

Bases: BaseSystem

An irrigation system.

A reservoir and an aquifer keep the root zone of the crops supplied. A river fills the reservoir with a yearly cycle, and the reservoir loses water to evaporation and spills above its capacity. The irrigation demand is the potential crop evapotranspiration plus the refill of the root zone towards a target fraction of its field capacity. The reservoir releases the demand grossed up for the canal losses, as far as its stock allows, and the losses seep into the aquifer. When the release falls short, the farmers pump the unmet demand from the aquifer up to the pump capacity. The crops draw water from the root zone at the potential rate scaled by a water-stress table, and the root zone percolates to the aquifer, which drains as baseflow. Water is conserved, so in the dry season the reservoir falls, the pumping rises, and the aquifer is drawn down. The structure follows the irrigation example of Bala, Arshad and Noh (2017, Section 4.11), with illustrative parameters in millions of cubic metres and days.

The system has the water stocks scheme.reservoir, scheme.soil, and scheme.groundwater, and the flows scheme.inflow, scheme.reservoir_evaporation, scheme.spill, scheme.irrigation, scheme.seepage, scheme.groundwater_pumping, scheme.crop_water, scheme.deep_percolation, and scheme.baseflow per day, over days. The observables of the system are scheme.demand, scheme.release, and scheme.pumping.

Parameters:

Name Type Description Default
river_inflow float

The mean river inflow to the reservoir, per day.

0.5
seasonality float

The relative amplitude of the yearly inflow cycle.

0.9
reservoir_capacity float

The capacity of the reservoir.

80.0
potential_et float

The crop water requirement, the potential evapotranspiration of the irrigated area per day.

0.4
canal_loss float

The fraction of the release lost from the canals to the aquifer.

0.2
pump_capacity float

The largest groundwater pumping per day.

0.2
label str

The label of the system, which names it when it is nested in another one.

'system'
solver BaseSolver | str

The solver of the problem, or 'auto' for the one the system chooses.

'auto'
backend BaseBackend | str

The backend that evaluates the compiled functions, or 'auto' for the one the system chooses.

'auto'

Examples:

>>> from skcomplex.systems.engineering.processes import IrrigationSystem
>>> IrrigationSystem(pump_capacity=0.0).prepare().system_.elements[0].pump_capacity
0.0
Source code in src/skcomplex/systems/engineering/processes/_systems.py
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
def __init__(
    self,
    *,
    river_inflow: float = 0.5,
    seasonality: float = 0.9,
    reservoir_capacity: float = 80.0,
    potential_et: float = 0.4,
    canal_loss: float = 0.2,
    pump_capacity: float = 0.2,
    label: str = 'system',
    solver: BaseSolver | str = 'auto',
    backend: BaseBackend | str = 'auto',
) -> None:
    super().__init__(label, solver=solver, backend=backend)
    self.river_inflow = river_inflow
    self.seasonality = seasonality
    self.reservoir_capacity = reservoir_capacity
    self.potential_et = potential_et
    self.canal_loss = canal_loss
    self.pump_capacity = pump_capacity

ReliefPipelineInteraction(label, *, target)

Bases: Interaction

Shipments, arrivals, and distribution of the food of a relief supply line.

The flows read the stocks and the parameters of the element the role target binds.

Parameters:

Name Type Description Default
label str

The label of the interaction.

required
target Role

The path of the element that holds the stocks and the parameters.

required

Examples:

>>> from skcomplex.systems.engineering.processes import ReliefPipelineInteraction
>>> ReliefPipelineInteraction('flows', target='relief').target
'relief'
Source code in src/skcomplex/systems/engineering/processes/_systems.py
90
91
92
def __init__(self, label: str, *, target: Role) -> None:
    super().__init__(label)
    self.target = target

RiceMillInteraction(label, *, target)

Bases: Interaction

Procurement, milling, and sales of a rice mill, and the adjustment of its capacity.

The flows read the stocks and the parameters of the element the role target binds.

Parameters:

Name Type Description Default
label str

The label of the interaction.

required
target Role

The path of the element that holds the stocks and the parameters.

required

Examples:

>>> from skcomplex.systems.engineering.processes import RiceMillInteraction
>>> RiceMillInteraction('flows', target='mill').target
'mill'
Source code in src/skcomplex/systems/engineering/processes/_systems.py
212
213
214
def __init__(self, label: str, *, target: Role) -> None:
    super().__init__(label)
    self.target = target

RiceMillingSystem(*, harvest=2000.0, seasonality=0.8, procurement_delay=1.0, outturn=0.65, capacity=2000.0, expansion_time=12.0, label='system', solver='auto', backend='auto')

Bases: BaseSystem

A rice milling system.

A mill buys paddy, mills it into rice and by-products, and sells them. Paddy arrives from the farms through a third-order procurement delay, at a rate that follows the harvest season around its mean. The mill processes its paddy stock in a month, as far as its milling capacity allows, and splits the milled paddy by mass into rice, the outturn, husk, bran, and milling losses. Rice, husk, and bran leave their inventories for the market at a fixed coverage. The capacity adjusts to the smoothed indicated milling rate, so in the harvest season the capacity lags and paddy accumulates, and in the lean season the capacity idles. Grain is conserved, every change of the paddy, rice, husk, and bran stocks is a flow, and over a year the milled paddy and the rice sales match the mean harvest and its outturn. The structure follows the rice milling case of Bala, Arshad and Noh (2017), with illustrative parameters in tonnes and months, since the case data are specific to their study.

The system has the grain stocks mill.paddy, mill.rice, mill.husk, and mill.bran in tonnes, the capacity mill.capacity, and the flows mill.paddy_purchases, mill.milled_rice, mill.husk_output, mill.bran_output, mill.milling_losses, mill.rice_sales, mill.husk_sales, and mill.bran_sales in tonnes per month, over months. The observables of the system are mill.procurement, mill.indicated_milling, and mill.milling.

Parameters:

Name Type Description Default
harvest float

The mean paddy procurement in tonnes per month.

2000.0
seasonality float

The relative amplitude of the yearly harvest cycle.

0.8
procurement_delay float

The average time for purchased paddy to reach the mill, in months.

1.0
outturn float

The fraction of the milled paddy that becomes rice.

0.65
capacity float

The initial milling capacity in tonnes of paddy per month.

2000.0
expansion_time float

The time for the capacity to adjust to the perceived milling rate, in months.

12.0
label str

The label of the system, which names it when it is nested in another one.

'system'
solver BaseSolver | str

The solver of the problem, or 'auto' for the one the system chooses.

'auto'
backend BaseBackend | str

The backend that evaluates the compiled functions, or 'auto' for the one the system chooses.

'auto'

Examples:

>>> from skcomplex.systems.engineering.processes import RiceMillingSystem
>>> RiceMillingSystem(capacity=1500.0).prepare().system_.elements[0].capacity
1500.0
Source code in src/skcomplex/systems/engineering/processes/_systems.py
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
def __init__(
    self,
    *,
    harvest: float = 2000.0,
    seasonality: float = 0.8,
    procurement_delay: float = 1.0,
    outturn: float = 0.65,
    capacity: float = 2000.0,
    expansion_time: float = 12.0,
    label: str = 'system',
    solver: BaseSolver | str = 'auto',
    backend: BaseBackend | str = 'auto',
) -> None:
    super().__init__(label, solver=solver, backend=backend)
    self.harvest = harvest
    self.seasonality = seasonality
    self.procurement_delay = procurement_delay
    self.outturn = outturn
    self.capacity = capacity
    self.expansion_time = expansion_time

SolidWasteSystem(population=1000000.0, *, growth_rate=0.02, per_capita=0.2, recycling_share=0.2, composting_share=0.3, landfill_capacity=2000000.0, label='system', solver='auto', backend='auto')

Bases: BaseSystem

A solid waste system.

The waste of a growing city is collected, recycled, composted, and landfilled. The population grows exponentially and generates waste in proportion to its size. The waste waits uncollected until the collection, limited by a collection capacity that the city expands towards the generation with a delay, removes it. The collected waste is recycled, composted, or sent to the landfill in fixed shares. Recycled material and compost leave for industry and farms. The landfill accepts waste until it nears its capacity, and a table function then turns the residual waste to open dumping. Waste is conserved, so the landfill fills up to its capacity and dumping takes over. The structure follows the solid waste management case of Bala, Arshad and Noh (2017), with illustrative parameters in tonnes and years for a city of a million people.

The system has the population city.population, the waste stocks city.uncollected, city.recycled, city.composted, city.landfill, and city.dumped in tonnes, the capacity city.collection_capacity, and the flows city.population_growth, city.waste_generation, city.recycling, city.composting, city.landfilling, city.dumping, city.recycled_sales, and city.compost_sales per year, over years. The observables of the system are city.generation, city.collection, and city.acceptance.

Parameters:

Name Type Description Default
population float

The initial population.

1000000.0
growth_rate float

The yearly growth rate of the population.

0.02
per_capita float

The waste generated per person, in tonnes per year.

0.2
recycling_share float

The share of the collected waste that is recycled.

0.2
composting_share float

The share of the collected waste that is composted.

0.3
landfill_capacity float

The capacity of the landfill in tonnes.

2000000.0
label str

The label of the system, which names it when it is nested in another one.

'system'
solver BaseSolver | str

The solver of the problem, or 'auto' for the one the system chooses.

'auto'
backend BaseBackend | str

The backend that evaluates the compiled functions, or 'auto' for the one the system chooses.

'auto'

Examples:

>>> from skcomplex.systems.engineering.processes import SolidWasteSystem
>>> SolidWasteSystem(landfill_capacity=1e6).prepare().system_.elements[0].landfill_capacity
1000000.0
Source code in src/skcomplex/systems/engineering/processes/_systems.py
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
def __init__(
    self,
    population: float = 1e6,
    *,
    growth_rate: float = 0.02,
    per_capita: float = 0.2,
    recycling_share: float = 0.2,
    composting_share: float = 0.3,
    landfill_capacity: float = 2e6,
    label: str = 'system',
    solver: BaseSolver | str = 'auto',
    backend: BaseBackend | str = 'auto',
) -> None:
    super().__init__(label, solver=solver, backend=backend)
    self.population = population
    self.growth_rate = growth_rate
    self.per_capita = per_capita
    self.recycling_share = recycling_share
    self.composting_share = composting_share
    self.landfill_capacity = landfill_capacity

StageElement(label, *, m=0.0)

Bases: Element

Stage of a process, a stock of material m.

Parameters:

Name Type Description Default
label str

The label of the stage.

required
m Annotated[object, closed_open(0, oo)]

The initial material of the stage.

0.0

Examples:

>>> from skcomplex.systems.engineering.processes import StageElement
>>> StageElement('stage', m=2.0).m
2.0
Source code in src/skcomplex/systems/engineering/processes/_processes.py
47
48
49
def __init__(self, label: str, *, m: Annotated[object, RealSet.closed_open(0, oo)] = 0.0) -> None:
    super().__init__(label)
    self.m = m

StageSplitInteraction(label, *, target, above, below, k=0.6)

Bases: 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.

Parameters:

Name Type Description Default
label str

The label of the interaction.

required
target Role

The path of the stage the material leaves.

required
above Role

The path of the stage above.

required
below Role

The path of the stage below.

required
k Annotated[float, closed(0, 1)]

The distribution coefficient, the fraction of material moving up.

0.6

Examples:

>>> from skcomplex.systems.engineering.processes import StageSplitInteraction
>>> StageSplitInteraction('split', target='stage_2', above='stage_1', below='stage_3').k
0.6
Source code in src/skcomplex/systems/engineering/processes/_processes.py
124
125
126
127
128
129
130
131
132
133
134
135
136
137
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

WasteSystemInteraction(label, *, target)

Bases: Interaction

Generation, collection, treatment, and sales of the solid waste of a city.

The flows read the stocks and the parameters of the element the role target binds.

Parameters:

Name Type Description Default
label str

The label of the interaction.

required
target Role

The path of the element that holds the stocks and the parameters.

required

Examples:

>>> from skcomplex.systems.engineering.processes import WasteSystemInteraction
>>> WasteSystemInteraction('flows', target='city').target
'city'
Source code in src/skcomplex/systems/engineering/processes/_systems.py
487
488
489
def __init__(self, label: str, *, target: Role) -> None:
    super().__init__(label)
    self.target = target