This repository contains a simple 2D diffusion solver, packaged as an exercise for the Simulation Software Engineering course.
The code used in this exercise is based on Chapter 7 of the book "Learning Scientific Programming with Python".
This package provides a solver for the 2D diffusion equation over a square domain. The simulation starts with a domain at a constant T_cold temperature and a central circular disc at a higher T_hot temperature.
The equation is solved using the finite-difference method (FDM). The code then generates a plot showing the state of the diffusion at four different timepoints.
This package is hosted on TestPyPI. You can install it using pip.
Because the package dependencies (numpy, matplotlib) are on the main PyPI, you must tell pip to look in both indexes:
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ canselza_diffusion2dOnce installed, you can run the simulation in two ways:
The package installs a runnable script called solve-diffusion2d. Simply run this in your terminal:
solve-diffusion2dThis will run the simulation with default parameters.
You can also import and use the solve() function directly within a Python script or shell. This allows you to pass custom parameters.
from canselza_diffusion2d.diffusion2d import solve
# Run the simulation with default parameters
solve()
# Or run with custom parameters
# solve(dx=0.05, dy=0.05, D=5.0)If you use this code, please cite the authors.