MY TEACHING CODES

Develop the code one step at a time.

We first write a small part of a calculation and test it. Once we understand the result, we add the next part. These lessons follow that approach rather than beginning with a complete program and asking students to understand everything at once.

How we develop each lesson

We first explain what we want to calculate and define the quantities. We write a small code cell, then compare its result with a known answer. If the check fails, we examine that part before adding the next operation. Each Python lesson retains the complete calculation for comparison. The notebook cells follow this sequence.

Download the Python notebook collection

Technical details

Read the completed checks

Python notebooks for the complete examples

The Python notebook collection includes the color portrait, all five portrait programs, full diffusion and random-walk examples, binary spinodal simulation, topology, full-resolution 3D algorithms and native VPython viewers. The pages show explained code cells and their measured outputs. The short lessons below provide a smaller starting point.

If you would like a similar tutorial in Julia or C, email me with the lesson title and your intended use. I can share a Google Colab notebook with step-by-step explanations and worked examples.

Email: saswata_at_msme.iith.ac.in (replace _at_ with @).

Worked code lessons

Ternary spinodal decomposition

Our NumPy code, from initial composition through a checked polynomial free energy and a coupled Fourier update on a 256 × 256 grid.

Existing notebook lessons

The following resources develop their calculations through notebook cells. The elasticity pages retain worked snippets; complete solver notebooks require a separate code request.

Larger models and original programs

The 256³ spinodal example, topology playground and NRCM C examples provide simulations and explanations. Complete research implementations and historical source archives require a separate code request. The short lessons above do not replace those models or their measured results.

Return to the resource library