Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix the pseudopotential bugs #323

Merged
merged 1 commit into from
May 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 39 additions & 28 deletions notebook/band-theory/pseudopotential.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"img = plt.figure(tight_layout=True, figsize=(9,9))\n",
Expand Down Expand Up @@ -395,13 +397,13 @@
" x1 = np.arange(0, 50.0, 0.01)\n",
" y1 = rf(x1)*x1\n",
" line_rho.set_data([x1, y1])\n",
" line_rc1.set_data(s_rc.value, [-1, 1])\n",
" line_rc1.set_data([s_rc.value], [-1, 1])\n",
" ann_rc.set_position((s_rc.value + 1.0, rf(s_rc.value)*s_rc.value))\n",
"\n",
" x2 = np.arange(0, 50.0, 0.01)\n",
" y2 = (rf(x2)*x2)**2\n",
" line_rho2.set_data([x2, y2])\n",
" line_rc2.set_data(s_rc.value, [-1, 1])\n",
" line_rc2.set_data([s_rc.value], [-1, 1])\n",
" ann_rc2.set_position((s_rc.value + 1.0, (rf(s_rc.value)*s_rc.value)**2))\n",
" \n",
"\n",
Expand All @@ -420,17 +422,19 @@
" line_logdr_ps.set_data([],[])\n",
" \n",
" # line_logdr_rho.set_data([x3, y3])\n",
" line_rc3.set_data(s_rc.value, [-1, 1])\n",
" line_rc4.set_data(s_rc.value, [-1, 1])\n",
" line_rc3.set_data([s_rc.value], [-1, 1])\n",
" line_rc4.set_data([s_rc.value], [-1, 1])\n",
"\n",
" ann_rc2.set_position((s_rc.value + 1.0, (rf(s_rc.value)*s_rc.value)**2))\n",
" \n",
" \n",
"\n",
" ax1.collections.clear()\n",
" ax2.collections.clear()\n",
" ax3.collections.clear()\n",
" for line in ax1.collections:\n",
" line.remove()\n",
" \n",
" for line in ax2.collections:\n",
" line.remove()\n",
"\n",
" for line in ax3.collections:\n",
" line.remove()\n",
"\n",
" ax2.fill_between(x2, y2, 0, where=x2<s_rc.value, facecolor='yellow', alpha=0.5)\n",
" ax1.hlines(0, 0, 50, 'k','--')\n",
Expand All @@ -440,8 +444,8 @@
" line_pswf2.set_data([],[])\n",
"\n",
" line_psv.set_data([],[])\n",
" point.set_data(s_rc.value, rf(s_rc.value)*s_rc.value)\n",
" point2.set_data(s_rc.value, (rf(s_rc.value)*s_rc.value)**2)\n",
" point.set_data([s_rc.value], [rf(s_rc.value)*s_rc.value])\n",
" point2.set_data([s_rc.value], [(rf(s_rc.value)*s_rc.value)**2])\n",
"\n",
" ax1.set_ylim([y1.min()-0.04, y1.max()+0.04])\n",
" ax2.set_ylim([y2.min()-0.04, y2.max()+0.04])\n",
Expand All @@ -466,24 +470,31 @@
" x2 = np.arange(0, 50.0, 0.01)\n",
" y2 = (rf(x2)*x2)**2\n",
" \n",
" line_rc1.set_data(s_rc.value, [-1, 1])\n",
" line_rc2.set_data(s_rc.value, [-1, 1])\n",
" line_rc3.set_data(s_rc.value, [-1, 1])\n",
" line_rc4.set_data(s_rc.value, [-1, 1])\n",
" line_rc1.set_data([s_rc.value], [-1, 1])\n",
" line_rc2.set_data([s_rc.value], [-1, 1])\n",
" line_rc3.set_data([s_rc.value], [-1, 1])\n",
" line_rc4.set_data([s_rc.value], [-1, 1])\n",
"\n",
" ann_rc.set_position((s_rc.value + 1.0, rf(s_rc.value)*s_rc.value))\n",
" ax1.collections.clear()\n",
" ax2.collections.clear()\n",
" ax3.collections.clear()\n",
" \n",
" for line in ax1.collections:\n",
" line.remove()\n",
" \n",
" for line in ax2.collections:\n",
" line.remove()\n",
"\n",
" for line in ax3.collections:\n",
" line.remove()\n",
"\n",
"\n",
" ax2.fill_between(x2, y2, 0, where=x2<s_rc.value, facecolor='yellow', alpha=0.5)\n",
" ax2.hlines(0, 0, 50, 'k','--')\n",
" line_pswf.set_data([],[])\n",
" line_pswf2.set_data([],[])\n",
" line_psv.set_data([],[])\n",
" point.set_data(s_rc.value, rf(s_rc.value)*s_rc.value)\n",
" point2.set_data(s_rc.value, (rf(s_rc.value)*s_rc.value)**2)\n",
" point.set_data([s_rc.value], rf(s_rc.value)*s_rc.value)\n",
" point2.set_data([s_rc.value], (rf(s_rc.value)*s_rc.value)**2)\n",
" ax1.hlines(0, 0, 50, 'k','--')\n",
"\n",
" clear_texts()\n",
" \n",
Expand Down Expand Up @@ -583,8 +594,8 @@
" # x3 = np.linspace(0, rc, 800);\n",
" x3 = np.arange(0, 50.0, 0.01)\n",
"\n",
" line_pswf.set_data(x1, psf(x1));\n",
" line_pswf2.set_data(x2, psf2(x2));\n",
" line_pswf.set_data([x1], [psf(x1)]);\n",
" line_pswf2.set_data([x2], [psf2(x2)]);\n",
"\n",
" ax2.fill_between(x2, psf2(x2), 0, where=x2<s_rc.value, facecolor='green', alpha=0.5)\n",
" \n",
Expand All @@ -595,10 +606,10 @@
" logr = diff(ho, r).subs(r, rc).evalf()/ho.subs(r, rc).evalf()\n",
" \n",
" \n",
" line_logdr_rho.set_data(x3,logr_r(x3))\n",
" line_logdr_ps.set_data(x3,logl_r(x3))\n",
" line_logdr_rho.set_data([x3],[logr_r(x3)])\n",
" line_logdr_ps.set_data([x3],[logl_r(x3)])\n",
" \n",
" point3.set_data(s_rc.value, logr_r(s_rc.value))\n",
" point3.set_data([s_rc.value], [logr_r(s_rc.value)])\n",
" ann_rc3.remove()\n",
" ann_rc3 = ax3.annotate(\"$R_c$\", xy=(s_rc.value + 1.0,logr_r(s_rc.value)) , fontsize=20)\n",
" # ann_rc3.set_position((s_rc.value + 1.0,logr_r(s_rc.value)))\n",
Expand Down Expand Up @@ -640,7 +651,7 @@
" \n",
" x1 = np.linspace(0.001, rc, 800);\n",
" x2 = np.linspace(rc, 50, 800);\n",
" line_psv.set_data(np.concatenate((x1,x2)), np.concatenate((psfnl(x1),psfnr(x2))));\n",
" line_psv.set_data([np.concatenate((x1,x2))], [np.concatenate((psfnl(x1),psfnr(x2)))]);\n",
" ax4.set_ylim([psfnl(x1).min(axis=0)-0.05, max(psfnl(x1).max(axis=0)+0.1, 0.05)])\n",
"\n",
"def compute_pseudopotential(c):\n",
Expand Down Expand Up @@ -733,7 +744,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.12"
"version": "3.11.7"
},
"voila": {
"authors": "Dou Du and Giovanni Pizzi"
Expand Down
Loading