Add the size vs. lMax script from triton.
Former-commit-id: b2670f5fb1c54242dd670a4e71eb018a85e2ea6c
This commit is contained in:
parent
7f2e36e956
commit
14e415dfc5
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,19 @@
|
|||
#!/bin/bash
|
||||
#SBATCH --mem=200
|
||||
#SBATCH -t 30:00
|
||||
#SBATCH -c 4
|
||||
#SBATCH -p short-ivb
|
||||
#SBATCH --array=0-250
|
||||
|
||||
cat $0
|
||||
|
||||
contour_points=410
|
||||
|
||||
#radii_nm=(`seq 80 1 150`)
|
||||
radii_nm=(`seq 50 1 300`)
|
||||
radius_nm=${radii_nm[$SLURM_ARRAY_TASK_ID]}
|
||||
|
||||
for lMax in $(seq 1 5); do
|
||||
srun rectlat_simple_modes.py -p 580e-9 -m '4+0.7j' -r ${radius_nm}e-9 -k 0 0 --kpi -n 1.52 -L lMax -t 1e11 -b -2 -f 0.1 -i 1. -T .3 -N ${contour_points}
|
||||
done
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
|
||||
kx=0.0
|
||||
contour_points=410
|
||||
|
||||
radii_nm=(`seq 50 1 300`)
|
||||
radius_nm=${radii_nm[$SLURM_ARRAY_TASK_ID]}
|
||||
|
||||
for lMax in $(seq 1 5) ; do
|
||||
for radius_nm in $(seq 50 1 300) ; do
|
||||
rectlat_simple_modes.py -p 580e-9 -m 'Au' -r ${radius_nm}e-9 -k $kx 0 --kpi -n 1.52 -L $lMax -t 1e11 -b -2 -f 0.1 -i 1. -T .3 -N ${contour_points} --lMax-extend 10
|
||||
done
|
||||
done
|
|
@ -0,0 +1,11 @@
|
|||
#!/bin/bash
|
||||
|
||||
kx=0.0
|
||||
contour_points=410
|
||||
|
||||
radii_nm=(`seq 50 1 300`)
|
||||
radius_nm=${radii_nm[$SLURM_ARRAY_TASK_ID]}
|
||||
|
||||
for radius_nm in $(seq 50 1 300) ; do
|
||||
rectlat_simple_modes.py -p 580e-9 -m 'Au' -r ${radius_nm}e-9 -k $kx 0 --kpi -n 1.52 -L 1 -t 1e11 -b -2 -f 0.1 -i 1. -T .3 -N ${contour_points}
|
||||
done
|
|
@ -0,0 +1,300 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%matplotlib inline\n",
|
||||
"import re\n",
|
||||
"import numpy as np\n",
|
||||
"import matplotlib\n",
|
||||
"from matplotlib import pyplot as plt\n",
|
||||
"from scipy.constants import hbar, e as eV, c\n",
|
||||
"eh = eV/hbar\n",
|
||||
"import glob\n",
|
||||
"def ri(z): return (z.real, z.imag)\n",
|
||||
"#m = re.compile(r\"([^_]+)_r([0-9.]+)nm_\")\n",
|
||||
"#removek = re.compile(r\"(k\\([^)]+\\)um-1_)\")\n",
|
||||
"remover = re.compile(r\"r[0-9.]+nm_\")\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"markerdict = {\n",
|
||||
" 4: \"3\",\n",
|
||||
" -4: \"4\",\n",
|
||||
" 3: \"^\",\n",
|
||||
" -3: \"v\",\n",
|
||||
" -2: 'x',\n",
|
||||
" 2: '+',\n",
|
||||
" 1: 's',\n",
|
||||
" -1: 'd',\n",
|
||||
"}\n",
|
||||
"\n",
|
||||
"prop_cycle = plt.rcParams['axes.prop_cycle']\n",
|
||||
"colors = prop_cycle.by_key()['color']\n",
|
||||
"colordict = {i: colors[(i+1)] for i in range(-4,8)}\n",
|
||||
"\n",
|
||||
"def markerfun(b):\n",
|
||||
" if b in markerdict.keys():\n",
|
||||
" return markerdict[b]\n",
|
||||
" else: return 'X'\n",
|
||||
"\n",
|
||||
"def colorfun(b):\n",
|
||||
" if (b+1) in colordict.keys():\n",
|
||||
" return colordict[b+1]\n",
|
||||
" else: return colordict[0]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"allfiles=glob.glob('*sph*k(0_0)*.npz')\n",
|
||||
"allgraphs=dict()\n",
|
||||
"for f in allfiles:\n",
|
||||
" base = remover.sub('', f)\n",
|
||||
" if base in allgraphs.keys():\n",
|
||||
" allgraphs[base] += 1\n",
|
||||
" else:\n",
|
||||
" allgraphs[base] = 1\n",
|
||||
"for k in sorted(allgraphs.keys()):\n",
|
||||
" print(k, allgraphs[k])"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"ename": "FileNotFoundError",
|
||||
"evalue": "[Errno 2] No such file or directory: 'projectors_D4h_lMax1.npz'",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
||||
"\u001b[0;31mFileNotFoundError\u001b[0m Traceback (most recent call last)",
|
||||
"\u001b[0;32m<ipython-input-3-0c266089be08>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mlMaxes\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0mlMax\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mlMax\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m6\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mlMax\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mlMaxes\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 5\u001b[0;31m \u001b[0mproj\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mload\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'projectors_D4h_lMax%d.npz'\u001b[0m \u001b[0;34m%\u001b[0m \u001b[0mlMax\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 6\u001b[0m \u001b[0mirlabels\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0msorted\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mproj\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mkeys\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 7\u001b[0m \u001b[0mproj\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m{\u001b[0m\u001b[0mf\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mproj\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mf\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mf\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mirlabels\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
||||
"\u001b[0;32m~/.local/lib/python3.7/site-packages/numpy-1.17.3-py3.7-linux-x86_64.egg/numpy/lib/npyio.py\u001b[0m in \u001b[0;36mload\u001b[0;34m(file, mmap_mode, allow_pickle, fix_imports, encoding)\u001b[0m\n\u001b[1;32m 426\u001b[0m \u001b[0mown_fid\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mFalse\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 427\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 428\u001b[0;31m \u001b[0mfid\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mopen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mos_fspath\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfile\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"rb\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 429\u001b[0m \u001b[0mown_fid\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mTrue\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 430\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
|
||||
"\u001b[0;31mFileNotFoundError\u001b[0m: [Errno 2] No such file or directory: 'projectors_D4h_lMax1.npz'"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"projectors = dict()\n",
|
||||
"projectors_list = dict()\n",
|
||||
"lMaxes = [lMax for lMax in range(1,6)]\n",
|
||||
"for lMax in lMaxes:\n",
|
||||
" proj = np.load('projectors_D4h_lMax%d.npz' % lMax)\n",
|
||||
" irlabels = sorted(proj.keys())\n",
|
||||
" proj = {f: proj[f] for f in irlabels}\n",
|
||||
" proj_list = [proj[irlabels[i]] for i in range(len(proj))]\n",
|
||||
" projectors[lMax] = proj\n",
|
||||
" projectors_list[lMax] = proj_list\n",
|
||||
"globpattern = '*sph_r*_p580nmx580nm_mAu_n1.52_b?2_k(0_0)um-1_L?_cn???.npz'\n",
|
||||
"filenames=glob.glob(globpattern)\n",
|
||||
"plotfilename = 'collected_' + globpattern.replace('*', 'XXX').replace('?', 'X').replace('npz','pdf')\n",
|
||||
"print(filenames[:4], plotfilename)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 41,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"#projectors\n",
|
||||
"#glob.glob('cyl_r100nm*L3*3100.npz')\n",
|
||||
"#glob.glob('sph_r100*m5*.npz')\n",
|
||||
"#dat['meta'][()],list(dat.keys())"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 42,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"inpure result detected [1. 0.99999999 1. 0.97991334 0.99999996 0.9999989\n",
|
||||
" 0.99999983 0.99999966 0.99999322 0.99999721 0.99999653] [3.28735741e-04 2.66532534e-05 2.47011478e-05 1.45012420e-01\n",
|
||||
" 2.44785416e-04 7.05405359e-04 1.60203586e-03 1.71245137e-03\n",
|
||||
" 1.03244480e-02 9.18732728e-03 1.18651583e-02]\n",
|
||||
"inpure result detected [1. 1. 0.99999998 0.99999999 0.99999996 0.96608887\n",
|
||||
" 0.99999852 0.99999397 0.99998951 0.99999912 0.99982435] [2.66223026e-04 2.12357147e-05 3.54211968e-05 1.06651057e-04\n",
|
||||
" 2.79595790e-04 2.41939163e-01 2.17645058e-03 3.41541473e-03\n",
|
||||
" 1.14507609e-02 1.49639498e-02 2.33483138e-02]\n",
|
||||
"inpure result detected [1. 1. 0.92521572 1. 0.99999627 0.99990293\n",
|
||||
" 0.99946049] [1.59712906e-05 3.60193407e-05 2.48341492e-01 1.21848930e-03\n",
|
||||
" 3.81805601e-03 2.42649228e-02 2.99534246e-02]\n",
|
||||
"inpure result detected [1. 1. 0.99999998 0.99999961 0.93267685 0.99999964\n",
|
||||
" 0.99999822 0.99921774 0.99995547 0.99997301] [5.22490396e-04 3.01556792e-05 4.88795563e-05 6.29703960e-04\n",
|
||||
" 2.34414238e-01 3.72766210e-03 4.72444059e-03 7.62106094e-02\n",
|
||||
" 6.32796684e-02 5.63231562e-02]\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"plotdata = {}\n",
|
||||
"for file in filenames:\n",
|
||||
" dat = np.load(file, allow_pickle=True)\n",
|
||||
" kx = dat['meta'][()]['k'][0]\n",
|
||||
" radius = dat['meta'][()]['radius']\n",
|
||||
" b = dat['meta'][()]['band_index']\n",
|
||||
" eigvals = dat['eigval']\n",
|
||||
" lMax = dat['meta'][()]['lMax']\n",
|
||||
" residuals = dat['residuals']\n",
|
||||
" ef =dat['empty_freqs']\n",
|
||||
" eigvecs = dat['eigvec']\n",
|
||||
" irweights = []\n",
|
||||
" #for proj in projectors_list[lMax]:\n",
|
||||
" # try:\n",
|
||||
" # irweights.append(np.linalg.norm(np.tensordot(proj, eigvecs, axes=(-1, -1)), axis=0,ord=2) if len(proj) != 0 else np.zeros((len(eigvecs),)))\n",
|
||||
" # except ValueError as err:\n",
|
||||
" # print(proj, len(proj))\n",
|
||||
" # raise err\n",
|
||||
" irweights = np.array(irweights)\n",
|
||||
" #print(irweights)\n",
|
||||
" irweights = np.array([np.linalg.norm(np.tensordot(proj, eigvecs, axes=(-1, -1)), axis=0,ord=2) if len(proj) != 0 else np.zeros((len(eigvecs),)) for proj in projectors_list[lMax]]).T\n",
|
||||
" irclass = np.argmax(irweights, axis=-1)\n",
|
||||
" purities = np.amax(irweights, axis=-1)\n",
|
||||
" if (np.any(purities < 0.98)):\n",
|
||||
" print(\"inpure result detected\", purities, residuals)\n",
|
||||
" #print(purities)\n",
|
||||
" \n",
|
||||
" #for i in range(len(residuals)): \n",
|
||||
" # if residuals[i] < 0.01:\n",
|
||||
" # vec = eigvecs[i]\n",
|
||||
" # for irlabel, proj in projectors.items():\n",
|
||||
" # print(irlabel, np.linalg.norm(np.dot(proj, vec))) #maybe some conj() here?\n",
|
||||
" # print('--->', irlabels[irclass[i]])\n",
|
||||
"\n",
|
||||
" \n",
|
||||
" plotdata[(lMax,radius)] = (eigvals, residuals, b, ef, irclass,)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"fig = plt.figure(figsize=(15,6))\n",
|
||||
"axesR = {}\n",
|
||||
"axesI = {}\n",
|
||||
"for i, lMax in enumerate(lMaxes):\n",
|
||||
" axesR[lMax] = fig.add_subplot(2,len(lMaxes),i+1)\n",
|
||||
" axesR[lMax].set_xlim([50,300])\n",
|
||||
" axesR[lMax].set_ylim([1.25, ef[1]/eh])\n",
|
||||
" axesI[lMax] = fig.add_subplot(2,len(lMaxes),len(lMaxes)+i+1)\n",
|
||||
" axesI[lMax].set_xlim([50,300])\n",
|
||||
" axesI[lMax].set_ylim([-60, 30])\n",
|
||||
" axesR[lMax].set_title('$l_\\max = %d $' % lMax) \n",
|
||||
" axesR[lMax].tick_params(labelbottom=False) \n",
|
||||
" if i == len(lMaxes)//2:\n",
|
||||
" axesI[lMax].set_xlabel(\"Particle base radius / nm\")\n",
|
||||
" if i == 0:\n",
|
||||
" axesR[lMax].set_ylabel('$\\hbar \\Re \\omega / \\mathrm{eV}$')\n",
|
||||
" axesI[lMax].set_ylabel('$\\hbar \\Im \\omega / \\mathrm{meV}$')\n",
|
||||
" else:\n",
|
||||
" axesR[lMax].tick_params(labelleft=False) \n",
|
||||
" axesI[lMax].tick_params(labelleft=False) \n",
|
||||
"\n",
|
||||
"res_thr = 0.005\n",
|
||||
"\n",
|
||||
"ir_labeled=set()\n",
|
||||
"if True:\n",
|
||||
" for (lMax, radius), (eigvals, residuals, b, ef, irclass) in plotdata.items():\n",
|
||||
" for i, (e, res, iri) in enumerate(zip(eigvals, residuals, irclass)):\n",
|
||||
" #if i == 0:\n",
|
||||
" if res < res_thr:# and e.real < 2.14e15:\n",
|
||||
" if iri in ir_labeled: \n",
|
||||
" label=None\n",
|
||||
" else:\n",
|
||||
" ir_labeled.add(iri)\n",
|
||||
" label=irlabels[iri]\n",
|
||||
" axesR[lMax].plot(radius*1e9, e.real/eh, \n",
|
||||
" marker='.',\n",
|
||||
" #marker=markerfun(b),\n",
|
||||
" ms=4, #c=colorfun(b)\n",
|
||||
" c=matplotlib.cm.hsv(iri/9),\n",
|
||||
" #c = colorfun(iri),\n",
|
||||
" label=label,\n",
|
||||
" )\n",
|
||||
" axesI[lMax].plot(radius*1e9, e.imag/eh*1000, \n",
|
||||
" #marker='x', \n",
|
||||
" #c=colorfun(b), \n",
|
||||
" c=matplotlib.cm.hsv(iri/9),#colorfun(iri),\n",
|
||||
" marker='.', #markerfun(b),\n",
|
||||
" ms=4,\n",
|
||||
" #label=label\n",
|
||||
" )\n",
|
||||
"fig.legend(title=\"Irrep\", loc=\"center right\")\n",
|
||||
"#fig.suptitle('$l_\\mathrm{max}=%d$, residual threshold = %g' % (lMax, res_thr) )\n",
|
||||
"fig.savefig(plotfilename)\n",
|
||||
"fig.savefig(plotfilename.replace('pdf', 'png'))\n",
|
||||
"print(plotfilename)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 55,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"array([0. , 1.40635433, 1.98888536, 2.81270865, 3.14470387,\n",
|
||||
" 3.97777072, 4.21906298, 4.44728287])"
|
||||
]
|
||||
},
|
||||
"execution_count": 55,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"ef / eh"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"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.7.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 4
|
||||
}
|
Loading…
Reference in New Issue