Skip to content
Mark Piper edited this page Sep 25, 2026 · 9 revisions

Overview

We will develop a one-dimensional numerical model of the physical process of diffusion. We'll use the forward in time, centered in space (FTCS) finite difference method to solve the diffusion equation, and we'll apply Dirichlet boundary conditions.

We'll prototype the model in a Jupyter notebook, then we'll convert the notebook to Python source code--first to a script, then to a packaged module--for more robust use.

Along the way, we'll use the development of the model to explore:

  • concepts in Python (imports, loops, conditionals, arrays, functions)
  • software tools (shell, Git, conda)
  • software development practices (refactoring, pull requests, unit testing, documentation, packaging)

Although the model is simple, the topics we cover in developing it are reusable.

Development plan

Here are the topics we'll cover to develop our model.

  • Project Jupyter (Reference)
    • JupyterHub: login to the explore Hub
    • JupyterLab: show components
    • Notebook: add commands in a new notebook
  • Build a diffusion model in a notebook (Reference)
    • Python libraries
    • NumPy arrays
    • Loops
    • Conditionals
    • Basic plotting with Matplotlib
  • Shell (bash) commands (Reference)
  • Version control with Git and GitHub (Reference)
    • Set up SSH keys
    • Create a repository for the diffusion model notebook
    • Clone the repository to the explore Hub
  • Export a notebook to Python source code with nbconvert
  • Text editors and IDEs (Reference)
  • Virtual environments (Reference)
    • Use conda
    • Use venv (preferred)
  • Refactor the diffusion model
    • Modularize model script with functions
    • Create a feature branch with Git
    • Organize changes with a pull request
    • (Repeat)
  • Unit testing (Reference)
  • Lint the model code
    • Use black and flake8
  • Package the model (Reference)
    • Write a basic pyproject.toml file
    • Install model into a virtual environment with pip
    • Tag version v0.1.0

Here are a few more topics we can cover, given time.

  • Use the diffusion model
    • Import the diffusion model from new package
    • Try to import someone else's diffusion model
  • Document the model
    • Docstrings
    • Sphinx documentation system
  • Visualize model output interactively with Jupyter widgets

Clone this wiki locally