Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • calvindijksman98/lectures
  • solidstate/lectures
  • basnijholt/lectures
  • Hugo/lectures
  • mflor/lectures
  • lucasdekam/lectures
  • physicszerozero/lectures
  • lexhuismans/lectures
  • Gijs0172/lectures
  • YellowCherry/lectures
  • Pjieter/lectures
  • isidoraarayad/lectures
  • MarkusLid/lectures
  • alienfromabove99/lectures
  • Physics00/lectures
  • fenna.timsi/lectures
  • fr.looman/lectures
  • sjoerdakk/lectures
  • tobias.clausen1/lectures
  • NiekGoudswaard/lectures
  • weel.thies/lectures
  • tbvanderwoude/lectures
22 results
Show changes
Showing
with 6117 additions and 0 deletions
This diff is collapsed.
---
search:
exclude: true
jupyter:
jupytext:
text_representation:
extension: .md
format_name: markdown
format_version: '1.0'
jupytext_version: 0.8.6
kernelspec:
display_name: Python 3
language: python
name: python3
---
```python tags=["initialize"]
from matplotlib import pyplot as plt
from mpl_toolkits.axes_grid1 import make_axes_locatable
import numpy as np
from scipy.optimize import curve_fit
from scipy.integrate import quad
from common import draw_classic_axes, configure_plotting
configure_plotting()
```
# Solutions for lecture 2 exercises
### Warm-up exercises
1. For low T, $1/T \rightarrow \infty$. The heat capacity is then given as:
$$
C \overset{\mathrm{low \: T}}{\approx} 9Nk_{\mathrm{B}}\left(\frac{T}{T_{D}}\right)^3\int_0^{\infty}\frac{x^4{\mathrm{e}}^x}{({\mathrm{e}}^x-1)^2}{\mathrm{d}}x.
$$
2. See plot below (shown for $T_{D,1} < T_{D,2}$)
3. The polarization describes the direction of the motion of the atoms in the wave with respect to the direction in which the wave travels. In 3D, there are only 3 different polarizations possible.
4. The integral can be expressed as
$$
\int dk_x dk_y = \int k dk d\phi
$$
5. The Debye frequency $\omega_D$ is the frequency of the vibrational mode with the highest eigenfrequency. It has corresponding Debye temperature $T_D = \hbar\omega_D/k_B$, which is the temperature above which all the vibrational modes in the system become excited
6. The wavelength is of the order of the interatomic spacing:
$$
\lambda = (\frac{4}{3}\pi)^{1/3} a.
$$
```python
fig, ax = plt.subplots()
T = np.linspace(0.1, 3)
T_D = [1,2]
ax.plot(T, (T/T_D[0])**3, 'b-', label = r'$T_{D,1}$')
ax.plot(T, (T/T_D[1])**3, 'r-', label = r'$T_{D,2}$')
ax.set_ylim([0,3])
ax.set_xlim([0,3])
ax.set_xlabel('$T$')
ax.set_xticks([0])
ax.set_xticklabels(['$0$'])
ax.set_ylabel('$C$')
ax.set_yticks([0])
ax.set_yticklabels(['$0$'])
ax.legend();
```
### Exercise 1: Deriving the density of states for the linear dispersion relation of the Debye model
1. $\omega = v_s|\mathbf{k}|$
2. The distance between nearest-neighbour points in $\mathbf{k}$-space is $2\pi/L$. The density of $\mathbf{k}$-points in 1, 2, and 3 dimensions is $L/(2\pi)$, $L^2/(2\pi)^2$, and $L^3/(2\pi)^3$ respectively.
3. Express the number of states between frequencies $0<\omega<\omega_0$ as an integral over k-space. Do so for 1D, 2D and 3D. Do not forget the possible polarizations. We assume that in $d$ dimensions there are $d_p$ polarizations.
\begin{align*}
N_\text{states, 1D} & = 1_p \frac{L}{2\pi} \int_0^{k_0} 2 dk \\
N_\text{states, 2D} & = 2_p \left(\frac{L}{2\pi}\right)^2 \int_0^{k_0} 2\pi k dk \\
N_\text{states, 3D} & = 3_p \left(\frac{L}{2\pi}\right)^3 \int_0^{k_0} 4\pi k^2 dk
\end{align*}
4. We use $k=\mathbf{k}| = \omega/v_s$ and $dk = d\omega/v_s$ to get
\begin{align*}
N_\text{states, 1D} & = 1_p \frac{L}{2\pi} \int_0^{\omega_0} 2 \frac{1}{v_s} d\omega := \int_0^{\omega_0} g_{1D}(\omega) d\omega \\
N_\text{states, 2D} & = 2_p \left(\frac{L}{2\pi}\right)^2 \int_0^{\omega_0} 2\pi \frac{\omega}{v_s^2} d\omega := \int_0^{\omega_0} g_{2D}(\omega) d\omega \\
N_\text{states, 3D} & = 3_p \left(\frac{L}{2\pi}\right)^3 \int_0^{\omega_0} 4\pi \frac{\omega^2}{v_s^3} d\omega := \int_0^{\omega_0} g_{3D}(\omega) d\omega
\end{align*}
The integral boundaries set the frequency region in which you calculate the density of states.
5. The density of states is the number of states per unit frequency. It has units of 1 over frequency
### Exercise 2: Debye model in 2D
1. The energy stored in the vibrational modes of a two-dimensional Debye solid is:
\begin{align*}
E & = 2_p \frac{L^2}{4\pi^2}\int_0^{\infty}(n_B(\omega(\mathbf{k}))+\frac{1}{2})\hbar\omega(\mathbf{k}) d\mathbf{k} \\
& = \frac{L^2}{\pi v^2\hbar^2\beta^3}\int_{0}^{\beta\hbar\omega_D}\frac{x^2}{e^{x} - 1}dx + E_0
\end{align*}
2. The high-$T$ limit implies $\beta \rightarrow 0$. Therefore, $n_B \approx k_B T/\hbar\omega$, and the integral becomes particularly illuminating:
$$
E = \int_{0}^{\omega_D} \hbar\omega n_B(\omega) g(\omega) d\omega \approx \int_{0}^{\omega_D} k_B T g(\omega) d\omega = N_\text{modes} k_B T
$$
where we neglected the zero-point energy. In 2D, we have $N_\text{modes} = 2_p N_\text{atoms}$, so that we recover the 2D law of Dulong–Petit $C_v = dE/dT = 2 k_B$ per atom.
3. In the low temperature limit, the high-energy modes are not excited so we can safely let the upper boundary of the integral go to infinity. For convenience, we write $g(\omega) = \alpha \omega$, with $\alpha = \frac{L^2}{\pi v_s^2}$. We get
$$
E = \int_0^{\omega_D}\frac{\hbar\omega g(\omega)}{e^{\hbar\omega/k_B T}- 1}d\omega \approx \alpha\frac{k^3 T^3}{\hbar^2}\int_0^\infty\frac{x^2}{e^x-1}dx
$$
From which we find $C_v = dE/dT = K T^2$, with
$$
K = 3\alpha\frac{k^3}{\hbar^2}\int_0^\infty\frac{x^2}{e^x-1}dx
$$
### Exercise 3: Longitudinal and transverse vibrations with different sound velocities
1. The key idea is that the total energy in the individual harmonic oscillators (the vibrational modes) is the sum of the energies in the individual oscillators: $E = \int_0^{\omega_D}\frac{\hbar \omega g(\omega)}{e^{\beta\hbar\omega} - 1}d\omega + E_Z$, where $g(\omega) = g_\parallel(\omega) + g_\perp(\omega)$. Using
\begin{align*}
g_\parallel & = 1_p \frac{L^3}{2\pi^2} \frac{\omega^2}{v_\parallel^3}, \\
g_\perp & = 2_p \frac{L^3}{2\pi^2} \frac{\omega^2}{v_\perp^3},
\end{align*}
we get
$$
E = \frac{L^3 k_B^4 T^4}{2\pi^2\hbar^3}\left(\frac{2}{v_\perp^3} + \frac{1} {v_\parallel^3}\right)\int_{0}^{\beta\hbar\omega_D}\frac{x^3}{e^{x} - 1}dx.
$$
2. As in exercise 1, in the high-T limit, we have $\beta \rightarrow 0. Therefore, $n_B \approx k_B T/\hbar\omega$ and the integral for $E$ becomes:
$$
E = \int_{0}^{\omega_D} \hbar\omega n_B(\omega) g(\omega) d\omega \approx \int_{0}^{\omega_D} k_B T g(\omega) d\omega +E_Z = N_\text{modes} k_B T + E_Z
$$
and we are left with the Dulong-Petit law $C = 3N_\text{atoms} k_B$.
3. In the low temperature limit, we can let the upper integral boundary go to infinity as in exercise 1. This yields
$$
C \approx \frac{2\pi^2 k_B^4 L^3}{15\hbar^3}\left(\frac{2}{v_\perp^3} + \frac{1}{v_\parallel^3}\right)T^3
$$
where we used $\int_{0}^{\infty}\frac{x^3}{e^{x} - 1}dx = \frac{\pi^4}{15}$.
### Exercise 4: Anisotropic sound velocities
In this case, the velocity depends on the direction. Note however that, in contrast with the previous exercise, the polarization does not affect the dispersion of the waves. We get
\begin{align*}
E =& 3_p\left(\frac{L}{2\pi}\right)^3 \int \frac{\hbar\omega(\mathbf{k})}{e^{\beta\hbar\omega(\mathbf{k})}-1} dk_x dk_y dk_z + E_Z \\
=& 3_p\left(\frac{L}{2\pi}\right)^3\frac{1}{v_x v_y v_z} \int \frac{\hbar\kappa}{e^{\beta\hbar\kappa} - 1}d\kappa_x d\kappa_y d\kappa_z + E_Z,
\end{align*}
where we made the substitutions $\kappa_x = k_x v_x,\kappa_y = k_y v_y, \kappa_z = k_z v_z$ so that $\omega = \kappa$. Going to spherical coordinates:
\begin{align*}
E &= \frac{3_p L^3}{2\pi^2}\frac{1}{v_x v_y v_z}\int_{0}^{\kappa_D} \frac{\hbar\kappa^3}{e^{\beta\hbar\kappa} - 1} d\kappa + E_Z
\end{align*}
To calculate the specific heat $C = \frac{dE}{dT}$, let's differentiate this expression directly:
\begin{align*}
C &= \frac{dE}{dT} = \frac{3_p L^3}{2\pi^2}\frac{1}{v_x v_y v_z}\int_{0}^{\kappa_D} \frac{d}{dT}\left(\frac{\hbar\kappa^3}{e^{\beta\hbar\kappa} - 1}\right) d\kappa \\
&= \frac{3_p L^3}{2\pi^2}\frac{1}{v_x v_y v_z}\int_{0}^{\kappa_D} \frac{\hbar\kappa^3 \cdot \hbar\kappa \cdot e^{\beta\hbar\kappa}}{(e^{\beta\hbar\kappa} - 1)^2} \cdot \frac{d\beta}{dT} d\kappa
\end{align*}
Since $\beta = \frac{1}{k_B T}$, we have $\frac{d\beta}{dT} = -\frac{1}{k_B T^2} = -\frac{\beta}{T}$. Substituting this:
\begin{align*}
C &= - \frac{3_p L^3}{2\pi^2}\frac{1}{v_x v_y v_z}\int_{0}^{\kappa_D} \frac{\hbar^2\kappa^4 e^{\beta\hbar\kappa}}{(e^{\beta\hbar\kappa} - 1)^2} \cdot \frac{\beta}{T} d\kappa \\
&= - \frac{3_p L^3}{2\pi^2}\frac{1}{v_x v_y v_z} \cdot \frac{\hbar^2\beta}{T}\int_{0}^{\kappa_D} \frac{\kappa^4 e^{\beta\hbar\kappa}}{(e^{\beta\hbar\kappa} - 1)^2} d\kappa
\end{align*}
Now, we can make the substitution $x = \beta\hbar\kappa$, which gives $d\kappa = \frac{dx}{\beta\hbar}$ and changes our limits to $\int_{0}^{\beta\hbar\kappa_D}$:
\begin{align*}
C &= - \frac{3_p L^3}{2\pi^2}\frac{1}{v_x v_y v_z} \cdot \frac{\hbar^2\beta}{T} \cdot \int_{0}^{\beta\hbar\kappa_D} \left(\frac{x}{\beta\hbar}\right)^4 \frac{e^x}{(e^x - 1)^2} \cdot \frac{dx}{\beta\hbar} \\
&= - \frac{3_p L^3}{2\pi^2}\frac{1}{v_x v_y v_z} \cdot \frac{\hbar^2\beta}{T} \cdot \frac{1}{(\beta\hbar)^5} \int_{0}^{\beta\hbar\kappa_D} \frac{x^4 e^x}{(e^x - 1)^2} dx \\
&= - \frac{3_p L^3}{2\pi^2}\frac{1}{v_x v_y v_z} \cdot \frac{1}{T\beta^4\hbar^3} \int_{0}^{\beta\hbar\kappa_D} \frac{x^4 e^x}{(e^x - 1)^2} dx
\end{align*}
Since $\frac{1}{T\beta^4} = \frac{k_B^4 T^3}{1} = k_B^4 T^3$, we get:
\begin{align*}
C &= -3_p \frac{3_p L^3}{2\pi^2}\frac{1}{v_x v_y v_z} \cdot \frac{k_B^4 T^3}{\hbar^3} \int_{0}^{\beta\hbar\kappa_D} \frac{x^4 e^x}{(e^x - 1)^2} dx \\
&= 3_p \frac{3_p L^3 k_B^4 T^3}{2\pi^2\hbar^3}\frac{1}{v_x v_y v_z} \int_{0}^{\beta\hbar\kappa_D} \frac{x^4 e^x}{(e^x - 1)^2} dx
\end{align*}
This is similar to the result with isotropic linear dispersion, with the difference being the factor $1/(v_x v_y v_z)$ instead of $1/v^3$.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
File moved
[{"number": 1, "abbr": "H", "full_name": "hydrogen", "remark": "(H 2 , gas)", "c": 28.836}, {"number": 2, "abbr": "He", "full_name": "helium", "remark": "(gas)", "c": 20.786}, {"number": 3, "abbr": "Li", "full_name": "lithium", "remark": "", "c": 24.86}, {"number": 4, "abbr": "Be", "full_name": "beryllium", "remark": "", "c": 16.443}, {"number": 5, "abbr": "B", "full_name": "boron", "remark": "(rhombic)", "c": 11.087}, {"number": 6, "abbr": "C", "full_name": "carbon", "remark": "(graphite)", "c": 8.517}, {"number": 6, "abbr": "C", "full_name": "carbon", "remark": "(diamond, nonstd state)", "c": 6.115}, {"number": 7, "abbr": "N", "full_name": "nitrogen", "remark": "(N 2 , gas)", "c": 29.124}, {"number": 8, "abbr": "O", "full_name": "oxygen", "remark": "(O 2 , gas)", "c": 29.378}, {"number": 9, "abbr": "F", "full_name": "fluorine", "remark": "(F 2 , gas)", "c": 31.304}, {"number": 10, "abbr": "Ne", "full_name": "neon", "remark": "(gas)", "c": 20.786}, {"number": 11, "abbr": "Na", "full_name": "sodium", "remark": "", "c": 28.23}, {"number": 12, "abbr": "Mg", "full_name": "magnesium", "remark": "", "c": 24.869}, {"number": 13, "abbr": "Al", "full_name": "aluminium", "remark": "", "c": 24.2}, {"number": 14, "abbr": "Si", "full_name": "silicon", "remark": "", "c": 19.789}, {"number": 15, "abbr": "P", "full_name": "phosphorus", "remark": "(white)", "c": 23.824}, {"number": 15, "abbr": "P", "full_name": "phosphorus", "remark": "(red, nonstd state)", "c": 21.19}, {"number": 16, "abbr": "S", "full_name": "sulfur", "remark": "(rhombic)", "c": 22.75}, {"number": 16, "abbr": "S", "full_name": "sulfur", "remark": "(monoclinic, nonstd state)", "c": 23.23}, {"number": 17, "abbr": "Cl", "full_name": "chlorine", "remark": "(Cl 2 gas)", "c": 33.949}, {"number": 18, "abbr": "Ar", "full_name": "argon", "remark": "(gas)", "c": 20.786}, {"number": 19, "abbr": "K", "full_name": "potassium", "remark": "", "c": 29.6}, {"number": 20, "abbr": "Ca", "full_name": "calcium", "remark": "", "c": 25.929}, {"number": 21, "abbr": "Sc", "full_name": "scandium", "remark": "", "c": 25.52}, {"number": 22, "abbr": "Ti", "full_name": "titanium", "remark": "", "c": 25.06}, {"number": 23, "abbr": "V", "full_name": "vanadium", "remark": "", "c": 24.89}, {"number": 24, "abbr": "Cr", "full_name": "chromium", "remark": "", "c": 23.35}, {"number": 25, "abbr": "Mn", "full_name": "manganese", "remark": "", "c": 26.32}, {"number": 26, "abbr": "Fe", "full_name": "iron", "remark": "(alpha)", "c": 25.1}, {"number": 27, "abbr": "Co", "full_name": "cobalt", "remark": "", "c": 24.81}, {"number": 28, "abbr": "Ni", "full_name": "nickel", "remark": "", "c": 26.07}, {"number": 29, "abbr": "Cu", "full_name": "copper", "remark": "", "c": 24.44}, {"number": 30, "abbr": "Zn", "full_name": "zinc", "remark": "", "c": 25.39}, {"number": 31, "abbr": "Ga", "full_name": "gallium", "remark": "", "c": 25.86}, {"number": 32, "abbr": "Ge", "full_name": "germanium", "remark": "", "c": 23.222}, {"number": 33, "abbr": "As", "full_name": "arsenic", "remark": "(alpha, gray)", "c": 24.64}, {"number": 34, "abbr": "Se", "full_name": "selenium", "remark": "(hexagonal)", "c": 25.363}, {"number": 35, "abbr": "Br", "full_name": "bromine", "remark": "", "c": 75.69}, {"number": 36, "abbr": "Kr", "full_name": "krypton", "remark": "(gas)", "c": 20.786}, {"number": 37, "abbr": "Rb", "full_name": "rubidium", "remark": "", "c": 31.06}, {"number": 38, "abbr": "Sr", "full_name": "strontium", "remark": "", "c": 26.4}, {"number": 39, "abbr": "Y", "full_name": "yttrium", "remark": "", "c": 26.53}, {"number": 40, "abbr": "Zr", "full_name": "zirconium", "remark": "", "c": 25.36}, {"number": 41, "abbr": "Nb", "full_name": "niobium", "remark": "", "c": 24.6}, {"number": 42, "abbr": "Mo", "full_name": "molybdenum", "remark": "", "c": 24.06}, {"number": 43, "abbr": "Tc", "full_name": "technetium", "remark": "", "c": 24.27}, {"number": 44, "abbr": "Ru", "full_name": "ruthenium", "remark": "", "c": 24.06}, {"number": 45, "abbr": "Rh", "full_name": "rhodium", "remark": "", "c": 24.98}, {"number": 46, "abbr": "Pd", "full_name": "palladium", "remark": "", "c": 25.98}, {"number": 47, "abbr": "Ag", "full_name": "silver", "remark": "", "c": 25.35}, {"number": 48, "abbr": "Cd", "full_name": "cadmium", "remark": "", "c": 26.02}, {"number": 49, "abbr": "In", "full_name": "indium", "remark": "", "c": 26.74}, {"number": 50, "abbr": "Sn", "full_name": "tin", "remark": "(white)", "c": 27.112}, {"number": 50, "abbr": "Sn", "full_name": "tin", "remark": "(gray, nonstd state)", "c": 25.77}, {"number": 51, "abbr": "Sb", "full_name": "antimony", "remark": "", "c": 25.23}, {"number": 52, "abbr": "Te", "full_name": "tellurium", "remark": "", "c": 25.73}, {"number": 53, "abbr": "I", "full_name": "iodine", "remark": "", "c": 54.44}, {"number": 54, "abbr": "Xe", "full_name": "xenon", "remark": "(gas)", "c": 20.786}, {"number": 55, "abbr": "Cs", "full_name": "caesium", "remark": "", "c": 32.21}, {"number": 56, "abbr": "Ba", "full_name": "barium", "remark": "", "c": 28.07}, {"number": 57, "abbr": "La", "full_name": "lanthanum", "remark": "", "c": 27.11}, {"number": 58, "abbr": "Ce", "full_name": "cerium", "remark": "(gamma, fcc)", "c": 26.94}, {"number": 59, "abbr": "Pr", "full_name": "praseodymium", "remark": "", "c": 27.2}, {"number": 60, "abbr": "Nd", "full_name": "neodymium", "remark": "", "c": 27.45}, {"number": 62, "abbr": "Sm", "full_name": "samarium", "remark": "", "c": 29.54}, {"number": 63, "abbr": "Eu", "full_name": "europium", "remark": "", "c": 27.66}, {"number": 64, "abbr": "Gd", "full_name": "gadolinium", "remark": "", "c": 37.03}, {"number": 65, "abbr": "Tb", "full_name": "terbium", "remark": "", "c": 28.91}, {"number": 66, "abbr": "Dy", "full_name": "dysprosium", "remark": "", "c": 27.7}, {"number": 67, "abbr": "Ho", "full_name": "holmium", "remark": "", "c": 27.15}, {"number": 68, "abbr": "Er", "full_name": "erbium", "remark": "", "c": 28.12}, {"number": 69, "abbr": "Tm", "full_name": "thulium", "remark": "", "c": 27.03}, {"number": 70, "abbr": "Yb", "full_name": "ytterbium", "remark": "", "c": 26.74}, {"number": 71, "abbr": "Lu", "full_name": "lutetium", "remark": "", "c": 26.86}, {"number": 72, "abbr": "Hf", "full_name": "hafnium", "remark": "(hexagonal)", "c": 25.73}, {"number": 73, "abbr": "Ta", "full_name": "tantalum", "remark": "", "c": 25.36}, {"number": 74, "abbr": "W", "full_name": "tungsten", "remark": "", "c": 24.27}, {"number": 75, "abbr": "Re", "full_name": "rhenium", "remark": "", "c": 25.48}, {"number": 76, "abbr": "Os", "full_name": "osmium", "remark": "", "c": 24.7}, {"number": 77, "abbr": "Ir", "full_name": "iridium", "remark": "", "c": 25.1}, {"number": 78, "abbr": "Pt", "full_name": "platinum", "remark": "", "c": 25.86}, {"number": 79, "abbr": "Au", "full_name": "gold", "remark": "", "c": 25.418}, {"number": 80, "abbr": "Hg", "full_name": "mercury", "remark": "(liquid)", "c": 27.983}, {"number": 81, "abbr": "Tl", "full_name": "thallium", "remark": "", "c": 26.32}, {"number": 82, "abbr": "Pb", "full_name": "lead", "remark": "", "c": 26.65}, {"number": 83, "abbr": "Bi", "full_name": "bismuth", "remark": "", "c": 25.52}, {"number": 84, "abbr": "Po", "full_name": "polonium", "remark": "", "c": 26.4}, {"number": 86, "abbr": "Rn", "full_name": "radon", "remark": "(gas)", "c": 20.786}, {"number": 87, "abbr": "Fr", "full_name": "francium", "remark": "", "c": 31.8}, {"number": 89, "abbr": "Ac", "full_name": "actinium", "remark": "", "c": 27.2}, {"number": 90, "abbr": "Th", "full_name": "thorium", "remark": "", "c": 26.23}, {"number": 92, "abbr": "U", "full_name": "uranium", "remark": "", "c": 27.665}, {"number": 93, "abbr": "Np", "full_name": "neptunium", "remark": "", "c": 29.46}, {"number": 94, "abbr": "Pu", "full_name": "plutonium", "remark": "", "c": 35.5}, {"number": 95, "abbr": "Am", "full_name": "americium", "remark": "", "c": 62.7}]
\ No newline at end of file
# -*- coding: utf-8 -*-
# ---
# jupyter:
# jupytext:
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.3'
# jupytext_version: 0.8.6
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# +
from pathlib import Path
import json
import wikitables
raw, = wikitables.import_tables('Heat capacities of the elements (data page)')
# +
elements = []
for index, row in enumerate(raw.rows):
if not row[''].value.startswith('<'):
continue
description = row[''].value
description = description[description.index('>') + 2:]
c = raw.rows[index+1]['J/(mol·K)'].value
if not isinstance(c, float):
c = float(c.split()[-1])
number, abbr, full_name, *remark = description.split()
element = {
'number': int(number),
'abbr': abbr,
'full_name': full_name,
'remark': ' '.join(remark),
'c': c,
}
elements.append(element)
Path('elements.json').write_text(json.dumps(elements))
./code/common.py
\ No newline at end of file