diff --git a/notebook/lattice-vibration/NGLTrajectoryClass2D.py b/notebook/lattice-vibration/NGLTrajectoryClass2D.py index 4dccdd9..bb70b9d 100644 --- a/notebook/lattice-vibration/NGLTrajectoryClass2D.py +++ b/notebook/lattice-vibration/NGLTrajectoryClass2D.py @@ -162,10 +162,16 @@ def __init__(self, trajectory): self.kx_array = np.linspace(-1.5 * np.pi, 1.5 * np.pi, 61) self.ky_array = np.linspace(-1.5 * np.pi, 1.5 * np.pi, 61) self.KX, self.KY = np.meshgrid(self.kx_array, self.ky_array) - # Center of Brillouin zone - self.idx_x = 30 - self.idx_y = 30 + + # Initialize to nontrivial k-point + self.x=np.pi/2 + self.y=np.pi/2 + self.idx_x = (np.abs(self.kx_array - self.x)).argmin() + self.idx_y = (np.abs(self.ky_array - self.y)).argmin() + kx = self.kx_array[self.idx_x] + ky = self.ky_array[self.idx_y] + # kx,ky bounds are 1.5*BZ edge self.kx_array_honey = np.linspace(-1.5 * 2 * np.pi / 3, 1.5 * 2 * np.pi / 3, 61) @@ -176,8 +182,8 @@ def __init__(self, trajectory): self.KX_honey, self.KY_honey = np.meshgrid( self.kx_array_honey, self.ky_array_honey ) - self.idx_x_honey = 30 - self.idx_y_honey = 30 + self.idx_x_honey = 50 + self.idx_y_honey = 50 # View settings self.init_delay = 20 @@ -498,7 +504,15 @@ def initialize_2D_band_plot(self): self.ax.set_yticks(np.linspace(-np.pi, np.pi, 5)) self.ax.set_yticklabels(["$-\pi/a$", "", "0", "", "$\pi/a$"]) - (self.point,) = self.ax.plot([0], [0], ".", c="crimson", markersize=10) + + self.x=np.pi/2 + self.y=np.pi/2 + self.idx_x = (np.abs(self.kx_array - self.x)).argmin() + self.idx_y = (np.abs(self.ky_array - self.y)).argmin() + + kx = self.kx_array[self.idx_x] + ky = self.ky_array[self.idx_y] + (self.point,) = self.ax.plot([kx], [ky], ".", c="crimson", markersize=10) # TODO CHANGE INITIAL MARKER POS self.fig.canvas.mpl_connect("button_press_event", self.onclick) plt.ion() @@ -544,7 +558,20 @@ def initialize_paths_bands(self): self.ax_.plot([20, 20], [0, 10000], "k--") self.ax_.plot([40, 40], [0, 10000], "k--") - (self.point_,) = self.ax_.plot([], [], "r.", markersize=10) + + self.x=np.pi/2 + self.y=np.pi/2 + self.idx_x = (np.abs(self.kx_array - self.x)).argmin() + self.idx_y = (np.abs(self.ky_array - self.y)).argmin() + + kx = self.kx_array[self.idx_x] + ky = self.ky_array[self.idx_y] + + # default chosen to be on gamma-M + idx = np.where(np.all([kx, ky] == np.c_[self.kx_GM, self.ky_GM], axis=1))[ + 0 + ][0] + (self.point_,) = self.ax_.plot([idx], [self.w_long[self.idx_x][self.idx_y]], "r.", markersize=10) # Position of the high symmetry points self.ax_.set_xticks([0, 20, 40, 60]) diff --git a/notebook/lattice-vibration/Phonon_2D.ipynb b/notebook/lattice-vibration/Phonon_2D.ipynb index a929280..fbd542f 100644 --- a/notebook/lattice-vibration/Phonon_2D.ipynb +++ b/notebook/lattice-vibration/Phonon_2D.ipynb @@ -100,9 +100,22 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "5ae458bbda7148e89af095238743499d", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "import matplotlib.pyplot as plt\n", "%matplotlib widget\n", @@ -122,7 +135,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -135,7 +148,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -149,7 +162,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -170,6 +183,21 @@ "\"\"\")\n", "\n", "\n", + "# Cause animation to play and loop by default.\n", + "stop = False\n", + "def loop(view):\n", + " import time\n", + " def do():\n", + " while True and not stop:\n", + " if view.frame == view.max_frame:\n", + " view.frame = 0\n", + " view.frame = view.frame + 1\n", + " time.sleep(0.2)\n", + " view._run_on_another_thread(do)\n", + " \n", + "view = handler.view \n", + "view.on_displayed(loop)\n", + "\n", "widgets = [\n", " handler.slider_amplitude,\n", " handler.slider_C1,\n", @@ -335,9 +363,26 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "\n" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "%%html\n", "