From 37a877a52edd1ea14f2c0d2e8775a05eb02f2218 Mon Sep 17 00:00:00 2001
From: Anton Akhmerov <anton.akhmerov@gmail.com>
Date: Wed, 25 Apr 2018 12:23:18 +0200
Subject: [PATCH] start migrating heat capacity plots

---
 code/heat_capacity.py      |  56 ++++++++++++++++
 docs/figures/zeropoint.svg | 129 -------------------------------------
 2 files changed, 56 insertions(+), 129 deletions(-)
 create mode 100644 code/heat_capacity.py
 delete mode 100644 docs/figures/zeropoint.svg

diff --git a/code/heat_capacity.py b/code/heat_capacity.py
new file mode 100644
index 00000000..ebd054fa
--- /dev/null
+++ b/code/heat_capacity.py
@@ -0,0 +1,56 @@
+import matplotlib
+matplotlib.use('agg')
+from matplotlib import pyplot
+
+import numpy as np
+from scipy.optimize import curve_fit
+from scipy.integrate import quad
+
+import common
+from common import draw_classic_axes
+
+
+# Data from Einstein's paper
+T = [222.4, 262.4, 283.7, 306.4, 331.3, 358.5, 413.0, 479.2, 520.0, 879.7, 1079.7, 1258.0],
+c = [0.384, 0.578, 0.683, 0.798, 0.928, 1.069, 1.343, 1.656, 1.833, 2.671, 2.720, 2.781]
+
+
+def c_einstein(T, T_E=1):
+    x = T_E / T
+    return 3 * x**2 * np.exp(x) / (np.exp(x) - 1)**2
+
+
+def integrand(y):
+    return y**4 * np.exp(y) / (np.exp(y) - 1)**2
+
+
+@np.vectorize
+def c_debye(T, T_D=1):
+    x = T / T_D
+    return 9 * x**3 * quad(integrand, 0, 1/x)[0]
+
+
+def plot_einstein():
+    T = np.linspace(0.01, 3, 500)
+    fig, ax = pyplot.subplots()
+
+    ax.plot(T, c_einstein(T)/3)
+    ax.fill_between(T, c_einstein(T)/3, 1, alpha=0.5)
+
+    ax.set_ylim(bottom=0, top=1.2)
+    ax.set_xlabel('$T$')
+    ax.set_ylabel(r'$\omega$')
+    ax.set_xticks([1])
+    ax.set_xticklabels([r'$\hbar \omega/k_B$'])
+    ax.set_yticks([1])
+    ax.set_yticklabels(['$k_B$'])
+    pyplot.hlines([1], 0, 3, linestyles='dashed')
+    draw_classic_axes(ax)
+    pyplot.savefig('zeropoint.svg')
+
+def main():
+    os.chdir('docs/figures')
+    plot_einstein()
+
+if __name__ == "__main__":
+    main()
diff --git a/docs/figures/zeropoint.svg b/docs/figures/zeropoint.svg
deleted file mode 100644
index 382274fc..00000000
--- a/docs/figures/zeropoint.svg
+++ /dev/null
@@ -1,129 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Generator: Adobe Illustrator 21.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
-<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
-	 viewBox="0 0 425.2 95.2" style="enable-background:new 0 0 425.2 95.2;" xml:space="preserve">
-<style type="text/css">
-	.st0{fill:#D1D3D4;stroke:#000000;stroke-width:0.5;stroke-miterlimit:10;}
-	.st1{fill:#FFFFFF;}
-	.st2{fill:none;stroke:#000000;stroke-width:0.5;stroke-miterlimit:10;stroke-dasharray:2;}
-	.st3{fill:none;stroke:#000000;stroke-width:0.5;stroke-miterlimit:10;}
-	.st4{clip-path:url(#SVGID_2_);}
-	.st5{clip-path:url(#SVGID_4_);}
-	.st6{clip-path:url(#SVGID_6_);}
-	.st7{clip-path:url(#SVGID_8_);}
-</style>
-<path class="st0" d="M277.9,7.7H150.1c0,0-17.6,72.2,0,72.2c27.8,0,9.6-57.6,127.8-57.6C281.5,22.2,277.9,7.7,277.9,7.7z"/>
-<rect x="127" y="5.2" class="st1" width="22.8" height="77.8"/>
-<rect x="208.4" y="-53.1" transform="matrix(6.123234e-17 -1 1 6.123234e-17 203.1854 229.4335)" class="st1" width="15.9" height="132.4"/>
-<rect x="275.3" y="7.6" class="st1" width="22.8" height="77.8"/>
-<line class="st2" x1="150.1" y1="21.2" x2="275.3" y2="21.2"/>
-<g>
-	<g>
-		<line class="st3" x1="150.1" y1="80" x2="150.1" y2="5.7"/>
-		<g>
-			<polygon points="151.3,6.5 150.1,2.2 148.9,6.5 			"/>
-		</g>
-	</g>
-</g>
-<g>
-	<g>
-		<line class="st3" x1="149.9" y1="80" x2="271.8" y2="80"/>
-		<g>
-			<polygon points="271,81.2 275.3,80 271,78.8 			"/>
-		</g>
-	</g>
-</g>
-<g>
-	<defs>
-		<rect id="SVGID_1_" x="137.4" y="15.3" width="10.3" height="9.4"/>
-	</defs>
-	<clipPath id="SVGID_2_">
-		<use xlink:href="#SVGID_1_"  style="overflow:visible;"/>
-	</clipPath>
-	<path class="st4" d="M140,16.2c0,0,0-0.1-0.1-0.1c-0.2,0-0.9,0.1-1.1,0.1c-0.1,0-0.2,0-0.2,0.2c0,0.1,0.1,0.1,0.2,0.1
-		c0.5,0,0.5,0.1,0.5,0.2l0,0.2l-1.4,5.4c0,0.1,0,0.2,0,0.2c0,0.2,0.2,0.3,0.3,0.3c0.1,0,0.3-0.1,0.3-0.2c0.1-0.1,0.5-1.8,0.5-2.1
-		c0.3,0,1.1,0.2,1.1,0.8c0,0.1,0,0.1,0,0.2c0,0.1,0,0.2,0,0.3c0,0.6,0.4,0.9,0.9,0.9c0.3,0,0.5-0.2,0.8-0.5c0.2-0.4,0.3-0.9,0.3-1
-		c0-0.1-0.1-0.1-0.1-0.1c-0.1,0-0.1,0-0.2,0.2c-0.2,0.7-0.4,1.2-0.8,1.2c-0.2,0-0.3-0.1-0.3-0.5c0-0.2,0-0.4,0.1-0.5
-		c0-0.2,0-0.2,0-0.3c0-0.6-0.6-0.9-1.4-1c0.3-0.2,0.6-0.5,0.8-0.7c0.5-0.5,0.9-0.9,1.4-0.9c0.1,0,0.1,0,0.1,0c0.1,0,0.1,0,0.2,0.1
-		c0,0,0,0,0,0.1c-0.5,0-0.5,0.4-0.5,0.5c0,0.2,0.1,0.3,0.4,0.3s0.5-0.2,0.5-0.6c0-0.3-0.2-0.6-0.7-0.6c-0.3,0-0.7,0.1-1.4,0.8
-		c-0.3,0.4-0.7,0.7-1.1,0.9L140,16.2"/>
-	<path class="st4" d="M144.2,23.7c-0.3,0-0.3-0.1-0.3-0.3v-1.8h1.4c0.7,0,1.1,0.6,1.1,1c0,0.5-0.5,1-1.2,1H144.2 M143.9,21.5v-1.6
-		c0-0.2,0-0.3,0.3-0.3h1c0.7,0,1,0.5,1,0.9c0,0.5-0.4,1-1.2,1H143.9z M142.6,19.4v0.2h0.2c0.5,0,0.5,0.1,0.5,0.3v3.5
-		c0,0.2,0,0.3-0.5,0.3h-0.2v0.3h2.8c1,0,1.6-0.6,1.6-1.2c0-0.6-0.6-1.1-1.4-1.2c0.7-0.1,1.2-0.5,1.2-1c0-0.6-0.7-1.1-1.6-1.1H142.6z
-		"/>
-</g>
-<g>
-	<defs>
-		<rect id="SVGID_3_" x="137.8" y="2.6" width="7.5" height="7.5"/>
-	</defs>
-	<clipPath id="SVGID_4_">
-		<use xlink:href="#SVGID_3_"  style="overflow:visible;"/>
-	</clipPath>
-	<path class="st5" d="M144.6,3.3c0,0,0-0.1-0.1-0.1c0,0,0,0-0.1,0.1L143.7,4c-0.1-0.1-0.5-0.8-1.5-0.8c-2.1,0-4.2,2.1-4.2,4.2
-		c0,1.6,1.1,2.6,2.5,2.6c0.8,0,1.5-0.4,2-0.8c0.9-0.8,1-1.6,1-1.7c0-0.1-0.1-0.1-0.1-0.1c-0.1,0-0.1,0-0.1,0.1c-0.1,0.3-0.3,1-1,1.5
-		c-0.7,0.5-1.2,0.7-1.7,0.7c-0.8,0-1.8-0.5-1.8-2c0-0.5,0.2-2.1,1.1-3.1c0.6-0.7,1.5-1.1,2.3-1.1c1,0,1.5,0.7,1.5,1.8
-		c0,0.4-0.1,0.4-0.1,0.5c0,0.1,0.1,0.1,0.2,0.1c0.1,0,0.1,0,0.2-0.2L144.6,3.3"/>
-</g>
-<g>
-	<defs>
-		<rect id="SVGID_5_" x="268.8" y="82.9" width="7.5" height="7.5"/>
-	</defs>
-	<clipPath id="SVGID_6_">
-		<use xlink:href="#SVGID_5_"  style="overflow:visible;"/>
-	</clipPath>
-	<path class="st6" d="M272.8,84.4c0.1-0.3,0.1-0.3,0.2-0.4c0.1,0,0.4,0,0.6,0c1,0,1.4,0,1.4,0.8c0,0.1-0.1,0.5-0.1,0.7
-		c0,0.1,0,0.2,0,0.2c0,0.1,0,0.1,0.1,0.1c0.1,0,0.1-0.1,0.2-0.2l0.3-1.6c0-0.1,0-0.1,0-0.2c0-0.1-0.1-0.1-0.3-0.1H270
-		c-0.2,0-0.3,0-0.3,0.2l-0.6,1.7l0,0.2c0,0.1,0,0.1,0.1,0.1c0.1,0,0.1,0,0.2-0.2c0.5-1.5,0.8-1.6,2.1-1.6h0.4c0.3,0,0.3,0,0.3,0.1
-		c0,0.1,0,0.2-0.1,0.2l-1.3,5c-0.1,0.3-0.1,0.4-1.1,0.4c-0.3,0-0.4,0-0.4,0.2c0,0.1,0.1,0.1,0.2,0.1c0.3,0,0.5,0,0.8,0
-		c0.3,0,0.5,0,0.8,0c0.3,0,0.5,0,0.8,0c0.3,0,0.6,0,0.8,0c0.1,0,0.2,0,0.2-0.2c0-0.1-0.1-0.1-0.3-0.1c-0.2,0-0.4,0-0.6,0
-		c-0.3,0-0.4-0.1-0.4-0.2c0,0,0-0.1,0.1-0.2L272.8,84.4"/>
-</g>
-<g>
-	<defs>
-		<rect id="SVGID_7_" x="189.1" y="81.6" width="25.4" height="10.3"/>
-	</defs>
-	<clipPath id="SVGID_8_">
-		<use xlink:href="#SVGID_7_"  style="overflow:visible;"/>
-	</clipPath>
-	<path class="st7" d="M191,83.7h1.8c0.2,0,0.3,0,0.3-0.1c0-0.1-0.1-0.1-0.3-0.1h-1.7c0.1-0.3,0.1-0.3,0.1-0.5
-		c0.1-0.2,0.1-0.5,0.1-0.5c0-0.1-0.1-0.1-0.1-0.1c-0.2,0-0.9,0.1-1.2,0.1c-0.1,0-0.2,0-0.2,0.2c0,0.1,0.1,0.1,0.2,0.1
-		c0.5,0,0.5,0.1,0.5,0.1c0,0.1-0.1,0.4-0.1,0.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