Appendix A — Running the notebooks
A.1 Three ways to use this companion
- Read the website. The live panels run in the browser with no installation.
- Run the code in Google Colab. Every chapter starts with an Open in Colab button. Colab is free and runs in the browser; you only need a Google account. Use File → Save a copy in Drive to keep your changes.
- Run it on your computer with Jupyter, or rebuild the whole book with Quarto.
A.2 Installation
pip install -r requirements.txt # numpy scipy matplotlib pandas jupyter ipywidgets (+ optional colour-science)
quarto preview # live preview while editing
quarto render # builds _book/ (HTML)Rendering executes every Python cell once. Results are cached in _freeze/ (freeze: auto), so later builds only re-run the chapters you changed.
A.3 Publishing the website (GitHub Pages)
The source lives at https://github.com/philippevelha/Optoelectronics-teaching (folder chapter3/) and the site at https://philippevelha.github.io/Optoelectronics-teaching/chapter3/. After editing a chapter:
cd notebooks && python build_notebooks.py && cd .. # refresh the notebooks (Colab buttons point to them)
git add -A && git commit -m "Update chapter 3" && git push # update the source on GitHub
bash ../publish.sh # render and update the websiteA.4 Regenerating the notebooks
cd notebooks
python build_notebooks.pyThe script converts every chapter, adds a setup cell that works both locally and in Colab (it downloads semilib.py from GitHub when running in Colab), and rebuilds interactive_explorers.ipynb.
A.5 The semilib module
| function | purpose |
|---|---|
kT, photon_energy_eV, wavelength_from_eV, CM3, CM2 |
units and conversions (SI inside, eV for energies) |
MATERIALS, VARSHNI, varshni, LATTICE, vegard, alloy_Eg |
material data (Table 3.1), bandgap vs temperature and composition |
dos_3d, fermi_dirac, fermi_half, eff_dos, n_i |
band statistics |
carriers, fermi_level, conductivity, einstein_D |
doping, Fermi level, transport |
built_in_voltage, depletion, junction_profile |
pn junction electrostatics |
diode_currents, diode_iv_rs |
diffusion, recombination and generation currents; series resistance |
c_dep, r_d, c_diff |
small-signal model |
led_spectrum, led_linewidth, wavelength_rgb |
LED emission spectrum |
qw_infinite, qw_finite, qw_wavefunction |
quantum wells |
extraction_ratio, V_photopic, luminous_flux |
extraction efficiency and photometry |
led_response, led_pulse |
modulation bandwidth and pulse response |
Every function was checked against the worked examples of the slides (see the “worked example” sections).