Assignment

Spruce Budworm App

This assignment turns the 1D ODE workflow into a complete mini-project. The spruce budworm model combines a scalar ODE, equilibrium structure, numerical integration, and an interactive front end (Strogatz 2024).

You can follow the guide here:

Spruce Budworm Model

Summary of Goals

Your submission should show that you can do three things:

  1. Implement the spruce budworm model and its supporting visualizations.
  2. Build an interactive app that evolves the dynamics correctly.
  3. Interpret the resulting equilibria, bistability, and hysteresis behavior.
Submission

Submit two files:

  1. The Python code for your Streamlit app and any helper module you created.
  2. A short report, 1 to 2 pages, that answers the exploration questions you chose.

Required

  1. Implement the spruce_budworm() right-hand side and the plotting helpers described in spruce-budworm.qmd.
  2. Build a Streamlit app that includes the phase portrait, the time-series plot, and an “Evolve Forward” control.
  3. Use st.session_state so the simulation persists across interactions.
  4. Answer at least three exploration questions from Exploration Questions.
  5. Include figures that support your interpretation.

Short Discussion

Your report should address questions such as:

  1. How many equilibria appear for the parameter values you explored?
  2. Did different initial conditions converge to different long-run states?
  3. Did you observe signs of hysteresis or threshold behavior?

Optional Extensions

  • Create a GitHub repository for your project and include the report.
  • Deploy the Streamlit app and share the link.
  • Add a reset button or multiple trajectories.
  • Implement Euler or Runge–Kutta yourself and compare with SciPy.

Tips for Success

  • Start with the ODE and the static plots before you build the app.
  • Test each helper function separately.
  • Keep the simulation state logic simple before adding extra features.
  • Use the reference script to compare shapes and parameter behavior.
  • Focus on interpretation, not only on getting the app to run.
Tip

Reference code is available in amlab/odes_1d/spruce_budworm.py.

Good luck.

References

Strogatz, Steven H. 2024. Nonlinear Dynamics and Chaos: With Applications to Physics, Biology, Chemistry, and Engineering. Chapman; Hall/CRC.