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:
Summary of Goals
Your submission should show that you can do three things:
- Implement the spruce budworm model and its supporting visualizations.
- Build an interactive app that evolves the dynamics correctly.
- Interpret the resulting equilibria, bistability, and hysteresis behavior.
Submission
Submit two files:
- The Python code for your Streamlit app and any helper module you created.
- A short report, 1 to 2 pages, that answers the exploration questions you chose.
Required
- Implement the
spruce_budworm()right-hand side and the plotting helpers described in spruce-budworm.qmd. - Build a Streamlit app that includes the phase portrait, the time-series plot, and an “Evolve Forward” control.
- Use
st.session_stateso the simulation persists across interactions. - Answer at least three exploration questions from Exploration Questions.
- Include figures that support your interpretation.
Short Discussion
Your report should address questions such as:
- How many equilibria appear for the parameter values you explored?
- Did different initial conditions converge to different long-run states?
- 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.