{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "from numpy.fft import fft, ifft, fftn, ifftn\n",
    "import scipy.signal\n",
    "import glob\n",
    "#import MDAnalysis as mda\n",
    "#from MDAnalysis.analysis import lineardensity as lin\n",
    "#import nglview as nv\n",
    "#import ipywidgets\n",
    "import matplotlib\n",
    "import matplotlib.pyplot as plt\n",
    "import matplotlib.colors as colors\n",
    "import matplotlib.ticker as ticker\n",
    "from matplotlib import cm\n",
    "#from functools import partial\n",
    "#import pathos.multiprocessing as mp"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Dispersion Maps\n",
    "### Copfe"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {},
   "outputs": [],
   "source": [
    "## In-bulk topological kappa_1,_2= 3000,1000 C-C-C-C-C... kappa_3 = kappa_4 = 1000\n",
    "## folder copfe/004\n",
    "## with b_0 = 1.9Å for all bonds\n",
    "## Figure 2 paper!!!\n",
    "fftxfefreeK=np.load(\"./gromacs/copfe/004/fftkx_200_nvt.copfe.52.freeKK.nj.52at.npy\")\n",
    "fftxfefreeM=np.load(\"./gromacs/copfe/004/fftkx_200_nvt.copfe.52.freeM.nj.52at.npy\")\n",
    "fftxfepbc=np.load(\"./gromacs/copfe/004/fftkx_200_nvt.copfe.52.pbc.nj.52at.npy\")\n",
    "fftxfefree=np.load(\"./gromacs/copfe/004/fftkx_200_nvt.copfe.52.free.nj.52at.npy\")\n",
    "fftxfefix=np.load(\"./gromacs/copfe/004/fftkx_200_nvt.copfe.52.fix.nj.52at.npy\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {},
   "outputs": [],
   "source": [
    "## In-bulk topological kappa_1,_2= 1000,3000 C-C-C-C-C... kappa_3 = kappa_4 = 1000\n",
    "## folder copfe/004/trivial\n",
    "## with b_0 = 1.9Å for all bonds\n",
    "## Figure SI 2 paper!!!\n",
    "fftxfefreeK=np.load(\"./gromacs/copfe/004/trivial/fftkx_200_nvt.copfe.52.freeK.nj.52at.npy\")\n",
    "fftxfefreeM=np.load(\"./gromacs/copfe/004/trivial/fftkx_200_nvt.copfe.52.freeM.nj.52at.npy\")\n",
    "fftxfepbc=np.load(\"./gromacs/copfe/004/trivial/fftkx_200_nvt.copfe.52.pbc.nj.52at.npy\")\n",
    "fftxfefree=np.load(\"./gromacs/copfe/004/trivial/fftkx_200_nvt.copfe.52.free.nj.52at.npy\")\n",
    "fftxfefix=np.load(\"./gromacs/copfe/004/trivial/fftkx_200_nvt.copfe.52.fix.nj.52at.npy\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 141772 characters]\n",
      "text/plain": [
       "<Figure size 1152x576 with 3 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 138496 characters]\n",
      "text/plain": [
       "<Figure size 1152x576 with 3 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 149092 characters]\n",
      "text/plain": [
       "<Figure size 1152x576 with 3 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 152796 characters]\n",
      "text/plain": [
       "<Figure size 1152x576 with 3 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 141392 characters]\n",
      "text/plain": [
       "<Figure size 1152x576 with 3 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "alldata=[fftxfepbc,fftxfefree,fftxfefreeK,fftxfefreeM,fftxfefix]\n",
    "for e in range(len(alldata)):\n",
    "    dataplot=alldata[e]\n",
    "    X=dataplot[0]/(33.35641)\n",
    "    Y=dataplot[1:]\n",
    "    X1=np.real(X)\n",
    "    Y1=np.real(Y)\n",
    "    stp=100\n",
    "    deltaf=(X1[1]-X1[0])\n",
    "    initfreq=0\n",
    "    finfreq=0.6\n",
    "    ifq=int(initfreq/deltaf)\n",
    "    ffq=int(finfreq/deltaf)\n",
    "    #y=np.real(X1[ifq:])\n",
    "    y=np.real(X1[ifq:ffq])\n",
    "    X2,Y2=np.meshgrid(range(-len(Y1)//2,len(Y1)//2),y)\n",
    "    Z=np.transpose(np.real(Y1[:,ifq:ffq]))\n",
    "\n",
    "    plt.figure(figsize=(16,8))\n",
    "    #plt.suptitle(\"Dispersion relation\", fontsize=14)\n",
    "\n",
    "    ax=plt.subplot(1, 2, 1)\n",
    "    s = \"Heat map - PSD of Rv\"\n",
    "    #plt.title(s,fontsize=14)\n",
    "    #plt.pcolormesh(X2/100,Y2,Z, cmap='jet', vmin=8, vmax=100,shading='auto')#vmax=np.max(Y1[stp,ifq+int(0.3/deltaf):ffq-int(0.3/deltaf)])/80)\n",
    "    plt.pcolormesh(X2/100,Y2,Z, cmap='jet', norm=colors.LogNorm(vmin=10, vmax=Z.max()*0.6),shading='auto')\n",
    "    plt.colorbar()\n",
    "    #plt.xlim(0,40)\n",
    "    #plt.zlim(0,30)\n",
    "    plt.ylabel('Frequency (cm$^{-1}$)', fontsize=20)\n",
    "    plt.xlabel('k$_x$ ($\\pi/a$)', fontsize=20)\n",
    "    plt.xticks(fontsize=16)\n",
    "    plt.yticks(fontsize=16)\n",
    "    ax.xaxis.set_major_locator(ticker.MultipleLocator(0.5))\n",
    "\n",
    "    bx=plt.subplot(1, 2, 2)\n",
    "    #s2='PSD'\n",
    "    #plt.title(s2)\n",
    "    #plt.legend()\n",
    "    plt.xlabel('PSD (Intensity)', fontsize=14)\n",
    "    #plt.ylabel('Freq (THz)')\n",
    "    plt.plot(Y1[stp]/1-1, X1,'b-')\n",
    "    #This X limit acts like the filter\n",
    "    plt.ylim(initfreq,finfreq)\n",
    "    plt.xlim(np.min(Y1),np.max(Y1[stp,ifq+int(0.1/deltaf):ffq-int(0./deltaf)])/0.9)\n",
    "    bx.set_xscale(\"log\")\n",
    "    plt.xticks(fontsize=16)\n",
    "    plt.yticks(fontsize=16)\n",
    "    #bx.yaxis.set_major_locator(ticker.MultipleLocator(0.02))\n",
    "    #bx.xaxis.set_major_locator(ticker.MultipleLocator(50))\n",
    "    plt.grid()\n",
    "    #plt.savefig(\"dispX_cop.1k.pbc.100K.\"+str(initfreq)+\"-\"+str(finfreq)+\"cm-1.png\") # The graphs can be as PNG, SVG, BMP or PDF"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "## In-bulk topological kappa_1,_2= 3000,1000 C-C-C-C-C... kappa_3 = kappa_4 = 1000\n",
    "## folder copfe/004/004a\n",
    "## replica 004\n",
    "# mismatch\n",
    "fftxfefreeK=np.load(\"./gromacs/copfe/004/004a/fftkx_200_nvt.copfe.52.freeK.nj.52at.npy\")\n",
    "fftxfefreeM=np.load(\"./gromacs/copfe/004/004a/fftkx_200_nvt.copfe.52.freeM.nj.52at.npy\")\n",
    "fftxfepbc=np.load(\"./gromacs/copfe/004/004a/fftkx_200_nvt.copfe.52.pbc.nj.52at.npy\")\n",
    "fftxfefree=np.load(\"./gromacs/copfe/004/004a/fftkx_200_nvt.copfe.52.free.nj.52at.npy\")\n",
    "fftxfefix=np.load(\"./gromacs/copfe/004/004a/fftkx_200_nvt.copfe.52.fix.nj.52at.npy\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 228,
   "metadata": {},
   "outputs": [],
   "source": [
    "## In-bulk trivial kappa_1,_2= 1000,3000 C-C-C-C-C... kappa_3 = kappa_4 = 1000\n",
    "## folder copfe/006\n",
    "fftxfefreeK=np.load(\"./gromacs/copfe/006/fftkx_200_nvt.copfe.52.freeKK.nj.52at.npy\")\n",
    "fftxfefreeK1=np.load(\"./gromacs/copfe/006/fftkx_200_nvt.copfe.52.freeK1.nj.52at.npy\")\n",
    "fftxfefreeK52=np.load(\"./gromacs/copfe/006/fftkx_200_nvt.copfe.52.freeK52.nj.52at.npy\")\n",
    "#fftxfepbc=np.load(\"./gromacs/copfe/006/fftkx_200_nvt.copfe.52.pbc.nj.52at.npy\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [],
   "source": [
    "## In-bulk topological kappa_1,_2= 3000,1000 C-C-C-C-C... kappa_3 = kappa_4 = 1000\n",
    "## folder copfe/008, similar to copfe/004 but with b_0 = 2Å for all bonds\n",
    "## Figure 2 paper!!\n",
    "fftxfefreeK=np.load(\"./gromacs/copfe/008/fftkx_200_nvt.copfe.52.freeK.nj.52at.npy\") # k_strong=10^6kJ/mol/nm\n",
    "fftxfefreeK2=np.load(\"./gromacs/copfe/008/fftkx_200_nvt.copfe.52.freeK-10p5.nj.52at.npy\") # k_strong=10^5kJ/mol/nm\n",
    "fftxfefreeK1=np.load(\"./gromacs/copfe/008/fftkx_200_nvt.copfe.52.freeK_1.nj.52at.npy\") # k_strong=10^4kJ/mol/nm\n",
    "fftxfefreeM=np.load(\"./gromacs/copfe/008/fftkx_200_nvt.copfe.52.freeM.nj.52at.npy\")\n",
    "fftxfefreeS=np.load(\"./gromacs/copfe/008/fftkx_200_nvt.copfe.52.freeS.nj.52at.npy\") # k_strong (within cop)=10^4kJ/mol/nm\n",
    "fftxfepbc=np.load(\"./gromacs/copfe/008/fftkx_200_nvt.copfe.52.pbc.nj.52at.npy\")\n",
    "fftxfefree=np.load(\"./gromacs/copfe/008/fftkx_200_nvt.copfe.52.free.nj.52at.npy\")\n",
    "fftxfefix=np.load(\"./gromacs/copfe/008/fftkx_200_nvt.copfe.52.fix.nj.52at.npy\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "## In-bulk topological kappa_1,_2= 3000,1000 C-C-C-C-C... kappa_3 = kappa_4 = 1000\n",
    "## folder copfe/009, similar to copfe/004 but with b_0 = 2Å for all bonds\n",
    "## tau-t=10ps\n",
    "fftxfefreeK=np.load(\"./gromacs/copfe/009/fftkx_200_nvt.copfe.52.freeK.nj.52at.npy\")\n",
    "fftxfefreeM=np.load(\"./gromacs/copfe/009/fftkx_200_nvt.copfe.52.freeM.nj.52at.npy\")\n",
    "fftxfepbc=np.load(\"./gromacs/copfe/009/fftkx_200_nvt.copfe.52.pbc.nj.52at.npy\")\n",
    "fftxfefree=np.load(\"./gromacs/copfe/009/fftkx_200_nvt.copfe.52.free.nj.52at.npy\")\n",
    "fftxfefix=np.load(\"./gromacs/copfe/009/fftkx_200_nvt.copfe.52.fix.nj.52at.npy\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [],
   "source": [
    "## Trivial kappa_1,_2= 1000,3000 C-C-C-C-C... kappa_3 = kappa_4 = 1000\n",
    "## folder copfe/010, similar to copfe/004 but with b_0 = 2Å for all bonds\n",
    "## Figure 2 paper!!\n",
    "fftxfefreeK=np.load(\"./gromacs/copfe/010/fftkx_200_nvt.copfe.52.freeK.nj.52at.npy\")\n",
    "fftxfefreeM=np.load(\"./gromacs/copfe/010/fftkx_200_nvt.copfe.52.freeM.nj.52at.npy\")\n",
    "fftxfepbc=np.load(\"./gromacs/copfe/010/fftkx_200_nvt.copfe.52.pbc.nj.52at.npy\")\n",
    "fftxfefree=np.load(\"./gromacs/copfe/010/fftkx_200_nvt.copfe.52.free.nj.52at.npy\")\n",
    "fftxfefix=np.load(\"./gromacs/copfe/010/fftkx_200_nvt.copfe.52.fix.nj.52at.npy\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "## In-bulk topological kappa_1,_2= 3000,1000 C-C-C-C-C... kappa_3 = kappa_4 = 1000\n",
    "## folder copfe/011, similar to copfe/004 but with b_0 = 2Å for all bonds\n",
    "## tau-t=100ps\n",
    "fftxfefreeK=np.load(\"./gromacs/copfe/011/fftkx_200_nvt.copfe.52.freeK.nj.52at.npy\")\n",
    "fftxfefreeM=np.load(\"./gromacs/copfe/011/fftkx_200_nvt.copfe.52.freeM.nj.52at.npy\")\n",
    "fftxfepbc=np.load(\"./gromacs/copfe/011/fftkx_200_nvt.copfe.52.pbc.nj.52at.npy\")\n",
    "fftxfefree=np.load(\"./gromacs/copfe/011/fftkx_200_nvt.copfe.52.free.nj.52at.npy\")\n",
    "fftxfefix=np.load(\"./gromacs/copfe/011/fftkx_200_nvt.copfe.52.fix.nj.52at.npy\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {},
   "outputs": [],
   "source": [
    "## In-bulk topological kappa_1,_2= 3000,1000 C-C-C-C-C... kappa_3 = kappa_4 = 1000\n",
    "## folder copfe/012, similar to copfe/004 but with b_0 = 0Å for all bonds\n",
    "fftxfefreeK=np.load(\"./gromacs/copfe/012/fftkx_200_nvt.copfe.52.freeK.nj.52at.npy\")\n",
    "fftxfefreeM=np.load(\"./gromacs/copfe/012/fftkx_200_nvt.copfe.52.freeM.nj.52at.npy\")\n",
    "fftxfepbc=np.load(\"./gromacs/copfe/012/fftkx_200_nvt.copfe.52.pbc.nj.52at.npy\")\n",
    "fftxfefree=np.load(\"./gromacs/copfe/012/fftkx_200_nvt.copfe.52.free.nj.52at.npy\")\n",
    "fftxfefix=np.load(\"./gromacs/copfe/012/fftkx_200_nvt.copfe.52.fix.nj.52at.npy\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [],
   "source": [
    "## trivial kappa_1,_2= 1000,3000 C-C-C-C-C... kappa_3 = kappa_4 = 1000\n",
    "## folder copfe/014, similar to copfe/004 but with b_0 = 0Å for all bonds\n",
    "fftxfefreeK=np.load(\"./gromacs/copfe/014/fftkx_200_nvt.copfe.52.freeK.nj.52at.npy\")\n",
    "fftxfefreeM=np.load(\"./gromacs/copfe/014/fftkx_200_nvt.copfe.52.freeM.nj.52at.npy\")\n",
    "fftxfepbc=np.load(\"./gromacs/copfe/014/fftkx_200_nvt.copfe.52.pbc.nj.52at.npy\")\n",
    "fftxfefree=np.load(\"./gromacs/copfe/014/fftkx_200_nvt.copfe.52.free.nj.52at.npy\")\n",
    "fftxfefix=np.load(\"./gromacs/copfe/014/fftkx_200_nvt.copfe.52.fix.nj.52at.npy\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [],
   "source": [
    "## In-bulk topological kappa_1,_2= 3000,1000 C-C-C-C-C... kappa_3 = kappa_4 = 1000\n",
    "## folder copfe/015, similar to copfe/004 but with b_0 = 0Å for all bonds\n",
    "## tau-t=100ps\n",
    "fftxfefreeK=np.load(\"./gromacs/copfe/015/fftkx_200_nvt.copfe.52.freeK.nj.52at.npy\")\n",
    "fftxfefreeM=np.load(\"./gromacs/copfe/015/fftkx_200_nvt.copfe.52.freeM.nj.52at.npy\")\n",
    "fftxfepbc=np.load(\"./gromacs/copfe/015/fftkx_200_nvt.copfe.52.pbc.nj.52at.npy\")\n",
    "fftxfefree=np.load(\"./gromacs/copfe/015/fftkx_200_nvt.copfe.52.free.nj.52at.npy\")\n",
    "fftxfefix=np.load(\"./gromacs/copfe/015/fftkx_200_nvt.copfe.52.fix.nj.52at.npy\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [],
   "source": [
    "## In-bulk topological kappa_1,_2= 3000,1000 C-C-C-C-C... kappa_3 = kappa_4 = 1000\n",
    "## folder copfe/016, d_subs = 0Å\n",
    "## similar to 012, but with mismatch\n",
    "fftxfefreeK=np.load(\"./gromacs/copfe/016/fftkx_200_nvt.copfe.52.freeK.nj.52at.npy\")\n",
    "fftxfefreeM=np.load(\"./gromacs/copfe/016/fftkx_200_nvt.copfe.52.freeM.nj.52at.npy\")\n",
    "fftxfepbc=np.load(\"./gromacs/copfe/016/fftkx_200_nvt.copfe.52.pbc.nj.52at.npy\")\n",
    "fftxfefree=np.load(\"./gromacs/copfe/016/fftkx_200_nvt.copfe.52.free.nj.52at.npy\")\n",
    "fftxfefix=np.load(\"./gromacs/copfe/016/fftkx_200_nvt.copfe.52.fix.nj.52at.npy\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
