Skip to content

Solid waste system

A solid waste system.

  • Class: SolidWasteSystem
  • Import: from skcomplex.systems.engineering.processes import SolidWasteSystem
  • Field: engineering/processes
  • Topics: waste management, urban, stocks and flows, system dynamics, ode
  • References:
    • Bala et al. 2017

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 SolidWasteSystem

trajectory = SolidWasteSystem().prepare().simulate()

Parameters

The model parameters take these defaults, and set_params changes them.

Parameter Default
population 1000000.0
growth_rate 0.02
per_capita 0.2
recycling_share 0.2
composting_share 0.3
landfill_capacity 2000000.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 SolidWasteSystem(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`.

    Args:
        population:
            The initial population.

        growth_rate:
            The yearly growth rate of the population.

        per_capita:
            The waste generated per person, in tonnes per year.

        recycling_share:
            The share of the collected waste that is recycled.

        composting_share:
            The share of the collected waste that is composted.

        landfill_capacity:
            The capacity of the landfill in tonnes.

        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 SolidWasteSystem
        >>> SolidWasteSystem(landfill_capacity=1e6).prepare().system_.elements[0].landfill_capacity
        1000000.0
    """

    field = 'engineering/processes'
    topics = ('waste management', 'urban', 'stocks and flows', 'system dynamics', 'ode')
    references = ('Bala et al. 2017',)
    until = 40.0
    dt = 0.1
    observables = (
        Observable('generation', WasteSystemInteraction._get_generation, element='city'),
        Observable('collection', WasteSystemInteraction._get_collection, element='city'),
        Observable('acceptance', WasteSystemInteraction._get_acceptance, element='city'),
    )

    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

    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)
        city = WasteSystemElement(
            'city',
            population=self.population,
            collection_capacity=INITIAL_COLLECTION_SHARE * self.per_capita * self.population,
            growth_rate=self.growth_rate,
            per_capita=self.per_capita,
            recycling_share=self.recycling_share,
            composting_share=self.composting_share,
            landfill_capacity=self.landfill_capacity,
        )
        self.system_ = System(
            self.label,
            elements=[city],
            interactions=[WasteSystemInteraction('flows', target='city')],
        )

Components

The system uses these element and interaction classes, each with its nearest class of the core.

Elements:

Interactions:

  • WasteSystemInteraction, from Interaction
class WasteSystemElement(Element):
    """Solid waste system of a growing city.

    It collects, recycles, composts, and landfills its waste.
    """

    def __init__(
        self,
        label: str,
        *,
        population: Annotated[object, RealSet.closed_open(0, oo), Quantity('people')] = 1000000.0,
        uncollected: Annotated[object, RealSet.closed_open(0, oo), Quantity('waste')] = 0.0,
        recycled: Annotated[object, RealSet.closed_open(0, oo), Quantity('waste')] = 0.0,
        composted: Annotated[object, RealSet.closed_open(0, oo), Quantity('waste')] = 0.0,
        landfill: Annotated[object, RealSet.closed_open(0, oo), Quantity('waste')] = 0.0,
        dumped: Annotated[object, RealSet.closed_open(0, oo), Quantity('waste')] = 0.0,
        collection_capacity: Annotated[object, RealSet.closed_open(0, oo)] = 150000.0,
        growth_rate: object = 0.02,
        per_capita: Annotated[object, RealSet.closed_open(0, oo)] = 0.2,
        collection_time: Annotated[object, RealSet.open(0, oo)] = 0.05,
        recycling_share: Annotated[object, RealSet.closed_open(0, oo)] = 0.2,
        composting_share: Annotated[object, RealSet.closed_open(0, oo)] = 0.3,
        landfill_capacity: Annotated[object, RealSet.open(0, oo)] = 2000000.0,
        recycling_time: Annotated[object, RealSet.open(0, oo)] = 0.25,
        composting_time: Annotated[object, RealSet.open(0, oo)] = 0.5,
        capacity_time: Annotated[object, RealSet.open(0, oo)] = 3.0,
    ) -> None:
        super().__init__(label)
        self.population = population
        self.uncollected = uncollected
        self.recycled = recycled
        self.composted = composted
        self.landfill = landfill
        self.dumped = dumped
        self.collection_capacity = collection_capacity
        self.growth_rate = growth_rate
        self.per_capita = per_capita
        self.collection_time = collection_time
        self.recycling_share = recycling_share
        self.composting_share = composting_share
        self.landfill_capacity = landfill_capacity
        self.recycling_time = recycling_time
        self.composting_time = composting_time
        self.capacity_time = capacity_time

class WasteSystemInteraction(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.

    Args:
        label:
            The label of the interaction.

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

    Examples:
        >>> from skcomplex.systems.engineering.processes import WasteSystemInteraction
        >>> WasteSystemInteraction('flows', target='city').target
        'city'
    """

    law_classes = (RateLaw,)

    def __init__(self, label: str, *, target: Role) -> None:
        super().__init__(label)
        self.target = target

    def _prepare(self, context: SimpleNamespace) -> None:
        """Set the flows of the stocks of the target.

        Args:
            context:
                The namespace of the target, the time `t`, and the parameters.
        """
        super()._prepare(context)
        s = SimpleNamespace(t=context.t, **vars(context.target))
        self.laws_: list[BaseLaw] = WasteSystemInteraction._get_waste_laws(s)

    @staticmethod
    def _get_generation(s: SimpleNamespace) -> Expression:
        """Return the generation of waste by the population."""
        return s.per_capita * s.population

    @staticmethod
    def _get_collection(s: SimpleNamespace) -> Expression:
        """Return the collection of waste, limited by the collection capacity."""
        return minimum(s.uncollected / s.collection_time, s.collection_capacity)

    @staticmethod
    def _get_acceptance(s: SimpleNamespace) -> Expression:
        """Return the share of the residual waste that the landfill accepts as it fills."""
        return series(s.landfill / s.landfill_capacity, *LANDFILL_ACCEPTANCE)

    @staticmethod
    def _get_waste_laws(s: SimpleNamespace) -> list[BaseLaw]:
        """Return the generation, collection, treatment, and disposal of solid waste.

        The waste is that of a growing city.
        """
        generation, collection, acceptance = (
            WasteSystemInteraction._get_generation(s),
            WasteSystemInteraction._get_collection(s),
            WasteSystemInteraction._get_acceptance(s),
        )
        residual = (1 - s.recycling_share - s.composting_share) * collection
        return [
            RateLaw({s.population: +1}, s.growth_rate * s.population, label='population_growth'),
            RateLaw({s.uncollected: +1}, generation, label='waste_generation'),
            RateLaw({s.uncollected: -1, s.recycled: +1}, s.recycling_share * collection, label='recycling'),
            RateLaw({s.uncollected: -1, s.composted: +1}, s.composting_share * collection, label='composting'),
            RateLaw({s.uncollected: -1, s.landfill: +1}, acceptance * residual, label='landfilling'),
            RateLaw({s.uncollected: -1, s.dumped: +1}, (1 - acceptance) * residual, label='dumping'),
            RateLaw({s.recycled: -1}, s.recycled / s.recycling_time, label='recycled_sales'),
            RateLaw({s.composted: -1}, s.composted / s.composting_time, label='compost_sales'),
            RateLaw(s.collection_capacity, (generation - s.collection_capacity) / s.capacity_time),
        ]

Equations

The equations are those that symbolic returns for the system with its default parameters.

city.population: diff(population_city(t), t) == growth_rate_city*population_city(t)
city.uncollected: diff(uncollected_city(t), t) == -(composting_share_city + recycling_share_city - 1)*(where(landfill_city(t)/landfill_capacity_city < 0.0, 1.0, where(landfill_city(t)/landfill_capacity_city < 0.9, 1.0, where(landfill_city(t)/landfill_capacity_city < 1.0, -10.000000000000002*landfill_city(t)/landfill_capacity_city + 10.000000000000002, 0.0))) - 1)*where(collection_capacity_city(t) < uncollected_city(t)/collection_time_city, collection_capacity_city(t), uncollected_city(t)/collection_time_city) + (composting_share_city + recycling_share_city - 1)*where(landfill_city(t)/landfill_capacity_city < 0.0, 1.0, where(landfill_city(t)/landfill_capacity_city < 0.9, 1.0, where(landfill_city(t)/landfill_capacity_city < 1.0, -10.000000000000002*landfill_city(t)/landfill_capacity_city + 10.000000000000002, 0.0)))*where(collection_capacity_city(t) < uncollected_city(t)/collection_time_city, collection_capacity_city(t), uncollected_city(t)/collection_time_city) + per_capita_city*population_city(t) - composting_share_city*where(collection_capacity_city(t) < uncollected_city(t)/collection_time_city, collection_capacity_city(t), uncollected_city(t)/collection_time_city) - recycling_share_city*where(collection_capacity_city(t) < uncollected_city(t)/collection_time_city, collection_capacity_city(t), uncollected_city(t)/collection_time_city)
city.recycled: diff(recycled_city(t), t) == recycling_share_city*where(collection_capacity_city(t) < uncollected_city(t)/collection_time_city, collection_capacity_city(t), uncollected_city(t)/collection_time_city) - recycled_city(t)/recycling_time_city
city.composted: diff(composted_city(t), t) == composting_share_city*where(collection_capacity_city(t) < uncollected_city(t)/collection_time_city, collection_capacity_city(t), uncollected_city(t)/collection_time_city) - composted_city(t)/composting_time_city
city.landfill: diff(landfill_city(t), t) == -(composting_share_city + recycling_share_city - 1)*where(landfill_city(t)/landfill_capacity_city < 0.0, 1.0, where(landfill_city(t)/landfill_capacity_city < 0.9, 1.0, where(landfill_city(t)/landfill_capacity_city < 1.0, -10.000000000000002*landfill_city(t)/landfill_capacity_city + 10.000000000000002, 0.0)))*where(collection_capacity_city(t) < uncollected_city(t)/collection_time_city, collection_capacity_city(t), uncollected_city(t)/collection_time_city)
city.dumped: diff(dumped_city(t), t) == (composting_share_city + recycling_share_city - 1)*(where(landfill_city(t)/landfill_capacity_city < 0.0, 1.0, where(landfill_city(t)/landfill_capacity_city < 0.9, 1.0, where(landfill_city(t)/landfill_capacity_city < 1.0, -10.000000000000002*landfill_city(t)/landfill_capacity_city + 10.000000000000002, 0.0))) - 1)*where(collection_capacity_city(t) < uncollected_city(t)/collection_time_city, collection_capacity_city(t), uncollected_city(t)/collection_time_city)
city.collection_capacity: diff(collection_capacity_city(t), t) == (per_capita_city*population_city(t) - collection_capacity_city(t))/capacity_time_city