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

Preprocessing notebook #51

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
195 changes: 195 additions & 0 deletions IPython/Pynta preprocessing.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import sys\n",
"sys.path.append(\"/Users/shikim/pynta_local/pynta/\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Preprocessing notebook"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Preprocessing notebook will calculate: \n",
"1. notes for choice of pseudopotentials\n",
"2. Lattice parameter optimization and analysis\n",
"3. Energy convergence test\n",
"4. k-points optimization\n",
"\n",
"*Preprocessing can only run with surfaces that ASE can build*"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"import numpy as np\n",
"from ase.visualize import view\n",
"import matplotlib.pyplot as plt\n",
"from pynta.calculator import get_lattice_parameters\n",
"from pynta.preprocessing import *"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 1. Notes on Pseudopotentials:\n",
"\n",
"We can choose from various pseudopotential libraries. Choice of pseudopotential depends on the problem we are investigating, *e.g.,* if there is a heavy element present in our system and we are interested in the spin-orbit coupling effects, we should choose a full relativistic pseudopotential. We need to be careful whether our chosen pseudopotential correctly reproduces physical properties. Various pseudopotential libraries:\n",
"\n",
"- https://www.quantum-espresso.org/pseudopotentials\n",
"- https://www.materialscloud.org/discover/sssp/table/efficiency\n",
"- http://www.pseudo-dojo.org\n",
"- https://www.physics.rutgers.edu/gbrv/\n",
"- https://nninc.cnf.cornell.edu\n",
"- http://www.quantum-simulation.org/potentials/\n",
"- BLYP pseudopotentials (https://pseudopotentials.quantum-espresso.org/legacy_tables/hartwigesen-goedecker-hutter-pp) \n",
"- SCAN pseudopotentials (https://yaoyi92.github.io/scan-tm-pseudopotentials.html)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 2. Lattice parameter optimization:\n",
"\n",
"\n",
"If your slab is not optimized, it is NOT recommended to use for Pynta production run. Please optimize your slab before running Pynta\n",
"\n",
"*Preprocessing can only run with surfaces that ASE can build*"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"#calculator\n",
"pseudo = {'Cu': 'Cu.pbe-spn-kjpaw_psl.1.0.0.UPF'}\n",
"command = '/Users/shikim/miniconda3/envs/pynta_env/bin/pw.x -in PREFIX.pwi > PREFIX.pwo'\n",
"software_kwargs={'command':command,'kpts': (10,10,10), 'ecutwfc': 70, 'degauss':0.02, 'mixing_mode': 'plain', \n",
" 'pseudopotentials':pseudo,'occupations':'smearing', 'smearing':'gauss',} "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#calculate lattice constant using Pynta\n",
"get_lattice_parameters('Cu','fcc111','Espresso',software_kwargs)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# test lattice constant\n",
"analyze_lattice_parameter('Cu','fcc111','Espresso',software_kwargs)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 3. Cutoff Energy convergence test: \n",
"\n",
"We can calculate the total energy of the system for various values of energy cutoff values. \n",
"Converged energy cutoff value with peudopotentials of choice can construct more accurate DFT input for Pynta. "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"prep = Prep(metal='Pt', surface_type='fcc111', a0=3.96, software='Espresso', software_kwargs={})\n",
"# Define your metal, software, software kwargs"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"cutoff_energy = prep.opt_cutoff_energy(slab=None, ecut_range=(200, 501, 50),output_file='cutoff_energy.txt')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 4. k-point convergence test:\n",
"\n",
"With the optimized slab, appropriate k-points should be calculated to execute Pynta efficiently. \n",
"\n",
"Lowest total energy is estimated from lattice parameter optimization. We use the lowest potential energy to estimate k-points.\n",
"\n",
"Tip: If you have already obtained satisfactory convergence with a (relatively) sparse k-point grid, there is no motivation to go for a denser grid. It makes calculations more expensive. "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"kpts_list, energies = prep.opt_kpoints(slab=None, kpts_range=[(1, 1, 1), (2, 2, 1)], output_file='kpts.txt')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"plot_results(cutoff_energy, kpts_list, energies)\n",
"# Plot energy vs energy cutoff \n",
"# Plot energy vs k-points"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "base",
"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.12.4"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading
Loading