Skip to content

Commit

Permalink
fix & reorg jupyter notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
eimrek committed Feb 5, 2025
1 parent 527ce85 commit fb4d360
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 88 deletions.
24 changes: 10 additions & 14 deletions ftsts_analysis.ipynb → notebooks/ftsts_analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
"source": [
"lat_param = 4.37 # angstrom\n",
"\n",
"wfn_file = \"./examples/polyphenylene_cp2k_scf/PROJ-RESTART.wfn\"\n",
"xyz_file = \"./examples/polyphenylene_cp2k_scf/ppp_12uc-opt.xyz\"\n",
"cp2k_inp = \"./examples/polyphenylene_cp2k_scf/cp2k.inp\"\n",
"basis_file = \"./examples/BASIS_MOLOPT\""
"wfn_file = \"../examples/data/polyphenylene_cp2k_scf/PROJ-RESTART.wfn\"\n",
"xyz_file = \"../examples/data/polyphenylene_cp2k_scf/ppp_12uc-opt.xyz\"\n",
"cp2k_inp = \"../examples/data/polyphenylene_cp2k_scf/cp2k.inp\"\n",
"basis_file = \"../examples/data/BASIS_MOLOPT\""
]
},
{
Expand Down Expand Up @@ -71,9 +71,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"cp2k_grid_orb.calc_morbs_in_region(0.10,\n",
Expand All @@ -98,8 +96,8 @@
"metadata": {},
"outputs": [],
"source": [
"qe_scf_xml = \"./examples/polyphenylene_qe_bands/scf.xml\"\n",
"qe_bands_xml = \"./examples/polyphenylene_qe_bands/bands.xml\"\n",
"qe_scf_xml = \"../examples/data/polyphenylene_qe_bands/scf.xml\"\n",
"qe_bands_xml = \"../examples/data/polyphenylene_qe_bands/bands.xml\"\n",
"\n",
"qe_kpts = None\n",
"qe_bands = None\n",
Expand Down Expand Up @@ -205,9 +203,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"for i_mo_wrt_homo in range(index_end, index_start-1, -1):\n",
Expand Down Expand Up @@ -246,7 +242,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "cp2k-spm-tools",
"language": "python",
"name": "python3"
},
Expand All @@ -260,7 +256,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.9"
"version": "3.10.16"
}
},
"nbformat": 4,
Expand Down
64 changes: 22 additions & 42 deletions overlap_viewer.ipynb → notebooks/overlap_viewer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,10 @@
"outputs": [],
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import cp2k_spm_tools.postprocess.overlap as pp"
"import matplotlib.pyplot as plt\n",
"import cp2k_spm_tools.postprocess.overlap as pp\n",
"\n",
"# NOTE: Generate the output of the examples first!"
]
},
{
Expand All @@ -25,8 +19,8 @@
"metadata": {},
"outputs": [],
"source": [
"pdos_folder = \"/Users/cpi/opt/cp2k-spm-tools/examples/o2_overlap/out\"\n",
"\n",
"# (optionally) load a CP2K PDOS calculation:\n",
"pdos_folder = None\n",
"dos = pp.process_pdos_files(pdos_folder)"
]
},
Expand All @@ -36,7 +30,7 @@
"metadata": {},
"outputs": [],
"source": [
"npz_path = \"/Users/cpi/opt/cp2k-spm-tools/examples/o2_overlap/out/overlap.npz\"\n",
"npz_path = \"../examples/o2_overlap/out/overlap.npz\"\n",
"\n",
"od = pp.load_overlap_npz(npz_path)\n",
"om = pp.match_and_reduce_spin_channels(od['overlap_matrix'])"
Expand All @@ -50,36 +44,15 @@
"source": [
"fwhm = 0.10\n",
"de = np.min([fwhm/5, 0.005])\n",
"energy_arr = np.arange(-3.0, 3.0, de)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"mpl_def_colors = plt.rcParams['axes.prop_cycle'].by_key()['color']"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"energy_arr = np.arange(-3.0, 3.0, de)\n",
"\n",
"mpl_def_colors = plt.rcParams['axes.prop_cycle'].by_key()['color']\n",
"\n",
"pdos_series = [\n",
" ['tdos', 'lightgray', 0.02, 'TDOS'],\n",
" ['mol', 'black', 1.0, 'molecule PDOS'],\n",
"]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"]\n",
"\n",
"fig = plt.figure(figsize=(12, 6))\n",
"\n",
"ax1 = plt.gca()\n",
Expand Down Expand Up @@ -162,11 +135,18 @@
"plt.xlabel(\"$E-E_F$ [eV]\")\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "cp2k-spm-tools",
"language": "python",
"name": "python3"
},
Expand All @@ -180,7 +160,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
"version": "3.10.16"
}
},
"nbformat": 4,
Expand Down
51 changes: 19 additions & 32 deletions stm_viewer.ipynb → notebooks/stm_viewer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@
"\n",
"import os\n",
"\n",
"from cp2k_spm_tools import igor"
"from cp2k_spm_tools import igor\n",
"\n",
"# NOTE: generate the example data first!\n",
"\n",
"stm_npz_path = \"../examples/benzene_stm/out/stm.npz\"\n",
"orb_npz_path = \"../examples/benzene_stm/out/orb.npz\""
]
},
{
Expand Down Expand Up @@ -119,16 +124,7 @@
"metadata": {},
"outputs": [],
"source": [
"npz_path = \"/home/kristjan/work/_tk_cp2k-spm-tools/examples/benzene_stm/out/stm.npz\"\n",
"loaded_data = np.load(npz_path, allow_pickle=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"loaded_data = np.load(stm_npz_path, allow_pickle=True)\n",
"loaded_data.files"
]
},
Expand All @@ -152,9 +148,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": true
},
"metadata": {},
"outputs": [],
"source": [
"figsize = (12, 3*(extent[3] - extent[2])/(extent[1] - extent[0]))\n",
Expand Down Expand Up @@ -186,8 +180,8 @@
"metadata": {},
"outputs": [],
"source": [
"orb_path = \"/home/kristjan/work/_tk_cp2k-spm-tools/examples/benzene_stm/out/orb.npz\"\n",
"loaded_data = np.load(orb_path, allow_pickle=True)"
"\n",
"loaded_data = np.load(orb_npz_path, allow_pickle=True)"
]
},
{
Expand All @@ -210,9 +204,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"for info, data in zip(s0_orb_series_info, s0_orb_series_data):\n",
Expand Down Expand Up @@ -274,15 +266,8 @@
"metadata": {},
"outputs": [],
"source": [
"igor_file_path = \"/home/kristjan/work/_proj_undecacene/FIGURES/FIG2/orb2_h6.0_s0_10lumo+0_e0.5906_ev.itx\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"igor_file_path = \"orbital.itx\"\n",
"\n",
"igor_wave = igor.igor_wave_factory(igor_file_path)"
]
},
Expand All @@ -292,11 +277,13 @@
"metadata": {},
"outputs": [],
"source": [
"first_wave = igor_wave[0]\n",
"\n",
"fig = plt.figure(figsize=(20, 4))\n",
"ax = plt.gca()\n",
"\n",
"make_plot(fig, ax, igor_wave.data, igor_wave.extent,\n",
" vmax=0.9*np.max(igor_wave.data),\n",
"make_plot(fig, ax, first_wave.data, first_wave.extent,\n",
" vmax=0.9*np.max(first_wave.data),\n",
" vmin=0.0, cmap='gist_gray')\n",
"\n",
"plot_name = os.path.splitext(igor_file_path)[0]\n",
Expand All @@ -314,7 +301,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "cp2k-spm-tools",
"language": "python",
"name": "python3"
},
Expand All @@ -328,7 +315,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.4"
"version": "3.10.16"
}
},
"nbformat": 4,
Expand Down

0 comments on commit fb4d360

Please sign in to comment.