Dynamic Behavior Patterns
Explore common system behaviors: exponential growth, goal-seeking decay, overshoot-and-collapse, and S-curve saturation.
Explore Dynamic Behavior PatternsSystem Archetypes
Learn recurring structural patterns like Limits to Growth, Fixes That Fail, and Tragedy of the Commons, plus high-leverage interventions.
Explore System Archetypessimulation.py
Watching a population grow logistically
This classic model starts with a small population that grows almost exponentially. Growth then slows as the number of individuals nudges up against the carrying capacity of the environment.
from tys import probe, progress
Simulate logistic population growth.
def simulate(cfg: dict):
import simpy
env = simpy.Environment()
population = cfg["initial_pop"]
r = cfg["growth_rate"]
K = cfg["carrying_capacity"]
steps = cfg["steps"]
done = env.event()
Evolve the population using the logistic equation.
def run():
nonlocal population
for t in range(steps):
growth = r * population * (1 - population / K)
population += growth
probe("population", env.now, population)
probe("growth", env.now, growth)
progress(int(100 * (t + 1) / steps))
yield env.timeout(1)
done.succeed({"final_population": population})
env.process(run())
env.run(until=done)
return done.value
def requirements():
return {
"builtin": ["micropip", "pyyaml"],
"external": ["simpy==4.1.1"],
}
Default.yaml
initial_pop: 10
growth_rate: 0.2
carrying_capacity: 100
steps: 40
Charts (Default)
Final Results (Default)
Metric | Value |
---|---|
final_population | 99.80 |
FAQ
- When does growth slow down?
- The logistic equation multiplies r by population*(1 - population/K), so as population nears K the growth term declines.
- How is the carrying capacity used?
- It sets the upper limit in the logistic term so population never exceeds K.
- Which probes are charted?
- Both population and instantaneous growth are emitted each step for plotting.