Skip to content

FabiolaCocchiararo/scientificcomputing_bicocca_2024

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Scientific Computing with Python

Davide Gerosa - [email protected]
University of Milano-Bicocca, 2024-2025.

Aims

The python programming language and its library ecosystem are essential tools in modern science. This class provides an advanced overview of python and its main functionalities, focusing in particular on its applications to computational physics. Targeted topics include: array vectorization with numpy, pretty plotting with matplotlib, scientific recipes with scipy, just-in-time compilation with numba, module packaging, and unit testing. I will also introduce other essential computational tools, notably Mathematica for symbolic manipulation and git for version control. The format will be highly interactive and tailored to the research interests of the participants.

Lectures

  1. Introduction: python. Why python. Basics. Datatypes. Control flow. Functions. Classes. Modules. Exceptions. File I/O.
  2. Arrays: numpy. Array. Shaping. Slicing. Masking. Avoid loops.
  3. Plotting: matplotlib. Pretty plotting. OO interface. Latex compatibility. Lines. Histograms. Contour maps. Annotations. Surfaces.
  4. Numerical methods: scipy. Integration. Interpolation. Root finding. Initial value problems. Boundary value problems. Fitting. Fourier transforms. Linear algebra.
  5. Symbolic maths: mathematica Simplification. Solvers. Calculus. Differential Equations
  6. Version control: git. Why. Git walkthrough. SSH keys. Github.
  7. Go faster: numba and multiprocessing. Python extensions. Decorators. Just-in-time compilation. Notions of parallel computing. Embarrassingly parallel tasks.
  8. Code development: pytest, pip, cprofile. Module setup. Module deployment. Unit tests. Automated tests. Benchmark tests. Profiling.

Other (not covered in class):

  1. Symbolic maths: sympy. Symbols. Substitution. Simplification. Calculus. Solvers. Units.
  2. Data manipulation: pandas. When I find the time I would like to prepare something about pandas.

Each lecture has some exercises at the end.

Resources

Textbooks

There are infinitely many textbooks on scientific computing. Here are three that I think are particularly useful.

  1. This textbook provides a gentle introduction to the beautiful world of python; it's a great starting point.

  2. This one is more advanced. It's ideal for sharpening your existing Python skills and go the extra mile. Instead of keep on coding the same way, as some point you'll need to do it better. It's one of my go-to references when looking for a specific package/topic/task.

  3. Perhaps a bit outdated, but the really nice thing about this textbook is that has a bit of everything you might need for science, not just python. Things like command line operations, data visualization, regular expressions, version control, debugging, latex, etc. This book is a perfect companion when starting your PhD.

Classes

Here are some classes similar to this one which you might find useful:

Recordings

For students at Milano-Bicocca, recordings are available at elearning.unimib.it/course/view.php?id=58494

Logistics:

Schedule

Here is our schedule:

  1. Mon Nov 18, 2024 - 10.30-12.30 - Room U4.07
  2. Wed Nov 20, 2024 - 14.30-16.30 - Room U2.02
  3. Fri Nov 22, 2024 - 10.30-12.30 - Room U4.05
  4. Mon Nov 25, 2024 - 14.30-16.30 - Room U6.26
  5. Wed Nov 27, 2024 - 10.30-12.30 - Room U1.11
  6. Fri Nov 29, 2024 - 10.30-12.30 - Room U6.03
  7. Mon Dec 2, 2024- 10.30-12.30 - Room U4.06
  8. Wed Dec 4, 2024 - 10.30-12.30 - Room U4.06
  9. Fri Dec 6, 2024 - 10.30-12.30 - Room U2.04 (backup slot in case we need to skip one lecture)

Here is a Google calendar with these dates, which you can import into your own calendar.

Prerequisites

  • Please come to class with your laptop.
  • Make sure to have a working python distribution already installed and fully working (with privileges to pip install packages). If you've never installed python, I recommend using brew on macOs and anaconda on Windows.
  • Also, install Mathematica (this is free for Milano-Bicocca PhD students, see here, otherwise you can get a 30-day free trial).

Exams

For students enrolled in the Physics and Astronomy PhD at Milano-Bicocca, this class awards 2 CFU (16 hours). Exams will be light touch and without grades (i.e. just approved / not approved).

Each notebook has some exercises at the end. Note that the exercises provided are far more than what you'll need to do! Overall, it's ok if you work on 2 exercises for each lecture (see the notebooks). You can choose what you prefer based on your interests and what you think will be more useful for your PhD research. You'll see the exercises are very different: some of them are long, some are short, some have defined tasks, and some are more open-ended. If in doubt, feel free to shoot me an email with "I'd like to prepare these ones; is that ok?".

That should be a total of 2 x 8 = 16 exercises. Hopefully you will have finished many of them during the lectures themselves. To submit your exercises, please fork this repository and add your codes to the working directory of your fork. Please send me an email with your github username to let me know you are done (do not send me code by email! Use git!). I will mark them in batches (about once a month) and communicate the outcome to the PhD secretary.

In general, I'm always happy to chat coding and science with you. My office is room U2-2007.

Credits

This class is built on top of that taught by Michael Zingale at Stony Brook University: https://sbu-python-class.github.io with changes and additions from a number of other sources, some from myself.

Careful...

Credit: xkcd 2582. This actually a Python easter egg... You can truly pip install antigravity and import antigravity. Try!

About

Scientific Computing with Python - PhD class at the University of Milan-Bicocca (Italy)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Jupyter Notebook 49.4%
  • Mathematica 40.2%
  • TeX 10.2%
  • Python 0.2%